/* ============================================================================
   tokens.css — the single source of truth.
   No hex value belongs anywhere else in the codebase.

   Two independent choices:

     data-palette   which set of colours   (cinema | slate)   default: cinema
     data-theme     light or dark          (light | dark)     default: the OS

   So the file is in two layers. A PALETTE declares both of its value sets at
   once, under --light-* / --dark-* names; the MODE blocks below map one of
   those sets onto the role names the rest of the CSS uses. Adding a palette
   therefore means adding one block, not one per mode, and no other file
   changes. The role names and the rule behind them are unchanged from
   calendar-design/tokens.css: the accent means duration and is never used for
   chrome. Every text pair clears 4.5:1 in both palettes and both modes
   (scratch check: contrast.py).
   ========================================================================= */

/* --- palette: cinema (default) ---------------------------------------------
   The blue-and-orange of a film poster: teal surfaces and teal chrome, with
   the warm half of the pair reserved for the calendar — a span is the only
   orange thing on the page, which is exactly the emphasis it wants.
   -------------------------------------------------------------------------- */

:root,
:root[data-palette="cinema"] {
  /* surfaces */
  --light-ground: #ECF1F3;   /* the page behind the calendar */
  --light-surface: #FFFFFF;  /* week strips, menus, dialog cards */
  --light-seam: #D7E2E5;     /* the 1px hairline between days, card edges, menu dividers */
  /* text */
  --light-ink: #0B2836;      /* day numerals, menu items, headings */
  --light-muted: #4E6B77;    /* weekday labels, captions, out-of-month days */
  --light-body: #234B59;     /* entry labels, paragraph text */
  /* recessed / filled control surfaces */
  --light-track: #E4EBEE;    /* segmented-control and stepper tracks, chips */
  --light-field: #EEF3F4;    /* text fields, date fields */
  --light-hover: #F1F6F7;    /* hovered menu item tile */
  /* meaning */
  --light-accent: #AC4E0A;   /* a multi-day span. NEVER used for chrome. */
  --light-accent-2: #0E7490; /* a second concurrent span */
  --light-danger: #DC2626;   /* destructive actions only */
  --light-on-accent: #FFFFFF;
  --light-on-danger: #FFFFFF;
  --light-on-ink: #EAF4F7;   /* text on the ink-filled today tile */
  /* chrome: the primary button and the avatar. A separate role from --accent
     so that "orange means duration" survives. */
  --light-primary: #0E5E72;
  --light-primary-hover: #0A4C5D;
  --light-on-primary: #FFFFFF;
  /* entries drawn on the inverted today tile, which is dark in light mode */
  --light-accent-inv: #F5A45A;
  --light-accent-2-inv: #66D3E8;
  --light-dot-inv: #EAF4F7;
  --light-body-inv: #C3DCE4;
  --light-scrim: rgba(7, 26, 34, 0.48);
  --light-shadow-pop: 0 1px 2px rgba(11, 40, 54, 0.08), 0 22px 44px -22px rgba(11, 40, 54, 0.45);
  --light-shadow-card: 0 2px 4px rgba(11, 40, 54, 0.10), 0 40px 80px -30px rgba(11, 40, 54, 0.55);
  --light-shadow-seg: 0 1px 2px rgba(11, 40, 54, 0.12);

  --dark-ground: #071A22;
  --dark-surface: #0F2A34;
  --dark-seam: #1C4150;
  --dark-ink: #EAF4F7;
  --dark-muted: #90AAB4;
  --dark-body: #C6DCE3;
  --dark-track: #0A212B;
  --dark-field: #0A212B;
  --dark-hover: #163946;
  --dark-accent: #FB923C;
  --dark-accent-2: #4DC7DF;
  --dark-danger: #F87171;
  /* On a light-on-dark accent, white text fails. These flip. */
  --dark-on-accent: #071A22;
  --dark-on-danger: #071A22;
  --dark-on-ink: #071A22;
  --dark-primary: #0E7490;
  --dark-primary-hover: #108099;
  --dark-on-primary: #FFFFFF;
  /* the today tile is light in dark mode, so these are the dark ends */
  --dark-accent-inv: #9A3D06;
  --dark-accent-2-inv: #0B5C70;
  --dark-dot-inv: #071A22;
  --dark-body-inv: #234C59;
  --dark-scrim: rgba(2, 10, 14, 0.62);
  --dark-shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.35), 0 22px 44px -22px rgba(0, 0, 0, 0.8);
  --dark-shadow-card: 0 2px 4px rgba(0, 0, 0, 0.4), 0 40px 80px -30px rgba(0, 0, 0, 0.9);
  --dark-shadow-seg: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* --- palette: slate --------------------------------------------------------
   Cool slate, after BookOrbit's dashboard — navy surfaces with a 1px edge,
   near-white / slate text, one saturated blue. The app's original scheme,
   kept as an option; these values are unchanged.
   -------------------------------------------------------------------------- */

