/* ============================================================
   Apostillum — MOBILE LAYER  (mobile.css)
   Loads AFTER apostillum.css. Adds nothing to desktop ≥ 921px.
   Goal: faithful DNA, reflowed for thumbs, ZERO horizontal
   overflow at 360 / 390 / 430 / 768.

   Variation hooks (set on <body>):
     data-mobilenav = drawer | overlay | bottombar
     data-hero      = scaled | hidden        (ghost wordmark)
     data-pricing   = stacked | carousel | accordion
   ============================================================ */

/* ───────────────────────────────────────────────────────────
   0 · GLOBAL OVERFLOW GUARD  (the #1 bug: text out of bounds)
   NOTE: use `clip`, NOT `hidden` — `overflow-x:hidden` turns the
   element into a scroll container and would break `position:sticky`
   on the masthead. `clip` contains overflow without that side-effect.
   ─────────────────────────────────────────────────────────── */
/* These three element groups are ADDED by the mobile layer (extra markup).
   Hide them on desktop so the big version is byte-for-byte the original. */
.nav-toggle { display: none; }
.m-menu, .m-bottombar { display: none; }

/* ───────────────────────────────────────────────────────────
   EVERYTHING the mobile layer changes is gated to ≤ 860px.
   At ≥ 861px the page renders EXACTLY the original apostillum.css —
   the mobile layer adds nothing above the breakpoint.
   ─────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    /* overflow guard — the #1 bug: text out of bounds. `clip` (not
       `hidden`) contains overflow without breaking position:sticky. */
    html, body { overflow-x: clip; max-width: 100%; }
    * { min-width: 0; }                 /* let flex/grid children shrink */
    p, li, h1, h2, h3, .tier-headline, .compare-col-headline,
    .thesis-line, .worm-card-title, .cost-row-label {
        overflow-wrap: break-word;
        word-break: normal;
    }
    .mono-wrap, .proof-sub, .compliance-group-items,
    .tier-foot, .price-annual { overflow-wrap: anywhere; }
    /* the masthead must sit above the sticky tier selector on mobile */
    .site-nav { position: sticky; top: 0; z-index: 800; }
}

/* ============================================================
   MOBILE NAV  — markup added: .nav-toggle + .m-menu + .m-bottombar
   All three live in the DOM; CSS shows the right one per variant.
   Breakpoint is 920px (not 860) so the hamburger takes over at exactly
   the width where apostillum.css hides the inline .nav-links — no
   dead band where neither is reachable. The rest of the layer stays 860.
   ============================================================ */
