/* ============================================================
 * theme.css — the light theme, and the control that chooses it.
 * ============================================================
 *
 * WHY A SEPARATE FILE (2026-11-16, operator instruction: "every app must
 * have a dark/light toggle, dark by default").
 *
 * site.css is at 24,379 bytes gzipped against a 24,576 byte budget
 * (scripts/ci/check-perf-budget.ps1): ~200 bytes of headroom. The light
 * palette is ~1.5 KB gzipped, so it cannot live in site.css. And it cannot
 * be an inline <style> either: the Content-Security-Policy is
 * `style-src 'self'` with no 'unsafe-inline' (public/_headers), so an
 * inline style block would be blocked. A second stylesheet is the only
 * legal home — the same reason hero-video.css exists.
 *
 * THE MECHANISM.
 *
 *   :root                      the DARK palette (site.css owns it)
 *   :root[data-theme="light"]  the LIGHT palette (this file)
 *
 * Dark is the ABSENCE of the attribute, so a visitor with no JavaScript, a
 * browser that rejects storage, or a crawler sees dark — which is the
 * contract ("dark by default", the operator's words). There is no
 * `prefers-color-scheme` rule anywhere on this site: the OS never wins.
 *
 * The pre-paint script (public/assets/js/theme.js's inline twin, in every
 * page's <head>) sets the attribute before the first paint, so a visitor who
 * chose light never sees a dark flash.
 *
 * THE TOKEN VALUES are in DESIGN.md §2.1 (Amendment 37) and are asserted by
 * scripts/ci/test-theme-contrast.mjs: every pair below is >= 4.5:1 on the
 * light canvas, which is DESIGN.md §8's floor.
 */

/* Dark is the default, and the UA should render form controls, scrollbars
   and the canvas to match it. */
:root { color-scheme: dark; }

/* ── The light palette ──────────────────────────────────────────────────
 * Each value is the dark token's light-mode counterpart. The accents get
 * DARKER, not paler: a light canvas needs more contrast from an accent,
 * not less. */
:root[data-theme="light"] {
  color-scheme: light;

  --bg:           #FFFFFF;
  --bg-elev:      #F6F8FC;
  --bg-card:      rgba(15, 23, 42, 0.035);

  --fg:           #0B1220;   /* 18.8:1 on --bg */
  --fg-muted:     #475569;   /*  7.1:1 */
  --fg-dim:       #5A6B80;   /*  5.5:1 (5.3:1 on --bg-elev) */

  --border:       rgba(15, 23, 42, 0.12);

  --accent-blue:   #2563EB;  /*  5.2:1 */
  --accent-violet: #6D28D9;  /*  7.1:1 */
  --accent-amber:  #B45309;  /*  4.8:1 */

  --fg-on-accent:  #FFFFFF;  /*  5.2:1 on --accent-blue */

  --status-live:   #047857;  /*  5.5:1 */
  --status-soon:   #92400E;  /*  7.1:1 — darker than --accent-amber on purpose:
                                the pill puts this colour on a tint of ITS OWN
                                hue, where #B45309 measured 4.39:1 */
  --status-dev:    #4338CA;  /*  8.0:1 */
  --status-oss:    #0E7490;  /*  5.4:1 */
  --status-error:  #DC2626;  /*  4.8:1 */

  /* The card shadows are for a white canvas: a black 25% shadow on white
     reads as a smudge, so the light theme uses a blue-grey shadow at a
     much lower alpha. */
  --shadow-glow:   0 0 40px rgba(37, 99, 235, 0.08);
  --shadow-card:   0 4px 24px rgba(15, 23, 42, 0.08);
  --shadow-card-h: 0 12px 32px rgba(15, 23, 42, 0.12);
}

/* ── The surfaces that are NOT tokens ─────────────────────────────────────
 * site.css carries ~30 raw rgba() literals. Each one is either decoration
 * that reads on both canvases, or a surface that would read as broken on
 * white. These are the ones that are broken, and each is overridden here
 * rather than edited in place (site.css has no room, and the rule belongs
 * with the palette it belongs to). */

