/* ==========================================================================
   Socle commun : polices, variables, réinitialisation, composants.
   Mobile d'abord. Pas de dégradés. Contrastes AA.
   ========================================================================== */

/* ---------- Polices (auto-hébergées, sous-ensemble latin, licence OFL) ---------- */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/poppins-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/poppins-latin-700-normal.woff2') format('woff2');
}

/* ---------- Variables ---------- */

:root {
  /* Palette imposée */
  --navy: #0b2545;
  --blue: #1f4e79;
  --orange: #e8681c;            /* accents uniquement : icônes, bordures, encadré (jamais sous du texte blanc) */
  --bg: #f7f9fc;
  --text: #202938;
  --text-muted: #595959;
  --white: #ffffff;

  /* Dérivées (teintes unies, pas de dégradé) */
  --action: #c2500e;            /* fond des boutons principaux : blanc dessus = 4,7:1 (AA) */
  --action-hover: #a8450c;      /* survol / appui : 6,0:1 */
  --orange-soft: #fdf0e7;       /* fond de l'encadré orange clair */
  --orange-border: #f4c3a1;
  --blue-soft: #e8eef5;
  --border: #dde3ec;
  --danger: #b3261e;            /* 6,5:1 sur blanc */
  --danger-soft: #fdecea;
  --success: #1e6b3a;           /* 6,6:1 sur blanc */
  --success-soft: #e7f4ec;
  --focus: #1f4e79;

  /* Typographie */
  --font-title: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-text: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;

  /* Espacements (échelle de 4 px) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(11, 37, 69, 0.06), 0 2px 8px rgba(11, 37, 69, 0.06);
  --tap: 44px;                  /* taille minimale des zones tactiles */
  --content-width: 34rem;
}

/* ---------- Réinitialisation ---------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;      /* aucun débordement horizontal à 360 px */
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

h1,
h2,
h3 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-title);
  font-weight: 700;
  line-height: 1.25;
  color: var(--navy);
}

h1 { font-size: 1.625rem; }
h2 { font-size: 1.3125rem; }
h3 { font-size: 1.0625rem; font-weight: 600; }

p {
  margin: 0 0 var(--space-4);
}

a {
  color: var(--blue);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--navy);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- Mise en page ---------- */

.container {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding: var(--space-5) var(--space-4);
}

.stack > * + * {
  margin-top: var(--space-4);
}

.text-muted {
  color: var(--text-muted);
}

.text-small {
  font-size: 0.875rem;
}

.text-center {
  text-align: center;
}

/* Masqué visuellement mais lu par les lecteurs d'écran */
.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;
}

[hidden] {
  display: none !important;
}

/* ---------- Carte ---------- */

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5) var(--space-4);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-5);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-text);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Action principale : orange foncé #C2500E (contraste AA pour tout texte, vérifié par test). */
.btn-primary {
  background: var(--action);
  color: var(--white);
  font-family: var(--font-title);
  font-size: 1.0625rem;
  font-weight: 600;
  min-height: 52px;
}

.btn-primary:hover:not(:disabled) {
  background: var(--action-hover);
  color: var(--white);
}

.btn-secondary {
  background: var(--white);
  color: var(--blue);
  border-color: var(--blue);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--blue-soft);
  color: var(--navy);
}

.btn-navy {
  background: var(--navy);
  color: var(--white);
}

.btn-navy:hover:not(:disabled) {
  background: var(--blue);
  color: var(--white);
}

.btn-danger {
  background: var(--white);
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

/* Action destructrice bien visible (désinscrire, supprimer) : blanc sur #B3261E = 6,5:1 */
.btn-danger-solid {
  background: var(--danger);
  color: var(--white);
}

.btn-danger-solid:hover:not(:disabled) {
  background: #8c1d17;
  color: var(--white);
}

.btn-link {
  min-height: var(--tap);
  padding: var(--space-2);
  background: none;
  border: none;
  color: var(--blue);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* État de chargement : spinner à gauche du libellé */
.btn.is-loading::before {
  content: '';
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Formulaires ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}

.field label,
.label {
  font-weight: 600;
  color: var(--text);
}

.field .hint {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--space-2) var(--space-3);
  border: 1px solid #7b8798;    /* 3,6:1 : au-dessus du minimum de 3:1 pour les bordures de champ */
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1rem;              /* ≥ 16 px : évite le zoom automatique sur iPhone */
}

.textarea {
  min-height: 8rem;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 0;
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

.field-error {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--danger);
}

.field-error:empty {
  display: none;
}

/* Case à cocher accessible (zone tactile de 44 px) */
.checkbox {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-height: var(--tap);
  cursor: pointer;
}

.checkbox input {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--blue);
}

/* ---------- Encadrés ---------- */

.notice {
  padding: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--blue-soft);
}

.notice-orange {
  background: var(--orange-soft);
  border-color: var(--orange-border);
}

.notice-danger {
  background: var(--danger-soft);
  border-color: #f2b8b5;
  color: var(--danger);
}

.notice-success {
  background: var(--success-soft);
  border-color: #b5dcc3;
  color: var(--success);
}

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  white-space: nowrap;
  padding: 0.125rem var(--space-2);
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--blue-soft);
  color: var(--navy);
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }

/* ---------- Notification brève ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  max-width: calc(100% - 2 * var(--space-4));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  background: var(--navy);
  color: var(--white);
  font-weight: 500;
  box-shadow: var(--shadow);
}

/* ---------- Mouvement réduit ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
