/*
 * Shared light/dark theme for the public Ferdinand Collective portal pages.
 *
 * Dark is the default (no attribute). A visible toggle (injected by theme.js)
 * sets [data-theme="light"] on <html>, which remaps the shared design-system
 * tokens plus the handful of hardcoded Tailwind utility and custom classes the
 * pages actually use. Media-backed bands (hero video/photo) deliberately stay
 * dark in both themes — a cinematic dark hero over a light body is intentional,
 * not a bug.
 *
 * Contrast: body ink on the light surface clears WCAG AA (>=4.5:1); the clay/red
 * brand accent is darkened to the deep crimson for text usage in light mode so
 * small labels/links stay legible, while the orange is retained for filled
 * buttons (white-on-orange, large/bold, >=3:1).
 */

:root {
    /* Semantic theme tokens (dark defaults). Light values live in the override
       block below; existing brand vars (--fc-black, --house-off-white, etc.)
       are declared per page and re-pointed there too. */
    --bg: #000000;
    --surface: #111111;
    --ink: #EDE9E6;
    --muted: rgba(237, 233, 230, 0.62);
}

/* The nav is position:fixed, so it is out of flow and every scroll anchor parks
   its target underneath the bar — the booking panel scrolled to after picking a
   session, and every #hash landing in the nav. Offsetting the scrollport's top
   padding corrects all callers at once, rather than adding scroll-margin to one
   element and leaving the sibling call sites broken. --nav-height/--banner-height
   are declared on :root by each page; the fallbacks cover pages that omit them. */
html {
    scroll-padding-top: calc(var(--nav-height, 80px) + var(--banner-height, 0px) + 1rem);
}

/* html[...] not [data-theme] alone: each page declares its dark tokens in an
   inline :root that loads after this file, and :root ties a bare attribute
   selector on specificity. The element-qualified selector outranks :root so the
   light tokens win regardless of source order. */
html[data-theme="light"] {
    --bg: #F4F1ED;
    --surface: #FFFFFF;
    --ink: #17130F;
    --muted: #574E45;

    /* Re-point the brand vars the pages already consume so every var-driven
       surface, border and control flips without touching its own CSS. */
    --fc-black: #F4F1ED;
    --house-off-white: #17130F;
    --surface-raised: #FFFFFF;
    --border-subtle: rgba(23, 19, 15, 0.14);
}

/* ── Page + section backgrounds ─────────────────────────────────────────── */
[data-theme="light"] body,
[data-theme="light"] .grit-bg,
[data-theme="light"] .bg-black { background-color: var(--bg) !important; }

/* Some pages hardcode `body{color:#fff}` instead of a token, so inherited text
   (e.g. a heading with no colour class) would stay white on the light surface.
   Flip the inherited colour; dark bands re-assert light inheritance below. */
[data-theme="light"] body { color: var(--ink); }

