/*
 * Beta Cell Foundation — the light theme (main site only).
 *
 * site.css is the dark theme and the only place a style is defined. This file does three things and
 * nothing else: it gives the same token NAMES light values, it swaps the few pictures that are drawn
 * for a dark ground, and it styles the footer's switch. A rule written with a token needs nothing here.
 *
 * Why a file of its own: partials/shared.css and tokens.css (taken live by the Member Map, and at
 * build by T1Ds in the Wild and the Education Hub) are sliced from site.css. Those sites are dark
 * only, so the light values must not reach them. Never move a rule from here into site.css without
 * deciding that.
 *
 * Which theme shows: the device's (prefers-color-scheme), until a visitor presses the switch in the
 * footer; then their choice (html[data-theme], set before paint by theme-init.js, saved by site.js).
 * The two token blocks below are the same values twice (a media query cannot share a block with an
 * attribute selector): change both. `_tools/style-check.py` fails when they differ.
 *
 * Contrast (WCAG AA), on --bg #fff / --surface #f3f6fa / --surface2 #e8eef6:
 *   text 19.3 / 17.8 / 16.6, text-muted 7.7 / 7.1 / 6.6, text-dim 5.8 / 5.3 / 4.9,
 *   accent 5.7 / 5.3 / 4.9, accent2 5.8 / 5.4 / 5.0.
 *   The metric and status colours are the Lab Notes app's light palette, the same values as
 *   embed/shared/sim-theme.css, so a page and the simulator it frames draw one blue. Every one is
 *   5.3 / 4.9 / 4.57 or better. The exception is --metric-exercise: the app's #6B6E74 is 4.38 on
 *   --surface2, so the site keeps #6b6b6b (4.57). --wild-orange is the site's own: 5.5 / 5.1 / 4.7.
 *   --edge-control 3.7 on the ground, 3.4 on a band, 3.1 on --surface2 (WCAG 1.4.11 asks 3).
 *   The yellow keeps its dark ink (12.3:1) and gains an edge (the rule under the token blocks),
 *   because yellow on white is 1.4:1. The edge is --metric-food: 5.8 on the ground, 5.3 on a band,
 *   5.2 on a simulator page's app callout.
 */

:root { color-scheme: dark; }

/* LIGHT-TOKENS:start */
@media screen and (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg:          #ffffff;
    --bg-rgb:      255, 255, 255;
    --surface:     #f3f6fa;
    --surface2:    #e8eef6;
    --border:      #d3dce8;
    --edge-control: #7a8799;
    --accent:      #006e99;
    --accent2:     #0864c2;
    --accent-glow: rgba(0,110,153,0.07);
    --accent-ring: rgba(0,110,153,0.32);
    --cta:         #FFD53F;
    --cta-text:    #1a1a1a;
    --text:        #0a0e14;
    --text-muted:  #44546a;
    --text-dim:    #566780;
    --metric-glucose:         #0b63c5;
    --metric-insulin:         #c0261a;
    --metric-insulin-inhaled: #8a0f22;
    --metric-food:            #865f00;
    --metric-exercise:        #6b6b6b;
    --metric-recovery:        #0e7490;
    --metric-basal:           #12733c;
    --metric-heart-rate:      #b02a72;
    --status-positive:        #177143;
    --status-caution:         #b43a0c;
    --status-negative:        #c0261f;
    --status-info:            #0b63c5;
    --reflection:             #6a3fcb;
    --wild-orange:            #ad4c18;
  }
}
@media screen {
:root[data-theme="light"] {
  color-scheme: light;
  --bg:          #ffffff;
  --bg-rgb:      255, 255, 255;
  --surface:     #f3f6fa;
  --surface2:    #e8eef6;
  --border:      #d3dce8;
  --edge-control: #7a8799;
  --accent:      #006e99;
  --accent2:     #0864c2;
  --accent-glow: rgba(0,110,153,0.07);
  --accent-ring: rgba(0,110,153,0.32);
  --cta:         #FFD53F;
  --cta-text:    #1a1a1a;
  --text:        #0a0e14;
  --text-muted:  #44546a;
  --text-dim:    #566780;
  --metric-glucose:         #0b63c5;
  --metric-insulin:         #c0261a;
  --metric-insulin-inhaled: #8a0f22;
  --metric-food:            #865f00;
  --metric-exercise:        #6b6b6b;
  --metric-recovery:        #0e7490;
  --metric-basal:           #12733c;
  --metric-heart-rate:      #b02a72;
  --status-positive:        #177143;
  --status-caution:         #b43a0c;
  --status-negative:        #c0261f;
  --status-info:            #0b63c5;
  --reflection:             #6a3fcb;
  --wild-orange:            #ad4c18;
}
}
/* LIGHT-TOKENS:end */

