/* Vetossimo — réinitialisation, typographie de base, utilitaires. */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: 1.55;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-modal-open { overflow: hidden; }

h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-variation-settings: 'SOFT' 50, 'WONK' 0, 'opsz' 40;
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
  text-wrap: balance;
}
h1 { font-size: clamp(1.75rem, 1.35rem + 1.7vw, 2.25rem); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); font-family: var(--font-body); font-weight: 650; }
p { margin: 0; text-wrap: pretty; }
ul, ol { margin: 0; padding-left: 1.25em; }

a {
  color: var(--primary);
  text-decoration-color: color-mix(in srgb, var(--primary) 35%, transparent);
  text-underline-offset: 3px;
}
a:hover { text-decoration-color: currentColor; }

img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:disabled { cursor: not-allowed; }

/* Focus : anneau vert 2 px, toujours visible (WCAG 2.4.11 — jamais masqué par un élément adjacent) */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--green-100); color: var(--green-900); }

/* Les chiffres qui doivent s'aligner ou se lire sans ambiguïté */
.tnum, .mono, .is-mono, td.num, .identifier {
  font-variant-numeric: tabular-nums slashed-zero;
}

.identifier {
  font-weight: 650;
  letter-spacing: 0.04em;
}

/* ───────── Utilitaires ───────── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-4); top: -100px; z-index: 200;
  background: var(--primary); color: var(--primary-contrast);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-weight: 600;
  transition: top var(--transition);
}
.skip-link:focus { top: var(--sp-4); }

.stack { display: flex; flex-direction: column; }
.stack-2 { gap: var(--sp-2); } .stack-3 { gap: var(--sp-3); }
.stack-4 { gap: var(--sp-4); } .stack-6 { gap: var(--sp-6); } .stack-8 { gap: var(--sp-8); }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--top { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; }
.hidden { display: none !important; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: var(--text-sm); }
.xsmall { font-size: var(--text-xs); }
.strong { font-weight: 650; }
.accent-text { color: var(--text-accent); }   /* bronze : le seul « or » lisible en texte sur clair */
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

.tone-success { color: var(--success); }
.tone-warning { color: var(--warning); }
.tone-danger  { color: var(--danger); }
.tone-info    { color: var(--info); }

.divider { height: 1px; background: var(--border); border: 0; margin: var(--sp-4) 0; }

/* Grilles réutilisées par les vues */
.grid { display: grid; gap: var(--sp-4); }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--form { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.span-2 { grid-column: 1 / -1; }

/* Chargement */
.skeleton {
  height: 14px; border-radius: var(--r-sm); margin-bottom: var(--sp-3);
  background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--border) 50%, var(--surface-sunken) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
.skeleton--title { height: 26px; width: 45%; margin-bottom: var(--sp-4); }
.skeleton--short { width: 60%; }
.skeleton-group { padding: var(--sp-2) 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--primary) 25%, transparent);
  border-top-color: var(--primary);
  animation: spin .7s linear infinite;
  display: inline-block;
}
.spinner-wrap { display: inline-flex; align-items: center; gap: var(--sp-2); }
@keyframes spin { to { transform: rotate(360deg); } }

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

@media print {
  .app-sidebar, .tabbar, .app-header, .toast-host, .no-print { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
}
