/* Day and night mode.
   Night is the site's own look and is defined in each stylesheet's :root. Day replaces the same color tokens, so every
   page follows. This file loads last. The selectors are more specific than the :root blocks they override, so the order
   of the other stylesheets does not matter.

   The text and background colors below were checked against WCAG AA (4.5:1 for body text, 3:1 for large text).
   Do not lighten --muted, --dim or the accent without re-checking: run tools/contrast-audit.js, which visits the pages in
   both modes on a desktop and a phone and lists every piece of text that falls under the line. */

:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }

/* ---------- Day palette ---------- */
:root[data-theme="light"] {
  /* site */
  --bg: #F3F5F8; --panel: #FFFFFF; --panel2: #E8ECF1; --border: #D8DEE5; --border2: #BFC8D2;
  --text: #12171D; --muted: #465261; --dim: #586474;
  --accent: #CC1027; --accent2: #D6283E; --outro: #0A74A8; --wave-dim: #B7C0CB; --danger: #B93A1A;
  --on-accent: #FFFFFF; --bad: #B3261E; --panel-glass: rgba(255,255,255,.96); --scrim: rgba(11,13,16,.75);
  /* crate and share page */
  --line: #D8DEE5; --line2: #BFC8D2; --ok: #CC1027; --bad: #B3261E;
  /* drops */
  --dk-bg: #F3F5F8; --dk-panel: #FFFFFF; --dk-line: #D8DEE5; --dk-line-2: #BFC8D2;
  --dk-text: #12171D; --dk-muted: #465261; --dk-accent: #CC1027; --dk-accent-ink: #FFFFFF; --dk-danger: #B3261E;
}
:root[data-theme="light"] .studio-mobile {
  --sm-bg: #F3F5F8; --sm-panel: #FFFFFF; --sm-panel2: #E8ECF1; --sm-border: #D8DEE5; --sm-border2: #BFC8D2;
  --sm-text: #0E1318; --sm-muted: #38434F; --sm-dim: #556171;
  --sm-accent: #CC1027; --sm-accent2: #D6283E; --sm-outro: #0A74A8; --sm-bar: #B7C0CB; --sm-err: #B3261E;
  --sm-btn: #CC1027; --sm-btn-down: #A80D20; --sm-on-accent: #FFFFFF;
}

/* ---------- The home hero is a photograph: it keeps the night colors in both modes ---------- */
:root[data-theme="light"] .po-hero {
  color-scheme: dark; color: #E8ECF1;
  --bg: #0B0D10; --panel: #12161B; --text: #E8ECF1; --muted: #8B95A3; --dim: #8591A0; --accent: #FF2B40; --accent2: #FF5F70; --on-accent: #0B0D10;
}
/* Ghost button in the closing call-to-action sits on the page, not the photo. */
:root[data-theme="light"] .po-cta .po-ghost { color: var(--text); background: transparent; border-color: var(--border2); }

/* ---------- Logo ---------- */
:root[data-theme="light"] .brand-logo--dark { display: none; }
:root[data-theme="light"] .brand-logo--light { display: block; }

/* ---------- The toggle ---------- */
.theme-toggle { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; margin: 0; border: 1px solid var(--border2); background: transparent; color: var(--text); border-radius: 10px; cursor: pointer; -webkit-appearance: none; appearance: none; }
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { display: block; }
.theme-toggle .ti-moon, .menu-theme .ti-moon { display: none; }
:root[data-theme="light"] .theme-toggle .ti-sun, :root[data-theme="light"] .menu-theme .ti-sun { display: none; }
:root[data-theme="light"] .theme-toggle .ti-moon, :root[data-theme="light"] .menu-theme .ti-moon { display: block; }
.menu-theme { justify-content: space-between; }
.menu-theme .menu-theme-ico { display: inline-grid; place-items: center; color: var(--muted); }
@media (max-width: 760px) { .topbar .theme-toggle { display: none; } }

/* ---------- Day mode: places that hard-code dark colors ---------- */
/* Dark text on an accent background becomes white text on the day accent. */
:root[data-theme="light"] .btn-accent, :root[data-theme="light"] a.btn-accent { color: var(--on-accent); border-color: var(--accent); }
/* Inline code in guides sits on a light panel in day mode: the lighter accent is only 3.7:1 there, so use the darker one. */
:root[data-theme="light"] .doc-body code { color: var(--accent); }
:root[data-theme="light"] .doc-body pre code { color: var(--text); }