/* ── The yellow button ─────────────────────────────────────────────────── */
/* Yellow on white is 1.4:1, so in light the one button to press takes an edge (WCAG 1.4.11). .btn has a
   transparent 1px border to colour; the header's Donate (.btn-support) has no border, so its edge is an
   inset ring and the button stays the size it is in dark. */
@media screen and (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .btn-primary { border-color: var(--metric-food); }
  :root:not([data-theme="dark"]) .btn-support { box-shadow: inset 0 0 0 1px var(--metric-food); }
}
@media screen {
  :root[data-theme="light"] .btn-primary { border-color: var(--metric-food); }
  :root[data-theme="light"] .btn-support { box-shadow: inset 0 0 0 1px var(--metric-food); }
}

/* ── The switch ────────────────────────────────────────────────────────── */
.theme-toggle {
  display: inline-grid; place-items: center;
  align-self: center;
  width: 44px; height: 44px; margin: -10px -10px -10px auto;   /* 44 to the finger, no taller row */
  border-radius: 50%; color: var(--text-muted); cursor: pointer;
  transition: color .15s, background-color .15s;
}
.theme-toggle:hover { color: var(--accent); background: var(--accent-glow); }
.theme-icon { grid-area: 1 / 1; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* The icon shows the theme that is on. */
.theme-toggle[aria-pressed="true"] .theme-icon--sun,
.theme-toggle[aria-pressed="false"] .theme-icon--moon { display: none; }

/* Print is white paper whatever the screen theme: the white-lettered logos would vanish on it. */
@media print {
  img[src$="/bcf-logo.svg"] { content: url('/images/bcf-logo-light.svg'); }
  img[src$="/bcf-avatar.svg"] { content: url('/images/bcf-avatar-light.svg'); }
}

/* ── The logos ─────────────────────────────────────────────────────────── */
/* The pages carry the dark-ground vectors (white lettering); the light theme takes their twins with the
   navy lettering (#2F475C, sampled from the PNGs Craig supplied; originals in _tools/brand-logos). Same
   paths as the dark files, one fill changed, so the two can never drift in shape. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) img[src$="/bcf-logo.svg"] { content: url('/images/bcf-logo-light.svg'); }
  :root:not([data-theme="dark"]) img[src$="/bcf-avatar.svg"] { content: url('/images/bcf-avatar-light.svg'); }
  :root:not([data-theme="dark"]) img[src$="/TOR-ALT-white.svg"] { content: url('/images/TOR-ALT-dark.svg'); }
}
:root[data-theme="light"] img[src$="/bcf-logo.svg"] { content: url('/images/bcf-logo-light.svg'); }
:root[data-theme="light"] img[src$="/bcf-avatar.svg"] { content: url('/images/bcf-avatar-light.svg'); }
:root[data-theme="light"] img[src$="/TOR-ALT-white.svg"] { content: url('/images/TOR-ALT-dark.svg'); }

/* ── Framed pages ──────────────────────────────────────────────────────── */
/* A simulator draws its own light theme when this page is light (embed/shared/sim-theme.js reads this page's
   theme), and stays dark in a dark page; the frame itself paints nothing of its own colour. */
/* An embedded page that does not declare a colour scheme must be framed as 'normal', or the browser paints an opaque white
   backdrop behind it whenever this page declares dark (the white block beside a simulator's controls). */
iframe { color-scheme: normal; }

/* ── The Finances charts ───────────────────────────────────────────────── */
/* The gold and the violet were 2.9:1 on a band (WCAG 1.4.11 asks 3 of a chart's marks); in light they
   step down to 3.5:1 there and 3.8:1 on white. The cyan, coral and green are 3.0 to 3.1 on a band as they are. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .fin { --grid: #d9dee6; --axis: #7b8796; --s2: #a37e00; --s4: #8176de; }
  :root:not([data-theme="dark"]) .fig-plot svg .focus-ring { fill: rgba(10,14,20,0.05); }
}
:root[data-theme="light"] .fin { --grid: #d9dee6; --axis: #7b8796; --s2: #a37e00; --s4: #8176de; }
:root[data-theme="light"] .fig-plot svg .focus-ring { fill: rgba(10,14,20,0.05); }

/* ── A select's chevron ────────────────────────────────────────────────── */
/* A picture in a data URI cannot read a token: site.css draws it in the dark --text-muted (2.7:1 on
   white), so light repeats it in the light --text-muted (#44546a, 7.7:1). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2344546a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); }
}
:root[data-theme="light"] .field select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%2344546a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); }
