/* Kuswar Season Tracker — tokens, base, app shell. Components live in components.css. */
@import url("fonts/faces.css");

:root {
  color-scheme: light;
  /* Warm paper, tinted toward cocoa (hue ~55). Crimson is the rare accent. */
  --paper: oklch(0.972 0.010 75);
  --paper-2: oklch(0.948 0.014 70);
  --paper-3: oklch(0.915 0.020 65);
  --surface: oklch(0.988 0.006 80);
  --rule: oklch(0.875 0.020 62);
  --rule-soft: oklch(0.925 0.014 65);
  --ink: oklch(0.255 0.030 55);
  --ink-2: oklch(0.430 0.030 55);
  --ink-3: oklch(0.500 0.025 58);
  --edge: oklch(0.600 0.025 58); /* input border: 3:1 on page and card */
  --brand: oklch(0.330 0.090 40);
  --accent: oklch(0.500 0.180 10);
  --accent-ink: oklch(0.440 0.170 10);
  --accent-tint: oklch(0.940 0.035 10);
  --bad: oklch(0.440 0.150 28);
  --bad-tint: oklch(0.945 0.035 28);
  --ok: oklch(0.470 0.120 145);
  --ok-tint: oklch(0.950 0.035 145);
  --warn: oklch(0.520 0.120 70);
  --warn-tint: oklch(0.950 0.050 85);
  --info: oklch(0.480 0.090 225);
  --info-tint: oklch(0.950 0.025 225);
  --focus: oklch(0.620 0.130 225);

  --font-display: "Baloo 2", "Mukta", system-ui, sans-serif;
  --font-body: "Mukta", system-ui, sans-serif;

  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-md: 1rem; --text-lg: 1.25rem;
  --text-xl: 1.625rem; --text-2xl: 2.125rem;

  --space-3xs: 2px; --space-2xs: 4px; --space-xs: 8px; --space-sm: 12px; --space-md: 16px;
  --space-lg: 24px; --space-xl: 32px; --space-2xl: 48px; --space-3xl: 64px;

  --radius: 6px; --radius-lg: 10px;
  --nav-w: 248px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}
/* Dark: the same warm browns at night (set by the head script and the theme switcher). Solid colours are light here, so
   the dark --surface text on them stays readable. src/darkTheme.test.ts checks every pair for WCAG AA. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: oklch(0.215 0.018 50); --paper-2: oklch(0.255 0.020 50); --paper-3: oklch(0.300 0.022 50);
  --surface: oklch(0.245 0.018 55); --rule: oklch(0.420 0.022 55); --rule-soft: oklch(0.320 0.018 55);
  --ink: oklch(0.930 0.012 75); --ink-2: oklch(0.820 0.016 70); --ink-3: oklch(0.730 0.018 65); --edge: oklch(0.550 0.022 55);
  --brand: oklch(0.830 0.065 60); --accent: oklch(0.740 0.140 15); --accent-ink: oklch(0.800 0.110 15);
  --accent-tint: oklch(0.310 0.055 15);
  --bad: oklch(0.760 0.120 28); --bad-tint: oklch(0.320 0.060 28); --ok: oklch(0.780 0.120 145); --ok-tint: oklch(0.310 0.050 145);
  --warn: oklch(0.800 0.120 80); --warn-tint: oklch(0.330 0.055 80); --info: oklch(0.780 0.090 225); --info-tint: oklch(0.310 0.040 225);
  --focus: oklch(0.740 0.120 225);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); font-size: var(--text-md); line-height: 1.45;
  background: var(--paper); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 700; line-height: 1.15; color: var(--brand); }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); font-family: var(--font-body); font-weight: 600; color: var(--ink); }
a { color: var(--accent-ink); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
  background: var(--paper-2); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; gap: var(--space-lg); padding: var(--space-lg) var(--space-sm);
}
.brand { padding: 0 var(--space-xs); display: grid; gap: 0; }
.brand:has(> .brand-logo) { grid-template-columns: auto 1fr; column-gap: var(--space-xs); align-items: center; }
.brand-logo { grid-row: 1 / span 2; height: 40px; width: auto; }
.brand b { font-family: var(--font-display); font-weight: 800; font-size: var(--text-lg); color: var(--accent); line-height: 1; }
.brand span { font-size: var(--text-xs); color: var(--ink-2); letter-spacing: 0.02em; }
.nav { display: grid; gap: var(--space-3xs); }
.nav .group { font-size: var(--text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; padding: var(--space-sm) var(--space-xs) var(--space-2xs); }
.nav a {
  display: flex; align-items: center; gap: var(--space-xs); justify-content: space-between;
  padding: 7px var(--space-xs); border-radius: var(--radius);
  color: var(--ink); text-decoration: none; font-weight: 500; font-size: var(--text-sm);
}
.nav a:hover { background: var(--paper-3); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--brand); font-weight: 700; box-shadow: 0 0 0 1px var(--rule); }
.nav kbd { font: inherit; font-size: var(--text-xs); color: var(--ink-3); }
/* Menu groups (issue 558): a button opens a body of links. A closed body is hidden, its links stay in the page. */
.nav-group { border-top: 1px solid var(--rule); padding-top: var(--space-3xs); }
.nav-gh {
  width: 100%; display: flex; align-items: center; gap: var(--space-xs); min-height: 36px; padding: 6px var(--space-xs);
  border: 0; border-radius: var(--radius); background: none; cursor: pointer; text-align: start;
  font: inherit; font-weight: 700; font-size: var(--text-sm); color: var(--ink);
}
.nav-gh:hover { background: var(--paper-3); }
.nav-gh::before { content: ""; flex: none; width: 6px; height: 6px; border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); rotate: -45deg; transition: rotate 0.15s var(--ease-out); }
.nav-gh[aria-expanded="true"]::before { rotate: 45deg; }
.nav-gname { flex: 1; }
.nav-gh[aria-expanded="true"] .nav-gcount, .nav-gcount[hidden] { display: none; }
.nav-gb { display: grid; gap: var(--space-3xs); padding: 0 0 var(--space-2xs) var(--space-sm); }
.nav-gb[hidden] { display: none; }
.nav .nav-sub { font-size: var(--text-xs); color: var(--ink-3); padding: var(--space-xs) var(--space-xs) var(--space-3xs); }
.sidebar .foot { margin-top: auto; font-size: var(--text-xs); color: var(--ink-3); padding: 0 var(--space-xs); }

