/* ============================================
   APP-LIKE POLISH LAYER
   Loaded last so it can override prior cascade where intentional.
   Scoped to gaps not already handled by:
     - styles.css
     - styles-mobile.css   (tap-highlight, safe-area on .container, prefers-reduced-motion)
     - styles-mobile-advanced.css
     - styles-improvements.css

   New behaviors only. Keeps the bundle additive and reviewable.
   ============================================ */

/* ----- Tell the UA we're a light-mode app (prevents UA dark FOUC) ----- */
html { color-scheme: light; }

/* ----- Crisper typography on mobile + retina screens ----- */
html, body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* ----- Kill 300ms tap delay + accidental long-press menus on actionables ----- */
button, a, .btn, .choice-btn, .pricing-card, .feature-card, .blog-preview-card,
.nav-item, .auth-tab, .password-toggle {
    touch-action: manipulation;
    -webkit-touch-callout: none;
}

/* ----- Prevent body rubber-band; contain scroll inside modals/drawers ----- */
html, body { overscroll-behavior-y: none; }
.modal,
.modal-content,
.bottom-navigation,
#quizContainer,
.results-container,
.question-bank-container {
    overscroll-behavior: contain;
}

/* ----- Smooth in-page anchor scroll (respects reduce-motion media query above) ----- */
@media (prefers-reduced-motion: no-preference) {
    html { scroll-behavior: smooth; }
}

/* ----- Use dynamic viewport height so iOS URL bar doesn't clip the hero ----- */
@supports (height: 100dvh) {
    .hero { min-height: 100dvh; }
}

/* ----- Safe-area top for the hero so content clears the notch.
        Base .hero in styles.css has no padding-top, so this is the SOLE
        top padding on notched phones — not compounded with another rule.
        On non-notched devices env(safe-area-inset-top) resolves to 0. ----- */
.hero { padding-top: env(safe-area-inset-top); }

/* ----- Native-feel button press: scale-down + suppress stuck hover on touch ----- */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .choice-btn,
    .pricing-card button,
    .nav-item,
    .auth-tab {
        transition: transform 0.16s cubic-bezier(0.22, 1, 0.36, 1),
                    box-shadow 0.16s cubic-bezier(0.22, 1, 0.36, 1),
                    background-color 0.16s ease;
    }
    .btn:active,
    .choice-btn:active,
    .pricing-card button:active,
    .nav-item:active,
    .auth-tab:active {
        transform: scale(0.97);
    }
    /* Touch devices: kill the desktop hover-lift that gets stuck after tap */
    .btn-primary:hover,
    .btn-secondary:hover,
    .btn-cta:hover,
    .btn-upgrade:hover,
    .pricing-card:hover,
    .feature-card:hover,
    .blog-preview-card:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ----- Glassmorphic sticky quiz progress (iOS-style header) ----- */
@supports ((backdrop-filter: blur(12px)) or (-webkit-backdrop-filter: blur(12px))) {
    .quiz-progress {
        background: rgba(255, 255, 255, 0.72);
        -webkit-backdrop-filter: saturate(180%) blur(14px);
        backdrop-filter: saturate(180%) blur(14px);
    }
}

/* ----- Bottom-sheet feel for mobile modals: rounded top, safe-area pad ----- */
@media (max-width: 768px) {
    .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: calc(100vh - env(safe-area-inset-top) - 16px);
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    @supports (max-height: 100dvh) {
        .modal-content {
            max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
        }
    }
}

/* ----- Keyboard-only focus ring (touch users don't see a webby outline) ----- */
:focus { outline: none; }
:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 6px;
}
.btn:focus-visible,
.choice-btn:focus-visible {
    outline-offset: 4px;
}

/* ----- Below-the-fold paint-skip: huge scroll-perf win on long landing ----- */
.features,
.pricing,
.blog-preview,
.landing-footer {
    content-visibility: auto;
    contain-intrinsic-size: 1px 800px;
}

/* ----- Layout-shift guard for any image rendered in content ----- */
img {
    max-width: 100%;
    height: auto;
}

/* ----- Brand selection color ----- */
::selection {
    background: rgba(0, 132, 61, 0.18);
    color: var(--text-dark);
}

/* ----- Smooth horizontal-scroll containers if they exist on mobile ----- */
@media (max-width: 768px) {
    .blog-preview-cards,
    .features-grid,
    .pricing-cards {
        -webkit-overflow-scrolling: touch;
    }
}

/* ----- Prevent long words from clipping past the viewport edge ----- */
.hero-content h1,
.hero-subtitle,
.features h2,
.pricing h2,
.blog-preview h2,
.feature-card h3,
.pricing-card h3,
.blog-preview-card h3,
.modal-content h2 {
    overflow-wrap: anywhere;
    word-break: break-word;
    hyphens: auto;
}

/* ----- Tighten oversized headings so they fit narrow phones cleanly ----- */
@media (max-width: 380px) {
    .hero-content h1 { font-size: 28px !important; line-height: 1.18; }
    .hero-subtitle  { font-size: 15px; }
    .btn-cta        { font-size: 16px !important; padding: 14px 24px !important; }
}

