/*
 * base.css - Jetons de design, remise à zéro, typographie, boutons, champs.
 *
 * Thème : clair / sombre automatique, ou forcé par data-theme sur <html>.
 * Toutes les couleurs passent par light-dark(), une seule définition par jeton.
 */

:root {
  color-scheme: light dark;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-serif: "Sitka Heading", "Sitka Text", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: "Cascadia Mono", Consolas, ui-monospace, monospace;

  /* Surfaces : papier chaud le jour, ardoise la nuit */
  --bg:             light-dark(#f3f1ec, #111316);
  --surface:        light-dark(#ffffff, #181b1f);
  --surface-2:      light-dark(#faf8f5, #1d2025);
  --surface-3:      light-dark(#f1eee8, #24282e);
  --overlay:        light-dark(rgb(255 255 255 / .82), rgb(24 27 31 / .82));
  --border:         light-dark(#e5e1d9, #2a2f35);
  --border-strong:  light-dark(#d2ccc1, #3a4047);

  /* Texte */
  --text:           light-dark(#1d1c1a, #ebe8e2);
  --text-2:         light-dark(#5b5750, #aca79e);
  --text-3:         light-dark(#8a857b, #7c776f);

  /* Accent : bleu pétrole, couleur d'encre */
  --accent:         light-dark(#2a5d71, #82b9cc);
  --accent-hover:   light-dark(#214b5c, #a0cbda);
  --accent-soft:    light-dark(#e3eef1, #1d3440);
  --accent-softer:  light-dark(#f0f6f8, #18272f);
  --on-accent:      light-dark(#ffffff, #0d1a20);

  --danger:         light-dark(#b2443b, #e7837a);
  --danger-soft:    light-dark(#f8e7e5, #3a2321);
  --warn:           light-dark(#9a5f17, #e3ac5f);
  --warn-soft:      light-dark(#fbf1e1, #342817);
  --ok:             light-dark(#2e7550, #7fc79e);

  --shadow-sm: 0 1px 2px light-dark(rgb(29 28 26 / .06), rgb(0 0 0 / .3));
  --shadow-md: 0 6px 20px light-dark(rgb(29 28 26 / .08), rgb(0 0 0 / .35)), 0 1px 3px light-dark(rgb(29 28 26 / .06), rgb(0 0 0 / .3));
  --shadow-lg: 0 28px 70px light-dark(rgb(29 28 26 / .2), rgb(0 0 0 / .55)), 0 4px 14px light-dark(rgb(29 28 26 / .08), rgb(0 0 0 / .3));
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 32%, transparent);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --topbar-h: 60px;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* ------------------------------------------------------------------ Reset */

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 400 15px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

h1, h2, h3, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
[hidden] { display: none !important; }

::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  font: 500 11.5px/1.5 var(--font-mono);
  text-align: center;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------------ Icônes */

.sprite { display: none; }

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

/* ----------------------------------------------------------------- Boutons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}

.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { color: var(--on-accent); background: var(--accent); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-ghost { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }

.btn-quiet { color: var(--text-2); }
.btn-quiet:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }

.btn-danger { color: #fff; background: var(--danger); }
.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 88%, #000); }

.btn-icon { width: 36px; padding: 0; color: var(--text-2); }
.btn-icon:hover:not(:disabled) { color: var(--text); background: var(--surface-3); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-icon.btn-sm { width: 30px; padding: 0; }

/* ------------------------------------------------------------------ Champs */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.input,
.field input,
.field select,
.field textarea,
.row input,
.row select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 11px;
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}

.field textarea { height: auto; min-height: 92px; padding: 9px 11px; line-height: 1.5; resize: vertical; }

.field input:hover, .field select:hover, .field textarea:hover,
.row input:hover, .row select:hover { border-color: color-mix(in srgb, var(--text-3) 70%, var(--border-strong)); }

.field input:focus, .field select:focus, .field textarea:focus,
.row input:focus, .row select:focus,
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }

select {
  appearance: none;
  padding-right: 30px !important;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

/* ------------------------------------------------------------ Animations */

@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