.main-col { min-width: 0; display: flex; flex-direction: column; }
.season {
  display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-xl); align-items: baseline;
  padding: var(--space-sm) var(--space-xl); border-bottom: 1px solid var(--rule);
  background: var(--surface); font-size: var(--text-sm); color: var(--ink-2);
}
.season .stream { display: flex; gap: var(--space-xs); align-items: baseline; flex-wrap: wrap; }
.season .tag { font-weight: 700; color: var(--ink); }
.season .days { font-weight: 700; color: var(--ink); }
.season .days.soon { color: var(--warn); }
.season .days.past { color: var(--accent-ink); }
.season .note { color: var(--ink-3); font-size: var(--text-xs); }
main { padding: var(--space-xl) var(--space-xl) var(--space-3xl); width: 100%; max-width: 1240px; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }

.page-head { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-lg); align-items: end; justify-content: space-between; margin-bottom: var(--space-lg); }
.page-head .sub { color: var(--ink-2); font-size: var(--text-sm); margin-top: var(--space-2xs); max-width: 70ch; }
.page-head .actions { display: flex; gap: var(--space-xs); flex-wrap: wrap; align-items: center; }
.section { margin-top: var(--space-2xl); }
.section > h2 { margin-bottom: var(--space-sm); }

.toast {
  position: fixed; right: var(--space-lg); bottom: var(--space-lg); z-index: 40;
  background: var(--ink); color: var(--paper); padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius); font-size: var(--text-sm); max-width: min(420px, calc(100vw - 32px));
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity 0.2s var(--ease-out), transform 0.2s var(--ease-out);
}
.toast.show { opacity: 1; transform: none; }
.toast.err { background: var(--bad); }
.toast.act.show { pointer-events: auto; }
.toast a { color: inherit; font-weight: 600; text-decoration: underline; }

@media (max-width: 860px) {
  /* The closed header row fits its controls; the main row takes the rest (issue 1012). */
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; align-items: center;
    gap: var(--space-sm); padding: var(--space-xs) var(--space-md); border-right: 0; border-bottom: 1px solid var(--rule);
  }
  .brand b { font-size: var(--text-md); }
  .sidebar .brand span, .sidebar .foot, .nav kbd { display: none; }
  .brand-logo { grid-row: 1; height: 32px; }
  .auth-box .brand-logo { grid-row: 1 / span 2; }
  /* Phone: the menu is in a full-height dialog that the bottom bar opens (issue 561, nav-phone.css). */
  .season { padding: var(--space-xs) var(--space-md); gap: var(--space-2xs) var(--space-md); }
  main { padding: var(--space-lg) var(--space-md) var(--space-3xl); }
}

@media (prefers-reduced-motion: reduce) {
  .nav-gh::before { transition: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
.nav-count { display: inline-block; min-width: 1.4em; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--brand); color: var(--surface); font-size: 0.8em; text-align: center; }

/* Issue 817: the error of one field, under that field (field-error.ts). Select and text area get the same mark as an input. */
.fld-error { margin: 0; font-size: var(--text-sm); font-weight: 600; line-height: 1.4; color: var(--bad); }
select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); background: var(--bad-tint); }