/* ----- Horizontal-overflow guard.
        IMPORTANT: do NOT use `overflow-x: hidden` on html or body — that
        flips the same axis to `auto`, creating two nested scroll containers
        and freezing scroll on iOS Safari. `overflow-x: clip` clips without
        creating a scroll container. Apply only to body so html stays the
        sole scroll container.
        The flex `min-width: 0` rules below are the real overflow guard;
        this is just a belt for older renderers. ----- */
body { overflow-x: clip; }

/* ----- Flex-item overflow guard: stop intrinsic content size from making
        a flex child wider than its container (classic flex min-width: auto bug) ----- */
.hero,
.hero > .container,
.landing-nav,
.nav-buttons,
.hero-content,
.features-grid,
.pricing-cards,
.blog-preview-cards {
    min-width: 0;
}

/* Belt-and-suspenders: clamp the top-level container at viewport on phones */
@media (max-width: 768px) {
    .hero > .container,
    .features > .container,
    .pricing > .container,
    .blog-preview > .container,
    .landing-footer > .container {
        max-width: 100vw;
        width: 100%;
    }
}

/* ============================================
   ITERATION 2: COMPACT MOBILE NAV + HERO
   The default mobile cascade stacks nav vertically and gives 60px
   hero padding. On a 375px phone that wastes the top half of the
   first paint. Restore a compact, app-bar-style header.
   ============================================ */

@media (max-width: 768px) {
    /* App-bar style header: single horizontal row, compact */
    .landing-nav {
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 12px 0 !important;
        text-align: left !important;
    }

    .nav-buttons {
        flex-direction: row !important;
        gap: 8px !important;
        flex: 0 0 auto !important;
    }

    /* Compact pill-style buttons in the header */
    .nav-buttons .btn,
    .landing-nav .btn {
        min-height: 38px !important;
        padding: 8px 14px !important;
        font-size: 13px !important;
        border-radius: 999px !important;
        white-space: nowrap;
        flex: 0 0 auto !important;        /* don't shrink: keep text intact */
        width: auto !important;           /* size to content */
    }

    /* Logo: scale down so it pairs with compact buttons */
    .landing-nav .logo {
        font-size: 20px;
    }
}

/* Narrow phones (≤420px): tighten labels to fit alongside logo */
@media (max-width: 420px) {
    .landing-nav { padding: 10px 0 !important; }
    .landing-nav .logo { font-size: 18px; }
    .nav-buttons { gap: 6px !important; }
    .nav-buttons .btn,
    .landing-nav .btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
        letter-spacing: 0;
        min-height: 34px !important;
    }

    /* Tighter hero padding: claw back vertical space on phones */
    .hero-content {
        padding: 32px 16px 48px !important;
    }

    /* Subtitle: more readable with constrained width */
    .hero-subtitle {
        max-width: 32ch;
        margin-left: auto;
        margin-right: auto;
    }

    /* CTA: full-width on phones, more thumb-friendly */
    .hero-cta { width: 100%; }
    .hero-cta .btn-cta {
        width: 100%;
        max-width: 360px;
    }
}

/* ============================================
   ITERATION 2: TRUST INDICATORS — graceful wrap
   ============================================ */

@media (max-width: 768px) {
    .hero-trust {
        margin-top: 20px;
        padding-top: 20px;
        gap: 10px 14px;
        justify-content: center;
        font-size: 13px;
    }

    .trust-rating { font-size: 14px; }
    .trust-stars  { font-size: 16px; }

    .trust-badge {
        background: rgba(255, 255, 255, 0.10);
        padding: 4px 10px;
        border-radius: 999px;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
    }
}

/* ============================================
   ITERATION 2: SECTION RHYTHM
   Tighter, more app-like vertical spacing on phones
   ============================================ */

@media (max-width: 768px) {
    .features,
    .pricing,
    .blog-preview {
        padding-top: 40px !important;
        padding-bottom: 40px !important;
    }

    .features h2,
    .pricing h2,
    .blog-preview h2 {
        margin-bottom: 20px !important;
        line-height: 1.2;
    }

    /* Feature/pricing/blog cards: full-width, tactile */
    .feature-card,
    .pricing-card,
    .blog-preview-card {
        border-radius: 16px;
    }
}

/* ============================================
   ITERATION 2: BUTTON LIFT (subtle elevation transitions)
   Replaces hover-lift on touch with a softer, app-feel shadow.
   ============================================ */

@media (max-width: 768px) {
    .btn-cta {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18),
                    0 1px 0 rgba(255, 255, 255, 0.25) inset;
    }

    .btn-primary,
    .btn-secondary {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
    }
}

/* ============================================
   ITERATION 2: DEEPER 3-STOP HERO GRADIENT
   Replaces the base 2-stop gradient in styles.css with one extra mid stop
   for more visual depth.

   CASCADE-ORDER DEPENDENCY:
   This rule wins because styles-mobile-polish.css is the LAST stylesheet
   linked in index.html. If the link order is changed (or this file is
   merged into styles.css ahead of the original .hero declaration), the
   base 2-stop gradient will silently win. Keep this file linked last.

   The <meta name="theme-color"> in index.html is intentionally left at
   the existing #2C5F2D — that color matches the gradient TOP visually
   on iOS Safari's URL bar tint, so no change is needed here.
   ============================================ */

.hero {
    background: linear-gradient(
        180deg,
        var(--primary-color) 0%,
        #015E2C 55%,
        var(--secondary-color) 100%
    );
}
