/*
 * Design tokens — direction « premium Apple » :
 * gris neutres Apple, bleu système, typographie SF (police système),
 * matériaux translucides réservés à la navigation et aux contrôles,
 * ombres très douces, grands rayons, mouvements « ressort ».
 * Textes : contraste ≥ 4,5:1 sur leur fond dans les deux thèmes.
 */
:root {
  /* Surfaces */
  --bg: #f2f2f7;
  --surface: #ffffff;
  --surface-2: #f5f5f7;
  --surface-hover: #ececf0;
  --selection: #e3e3e8;
  --fill: #e8e8ed; /* pistes des contrôles segmentés, boutons gris */
  --border: #e5e5ea;
  --border-strong: #d2d2d7;

  /* Texte */
  --text: #1d1d1f;
  --text-2: #424245;
  --text-3: #636366;

  /* Couleurs système (variantes accessibles) */
  --accent: #0066cc;
  --accent-hover: #0071e3;
  --accent-fill: #0071e3;
  --accent-weak: #e8f2fd;
  --accent-on: #ffffff;
  --danger: #d70015;
  --danger-weak: #fdeceb;
  --warn: #b25000;
  --warn-weak: #fff3e0;
  --ok: #1f7a35;
  --ok-weak: #e7f6ea;
  --info: #8944ab;
  --info-weak: #f5ecfa;

  /* Matériaux */
  --glass: rgb(255 255 255 / 0.72);
  --glass-strong: rgb(255 255 255 / 0.86);
  --glass-filter: saturate(180%) blur(20px);
  --backdrop: rgb(0 0 0 / 0.28);

  /* Profondeur */
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 1px rgb(0 0 0 / 0.02);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.03), 0 8px 24px rgb(0 0 0 / 0.06);
  --shadow-lg: 0 4px 12px rgb(0 0 0 / 0.06), 0 24px 64px rgb(0 0 0 / 0.16);

  --badge: #d70015; /* pastille : rouge fixe, texte blanc 5,4:1 dans les deux thèmes */
  --prio-high: var(--danger);
  --prio-medium: var(--warn);
  --prio-low: var(--text-3);

  /* Formes et typographie */
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --tracking-tight: -0.022em;
  --tracking-title: -0.028em;

  /* Mouvement */
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-fast: 150ms;
  --dur: 220ms;
  --dur-slow: 360ms;

  --sidebar-w: 236px;

  /* Bureau : formes des widgets et panneaux */
  --r-tile: 24px;
  --r-panel: 30px;
  --tile-gap: 18px;
  --tile-row: 172px;

  /* Couleurs des modules (couche de contenu : pastilles d'icône, jamais sur les contrôles) */
  --c-tasks: #0071e3;
  --c-cal: #5e5ce6;
  --c-notes: #b87400;
  --c-today: #ff8a3d;
  --c-neutral: #8e8e93;

  /* Fond du moment de la journée (data-phase sur <html>) */
  --wp-1: #cfe5ff;
  --wp-2: #e9ddff;
  --wp-3: #ffe6d3;
  --wp-strength: 100%;
  --focus: 0 0 0 4px color-mix(in srgb, var(--accent) 28%, transparent);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #161618;
    --surface-hover: #2c2c2e;
    --selection: #323236;
    --fill: #2c2c2e;
    --border: #2c2c2e;
    --border-strong: #3a3a3c;
    --text: #f5f5f7;
    --text-2: #c7c7cc;
    --text-3: #98989d;
    --accent: #3e9bff;
    --accent-hover: #64afff;
    --accent-fill: #0a6fe0;
    --accent-weak: #0f2a47;
    --accent-on: #ffffff;
    --danger: #ff6961;
    --danger-weak: #3b1715;
    --warn: #ffb340;
    --warn-weak: #3a2a10;
    --ok: #30d158;
    --ok-weak: #0f3019;
    --info: #da8fff;
    --info-weak: #36203f;
    --glass: rgb(28 28 30 / 0.72);
    --glass-strong: rgb(28 28 30 / 0.88);
    --backdrop: rgb(0 0 0 / 0.55);
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-md: 0 2px 4px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
    --shadow-lg: 0 4px 12px rgb(0 0 0 / 0.4), 0 24px 64px rgb(0 0 0 / 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --surface-2: #161618;
  --surface-hover: #2c2c2e;
  --selection: #323236;
  --fill: #2c2c2e;
  --border: #2c2c2e;
  --border-strong: #3a3a3c;
  --text: #f5f5f7;
  --text-2: #c7c7cc;
  --text-3: #98989d;
  --accent: #3e9bff;
  --accent-hover: #64afff;
  --accent-fill: #0a6fe0;
  --accent-weak: #0f2a47;
  --accent-on: #ffffff;
  --danger: #ff6961;
  --danger-weak: #3b1715;
  --warn: #ffb340;
  --warn-weak: #3a2a10;
  --ok: #30d158;
  --ok-weak: #0f3019;
  --info: #da8fff;
  --info-weak: #36203f;
  --glass: rgb(28 28 30 / 0.72);
  --glass-strong: rgb(28 28 30 / 0.88);
  --backdrop: rgb(0 0 0 / 0.55);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-md: 0 2px 4px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 4px 12px rgb(0 0 0 / 0.4), 0 24px 64px rgb(0 0 0 / 0.6);
  color-scheme: dark;
}

/* Transparence réduite : matériaux opaques. */
@media (prefers-reduced-transparency: reduce) {
  :root, :root[data-theme] {
    --glass: var(--surface);
    --glass-strong: var(--surface);
    --glass-filter: none;
  }
}

/* Contraste augmenté : séparateurs et textes secondaires renforcés, matériaux opaques. */
@media (prefers-contrast: more) {
  :root, :root[data-theme] {
    --border: color-mix(in srgb, var(--text) 32%, transparent);
    --border-strong: color-mix(in srgb, var(--text) 55%, transparent);
    --text-3: var(--text-2);
    --glass: var(--surface);
    --glass-strong: var(--surface);
    --glass-filter: none;
  }
}

/* --- Fond « moment de la journée » --- */
:root[data-phase="matin"] { --wp-1: #ffd6bf; --wp-2: #ffedc8; --wp-3: #dcebff; --c-today: #ff8a3d; }
:root[data-phase="jour"] { --wp-1: #c8e2ff; --wp-2: #dff3ff; --wp-3: #ece2ff; --c-today: #0a84ff; }
:root[data-phase="soir"] { --wp-1: #ffcfc4; --wp-2: #e3d2ff; --wp-3: #ffe2cc; --c-today: #e0567a; }
:root[data-phase="nuit"] { --wp-1: #cdd3ff; --wp-2: #c4c4f0; --wp-3: #e6dcfb; --c-today: #5e5ce6; }

@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --wp-strength: 30%; } }
:root[data-theme="dark"] { --wp-strength: 30%; }
@media (prefers-contrast: more) { :root, :root[data-theme] { --wp-strength: 0%; } }