:root[data-palette="slate"] {
  --light-ground: #EEF2F7;
  --light-surface: #FFFFFF;
  --light-seam: #E2E8F0;
  --light-ink: #0F172A;
  --light-muted: #5B6B84;
  --light-body: #334155;
  --light-track: #EDF1F7;
  --light-field: #F1F5F9;
  --light-hover: #F5F8FC;
  --light-accent: #2563EB;
  --light-accent-2: #C2410C;
  --light-danger: #DC2626;
  --light-on-accent: #FFFFFF;
  --light-on-danger: #FFFFFF;
  --light-on-ink: #F8FAFC;
  --light-primary: #2563EB;
  --light-primary-hover: #1D4ED8;
  --light-on-primary: #FFFFFF;
  --light-accent-inv: #60A5FA;
  --light-accent-2-inv: #FB923C;
  --light-dot-inv: #F8FAFC;
  --light-body-inv: #E2E8F0;
  --light-scrim: rgba(15, 23, 42, 0.48);
  --light-shadow-pop: 0 1px 2px rgba(15, 23, 42, 0.08), 0 22px 44px -22px rgba(15, 23, 42, 0.45);
  --light-shadow-card: 0 2px 4px rgba(15, 23, 42, 0.10), 0 40px 80px -30px rgba(15, 23, 42, 0.55);
  --light-shadow-seg: 0 1px 2px rgba(15, 23, 42, 0.12);

  --dark-ground: #0B1120;
  --dark-surface: #161E31;
  --dark-seam: #232F4B;
  --dark-ink: #F1F5F9;
  --dark-muted: #8E9BB3;
  --dark-body: #CBD5E1;
  --dark-track: #0E1424;
  --dark-field: #0E1424;
  --dark-hover: #1D2740;
  --dark-accent: #5B8DF6;
  --dark-accent-2: #FB923C;
  --dark-danger: #F87171;
  --dark-on-accent: #0B1120;
  --dark-on-danger: #0B1120;
  --dark-on-ink: #0B1120;
  --dark-primary: #2563EB;
  --dark-primary-hover: #2F6FEB;
  --dark-on-primary: #FFFFFF;
  --dark-accent-inv: #1D4ED8;
  --dark-accent-2-inv: #9A3412;
  --dark-dot-inv: #0B1120;
  --dark-body-inv: #334155;
  --dark-scrim: rgba(3, 7, 18, 0.62);
  --dark-shadow-pop: 0 1px 2px rgba(0, 0, 0, 0.35), 0 22px 44px -22px rgba(0, 0, 0, 0.8);
  --dark-shadow-card: 0 2px 4px rgba(0, 0, 0, 0.4), 0 40px 80px -30px rgba(0, 0, 0, 0.9);
  --dark-shadow-seg: 0 1px 2px rgba(0, 0, 0, 0.45);
}

/* --- swatches --------------------------------------------------------------
   The two-colour previews in the appearance menu. Defined outside the palette
   blocks on purpose: an inactive palette's swatch must show that palette's
   colours, not the current one's.
   -------------------------------------------------------------------------- */

:root {
  --swatch-cinema-a: #0E5E72;
  --swatch-cinema-b: #E2620E;
  --swatch-slate-a: #2563EB;
  --swatch-slate-b: #C2410C;
}

/* --- mode: light (the default) --------------------------------------------- */

