/* Jarvis Card, socle partagé : polices, jetons, composants.
   Règle de formes : boutons en pilule, cartes 16 px, champs 10 px. */

@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Schibsted Grotesk";
  src: url("../fonts/schibsted-grotesk-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 400 900; font-style: normal; font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}

:root {
  color-scheme: light dark;
  --font: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --paper: #F3F5FA;
  --surface: #FCFDFE;
  --surface-2: #EAEEF6;
  --surface-3: #DFE5F0;
  --ink: #0E1A33;
  --ink-2: #33405C;
  --muted: #59657F;
  --line: #D6DCE8;
  --line-2: #C3CBDA;
  --accent: #2E5CE6;
  --accent-hover: #2149C4;
  --accent-soft: #E3EAFD;
  --on-accent: #F7F9FF;
  --ok: #187547;
  --ok-soft: #DDF2E6;
  --warn: #A55508;
  --warn-soft: #FBEBD8;
  --danger: #BE3127;
  --danger-soft: #FBE1DE;
  --shadow-1: 0 1px 2px rgb(14 26 51 / .06), 0 2px 8px rgb(14 26 51 / .05);
  --shadow-2: 0 2px 6px rgb(14 26 51 / .08), 0 16px 40px rgb(14 26 51 / .10);
  --ring: 0 0 0 3px rgb(46 92 230 / .35);

  --r-card: 16px;
  --r-field: 10px;
  --r-pill: 999px;

  --ease: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 160ms;
  --t: 240ms;

  /* Couleurs de l'école (remplacées par ecoles.js) */
  --ecole: var(--accent);
  --ecole-2: #E8A317;
  --on-ecole: #F7F9FF;
  --ecole-soft: var(--accent-soft);
  --ecole-lite: var(--accent);

  /* Échelle des plans */
  --z-nav: 20;
  --z-demo: 30;
  --z-sheet: 40;
  --z-toast: 50;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0A1226;
    --surface: #101A31;
    --surface-2: #17223D;
    --surface-3: #1F2C4B;
    --ink: #EDF1FA;
    --ink-2: #C5CDE0;
    --muted: #98A3BD;
    --line: #253250;
    --line-2: #33426A;
    --accent: #7E9CFF;
    --accent-hover: #9DB4FF;
    --accent-soft: #1B2A55;
    --on-accent: #0A1226;
    --ok: #5BD08E;
    --ok-soft: #12321F;
    --warn: #F2A659;
    --warn-soft: #3A2610;
    --danger: #FF8A7F;
    --danger-soft: #3E1715;
    --shadow-1: 0 1px 2px rgb(0 0 0 / .3);
    --shadow-2: 0 2px 6px rgb(0 0 0 / .3), 0 18px 48px rgb(0 0 0 / .35);
    --ring: 0 0 0 3px rgb(126 156 255 / .45);
  }
}
:root[data-theme="dark"] {
  --paper: #0A1226;
  --surface: #101A31;
  --surface-2: #17223D;
  --surface-3: #1F2C4B;
  --ink: #EDF1FA;
  --ink-2: #C5CDE0;
  --muted: #98A3BD;
  --line: #253250;
  --line-2: #33426A;
  --accent: #7E9CFF;
  --accent-hover: #9DB4FF;
  --accent-soft: #1B2A55;
  --on-accent: #0A1226;
  --ok: #5BD08E;
  --ok-soft: #12321F;
  --warn: #F2A659;
  --warn-soft: #3A2610;
  --danger: #FF8A7F;
  --danger-soft: #3E1715;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .3);
  --shadow-2: 0 2px 6px rgb(0 0 0 / .3), 0 18px 48px rgb(0 0 0 / .35);
  --ring: 0 0 0 3px rgb(126 156 255 / .45);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.015em; font-weight: 700; }
p { margin: 0; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 70%, transparent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); font-feature-settings: "tnum" 1; letter-spacing: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* Icônes (sprite Phosphor) */
.ic { width: 20px; height: 20px; fill: currentColor; flex: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }
.ic-xl { width: 32px; height: 32px; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-weight: 600; font-size: 15px; white-space: nowrap; text-decoration: none;
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ecole { background: var(--ecole); color: var(--on-ecole); }
.btn-ecole:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 14px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-block { width: 100%; }

/* Pastilles de statut (toujours texte + couleur, jamais la couleur seule) */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 13px; font-weight: 600; white-space: nowrap;
  background: var(--surface-2); color: var(--ink-2);
}
.badge .ic { width: 14px; height: 14px; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-ecole { background: var(--ecole-soft); color: var(--ecole-lite); }

/* Champs */
.field { display: grid; gap: 6px; }
.field > label, .field > .label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: var(--r-field);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

/* Cartes et surfaces */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); }
.card-pad { padding: 20px; }
.elev { box-shadow: var(--shadow-1); }

/* Avatars */
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-3); flex: none; }
.avatar-initiales { display: grid; place-items: center; font-weight: 700; font-size: 15px; color: var(--on-ecole); background: var(--ecole); }
.avatar-lg { width: 56px; height: 56px; }

/* Tableaux */
.tbl-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 12px 16px; background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.tbl .r { text-align: right; }

/* Onglets segmentés */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: var(--r-pill); }
.seg button { min-height: 44px; padding: 0 14px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Messages courts */
.toast-zone { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: var(--z-toast); display: grid; gap: 8px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--ink); color: var(--paper); border-radius: 14px; box-shadow: var(--shadow-2); font-size: 15px; font-weight: 500; animation: toast-in var(--t) var(--ease) both; }
.toast .ic { color: var(--paper); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Feuille qui monte du bas (téléphone) et fenêtre (bureau) */
.sheet-fond { position: fixed; inset: 0; z-index: var(--z-sheet); background: rgb(8 14 30 / .45); display: grid; align-items: end; justify-items: center; animation: fade var(--t) var(--ease) both; }
.sheet { width: min(560px, 100%); max-height: 88dvh; overflow: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 8px 20px calc(20px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-2); animation: sheet-in 320ms var(--ease) both; }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; margin: 4px auto 14px; border-radius: 4px; background: var(--line-2); }
@media (min-width: 720px) {
  .sheet-fond { align-items: center; }
  .sheet { border-radius: 20px; padding-top: 20px; }
  .sheet::before { display: none; }
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* États vides et chargement */
.vide { display: grid; justify-items: center; gap: 10px; padding: 36px 20px; text-align: center; color: var(--muted); }
.vide .ic { width: 36px; height: 36px; color: var(--line-2); }
.squelette { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; border-radius: 8px; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Bandeau « école de démonstration » */
.demo-ecole { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); background: var(--warn-soft); color: var(--warn); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
