/*
 * css/tokens.css - the Clinic Teal colour tokens (day and night) and the shared theme button.
 *
 * Purpose:    The only home of the site's colours (docs/DESIGN.md): light tokens on :root and
 *             [data-theme="light"], dark tokens on [data-theme="dark"], and the same dark tokens for phones
 *             set to dark when no script ran (no data-theme). Derived helpers: --muted (secondary text, a mix
 *             of --ink and --bg that keeps 4.5:1 on --bg, --surface and --surface-2 in both themes; plain
 *             --ink where color-mix is not supported) and --night (the night teal, for things that stay dark
 *             in both themes: video letterbox, the dimmed layer behind sheets). Also .theme-btn, the moon/sun
 *             button in every top bar (the moon shows in the day theme, the sun at night).
 * Used by:    index.html, the plain pages (pricing, terms, privacy*, refund, admin) and the blog; loaded
 *             after css/fonts.css and before the page's own CSS.
 * Depends on: data-theme on <html>, set before first paint by the inline script in each page's <head>
 *             and switched by js/app.js (worker app) or js/theme.js (other pages).
 */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #FFFFFF;
  --surface: #E8F4F3;
  --surface-2: #F7FBFB;
  --border: #DCEDEB;
  --ink: #14363A;
  --ink-soft: #0F6E74;
  --primary: #0F6E74;
  --on-primary: #FFFFFF;
  --accent: #F2A541;
  --accent-bg: #FFF1DE;
  --accent-ink: #9A5B00;
  --tip-bg: #FFF6EA;
  --correct: #2A8050;
  --correct-bg: #EAF6EF;
  --wrong: #C0463C;
  --wrong-bg: #FCEEEC;
  --wrong-ink: #8E2C24;
  --track: #FFFFFF;
  --whatsapp: #1A7A43;
  --on-whatsapp: #FFFFFF;
  --night: #0E1E20;
  --muted: var(--ink);
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1E20;
  --surface: #16302F;
  --surface-2: #132624;
  --border: #1F3A38;
  --ink: #E6F2F1;
  --ink-soft: #7FD3CC;
  --primary: #3FB8B0;
  --on-primary: #0E1E20;
  --accent: #F2A541;
  --accent-bg: #3A2C12;
  --accent-ink: #F2C27A;
  --tip-bg: #2E2614;
  --correct: #4FBF80;
  --correct-bg: #173225;
  --wrong: #E0685E;
  --wrong-bg: #3A1F1E;
  --wrong-ink: #F2B0A8;
  --track: #24403F;
  --whatsapp: #1A7A43;
  --on-whatsapp: #FFFFFF;
}
/* No script ran (data-theme missing): follow the phone setting. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #0E1E20;
    --surface: #16302F;
    --surface-2: #132624;
    --border: #1F3A38;
    --ink: #E6F2F1;
    --ink-soft: #7FD3CC;
    --primary: #3FB8B0;
    --on-primary: #0E1E20;
    --accent: #F2A541;
    --accent-bg: #3A2C12;
    --accent-ink: #F2C27A;
    --tip-bg: #2E2614;
    --correct: #4FBF80;
    --correct-bg: #173225;
    --wrong: #E0685E;
    --wrong-bg: #3A1F1E;
    --wrong-ink: #F2B0A8;
    --track: #24403F;
    --whatsapp: #1A7A43;
    --on-whatsapp: #FFFFFF;
  }
}
/* Secondary text: 74% ink on the page colour (checked: at least 4.5:1 on --bg, --surface and --surface-2, both themes). */
@supports (color: color-mix(in srgb, red, blue)) {
  :root { --muted: color-mix(in srgb, var(--ink) 74%, var(--bg)); }
}
html, body { background: var(--bg); color: var(--ink); }

/* The moon/sun button in the top bar: one tap switches day and night. */
.theme-btn {
  flex: none; display: inline-grid; place-items: center;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0;
  border: 0; border-radius: 50%; background: var(--surface); color: var(--ink-soft); cursor: pointer;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; touch-action: manipulation;
}
.theme-btn svg { display: block; width: 22px; height: 22px; }
.theme-btn .sun { display: none; }
[data-theme="dark"] .theme-btn .moon { display: none; }
[data-theme="dark"] .theme-btn .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-btn .moon { display: none; }
  :root:not([data-theme]) .theme-btn .sun { display: block; }
}
.theme-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
