/**
 * FastWebTools — Android app embed mode layout.
 *
 * Activated when <html> has class .fw-embed-mode (set by embed-context.js).
 * Hides website chrome; adjusts viewport for native shell.
 */

/* ── Dark theme tokens (applied before body paint via embed-context.js) ── */
html.fw-embed-mode.fw-theme-dark {
    --fw-bg: #0B1220;
    --fw-surface: #111827;
    --fw-surface-2: #1E293B;
    --fw-border: #334155;
    --fw-border-strong: #475569;
    --fw-text: #F1F5F9;
    --fw-text-2: #CBD5E1;
    --fw-text-3: #94A3B8;
    --fw-accent: #818CF8;
    --fw-accent-soft: #1E1B4B;
    --fw-inverse: #F1F5F9;
    --fw-inverse-text: #0B1220;
    color-scheme: dark;
}

html.fw-embed-mode.fw-theme-dark,
html.fw-embed-mode.fw-theme-dark body {
    background-color: var(--fw-bg);
    color: var(--fw-text);
}

/* ── Hide website chrome ── */
html.fw-embed-mode .site-topbar,
html.fw-embed-mode .fw-ph-banner,
html.fw-embed-mode .fw-games-banner,
html.fw-embed-mode .home-brand-banner,
html.fw-embed-mode .fastpdf-brand-banner,
html.fw-embed-mode .home-brand-banner--static,
html.fw-embed-mode #footer-container,
html.fw-embed-mode .fw-slide-footer,
html.fw-embed-mode .fw-cross-nav-row,
html.fw-embed-mode .home-banner,
html.fw-embed-mode .fastpdf-scanner-banner,
html.fw-embed-mode .fastpdf-converter-banner,
html.fw-embed-mode .fw-tool-launcher-list,
html.fw-embed-mode #pwa-install-btn,
html.fw-embed-mode #pwa-update-banner,
html.fw-embed-mode #scannerPwaInstallBtn,
html.fw-embed-mode .contrast-adriantiba-link,
html.fw-embed-mode .lang-switcher {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none !important;
}

/* Remove from accessibility tree */
html.fw-embed-mode .site-topbar,
html.fw-embed-mode #footer-container,
html.fw-embed-mode .fw-tool-launcher-list {
    aria-hidden: true;
}

/* ── Reset layout offsets ── */
html.fw-embed-mode {
    --fw-ph-banner-h: 0px;
    --fw-games-banner-h: 0px;
    --fw-top-offset: 0px;
}

html.fw-embed-mode body {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

html.fw-embed-mode body.has-fw-ph-banner,
html.fw-embed-mode body.has-fw-games-banner,
html.fw-embed-mode body.has-fw-slide-footer {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* ── Embedded viewport ── */
html.fw-embed-mode .container,
html.fw-embed-mode .container--tools,
html.fw-embed-mode .fastpdf-wrap,
html.fw-embed-mode .utility-tool-wrap,
html.fw-embed-mode .converter-wrap,
html.fw-embed-mode .scanner-wrap {
    max-width: 100%;
    width: 100%;
    margin-top: 0;
    padding-top: var(--fw-space-4);
    padding-left: var(--fw-space-4);
    padding-right: var(--fw-space-4);
    box-sizing: border-box;
}

/* Hide duplicate page titles when native shell shows tool name */
html.fw-embed-mode .home-brand-text,
html.fw-embed-mode .fastpdf-logo-banner,
html.fw-embed-mode .utility-tool-hero h1,
html.fw-embed-mode .converter-hero h1 {
    /* Keep visually hidden but accessible to screen readers */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Home hub: hide tool launcher, show only active tool section */
html.fw-embed-mode .tabs {
    /* Keep tabs visible for home hub tools — user needs to switch modes */
}

html.fw-embed-mode .subtitle.home-tagline {
    display: none;
}

/* ── Dark theme: fix hardcoded light backgrounds ── */
html.fw-embed-mode.fw-theme-dark .container,
html.fw-embed-mode.fw-theme-dark .drop-zone,
html.fw-embed-mode.fw-theme-dark input,
html.fw-embed-mode.fw-theme-dark select,
html.fw-embed-mode.fw-theme-dark textarea {
    background-color: var(--fw-surface);
    color: var(--fw-text);
    border-color: var(--fw-border);
}

html.fw-embed-mode.fw-theme-dark .tab {
    background: var(--fw-surface-2);
    color: var(--fw-text-2);
}

html.fw-embed-mode.fw-theme-dark .tab.active {
    background: var(--fw-accent-soft);
    color: var(--fw-text);
}

html.fw-embed-mode.fw-theme-dark .drop-zone {
    background: var(--fw-surface-2);
    border-color: var(--fw-border-strong);
}

html.fw-embed-mode.fw-theme-dark .url-zone input,
html.fw-embed-mode.fw-theme-dark .url-result input {
    background: var(--fw-surface-2);
    color: var(--fw-text);
}

/* Fast PDF dark overrides */
html.fw-embed-mode.fw-theme-dark .fastpdf-wrap {
    background: var(--fw-bg);
}

html.fw-embed-mode.fw-theme-dark .fastpdf-card,
html.fw-embed-mode.fw-theme-dark .fastpdf-panel {
    background: var(--fw-surface);
    border-color: var(--fw-border);
    color: var(--fw-text);
}

/* Utility tool dark overrides */
html.fw-embed-mode.fw-theme-dark .utility-tool-card {
    background: var(--fw-surface);
    border-color: var(--fw-border);
    color: var(--fw-text);
}

/* Converter dark overrides */
html.fw-embed-mode.fw-theme-dark .converter-panel {
    background: var(--fw-surface);
    color: var(--fw-text);
}

/* Prevent horizontal overflow */
html.fw-embed-mode body,
html.fw-embed-mode .container,
html.fw-embed-mode main {
    overflow-x: hidden;
    max-width: 100vw;
}

/* Defensive: collapse any future ad placeholder whitespace in embed mode */
html.fw-embed-mode [class*="ad-slot"],
html.fw-embed-mode [class*="ad_slot"],
html.fw-embed-mode ins[class*="ad"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}
