/* Design tokens. The dark palette is declared twice on purpose: once for the
   system preference, once for the explicit override, so the manual toggle wins
   in both directions (FS §12.1). */

:root {
  color-scheme: light dark;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-md: 0.875rem;
  --fs-lg: 1rem;
  --fs-xl: 1.125rem;

  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* In rem so the lanes widen with the base text size (FS §12.5). */
  --lane-width: 18.75rem;
  --header-height: 3.25rem;

  /* Set by viewport.js when the phone keyboard is up (FS §12.4). */
  --keyboard-inset: 0px;

  --shadow-sm: 0 1px 2px rgb(40 30 20 / 8%);
  --shadow-md: 0 2px 8px rgb(40 30 20 / 10%);
  --shadow-lg: 0 12px 40px rgb(40 30 20 / 22%);

  --transition: 120ms ease;

  /* Light palette */
  --bg: #EFE9DF;
  --surface: #FFFCF7;
  --surface-2: #F8F3EB;
  --surface-3: #EEE7DC;
  --border: #E1D8C9;
  --border-strong: #C9BDA9;
  --text: #2A211B;
  --text-muted: #6B6054;
  --text-faint: #9A8F80;
  --accent: #2A211B;
  --accent-hover: #43372D;
  --accent-contrast: #F6F0E6;
  --accent-soft: #E9E0D2;
  --danger: #cf4040;
  --danger-soft: #fdecec;
  --success: #2f8f5b;
  --overlay: rgb(30 24 18 / 45%);

  /* Urgency scale, worst first (FS §4.2). */
  --u-overdue: #cc0052;      /* past the due date */
  --u-today: #ff0000;        /* due today */
  --u-second-half: #dd7a2f;  /* second half of the planned time */
  --u-first-half: #c9a20f;   /* first half of the planned time */
  --u-soon: #2f7fd0;         /* should be started within three days */
  --u-later: #CDC3B3;        /* nothing asked of you yet */
  --u-done: #B9AF9F;

  /* Something waiting on the user or on the network — not an urgency. */
  --attention: #dd7a2f;

  /* The lamp (FS §12.6, ARCHITECTURE.md §22.5), « Cendre » in light mode: its light
     (l) and its shade (s) at the stops each surface uses, in % of its reach; the
     lane's own colour; the rim, the cast shadow and its edge; the dialog's veil and
     halo; how much longer cards and tiles cast their shadows; the two textures. The
     cards are not lit in light mode, so the table of FS §12.1.1 holds exactly. */
  --lamp-page-l0: rgb(255 210 150 / 50%);
  --lamp-page-l24: rgb(255 210 150 / 15%);
  --lamp-page-s52: rgb(86 92 102 / 15%);
  --lamp-page-s100: rgb(86 92 102 / 30%);
  --lamp-header-l0: rgb(255 210 150 / 32.5%);
  --lamp-header-s100: rgb(86 92 102 / 9%);
  --lamp-lane: #F3EFE9;
  --lamp-lane-l0: rgb(255 210 150 / 13%);
  --lamp-lane-l22: rgb(255 210 150 / 6%);
  --lamp-lane-s100: rgb(86 92 102 / 11.4%);
  --lamp-card-l0: transparent;
  --lamp-card-l22: transparent;
  --lamp-card-s100: transparent;
  --lamp-rim: rgb(255 255 255 / 90%);
  --lamp-shadow: rgb(46 50 58 / 34.5%);
  --lamp-edge: rgb(46 50 58 / 6.9%);
  --lamp-veil-centre: rgb(86 92 102 / 20%);
  --lamp-veil-edge: rgb(86 92 102 / 50%);
  --lamp-halo: rgb(255 210 150 / 42%);
  --lamp-cast: 1.4;
  --lamp-grain: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='f' x='0' y='0' width='100%' height='100%' color-interpolation-filters='sRGB'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='41' stitchTiles='stitch' result='n'/><feColorMatrix in='n' values='0 0 0 0 0.165 0 0 0 0 0.129 0 0 0 0 0.106 0.2273 0 0 0 -0.1273' result='d'/><feColorMatrix in='n' values='0 0 0 0 1.000 0 0 0 0 1.000 0 0 0 0 1.000 0 -0.6364 0 0 0.2800' result='l'/><feMerge><feMergeNode in='l'/><feMergeNode in='d'/></feMerge></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  --lamp-relief: url("/textures/relief-light.webp");

  /* …and what both themes share: the lamp's reach, the dialog's drop, the two
     opacities the relief's mask is drawn with. */
  --lamp-reach: 980px;
  --lamp-drop: rgb(0 0 0 / 50%);
  --lamp-mask-full: rgb(0 0 0);
  --lamp-mask-half: rgb(0 0 0 / 50%);
}

/* A forced theme names its own scheme, so that native controls (Réglages'
   checkbox) follow it: with `light dark` alone, light forced on a device set to
   dark drew them dark. */
