/* =============================================================================
   Login consent / legal-gate screen — templates/consent.html
   -----------------------------------------------------------------------
   2026-07-24: the gate went live (CONSENT_GATE_ENABLED_ORG_IDS=*) and the
   screen rendered in generic light styling — jarring, because it looked
   nothing like the app the user was already in. This sheet rebuilds it on
   the SAME theme tokens the rest of Claimind uses (static/styles.css
   :root + body[data-theme="pro"|"slate"|"dark"]), so the gate inherits
   whatever theme the user picked instead of ambushing them with white.

   HEX-FREE BY CONTRACT. Every color here is a var(--…) token so all three
   themes track automatically; tests/test_consent_page_theming.py pins it.
   (`rgba(0,0,0,…)` shadow washes are the one allowed literal, matching the
   convention in tests/test_theme_content_recolor_contract.py.)

   Loaded from templates/consent.html's `head_extra` block AFTER
   static/styles.css, which is what lets `body.auth-body.consent-body`
   below beat styles.css's hardcoded `body.auth-body { background: … }`.
   ============================================================================= */

/* ---- Page shell ---------------------------------------------------------- */

/* styles.css centers .auth-body vertically (flex + align-items:center) — right
   for a short login card, wrong here: the consent card is tall, and on a phone
   a vertically-centered overflowing flex item gets its TOP clipped and becomes
   unreachable (the classic flex-centering overflow trap). flex-start + page
   scroll keeps the whole card reachable at every height. */
body.auth-body.consent-body {
    background: var(--bg);
    color: var(--text);
    align-items: flex-start;
    justify-content: center;
    /* Safe-area aware for the installed PWA — consent.html opts into
       `viewport-fit=cover`, so these resolve to the real iOS insets and
       nothing tucks under the status bar / home indicator. The max()/calc()
       pairs keep a sane minimum on non-notched devices (env() → 0px). */
    padding-top: calc(24px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
}

/* Tell the UA these themes are dark so native affordances — the checkbox,
   the .policy-scroll scrollbar, focus rings — render dark instead of
   painting a light-mode widget onto a dark card. */
body[data-theme="slate"].consent-body,
body[data-theme="dark"].consent-body {
    color-scheme: dark;
}

.consent-page {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
}

/* ---- Brand mark ---------------------------------------------------------- */

.consent-brand {
    text-align: center;
    margin-bottom: var(--space-5, 24px);
}

.consent-brand img {
    height: 44px;
    width: auto;
    max-width: 100%;
    display: inline-block;
}

/* static/brand/logo.png is a solid dark-navy mark on a fully transparent
   background — it all but disappears on Slate (#1e293b) and Dark (#18181b).
   `brightness(0) invert(1)` flattens every opaque pixel to white while the
   transparent counters (the E bars, the M bolt) stay transparent, so the mark
   reads as a clean white lockup rather than a navy smudge. */
body[data-theme="slate"] .consent-brand img,
body[data-theme="dark"] .consent-brand img {
    filter: brightness(0) invert(1);
}

/* ---- Card ---------------------------------------------------------------- */

.consent-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 30px;
    box-shadow: var(--shadow-card);
}

.consent-title {
    font-size: clamp(19px, 4.4vw, 22px);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    margin: 0 0 6px;
}

.consent-sub {
    color: var(--text-muted);
    margin: 0 0 20px;
    font-size: 14px;
    line-height: 1.55;
}

.consent-card .auth-error {
    background: var(--error-bg);
    border: 1px solid var(--bad-line);
    color: var(--error-text);
    border-radius: var(--radius-sm, 6px);
    padding: 10px 12px;
    font-size: 13px;
    margin: 0 0 14px;
}

/* ---- Scrollable policy body --------------------------------------------- */