:root {
  color-scheme: light dark;

  --ground: var(--light-ground);
  --surface: var(--light-surface);
  --seam: var(--light-seam);
  --ink: var(--light-ink);
  --muted: var(--light-muted);
  --body: var(--light-body);
  --track: var(--light-track);
  --field: var(--light-field);
  --hover: var(--light-hover);
  --accent: var(--light-accent);
  --accent-2: var(--light-accent-2);
  --danger: var(--light-danger);
  --on-accent: var(--light-on-accent);
  --on-danger: var(--light-on-danger);
  --on-ink: var(--light-on-ink);
  --primary: var(--light-primary);
  --primary-hover: var(--light-primary-hover);
  --on-primary: var(--light-on-primary);
  --accent-inv: var(--light-accent-inv);
  --accent-2-inv: var(--light-accent-2-inv);
  --dot-inv: var(--light-dot-inv);
  --body-inv: var(--light-body-inv);
  --scrim: var(--light-scrim);
  --shadow-pop: var(--light-shadow-pop);
  --shadow-card: var(--light-shadow-card);
  --shadow-seg: var(--light-shadow-seg);

  /* --- radii ------------------------------------------------------------- */
  --r-card: 24px;       /* dialog card */
  --r-strip: 18px;      /* a week strip, a menu panel */
  --r-tile: 16px;       /* a day that becomes its own run (today, selected) */
  --r-track: 14px;      /* segmented / stepper track, textarea */
  --r-control: 12px;    /* menu item, chip, button, field */
  --r-seg: 11px;        /* active segment inside a 14px track (14 - 3 padding) */

  /* --- type -------------------------------------------------------------- */
  --font-display: 'Inter', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-ui: 'Inter', -apple-system, 'Segoe UI', Helvetica, Arial, sans-serif;

  /* --- geometry ---------------------------------------------------------- */
  --day-inset: 13px;    /* applied to a day's CHILDREN, never the day itself */
  --lane-h: 16px;
  --lane-gap: 4px;
  --row-gap: 9px;       /* between week strips */
  --hit: 44px;          /* minimum interactive height, everywhere */
}

/* --- mode: dark ------------------------------------------------------------
   Twice, because a media query cannot join a selector list: once for "the OS
   says dark and the user hasn't overridden it", once for an explicit choice.
   -------------------------------------------------------------------------- */

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: var(--dark-ground);
    --surface: var(--dark-surface);
    --seam: var(--dark-seam);
    --ink: var(--dark-ink);
    --muted: var(--dark-muted);
    --body: var(--dark-body);
    --track: var(--dark-track);
    --field: var(--dark-field);
    --hover: var(--dark-hover);
    --accent: var(--dark-accent);
    --accent-2: var(--dark-accent-2);
    --danger: var(--dark-danger);
    --on-accent: var(--dark-on-accent);
    --on-danger: var(--dark-on-danger);
    --on-ink: var(--dark-on-ink);
    --primary: var(--dark-primary);
    --primary-hover: var(--dark-primary-hover);
    --on-primary: var(--dark-on-primary);
    --accent-inv: var(--dark-accent-inv);
    --accent-2-inv: var(--dark-accent-2-inv);
    --dot-inv: var(--dark-dot-inv);
    --body-inv: var(--dark-body-inv);
    --scrim: var(--dark-scrim);
    --shadow-pop: var(--dark-shadow-pop);
    --shadow-card: var(--dark-shadow-card);
    --shadow-seg: var(--dark-shadow-seg);
  }
}

:root[data-theme="dark"] {
  --ground: var(--dark-ground);
  --surface: var(--dark-surface);
  --seam: var(--dark-seam);
  --ink: var(--dark-ink);
  --muted: var(--dark-muted);
  --body: var(--dark-body);
  --track: var(--dark-track);
  --field: var(--dark-field);
  --hover: var(--dark-hover);
  --accent: var(--dark-accent);
  --accent-2: var(--dark-accent-2);
  --danger: var(--dark-danger);
  --on-accent: var(--dark-on-accent);
  --on-danger: var(--dark-on-danger);
  --on-ink: var(--dark-on-ink);
  --primary: var(--dark-primary);
  --primary-hover: var(--dark-primary-hover);
  --on-primary: var(--dark-on-primary);
  --accent-inv: var(--dark-accent-inv);
  --accent-2-inv: var(--dark-accent-2-inv);
  --dot-inv: var(--dark-dot-inv);
  --body-inv: var(--dark-body-inv);
  --scrim: var(--dark-scrim);
  --shadow-pop: var(--dark-shadow-pop);
  --shadow-card: var(--dark-shadow-card);
  --shadow-seg: var(--dark-shadow-seg);
}