:root[data-theme="light"] {
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14110E;
    --surface: #1D1915;
    --surface-2: #24201B;
    --surface-3: #2C2721;
    --border: #352F28;
    --border-strong: #4A4239;
    --text: #ECE4D6;
    --text-muted: #A99E8E;
    --text-faint: #7A7063;
    --accent: #E3D8C6;
    --accent-hover: #F3ECDF;
    --accent-contrast: #14110E;
    --accent-soft: #2E2924;
    --danger: #ec6a6a;
    --danger-soft: #3a1f1f;
    --success: #4caf7d;
    --overlay: rgb(6 4 2 / 62%);

    --u-overdue: #cc0052;
    --u-today: #ff0000;
    --u-second-half: #ef8a5a;
    --u-first-half: #dcbc4c;
    --u-soon: #4a89e8;
    --u-later: #4A4239;
    --u-done: #574E44;

    --attention: #ef9a5a;

    --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-md: 0 2px 8px rgb(0 0 0 / 38%);
    --shadow-lg: 0 12px 40px rgb(0 0 0 / 55%);

    /* The lamp, « Lampe » in dark mode (FS §12.6). */
    --lamp-page-l0: rgb(255 204 148 / 22%);
    --lamp-page-l24: rgb(255 204 148 / 6.6%);
    --lamp-page-s52: rgb(0 0 0 / 30%);
    --lamp-page-s100: rgb(0 0 0 / 60%);
    --lamp-header-l0: rgb(255 204 148 / 14.3%);
    --lamp-header-s100: rgb(0 0 0 / 24%);
    --lamp-lane: #110E0B;
    --lamp-lane-l0: rgb(255 204 148 / 5.72%);
    --lamp-lane-l22: rgb(255 204 148 / 2.64%);
    --lamp-lane-s100: rgb(0 0 0 / 45%);
    --lamp-card-l0: rgb(255 204 148 / 4.84%);
    --lamp-card-l22: rgb(255 204 148 / 2.2%);
    --lamp-card-s100: rgb(0 0 0 / 25.2%);
    --lamp-rim: rgb(255 222 178 / 15%);
    --lamp-shadow: rgb(0 0 0 / 72%);
    --lamp-edge: rgb(0 0 0 / 14.4%);
    --lamp-veil-centre: rgb(0 0 0 / 33.6%);
    --lamp-veil-edge: rgb(0 0 0 / 84%);
    --lamp-halo: rgb(255 204 148 / 13%);
    --lamp-cast: 1;
    --lamp-grain: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='f' x='0' y='0' width='100%' height='100%' color-interpolation-filters='sRGB'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='41' stitchTiles='stitch' result='n'/><feColorMatrix in='n' values='0 0 0 0 0.000 0 0 0 0 0.000 0 0 0 0 0.000 0.8182 0 0 0 -0.4582' result='d'/><feColorMatrix in='n' values='0 0 0 0 0.890 0 0 0 0 0.847 0 0 0 0 0.776 0 -0.1591 0 0 0.0700' result='l'/><feMerge><feMergeNode in='l'/><feMergeNode in='d'/></feMerge></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
    --lamp-relief: url("/textures/relief-dark.webp");
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110E;
  --surface: #1D1915;
  --surface-2: #24201B;
  --surface-3: #2C2721;
  --border: #352F28;
  --border-strong: #4A4239;
  --text: #ECE4D6;
  --text-muted: #A99E8E;
  --text-faint: #7A7063;
  --accent: #E3D8C6;
  --accent-hover: #F3ECDF;
  --accent-contrast: #14110E;
  --accent-soft: #2E2924;
  --danger: #ec6a6a;
  --danger-soft: #3a1f1f;
  --success: #4caf7d;
  --overlay: rgb(6 4 2 / 62%);

  --u-overdue: #cc0052;
  --u-today: #ff0000;
  --u-second-half: #ef8a5a;
  --u-first-half: #dcbc4c;
  --u-soon: #4a89e8;
  --u-later: #4A4239;
  --u-done: #574E44;

  --attention: #ef9a5a;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 30%);
  --shadow-md: 0 2px 8px rgb(0 0 0 / 38%);
  --shadow-lg: 0 12px 40px rgb(0 0 0 / 55%);

  /* The lamp, « Lampe » in dark mode (FS §12.6). */
  --lamp-page-l0: rgb(255 204 148 / 22%);
  --lamp-page-l24: rgb(255 204 148 / 6.6%);
  --lamp-page-s52: rgb(0 0 0 / 30%);
  --lamp-page-s100: rgb(0 0 0 / 60%);
  --lamp-header-l0: rgb(255 204 148 / 14.3%);
  --lamp-header-s100: rgb(0 0 0 / 24%);
  --lamp-lane: #110E0B;
  --lamp-lane-l0: rgb(255 204 148 / 5.72%);
  --lamp-lane-l22: rgb(255 204 148 / 2.64%);
  --lamp-lane-s100: rgb(0 0 0 / 45%);
  --lamp-card-l0: rgb(255 204 148 / 4.84%);
  --lamp-card-l22: rgb(255 204 148 / 2.2%);
  --lamp-card-s100: rgb(0 0 0 / 25.2%);
  --lamp-rim: rgb(255 222 178 / 15%);
  --lamp-shadow: rgb(0 0 0 / 72%);
  --lamp-edge: rgb(0 0 0 / 14.4%);
  --lamp-veil-centre: rgb(0 0 0 / 33.6%);
  --lamp-veil-edge: rgb(0 0 0 / 84%);
  --lamp-halo: rgb(255 204 148 / 13%);
  --lamp-cast: 1;
  --lamp-grain: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='f' x='0' y='0' width='100%' height='100%' color-interpolation-filters='sRGB'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' seed='41' stitchTiles='stitch' result='n'/><feColorMatrix in='n' values='0 0 0 0 0.000 0 0 0 0 0.000 0 0 0 0 0.000 0.8182 0 0 0 -0.4582' result='d'/><feColorMatrix in='n' values='0 0 0 0 0.890 0 0 0 0 0.847 0 0 0 0 0.776 0 -0.1591 0 0 0.0700' result='l'/><feMerge><feMergeNode in='l'/><feMergeNode in='d'/></feMerge></filter><rect width='100%' height='100%' filter='url(%23f)'/></svg>");
  --lamp-relief: url("/textures/relief-dark.webp");
}
