/* Design tokens: paper and ink. Light phases are warm paper, dusk deep indigo and night midnight blue,
   set on <html data-phase> from the place's sunrise and sunset and dulled toward smog by the
   measured AQI band (data-haze 0 to 5). One green carries actions and people's steps; a
   slate blue marks steps about the home. tests/test_contrast.py checks every phase and haze
   level against WCAG AA, so edit values there too. */

/* Anek, by the Indian foundry Ek Type: a humanist sans (the most legible kind on small
   screens) with matching Latin and Devanagari, so the Hindi plan is set as carefully as the
   English one. One variable file per script; headings use its narrower widths. */
@font-face {
  font-family: "Anek Latin"; font-style: normal; font-weight: 100 800; font-stretch: 75% 125%; font-display: swap;
  src: url("../fonts/anek-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Anek Latin"; font-style: normal; font-weight: 100 800; font-stretch: 75% 125%; font-display: swap;
  src: url("../fonts/anek-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Anek Devanagari"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("../fonts/anek-devanagari.woff2") format("woff2");
  unicode-range: U+0900-097F, U+1CD0-1CF4, U+1CF7-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF;
}

:root {
  /* One family: Anek for everything, figures in its tabular numerals. Headings are set
     narrower and bolder (--display-stretch); Devanagari falls to Anek Devanagari. */
  --sans: "Anek Latin", "Anek Devanagari", "Noto Sans", system-ui, sans-serif;
  --display: var(--sans);
  --display-stretch: 86%;

  /* CPCB AQI band colours: only ever a small swatch beside the band's name. */
  --band-good: #00A650;
  --band-satisfactory: #8FC93A;
  --band-moderate: #F5D90A;
  --band-poor: #F28C1C;
  --band-very_poor: #E02424;
  --band-severe: #8E1616;

  /* What each fact is: a small dot beside its label (decoration; the label is the text). */
  --kind-measured: #3E9A5A;
  --kind-forecast: #5B7FA8;
  --kind-estimate: #C08A2E;
  --kind-guidance: #8A8478;
  --kind-household: #8C6FAE;

  /* Wide screens use their width: only the side margin, growing with the screen, frames it. */
  --page-max: 2200px;
  --gutter: clamp(var(--space-5), 3.2vw, 64px);
  --radius: 14px;
  --radius-control: 10px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  --haze: 0%;
}

/* Smog dulls the paper a little, never into grey: the band name says how bad the air is. */
html[data-haze="1"] { --haze: 4%; }
html[data-haze="2"] { --haze: 7%; }
html[data-haze="3"] { --haze: 10%; }
html[data-haze="4"] { --haze: 14%; }
html[data-haze="5"] { --haze: 18%; }

/* Each phase: the paper (sky), the top bar (bar-sky), what smog mixes in, and the inks. */
html[data-phase="morning"] {
  --sky: #F2F1EC; --smog: #B5AC9B; --bar-sky: #FAFAF6;
  --ink: #1C1E1C; --muted: #55544D; --panel: #FBFBF8; --line: #DAD8CF;
  --accent: #2D5A3A; --on-accent: #FFFFFF; --home: #34506F; --warn: #8A5A00;
  color-scheme: light;
}
html[data-phase="afternoon"] {
  --sky: #F3F0E8; --smog: #B6AB97; --bar-sky: #FAF8F2;
  --ink: #1D1E1B; --muted: #57534A; --panel: #FBFAF6; --line: #DDD7CB;
  --accent: #2D5A3A; --on-accent: #FFFFFF; --home: #34506F; --warn: #8A5A00;
  color-scheme: light;
}
html[data-phase="evening"] {
  --sky: #F1E8DA; --smog: #B3A58F; --bar-sky: #F8F2E8;
  --ink: #1F1C17; --muted: #574F43; --panel: #FBF7F0; --line: #DCCFBB;
  --accent: #2B5637; --on-accent: #FFFFFF; --home: #344E6C; --warn: #864F00;
  color-scheme: light;
}
html[data-phase="dusk"] {
  --sky: #1A1832; --smog: #36323F; --bar-sky: #15132B;
  --ink: #EEEAF2; --muted: #B6B0CC; --panel: #221F3D; --line: #363256;
  --accent: #8DC59B; --on-accent: #10201A; --home: #AFC3E8; --warn: #E3B35C;
  color-scheme: dark;
}
html[data-phase="night"] {
  --sky: #0E1730; --smog: #2C3140; --bar-sky: #0B1328;
  --ink: #EDEFF5; --muted: #A9B2C8; --panel: #15213C; --line: #263354;
  --accent: #8DC59B; --on-accent: #10201A; --home: #AFC6EC; --warn: #E3B35C;
  color-scheme: dark;
}

/* Pages without a household's sky (the start page, errors) wear the brand: deep forest
   green with a gold accent, whatever the device's light or dark setting. Once a household is open, Today
   takes the colours of the place's sky. */
html[data-phase="brand"] {
  --sky: #173A2A; --smog: #173A2A; --bar-sky: #133224;
  --ink: #F2EFE6; --muted: #BFD0C3; --panel: #1E4633; --line: #2E5A44;
  --accent: #E9C46A; --on-accent: #1B1A12; --home: #B9D0E8; --warn: #E9C46A;
  color-scheme: dark;
}

:root {
  --ground: color-mix(in srgb, var(--smog) var(--haze), var(--sky));
  --bar: color-mix(in srgb, var(--smog) var(--haze), var(--bar-sky));
  --accent-tint: color-mix(in srgb, var(--accent) 14%, var(--panel));
  --warn-tint: color-mix(in srgb, var(--warn) 14%, var(--panel));
}
