/* values.io's dark themes: Graphite, Midnight, Plum, Forest and Black, picked in Settings → Theme (app/theme.js).
   <html data-theme="NAME"> turns one on; no attribute = Light, the default (tokens.css). index.html's head script sets it
   before the first frame from this browser's pick (localStorage 'vio:theme'). The admin panel stays light.

   How it works: every colour on the site comes from tokens.css (Duolingo's names: snow = the page, polar = a soft fill,
   swan = lines, hare = quiet grey, wolf = second text, eel = text). A theme gives those names its own values; the soft
   tints (iguana, sea-sponge, canary...) are mixed from the bright colour over the theme's page, so every note, chip and
   tile follows the theme by itself. Part 3 fixes the few spots a token alone doesn't (button lips, item tiles, the
   switch). Words and icons on a bright face use --color-on-bright: white in Light, the theme's own ink here. A new colour
   rule anywhere: a token, never a hex, and check it in a dark theme too. Linked last in the head. */

/* a theme swap (theme.js apply): no transitions for its two frames, so nothing fades between themes while the rest jumps */
html.t-swap *, html.t-swap *::before, html.t-swap *::after { transition: none !important; }

/* ================================================================ 1. the five themes: the page's greys */

/* Graphite: neutral charcoal, a breath of cool (the Roblox app's dark) */
html[data-theme="graphite"] {
  --color-snow: #121314; --color-snow-rgb: 18, 19, 20;
  --color-polar: #1b1c1f; --color-polar-rgb: 27, 28, 31;
  --color-swan: #2c2e32; --color-swan-rgb: 44, 46, 50;
  --color-hare: #63676e; --color-hare-rgb: 99, 103, 110;
  --color-wolf: #a3a7ae; --color-wolf-rgb: 163, 167, 174;
  --color-eel: #eceef0; --color-eel-rgb: 236, 238, 240;
  --color-black-text: #e4e6e9; --color-black-text-rgb: 228, 230, 233;
}

/* Midnight: deep ink blue, a night sky (not teal) */
html[data-theme="midnight"] {
  /* its buttons: a cool mint green and a soft sky blue, the colours of a night sky over the navy */
  --color-owl: #2fd48f; --color-owl-rgb: 47, 212, 143; --color-owl-lip: #1f9e69;
  --color-macaw: #5aa9ff; --color-macaw-rgb: 90, 169, 255;
  --color-whale: #3a7fd6; --color-whale-rgb: 58, 127, 214;
  --color-snow: #0d111e; --color-snow-rgb: 13, 17, 30;
  --color-polar: #151a2b; --color-polar-rgb: 21, 26, 43;
  --color-swan: #242b42; --color-swan-rgb: 36, 43, 66;
  --color-hare: #57617f; --color-hare-rgb: 87, 97, 127;
  --color-wolf: #a3abc4; --color-wolf-rgb: 163, 171, 196;
  --color-eel: #edf0f8; --color-eel-rgb: 237, 240, 248;
  --color-black-text: #e3e7f2; --color-black-text-rgb: 227, 231, 242;
}

/* Plum: a dark purple from the logo's flame */
html[data-theme="plum"] {
  --color-snow: #140f1a; --color-snow-rgb: 20, 15, 26;
  --color-polar: #1d1725; --color-polar-rgb: 29, 23, 37;
  --color-swan: #31283c; --color-swan-rgb: 49, 40, 60;
  --color-hare: #6b5d7c; --color-hare-rgb: 107, 93, 124;
  --color-wolf: #b3a8c1; --color-wolf-rgb: 179, 168, 193;
  --color-eel: #f3eff8; --color-eel-rgb: 243, 239, 248;
  --color-black-text: #ebe5f2; --color-black-text-rgb: 235, 229, 242;
}

/* Plum's accent: the flame's lavender where the other themes have blue (tabs, chips, links, the blue buttons); its green a
   fresh mint, the green that sits best beside purple */
html[data-theme="plum"] {
  --color-owl: #4ad991; --color-owl-rgb: 74, 217, 145; --color-owl-lip: #2fa86c;
  --color-macaw: #b58aff; --color-macaw-rgb: 181, 138, 255;
  --color-whale: #8d62dc; --color-whale-rgb: 141, 98, 220;
}