[data-theme="light"] .bg-neutral-950 { background-color: #ECE7E1 !important; }
[data-theme="light"] .bg-neutral-900 { background-color: #E6E0D8 !important; }
[data-theme="light"] .bg-neutral-800 { background-color: #DBD3C9 !important; }

/* Fixed nav uses a translucent bg-black/90 — flip it to a translucent light. */
[data-theme="light"] nav.header-fixed,
[data-theme="light"] nav.fixed { background-color: rgba(244, 241, 237, 0.9) !important; }

/* ── Text ───────────────────────────────────────────────────────────────── */
[data-theme="light"] .text-white { color: var(--ink) !important; }
[data-theme="light"] .text-neutral-200,
[data-theme="light"] .text-neutral-300 { color: #3B342D !important; }
[data-theme="light"] .text-neutral-400,
[data-theme="light"] .text-neutral-500 { color: #574E45 !important; }
[data-theme="light"] .primary-nav.text-neutral-300,
[data-theme="light"] [data-tenant-nav] a { color: #3B342D !important; }

/* Brand accent: darken to deep crimson for text/label usage so 11px bold labels
   and links clear AA on the light surface. */
[data-theme="light"] .text-rise-orange,
[data-theme="light"] .section-tag { color: var(--deep-crimson, #991B1B) !important; }

/* Filled buttons keep white text in both themes. */
[data-theme="light"] .btn-primary { color: #FFFFFF !important; }
[data-theme="light"] .btn-outline { color: var(--ink); }

/* Cinematic dark bands — the hero, image breakers, and the near-black arbitrary
   backgrounds the pages use for feature bands (#050505 / #0a0a0a) — deliberately
   keep their dark background in light mode. Everything nested inside them must
   therefore keep its light-on-dark treatment, otherwise the global light
   overrides above would paint dark text/surfaces onto a dark band. The four
   roots are grouped with :is() so each rule reads once. */
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) { color: #EDE9E6; }
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) .text-white { color: #FFFFFF !important; }
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) .field-label { color: rgba(237, 233, 230, 0.72) !important; }
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) .field-help { color: rgba(237, 233, 230, 0.58) !important; }
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) :is(.text-neutral-200, .text-neutral-300, .text-neutral-400, .text-neutral-500) { color: rgba(237, 233, 230, 0.85) !important; }
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) .surface-card {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: rgba(237, 233, 230, 0.12) !important;
}
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) :is(.section-tag, .text-rise-orange) { color: var(--rise-orange, #FF3A20) !important; }
[data-theme="light"] :is(.hero-section, .breaker-img, .bg-\[\#050505\], .bg-\[\#0a0a0a\]) .btn-outline {
    color: #EDE9E6 !important;
    border-color: rgba(237, 233, 230, 0.3) !important;
}

/* ── Borders ────────────────────────────────────────────────────────────── */
[data-theme="light"] .border-white\/5 { border-color: rgba(23, 19, 15, 0.08) !important; }
[data-theme="light"] .border-white\/10 { border-color: rgba(23, 19, 15, 0.12) !important; }

/* ── Shared custom surfaces (hardcoded rgba in per-page <style>) ─────────── */
[data-theme="light"] .glass-panel { background: rgba(255, 255, 255, 0.88) !important; }
[data-theme="light"] .surface-card,
[data-theme="light"] .social-feed-card { background: rgba(23, 19, 15, 0.04) !important; }
[data-theme="light"] .rss-widget-container { background: rgba(23, 19, 15, 0.03) !important; }
[data-theme="light"] .session-row { border-bottom-color: rgba(23, 19, 15, 0.08) !important; }
[data-theme="light"] .field-label { color: rgba(23, 19, 15, 0.72) !important; }
[data-theme="light"] .field-help { color: rgba(23, 19, 15, 0.58) !important; }
[data-theme="light"] .social-icon { color: rgba(23, 19, 15, 0.72); }
[data-theme="light"] .social-icon:hover { color: #FFFFFF; }

/* The after-school-club and camp cards, and the camps booking modal, hardcode a
   near-black rgba in their own page <style> instead of a token, and they sit in
   ordinary light sections rather than the cinematic dark bands above. So the
   surface stayed dark while the .text-white flip turned their headings to dark
   ink — school and camp names rendered at 1.22:1, i.e. invisible. Flip the
   surface, exactly as .glass-panel and .surface-card already do on these pages.
   background-COLOR, never the `background` shorthand: the shorthand expands to
   background-image:none, which would erase the custom caret that
   `select.form-control` draws with two linear-gradients.

   .modal-box (the camps booking modal) is deliberately EXCLUDED. Flipping it was
   tried and measured: the modal interior is broadly unreadable in light mode
   already (60 of 74 text elements below AA at rest) because of nested bg-white/10,
   bg-black/40, hardcoded borders and status pastels that this rule does not
   reach. Flipping only its outer surface moved it to 63 of 74 — i.e. worse, on a
   screen a parent uses to pay. It needs its own pass, tracked separately; leaving
   it dark keeps it at least self-consistent and regression-free. */
[data-theme="light"] :is(.asc-card, .camp-card) {
    background-color: var(--surface) !important;
    border-color: rgba(23, 19, 15, 0.12) !important;
}

/* The "Standard" price badge is white-on-rgba(255,255,255,0.1) — readable only
   because that translucent white sat on a DARK card. Flipping the card above turns
   it white-on-white, so it has to flip with it. Scoped to the flipped cards on
   purpose: the same badge also renders inside the camps modal, which stays dark,
   and a light-grey/dark-ink badge there would be unreadable. The other tiers
   (super/early/perday) carry solid gold/green/blue and read correctly on either
   surface, so they are deliberately left alone. */
[data-theme="light"] :is(.asc-card, .camp-card) .tier-standard {
    background-color: rgba(23, 19, 15, 0.08) !important;
    color: var(--ink) !important;
}

/* Inputs hardcode a near-black in the same per-page <style> (after-school-clubs,
   contact, camps). Left dark, their flipped ink makes typed text and the school
   search box unreadable in light mode. This also repairs a pre-existing portal
   bug: partner-portal sets color:#f0f0f0 on a surface theme.css already flips to
   white, i.e. white text in a white input.
   background-COLOR, not the `background` shorthand — the shorthand expands to
   background-image:none and would erase the caret that select.form-control draws
   with two linear-gradients (8 selects on the public site, 44 in the portal). */
[data-theme="light"] .form-control {
    background-color: var(--surface) !important;
    border-color: rgba(23, 19, 15, 0.18) !important;
    color: var(--ink) !important;
}
[data-theme="light"] .form-control::placeholder { color: rgba(23, 19, 15, 0.55) !important; }

/* ── Toggle control (injected by theme.js) ──────────────────────────────── */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; min-height: 44px; padding: 0;
    border-radius: 6px; cursor: pointer;
    background: transparent;
    border: 1px solid var(--border-subtle, rgba(237, 233, 230, 0.12));
    color: var(--ink, #EDE9E6);
    font-size: 1.05rem; line-height: 1;
    transition: border-color 0.2s ease, color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--rise-orange, #FF3A20); color: var(--rise-orange, #FF3A20); }
.theme-toggle:focus-visible { outline: 2px solid var(--rise-orange, #FF3A20); outline-offset: 2px; }

/* ════════════════════════════════════════════════════════════════════════════
   PARTNER PORTAL (admin SPA) — light-mode overrides. Scoped under .fc-portal so
   the public pages are untouched. The portal is Tailwind-CDN (no config, so its
   fc-black/rise-orange utilities are inert) plus a per-page <style> of custom
   classes. The shared token flips above already re-surface its body, cards,
   forms and buttons; these rules cover the hardcoded gray/white Tailwind
   utilities and the custom classes that carry their own dark hex, so nothing
   stays black-on-black. Ink #17130F / muted #574E45 both clear AA (>=4.5:1) on
   the light surfaces.
   ════════════════════════════════════════════════════════════════════════════ */

/* Muted + inverted text (pervasive as labels/secondary copy on the old dark UI). */
[data-theme="light"] .fc-portal :is(.text-gray-200, .text-gray-300) { color: #2A2620 !important; }
[data-theme="light"] .fc-portal :is(.text-gray-400, .text-gray-500, .text-gray-600) { color: #574E45 !important; }
[data-theme="light"] .fc-portal .text-white { color: var(--ink) !important; }
[data-theme="light"] .fc-portal .text-white\/90 { color: rgba(23, 19, 15, 0.9) !important; }
[data-theme="light"] .fc-portal .text-white\/80 { color: rgba(23, 19, 15, 0.8) !important; }
[data-theme="light"] .fc-portal :is(.text-white\/50, .text-white\/40) { color: rgba(23, 19, 15, 0.6) !important; }

/* Brand orange as text on a light surface only clears AA at large/bold sizes, so
   arbitrary-value orange labels drop to the deep crimson (kept branded, legible
   at any size). Harmless if the inert utility class produced no colour. */
[data-theme="light"] .fc-portal :is(.text-\[\#FF3A20\], .text-\[\#f87171\], .text-rise-orange) { color: var(--deep-crimson, #991B1B) !important; }

/* Translucent tints + hardcoded near-black panels (notifications, dropdowns). */
[data-theme="light"] .fc-portal .bg-white\/5 { background-color: rgba(23, 19, 15, 0.04) !important; }
[data-theme="light"] .fc-portal :is(.bg-\[\#1a1a1a\], .bg-\[\#111\]) { background-color: #FFFFFF !important; }

/* Borders + dividers (theme.css flips /5 and /10 globally; the portal also uses /15). */
[data-theme="light"] .fc-portal .border-white\/15 { border-color: rgba(23, 19, 15, 0.16) !important; }
[data-theme="light"] .fc-portal .divide-white\/5 > :not([hidden]) ~ :not([hidden]) { border-color: rgba(23, 19, 15, 0.08) !important; }

/* Tabs: white active/hover ink would vanish on the pale tint. */
[data-theme="light"] .fc-portal .tab-btn.active { color: var(--ink) !important; }
[data-theme="light"] .fc-portal .tab-btn:hover { color: var(--ink) !important; background: rgba(23, 19, 15, 0.04) !important; }

/* Primary button hover: the dark rule flips to white-bg/fc-black-text, but fc-black
   is now near-white, so pin a legible dark hover instead. */
[data-theme="light"] .fc-portal .btn-primary:hover:not(:disabled) { background-color: #17130F !important; color: #FFFFFF !important; }

/* Custom-class surfaces that carry their own dark hex. */
[data-theme="light"] .fc-portal :is(.bar-bg, .rev-bar-bg) { background-color: #E0DAD1 !important; }
[data-theme="light"] .fc-portal .player-card .avatar { background: #E6E0D8 !important; color: #574E45 !important; }
[data-theme="light"] .fc-portal .player-card .pcollect { color: #574E45 !important; }
[data-theme="light"] .fc-portal .vbar .vlab { color: #574E45 !important; }
[data-theme="light"] .fc-portal .vbar .vval { color: #2A2620 !important; }
[data-theme="light"] .fc-portal .history-row:nth-child(even) { background-color: rgba(23, 19, 15, 0.03) !important; }

/* Near-black NEUTRAL surfaces painted as inline styles by the render JS (payment-issue
   rows, kit tiles, register blocks, chips). Inline styles only yield to !important, so
   target them by substring. The paired text is class-driven (.text-white/.text-gray-*)
   and already flips above. Coloured status pills (#1e3a5f/#7c2d12/#7f1d1d/#064e3b …)
   are deliberately excluded — they stay light-on-colour and read fine on the light UI. */
[data-theme="light"] .fc-portal :is([style*="background:#1a1a1a"], [style*="background:#1a1010"], [style*="background:#1f2937"], [style*="background:#374151"], [style*="background:#3f3f46"]) { background: #FFFFFF !important; }
[data-theme="light"] .fc-portal :is([style*="background:#111"], [style*="background:#333"]) { background: #ECE7E1 !important; color: #2A2620 !important; }
[data-theme="light"] .fc-portal :is([style*="solid #333"], [style*="solid #444"], [style*="solid #555"]) { border-color: rgba(23, 19, 15, 0.14) !important; }

/* Dashboard stat cards paint their labels/deltas with hardcoded Tailwind
   pastels (gray-400 #9ca3af, mint #6ee7b7, rose #fca5a5) via raw-CSS custom
   classes — not utility classes — so the flips above miss them. On white cards
   in light mode those fail AA (2.5:1 labels, 1.5–1.9:1 deltas). Darken to the
   portal's own muted ink and to deep green/red that clear ≥4.5:1 on white,
   keeping the green=up / red=down semantic. Dark mode keeps its on-dark pastels. */
[data-theme="light"] .fc-portal .stat-card h3,
[data-theme="light"] .fc-portal .flat { color: #574E45 !important; }   /* 8.14:1 on #FFF */
[data-theme="light"] .fc-portal .up { color: #15803D !important; }     /* 5.02:1 on #FFF */
[data-theme="light"] .fc-portal .down { color: #B91C1C !important; }    /* 6.47:1 on #FFF */