/* The sticky header is a translucent dark bar. Over a white page it reads
   as a black slab, so the light theme gives it a white translucent bar. */
:root[data-theme="light"] .site-header {
  background: rgba(255, 255, 255, 0.78);
}

/* The status pills: the TEXT is a token (overridden above), but the
   background and the border are the raw hue of the old dark palette. A
   #FBBF24 tint on white is invisible, so each pill is re-tinted with its
   own light-mode hue. */
:root[data-theme="light"] .pill--live {
  background: rgba(4, 120, 87, 0.10);
  border-color: rgba(4, 120, 87, 0.30);
}
:root[data-theme="light"] .pill--soon {
  background: rgba(146, 64, 14, 0.10);
  border-color: rgba(146, 64, 14, 0.30);
}
:root[data-theme="light"] .pill--dev {
  background: rgba(67, 56, 202, 0.10);
  border-color: rgba(67, 56, 202, 0.30);
}
:root[data-theme="light"] .pill--oss {
  background: rgba(14, 116, 144, 0.10);
  border-color: rgba(14, 116, 144, 0.30);
}

/* The contact form's error region — same amber family, same reason. */
:root[data-theme="light"] .contact-error-region {
  background: rgba(146, 64, 14, 0.10);
  border-color: rgba(146, 64, 14, 0.30);
}

/* An inline code chip on a white card: a black 30% chip is a defect, not a
   style. */
:root[data-theme="light"] .oss-callout code {
  background: rgba(15, 23, 42, 0.06);
}

/* The accent hairlines: a #60A5FA line at 30% on white is invisible, so
   every rule that draws one is re-tinted with the light accent. */
:root[data-theme="light"] .card:hover,
:root[data-theme="light"] .product-card:hover,
:root[data-theme="light"] .contact-list a:hover,
:root[data-theme="light"] .deliverable:hover,
:root[data-theme="light"] .elsewhere-card:hover,
:root[data-theme="light"] .cookie-fab:hover {
  border-color: rgba(37, 99, 235, 0.40);
}
:root[data-theme="light"] .pill {
  border-color: rgba(37, 99, 235, 0.30);
}
:root[data-theme="light"] .support-disclosure > summary:hover {
  background: rgba(15, 23, 42, 0.04);
}
:root[data-theme="light"] .nl-banner-reject:hover,
:root[data-theme="light"] .nl-prefs-buttons .btn:hover {
  border-color: rgba(15, 23, 42, 0.30);
  background: rgba(15, 23, 42, 0.05);
}

/* The hero video sits on the canvas at 30% opacity; over white that washes
   the frame out entirely, so the light theme drops it to 12%. The
   reduced-motion rule (the poster frame stays visible) is unchanged. */
:root[data-theme="light"] .hero-video { opacity: 0.12; }

/* ── The toggle ───────────────────────────────────────────────────────────
 * A <button>, never an <a>: scripts/ci/check-static.ps1 §55 parses every
 * <a> inside <header> and compares the labels with the nav inventory in
 * DESIGN.md §3.3, so a link here would break that gate. A button is
 * invisible to it.
 *
 * It sits between the logo and the nav disclosure, outside the collapsing
 * <details>, so it is reachable on a phone without opening the menu. */
.theme-toggle {
  margin-left: auto;              /* the free space goes to the button, so
                                      the logo stays left and the button and
                                      the nav stay together on the right */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.theme-toggle:hover {
  color: var(--fg);
  border-color: var(--fg-dim);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}
.theme-toggle .icon { width: 18px; height: 18px; }
/* The UA rule `[hidden] { display: none }` is beaten by any author
   `display` declaration, so the hidden state needs its own rule: a
   JavaScript-less visitor must never see a control that cannot work. */
.theme-toggle[hidden] { display: none; }

/* The icon crossfades between the two themes. Under prefers-reduced-motion
   there is no transition at all (DESIGN.md §7). */
@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle .icon {
    transition: none;
  }
}