/* Forest: green-black, the brand's own green underneath */
html[data-theme="forest"] {
  --color-macaw: #1fc8ae; --color-macaw-rgb: 31, 200, 174;
  --color-whale: #14a08b; --color-whale-rgb: 20, 160, 139;
  --color-snow: #0c1310; --color-snow-rgb: 12, 19, 16;
  --color-polar: #141d18; --color-polar-rgb: 20, 29, 24;
  --color-swan: #233028; --color-swan-rgb: 35, 48, 40;
  --color-hare: #546a5c; --color-hare-rgb: 84, 106, 92;
  --color-wolf: #9fb2a5; --color-wolf-rgb: 159, 178, 165;
  --color-eel: #eaf3ed; --color-eel-rgb: 234, 243, 237;
  --color-black-text: #e0ebe4; --color-black-text-rgb: 224, 235, 228;
}

/* Black: true black, for phones with OLED screens */
html[data-theme="black"] {
  --color-snow: #000000; --color-snow-rgb: 0, 0, 0;
  --color-polar: #121212; --color-polar-rgb: 18, 18, 18;
  --color-swan: #262626; --color-swan-rgb: 38, 38, 38;
  --color-hare: #5c5c5c; --color-hare-rgb: 92, 92, 92;
  --color-wolf: #a3a3a3; --color-wolf-rgb: 163, 163, 163;
  --color-eel: #f5f5f5; --color-eel-rgb: 245, 245, 245;
  --color-black-text: #ececec; --color-black-text-rgb: 236, 236, 236;
}

/* the Trades band (pages/trading.css "the band"), one per theme from its own family: a deep, saturated face that stands off
   the page without glaring, the flames a tone lighter, the lip a tone darker, the title white (4.5:1 and more on every
   face). Graphite and Black: the brand green; Midnight: a royal blue under its navy; Plum: the flame's purple; Forest:
   its teal accent */