@media (max-width: 920px) {

    /* the masthead keeps brand on the left, a hamburger on the right.
       The long solid CTA + ghost button are pulled OUT of the bar
       (they were what overflowed) and re-homed in the menu. */
    .site-nav { gap: 10px; }
    .site-nav .nav-actions { display: none; }
    .nav-toggle {
        display: inline-flex;
        flex-direction: column;
        justify-content: center;
        gap: 5px;
        width: 44px; height: 44px;        /* real tap target */
        margin: -10px -8px -10px 0;
        padding: 0 10px;
        background: none; border: none; cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .nav-toggle span {
        display: block; height: 1.5px; width: 22px;
        background: var(--ink);
        transition: transform .32s cubic-bezier(.22,1,.36,1), opacity .2s;
    }
    body.menu-open .nav-toggle span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
    body.menu-open .nav-toggle span:nth-child(2) { opacity: 0; }
    body.menu-open .nav-toggle span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

    /* ---- the menu surface (shared by drawer + overlay) ---- */
    .m-menu {
        display: block;
        position: fixed; inset: 0;
        z-index: 1000;
        pointer-events: none;
        visibility: hidden;
    }
    .m-menu-scrim {
        position: absolute; inset: 0;
        background: rgba(21,19,15,0.42);
        backdrop-filter: blur(2px);
        opacity: 0; transition: opacity .34s ease;
    }
    .m-menu-panel {
        position: absolute;
        background: var(--paper);
        display: flex; flex-direction: column;
        will-change: transform;
    }
    .m-menu-head {
        display: flex; align-items: center; justify-content: space-between;
        padding: 18px 24px;
        border-bottom: 1px solid var(--rule);
    }
    .m-menu-head .wordmark { font-family: var(--serif); font-size: 22px; font-weight: var(--w-medium); color: var(--ink); }
    .m-menu-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
    .m-menu-close {
        width: 44px; height: 44px; margin: -10px -12px -10px 0;
        background: none; border: none; cursor: pointer;
        font-family: var(--mono); font-size: 22px; color: var(--mid); line-height: 1;
    }
    .m-menu-links { display: flex; flex-direction: column; padding: 8px 0; }
    .m-menu-links a {
        display: flex; align-items: center; gap: 14px;
        min-height: 56px; padding: 0 24px;
        font-family: var(--serif); font-size: var(--t-xl); color: var(--ink);
        text-decoration: none;
        border-bottom: 1px solid var(--rule-2);
    }
    .m-menu-links a .idx {
        font-family: var(--mono); font-size: var(--t-label-sm);
        letter-spacing: var(--track-label); color: var(--soft);
        min-width: 22px;
    }
    .m-menu-links a:active { background: var(--paper-2); }
    .m-menu-actions { margin-top: auto; padding: 22px 24px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--rule); }
    .m-menu-actions a {
        display: block; text-align: center; min-height: 52px; line-height: 52px;
        font-family: var(--mono); font-size: var(--t-label); letter-spacing: var(--track-label);
        text-transform: uppercase; text-decoration: none;
    }
    .m-menu-actions .m-solid { background: var(--ink); color: var(--paper); border: 1px solid var(--ink); }
    .m-menu-actions .m-ghost { border: 1px solid var(--rule); color: var(--ink); }

    /* OPEN state */
    body.menu-open .m-menu { pointer-events: auto; visibility: visible; }
    body.menu-open .m-menu-scrim { opacity: 1; }

    /* ── variant: DRAWER (slide from right, 84vw) ── */
    body[data-mobilenav="drawer"] .m-menu-panel {
        top: 0; right: 0; bottom: 0;
        width: min(84vw, 380px);
        box-shadow: -24px 0 60px rgba(21,19,15,0.16);
        transform: translateX(100%);
        transition: transform .42s cubic-bezier(.22,1,.36,1);
    }
    body[data-mobilenav="drawer"].menu-open .m-menu-panel { transform: translateX(0); }

    /* ── variant: OVERLAY (full-screen) ── */
    body[data-mobilenav="overlay"] .m-menu-scrim { background: none; backdrop-filter: none; }
    body[data-mobilenav="overlay"] .m-menu-panel {
        inset: 0; width: 100%;
        opacity: 0; transform: translateY(-8px);
        transition: opacity .3s ease, transform .42s cubic-bezier(.22,1,.36,1);
    }
    body[data-mobilenav="overlay"].menu-open .m-menu-panel { opacity: 1; transform: translateY(0); }
    body[data-mobilenav="overlay"] .m-menu-links { padding: 24px 0; justify-content: center; flex: 1; }
    body[data-mobilenav="overlay"] .m-menu-links a {
        font-size: clamp(28px, 9vw, 40px); min-height: 64px; border-bottom: none;
    }
    body[data-mobilenav="overlay"] .m-menu-links a .idx { font-size: var(--t-label); }

    /* ── variant: BOTTOM BAR (app-like, persistent) ── */
    /* hide the hamburger menu entirely; show a fixed bottom action bar.
       A small "More" item still opens the full menu for secondary links. */
    body[data-mobilenav="bottombar"] .m-bottombar {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0;
        z-index: 900;
        background: color-mix(in srgb, var(--paper) 92%, transparent);
        backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid var(--rule);
        padding-bottom: env(safe-area-inset-bottom);
    }
    body[data-mobilenav="bottombar"] .m-bottombar a,
    body[data-mobilenav="bottombar"] .m-bottombar button {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
        min-height: 58px; padding: 8px 4px;
        background: none; border: none; cursor: pointer;
        font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.1em;
        text-transform: uppercase; color: var(--mid); text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    body[data-mobilenav="bottombar"] .m-bottombar .bb-glyph {
        width: 20px; height: 20px; display: grid; place-items: center;
    }
    body[data-mobilenav="bottombar"] .m-bottombar .bb-glyph .stamp { width: 18px; height: 18px; border-radius: 4px; }
    body[data-mobilenav="bottombar"] .m-bottombar a.is-primary { color: var(--accent-deep); }
    /* give content room so the bar never covers the footer/CTA */
    body[data-mobilenav="bottombar"] { padding-bottom: 64px; }
    /* bottom bar owns navigation → drop the redundant top hamburger;
       the bar's "More" opens the full menu */
    body[data-mobilenav="bottombar"] .nav-toggle { display: none; }

    /* lock scroll when an overlay/drawer menu is open */
    body.menu-open { overflow: hidden; }
}

/* ============================================================
   HERO  — kill forced-wide lines, scale the ghost wordmark
   ============================================================ */
@media (max-width: 640px) {
    .hero { padding: 52px 22px 48px; }
    .hero h1 { font-size: clamp(32px, 8.6vw, 44px); line-height: 1.12; }
    /* keep the <br> (source has no spaces around it); long lines wrap, never overflow */
    .hero-bridge { font-size: var(--t-md); }
    .hero-cta { display: block; width: 100%; padding: 17px 24px; }
    .hero-links { margin-top: 18px; }

    /* ghost wordmark: scaled tastefully, never an overflow source */
    body[data-hero="scaled"] .hero .ghost {
        font-size: 34vw;
        -webkit-text-stroke: 1px rgba(26,24,20,0.06);
        top: 38%;
    }
    body[data-hero="hidden"] .hero .ghost { display: none; }
}

/* ============================================================
   DENSE SECTIONS  — reflow grids, fix nowrap overflow
   ============================================================ */
@media (max-width: 640px) {

    /* proof strip + compliance → single column, comfortable padding */
    .proof-strip { grid-template-columns: 1fr; }
    .proof-item { padding: 24px 22px; }
    .compliance-bar { grid-template-columns: 1fr; gap: 22px; padding: 28px 0; }

    /* ticker wraps centred, smaller items */
    .ticker-item { padding: 11px 16px; }

    /* the COST ROWS were the worst offender: amount was white-space:nowrap.
       Stack label over amount; let the amount wrap. */
    .cost-row { flex-direction: column; align-items: flex-start; gap: 3px; padding: 14px 0; }
    .cost-row-amount { white-space: normal; }
    .cost-grid, .how-grid, .faq-grid { gap: 26px; }

    /* scenario + comparison already stack < 860; tighten padding */
    .scenario-cell, .comparison-col { padding: 22px 20px; }

    /* big editorial figures shouldn't crowd the gutter */
    .stat-callout { font-size: var(--t-lg); }
    .asymmetry-quote { font-size: var(--t-xl); padding-left: 18px; }
    .worm-headline { font-size: var(--t-2xl); }
    .urgency-date { font-size: var(--t-2xl); }
    .urgency-title { font-size: var(--t-lg); }
    .section { padding: 48px 0; }
    .close { padding: 64px 24px; }
    .close h2 { font-size: var(--t-2xl); }
    .close-cta { padding: 40px 24px calc(40px + env(safe-area-inset-bottom)); }
    .close-cta-inner { flex-direction: column; }
    .close-cta-inner a { display: block; text-align: center; }

    /* worm cards stack (were 3-col → keep a single column on phones) */
    .worm-grid { grid-template-columns: 1fr; }

    /* footer: let items breathe, wrap centred */
    .site-footer { padding: 24px 22px calc(24px + env(safe-area-inset-bottom)); }
    .footer-inner { gap: 10px 12px; }
}

/* iPad portrait (768): keep two-up where it reads well */
@media (min-width: 641px) and (max-width: 820px) {
    .proof-strip { grid-template-columns: 1fr 1fr; }
    .compliance-bar { grid-template-columns: 1fr 1fr; }
    .worm-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   PRICING TIERS  — TABBED "spec sheet"  (the chosen design)
   A tier selector sits on top; tap a tab and that tier's full
   details render below. The monthly/annual toggle updates every
   price live — including the mini price on each tab. One tier on
   screen at a time → compare by tapping, not by scrolling.
   apostillum.css already stacks tiers < 860; we override to tabs.
   ============================================================ */
@media (max-width: 860px) {

    /* roomier billing pills, full-tap CTAs everywhere */
    .tier-cta { padding: 16px; min-height: 52px; }
    .page { padding: 40px 20px 72px; }
    .price-head h1 { font-size: clamp(30px, 8vw, 44px); }

    /* ════════ TIER SELECTOR — sliding segmented control ════════
       Modeled on the app's 24H / WEEK / ALL switch: a recessed track
       with a raised pill that SLIDES to the active tier. Premium depth,
       generous radius, hairline border. */
    body[data-pricing="tabbed"] .tier-tabs {
        position: sticky; top: 66px; z-index: 50;
        display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
        width: 100%; max-width: 460px; align-self: center; margin: 0 0 12px;
        padding: 5px;
        background: var(--paper-2);
        border: 1px solid var(--rule);
        box-shadow: inset 0 1px 2px rgba(21,19,15,0.06);
    }
    body[data-pricing="tabbed"] .tier-slide {
        position: absolute; top: 5px; bottom: 5px; left: 5px;
        width: calc((100% - 10px) / 4);
        background: var(--ink-card);
        box-shadow: 0 1px 2px rgba(21,19,15,0.28), 0 6px 16px -5px rgba(21,19,15,0.4);
        transition: transform .38s cubic-bezier(.22,1,.36,1);
        z-index: 0;
    }
    body[data-pricing="tabbed"] .tier-tab {
        position: relative; z-index: 1;
        background: none; border: none; cursor: pointer;
        min-height: 46px; padding: 0 2px;
        display: flex; align-items: center; justify-content: center; gap: 6px;
        font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.07em; text-transform: uppercase;
        color: var(--soft); transition: color .32s ease;
        -webkit-tap-highlight-color: transparent;
    }
    body[data-pricing="tabbed"] .tier-tab .tab-price { display: none; }   /* price lives in the card */
    body[data-pricing="tabbed"] .tier-tab .tab-seal {
        width: 5px; height: 5px; background: var(--accent);
    }
    body[data-pricing="tabbed"] .tier-tab.active { color: var(--accent); }

    /* ════════ THE CARD — rounded floating instrument panel ════════
       Soft-shadowed, hairline-bordered dark card on the warm paper.
       Same premium treatment for every tier (consistent, not just Charter). */
    body[data-pricing="tabbed"] .tiers {
        display: block; background: transparent; border: none; gap: 0;
        width: 100%; max-width: 460px; align-self: center; margin: 0;
    }
    body[data-pricing="tabbed"] .tier { display: none; }
    body[data-pricing="tabbed"] .tier.is-shown {
        display: flex; flex-direction: column;
        min-height: 470px;                 /* same card size across every tier */
        background:
            radial-gradient(120% 80% at 50% -10%, rgba(139,202,122,0.07), transparent 60%),
            var(--ink-card);
        border: 1px solid rgba(255,255,255,0.08);
        box-shadow: 0 1px 2px rgba(21,19,15,0.16), 0 26px 50px -26px rgba(21,19,15,0.5);
        padding: 24px 22px 22px;
        animation: m-fold .3s cubic-bezier(.22,1,.36,1);
    }
    body[data-pricing="tabbed"] .tier.is-shown .tier-ink { display: none; }

    /* dark treatment — generous, premium type */
    body[data-pricing="tabbed"] .tier.is-shown .tier-seal { margin: 0 0 14px; min-height: 20px; align-items: center; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-seal .seal-text { color: var(--accent); }
    body[data-pricing="tabbed"] .tier.is-shown .tier-name      { color: var(--accent); margin-bottom: 14px; min-height: 20px; }
    body[data-pricing="tabbed"] .tier--featured .tier-name     { display: none; }   /* seal row already names Charter */
    body[data-pricing="tabbed"] .tier.is-shown .tier-headline  { color: #F4EFE6; font-size: var(--t-lg); line-height: 1.2; min-height: 2.4em; margin-bottom: 12px; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-desc      { display: none; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-section-label { display: none; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-foot      { display: none; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-price     { align-items: baseline; gap: 4px 8px; margin-bottom: 2px; }
    body[data-pricing="tabbed"] .tier.is-shown .price-amount   { color: #FBF8F1; font-size: 46px; }
    body[data-pricing="tabbed"] .tier.is-shown .price-period   { color: #8E877D; }
    body[data-pricing="tabbed"] .tier.is-shown .price-annual   { color: #8E877D; font-size: var(--t-xs); margin-bottom: 2px; }
    body[data-pricing="tabbed"] .tier.is-shown .price-savings  { color: var(--accent); margin-bottom: 18px; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-cta       {
        background: var(--accent); border: none; color: var(--ink-card);
        min-height: 52px; margin-bottom: 18px; font-size: var(--t-label);
        box-shadow: 0 10px 26px -10px rgba(139,202,122,0.55);
        transition: transform .18s ease, box-shadow .2s ease, background .2s ease;
    }
    body[data-pricing="tabbed"] .tier.is-shown .tier-cta:hover { background: #9BD68B; box-shadow: 0 14px 32px -10px rgba(139,202,122,0.7); }
    body[data-pricing="tabbed"] .tier.is-shown .tier-cta:active { transform: translateY(1px); }
    body[data-pricing="tabbed"] .tier.is-shown .tier-divider   { background: rgba(255,255,255,0.10); margin-bottom: 16px; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-features  { display: flex; flex-direction: column; gap: 10px; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-features li { color: #CFC9BE; font-size: 14px; margin: 0; line-height: 1.32; padding-left: 26px; }
    body[data-pricing="tabbed"] .tier.is-shown .tier-features li::before {
        background: var(--accent); opacity: 1; width: 7px; height: 7px; border-radius: 0;
        top: 6px; box-shadow: 0 0 10px -1px rgba(139,202,122,0.6);
    }
    body[data-pricing="tabbed"] .tier.is-shown .tier-seal-spacer { display: none; }

    /* ── billing: square pill switch (matches the tier control) ── */
    body[data-pricing="tabbed"] .billing-pills { padding: 0; border: 1px solid var(--rule); background: var(--paper-2); box-shadow: inset 0 1px 2px rgba(21,19,15,0.06); }
    body[data-pricing="tabbed"] .billing-slide { background: var(--paper-hi); box-shadow: 0 1px 2px rgba(21,19,15,0.14); }
    body[data-pricing="tabbed"] .billing-btn { padding: 10px 22px; }

    /* ── ORDER: tool first (billing → switch → card), headline below ── */
    body[data-pricing="tabbed"] .page { padding-top: 18px; }
    body[data-pricing="tabbed"] .page > .billing    { order: 1; margin: 0 0 14px; }
    body[data-pricing="tabbed"] .page > .tier-tabs   { order: 2; }
    body[data-pricing="tabbed"] .page > .tiers       { order: 3; }
    body[data-pricing="tabbed"] .page > .price-head  { order: 4; margin-top: 56px; }
    body[data-pricing="tabbed"] .page > .guarantees  { order: 5; }
}

/* tier selector hidden by default — only the tabbed mobile view shows it */
.tier-tabs { display: none; }

@keyframes m-fold { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* compare grid + audit stats already collapse; just tighten on phones */
@media (max-width: 640px) {
    .compare-col { padding: 24px 22px; }
    .audit { padding: 30px 22px; }
    .audit-stats { grid-template-columns: 1fr; }
    .math, .charter-note { padding: 26px 22px; }
    .thesis-grid { gap: 20px; }
    .auth-list { columns: 1; }
}

/* ============================================================
   TAP TARGETS  — nothing tappable under 44px on touch devices
   ============================================================ */
@media (hover: none) and (pointer: coarse) {
    .nav-link, .footer-inner a, .hero-secondary, .auth-src a { padding: 6px 0; display: inline-block; }
}