.policy-scroll {
    /* clamp() instead of a bare 46vh: on phone LANDSCAPE 46vh is ~170px —
       a letterbox slit. The 200px floor keeps it usable (the page itself
       scrolls if the card outgrows the viewport) and the 520px ceiling stops
       it swallowing a tall desktop window. */
    max-height: clamp(200px, 46vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Keep a flick inside the policy box from chaining into the page scroll. */
    overscroll-behavior: contain;
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 10px);
    padding: 18px 20px;
    background: var(--surface-2);
}

.policy-section {
    margin-bottom: 20px;
}

.policy-section:last-child {
    margin-bottom: 0;
}

.policy-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text);
}

.policy-section p {
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--text-heading);
    margin: 0 0 8px;
}

.policy-section p:last-child {
    margin-bottom: 0;
}

/* ---- Acknowledgement + actions ------------------------------------------ */

.consent-agree {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 20px 0 18px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    cursor: pointer;
}

.consent-agree input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    /* Themes the CHECKED fill to the app CTA in every browser that supports
       it; `color-scheme` above handles the unchecked box on dark themes. */
    accent-color: var(--cta);
    cursor: pointer;
}

.consent-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

/* Inherits background/hover from styles.css .btn-primary (var(--cta) /
   var(--cta-hover)) so the gate's CTA is literally the app's CTA. Only the
   sizing is restated here. */
.consent-actions .btn-primary {
    min-width: 200px;
    /* 19px/700 is deliberate, not decorative. The shared --cta violet that
       Slate and Dark use (#8b5cf6) measures 4.23:1 against white — fine for
       WCAG AA *large* text (>= 18.66px bold, threshold 3:1) but just under
       the 4.5:1 normal-text bar. Sizing the label into the large-text band
       clears AA on all three themes WITHOUT forking the brand accent, which
       is the whole point of this PR: the gate's CTA must be the app's CTA.
       (Pro's blue is 5.17:1 and passes at any size.) */
    font-size: 19px;
    font-weight: 700;
    line-height: 1.2;
    /* Comfortable tap target on phones (>= 44px tall). */
    padding: 13px 22px;
}

.consent-decline {
    color: var(--text-muted);
    font-size: 13px;
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 2px;
}

.consent-decline:hover {
    color: var(--text);
}

.consent-meta {
    /* --text-muted, NOT --text-dim: the version string is the legal
       identifier for WHAT was agreed to, so it has to be readable.
       --text-dim measures 2.54:1 on Pro and 2.61:1 on Slate (below the 3:1
       floor); --text-muted lands 4.8-5.8:1 on all three themes. */
    color: var(--text-muted);
    font-size: 12px;
    margin-top: 18px;
    text-align: center;
}

/* ---- Focus visibility ---------------------------------------------------- */

/* --accent-text is the one token that is deliberately high-chroma against
   every theme surface (Pro blue #2563eb, Slate/Dark lavender #c4b5fd), so a
   single ring rule stays visible on all three. */
.consent-page a:focus-visible,
.consent-page button:focus-visible,
.consent-page input[type="checkbox"]:focus-visible,
.consent-page .policy-scroll:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 600px) {
    .consent-card {
        padding: 20px 16px;
        border-radius: var(--radius-md, 10px);
    }

    .policy-scroll {
        padding: 14px 14px;
    }

    .consent-brand img {
        height: 36px;
    }

    /* Stack the actions and let the CTA span the card — a 200px min-width
       button next to an underlined link wraps awkwardly at 320-390px. */
    .consent-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .consent-actions .btn-primary {
        width: 100%;
        min-width: 0;
    }

    .consent-decline {
        text-align: center;
    }
}

/* Phone landscape / any short viewport: reclaim vertical space so the
   checkbox and the CTA stay above the fold with the policy box still
   scrollable. */
@media (max-height: 520px) {
    body.auth-body.consent-body {
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    }

    .consent-brand {
        margin-bottom: var(--space-3, 12px);
    }

    .consent-brand img {
        height: 30px;
    }

    .policy-scroll {
        max-height: 40vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .consent-page * {
        transition: none !important;
        animation: none !important;
    }
}