html[data-theme="graphite"] { --color-band: #2a7a12; --color-band-lip: #1d5a0b; --color-band-flame: #348a1b; }
html[data-theme="midnight"] { --color-band: #1f3a8c; --color-band-lip: #152a68; --color-band-flame: #2846a0; }
html[data-theme="plum"] { --color-band: #4b2a7e; --color-band-lip: #361d5e; --color-band-flame: #59358f; }
html[data-theme="forest"] { --color-band: #0e5c4e; --color-band-lip: #094438; --color-band-flame: #126b5c; }
html[data-theme="black"] { --color-band: #226b0d; --color-band-lip: #174c08; --color-band-flame: #2b7a14; }
html[data-theme] { --color-band-title: var(--color-snow-always-light); }

/* every dark theme: words and icons on a bright face in the theme's own ink (6 to 10:1 on every green, blue and red face,
   where white was 1.8 to 2.6:1), the way Duolingo's own dark mode does; the green's lip its deep shade (tree-frog is a
   lighter green for words here). Graphite, Forest and Black keep the brand green; Midnight and Plum set their own above.
   The logo keeps the brand green in every theme. */
html[data-theme] { --color-on-bright: var(--color-snow); --color-owl-lip: #46a302; }
html[data-theme="midnight"] { --color-owl-lip: #1f9e69; }
html[data-theme="plum"] { --color-owl-lip: #2fa86c; }
html[data-theme] :is(.u-logo, .u-logo__word) { color: var(--color-owl-always-light); }

/* ================================================================ 2. every dark theme: colours tuned for a dark page */
html[data-theme] {
  color-scheme: dark;

  /* the soft tints: the bright colour over this theme's page (light: pale pastels) */
  --color-iguana: color-mix(in srgb, var(--color-macaw) 15%, var(--color-snow));
  --color-blue-jay: color-mix(in srgb, var(--color-macaw) 48%, var(--color-snow));
  --color-sea-sponge: color-mix(in srgb, var(--color-owl) 16%, var(--color-snow));
  --color-turtle: color-mix(in srgb, var(--color-owl) 45%, var(--color-snow));
  --color-canary: color-mix(in srgb, var(--color-bee) 13%, var(--color-snow));
  --color-walking-fish: color-mix(in srgb, var(--color-cardinal) 16%, var(--color-snow));
  --color-flamingo: color-mix(in srgb, var(--color-cardinal) 45%, var(--color-snow));
  --color-ice: color-mix(in srgb, var(--color-blue-jay) 20%, var(--color-snow));

  /* deep colours that are words in Light: lifted so they read on dark */
  --color-fire-ant: #ff6161;                         /* error words, "Remove" */
  --color-tree-frog: #6fcc1f;                        /* "Found it" words; also the green button's lip (fixed in 3) */
  --color-butterfly: #c9a3ff;                        /* the purple badge's words */
  --color-guinea-pig: #ffab38;                       /* orange words on a yellow tint */
  --color-legendary-foreground: #ffd166;
  --color-eddy-radio: #ff6b6b;
  --color-blue-space: #123a66;                       /* the Night banner: still a deep blue, a step off the page */

  /* pop.css's words that must read */
  --color-label: color-mix(in srgb, var(--color-wolf) 88%, var(--color-eel));
  --color-placeholder: color-mix(in srgb, var(--color-wolf) 80%, var(--color-snow));
  --color-up: var(--color-owl);                      /* "▲ 2.1%" */
  --color-down: #ff6b6b;                             /* "▼ 1.2%" */
  --color-warn-text: #ffd166;                        /* words on a yellow note */
  --color-info-text: #8fd8ff;                        /* words on a blue note */
  --color-on-soft-green: var(--color-eel);
  --color-timer: #ffa62b;
  --color-count: #e5484d;                            /* the red count badge (white words on it) */
  --color-link: color-mix(in srgb, var(--color-macaw) 82%, var(--color-snow-always-light));   /* small text links: the accent, a touch lighter */

  /* things that drop over the page: a lighter face than the page, a stronger shadow, a darker scrim */
  --u-scrim: rgba(var(--color-black-rgb), .62);
  --u-drop-edge: color-mix(in srgb, var(--color-swan) 70%, var(--color-hare));
  --u-drop-shadow: 0 4px 0 rgba(var(--color-black-rgb), .25), 0 16px 40px rgba(var(--color-black-rgb), .55);
  --u-toast-bg: color-mix(in srgb, var(--color-eel) 15%, var(--color-snow));   /* a raised grey, a step off the page */
  --u-toast-fg: var(--color-eel);
  --u-knob: var(--color-eel);
  --u-knob-edge: var(--color-hare);
}

/* the item tiles: the rarity's own colour as a deep jewel tone, mixed into one NEUTRAL dark (never the theme's tinted
   line grey: Godly's pink turned maroon on Forest's green-grey and plum on Midnight's navy), so a rarity is the same
   colour in every theme; a step lighter than the page, so a black knife still stands out on it and the tile doesn't
   glare. Black: a step deeper, for its true black page */
html[data-theme] { --tile-base: #1d1e22; }
html[data-theme="black"] { --tile-base: #161618; }
html[data-theme] [data-tier] {
  /* oklab: the tier's hue stays clean (an sRGB mix greys it, yellow goes olive); never oklch, whose hue walks */
  --tier-soft: color-mix(in oklab, var(--tier) 36%, var(--tile-base));
  --tier-line: color-mix(in srgb, var(--tier) 74%, var(--color-snow));   /* the profile banner: the tier's own colour, a step down (half-mixed with the dark page, yellow turned olive) */
}

/* a black knife on its tile: a faint light edge round every item picture, so a dark item never sinks into the tile */
html[data-theme] .u-pic[data-tier] > img { filter: drop-shadow(0 0 1px rgba(var(--color-snow-always-light-rgb), .26)); }

/* the switch: a quiet grey knob when off, white on the colour when on */
html[data-theme] .u-switch__track::before { --u-knob: color-mix(in srgb, var(--color-wolf) 78%, var(--color-swan)); --u-knob-edge: var(--color-swan); }
html[data-theme] .u-switch > input:checked + .u-switch__track::before { --u-knob: var(--color-snow-always-light); }

/* ================================================================ 3. spots the tokens alone don't fix */

/* the lips under green and red buttons: their own deep shade (tree-frog and fire-ant are lighter words here) */
html[data-theme] .u-btn--green { --edge: var(--color-owl-lip); }
html[data-theme] .u-btn--red { --edge: #d83a3a; }
html[data-theme] .c-tmenu__ic.is-cancel { box-shadow: 0 2px 0 #d83a3a; }

/* a toast: its raised face with a drop's edge and shadow, so it stands off the dark page */
html[data-theme] .u-toast { box-shadow: inset 0 0 0 2px var(--u-drop-edge), var(--u-drop-shadow); }
