/* Family Life — système visuel commun (jetons, typographie, composants).
   Documentation : docs/DESIGN.md */

@font-face {
  font-family: "Bricolage Grotesque";
  src: url("../fonts/bricolage-grotesque.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-next.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("../fonts/atkinson-next-italic.woff2") format("woff2");
  font-weight: 200 800;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Playwrite FR Moderne";
  src: url("../fonts/playwrite-fr.woff2") format("woff2");
  font-weight: 100 400;
  font-display: swap;
}

:root {
  /* Couleurs de marque */
  --marine: #183443;
  --marine-fonce: #0f2532;
  --marine-doux: #2d4e60;
  --marine-pale: #dde7ea;
  --creme: #f8f4ed;
  --papier: #fffdf9;
  --sable: #efe6d7;
  --ligne: #d9cfbf;
  --cuivre: #a94d28;
  --cuivre-fonce: #8a3c1d;
  --cuivre-pale: #f5e2d6;
  --cuivre-clair: #e3a57f;      /* le fil sur fond marine */
  --ecume: #d3ebe3;
  --ecume-fonce: #17695a;
  --or: #e9cba6;

  /* Couleurs de rôle */
  --texte: var(--marine);
  --texte-doux: #4a5d66;
  --fond: var(--creme);
  --surface: var(--papier);
  --danger: #a3282b;
  --danger-pale: #f9e3e0;
  --succes: var(--ecume-fonce);
  --focus: #c2571f;

  /* Typographie */
  --f-titre: "Bricolage Grotesque", "Atkinson Hyperlegible Next", system-ui, sans-serif;
  --f-texte: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-main: "Playwrite FR Moderne", "Segoe Script", "Bradley Hand", cursive;
  --t-xs: 0.875rem;
  --t-s: 1rem;
  --t-m: 1.125rem;
  --t-l: 1.375rem;
  --t-xl: 1.75rem;
  --t-2xl: 2.25rem;
  --t-3xl: clamp(2.4rem, 5.4vw, 4.5rem);

  /* Espacements */
  --e-1: 0.25rem;
  --e-2: 0.5rem;
  --e-3: 0.75rem;
  --e-4: 1rem;
  --e-5: 1.5rem;
  --e-6: 2rem;
  --e-7: 3rem;
  --e-8: 4rem;
  --e-9: 6rem;

  /* Formes : tirages photo presque droits, boutons en pilule, panneaux arrondis */
  --r-photo: 3px;
  --r-s: 10px;
  --r-m: 16px;
  --r-l: 26px;
  --r-pilule: 999px;

  --ombre-photo: 0 14px 28px -14px rgba(8, 24, 33, 0.55), 0 2px 5px rgba(8, 24, 33, 0.18);
  --ombre-flottant: 0 24px 60px -20px rgba(15, 37, 50, 0.45);

  --rapide: 140ms;
  --moyen: 280ms;
  --courbe: cubic-bezier(0.2, 0.7, 0.2, 1);

  --cible: 48px;   /* taille minimale de toute zone cliquable */
}

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

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

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font-family: var(--f-texte);
  font-size: var(--t-m);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--f-titre);
  font-weight: 650;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0;
  text-wrap: balance;
}
h1 { font-size: var(--t-2xl); }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-l); letter-spacing: -0.01em; }
p { margin: 0; text-wrap: pretty; }
a { color: inherit; text-decoration-thickness: 1.5px; text-underline-offset: 3px; }
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--ligne); margin: var(--e-5) 0; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.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;
}

.evitement {
  position: absolute; left: var(--e-4); top: -100px; z-index: 100;
  background: var(--papier); color: var(--marine); padding: var(--e-3) var(--e-4);
  border-radius: var(--r-s); font-weight: 700;
}
.evitement:focus { top: var(--e-4); }

/* ------------------------------------------------------------------ Icônes */
.icon {
  width: 1.35em; height: 1.35em; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.icon.petit { width: 1.1em; height: 1.1em; }
.icon.grand { width: 2rem; height: 2rem; }

/* ------------------------------------------------------------------ Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2);
  min-height: var(--cible); padding: 0 var(--e-5);
  border: 2px solid var(--marine); border-radius: var(--r-pilule);
  background: transparent; color: var(--marine);
  font-weight: 700; font-size: var(--t-s); line-height: 1.2; text-decoration: none; text-align: center;
  cursor: pointer;
  transition: background var(--rapide), color var(--rapide), border-color var(--rapide), transform var(--rapide);
}
.btn:hover { background: var(--marine); color: var(--papier); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-principal { background: var(--cuivre); border-color: var(--cuivre); color: #fff; }
.btn-principal:hover { background: var(--cuivre-fonce); border-color: var(--cuivre-fonce); color: #fff; }

.btn-plein { background: var(--marine); color: var(--papier); }
.btn-plein:hover { background: var(--marine-fonce); border-color: var(--marine-fonce); }

.btn-discret { border-color: transparent; padding: 0 var(--e-4); }
.btn-discret:hover { background: var(--sable); color: var(--marine); }

.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }

.btn-clair { border-color: rgba(255, 253, 249, 0.55); color: var(--papier); }
.btn-clair:hover { background: var(--papier); border-color: var(--papier); color: var(--marine); }

.btn-petit { min-height: 44px; padding: 0 var(--e-4); font-size: var(--t-xs); }
.btn-large { width: 100%; }
.btn-grand { min-height: 56px; padding: 0 var(--e-6); font-size: var(--t-m); }

.lien {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--cuivre-fonce); font-weight: 700; text-decoration: underline;
  text-decoration-thickness: 1.5px; text-underline-offset: 3px;
}
.lien:hover { color: var(--marine); }

/* ------------------------------------------------------------------ Formulaires */
.champ { display: grid; gap: var(--e-2); }
.champ + .champ { margin-top: var(--e-4); }
.champ > label, .etiquette { font-weight: 700; font-size: var(--t-s); }
.aide { color: var(--texte-doux); font-size: var(--t-xs); }

.saisie, select.saisie, textarea.saisie {
  width: 100%; min-height: 52px; padding: var(--e-3) var(--e-4);
  background: var(--papier); border: 2px solid var(--ligne); border-radius: var(--r-s);
  font-size: var(--t-m); line-height: 1.4;
  transition: border-color var(--rapide), box-shadow var(--rapide);
}
textarea.saisie { min-height: 8rem; resize: vertical; }
.saisie::placeholder { color: #5f6d73; opacity: 1; }
.saisie:hover { border-color: #b9ad9a; }
.saisie:focus { outline: none; border-color: var(--marine); box-shadow: 0 0 0 3px rgba(24, 52, 67, 0.18); }
select.saisie {
  appearance: none; padding-right: 2.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23183443' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.9rem center; background-size: 1.2rem;
}

.case {
  display: flex; align-items: flex-start; gap: var(--e-3); cursor: pointer;
  min-height: var(--cible); padding: var(--e-3) 0;
}
.case input {
  appearance: none; flex: none; width: 26px; height: 26px; margin: 1px 0 0;
  border: 2px solid var(--marine); border-radius: 7px; background: var(--papier);
  display: grid; place-content: center; cursor: pointer;
}
.case input[type="radio"] { border-radius: 50%; }
.case input::after {
  content: ""; width: 14px; height: 14px; transform: scale(0); transition: transform var(--rapide) var(--courbe);
  background: var(--papier);
  clip-path: polygon(14% 50%, 0 65%, 40% 100%, 100% 22%, 86% 10%, 39% 70%);
}
.case input[type="radio"]::after { clip-path: none; border-radius: 50%; width: 12px; height: 12px; }
.case input:checked { background: var(--marine); }
.case input:checked::after { transform: scale(1); }
.case span small { display: block; color: var(--texte-doux); font-size: var(--t-xs); }

/* ------------------------------------------------------------------ Messages */
.message {
  display: flex; gap: var(--e-3); align-items: flex-start;
  padding: var(--e-4); border-radius: var(--r-m);
  background: var(--ecume); color: #0f3d35; font-weight: 600;
}
.message.erreur { background: var(--danger-pale); color: #6f1719; }
.message.info { background: var(--marine-pale); color: var(--marine); }
.message.attente { background: var(--cuivre-pale); color: #6b2c13; }
.message .icon { margin-top: 0.1em; }

/* ------------------------------------------------------------------ Éléments communs */
.carte {
  background: var(--surface); border: 1px solid var(--ligne); border-radius: var(--r-m);
  padding: var(--e-5);
}

.avatar {
  --taille: 44px;
  position: relative; flex: none; display: inline-grid; place-items: center;
  width: var(--taille); height: var(--taille); border-radius: 50%;
  background: var(--sable); color: var(--marine);
  font-family: var(--f-titre); font-weight: 700; font-size: calc(var(--taille) * 0.38); letter-spacing: 0;
  user-select: none;
}
.avatar.t-petit { --taille: 34px; }
.avatar.t-grand { --taille: 64px; }
.avatar.c1 { background: var(--ecume); }
.avatar.c2 { background: var(--cuivre-pale); }
.avatar.c3 { background: var(--marine-pale); }
.avatar.c4 { background: var(--or); }
.avatar.en-ligne::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 30%; height: 30%; min-width: 11px; min-height: 11px;
  border-radius: 50%; background: #1f9c7c; border: 2.5px solid var(--papier);
}

.pastille {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.25em 0.75em; border-radius: var(--r-pilule);
  background: var(--sable); color: var(--marine); font-size: var(--t-xs); font-weight: 700; line-height: 1.4;
}
.pastille.ecume { background: var(--ecume); color: #0f3d35; }
.pastille.cuivre { background: var(--cuivre-pale); color: #6b2c13; }
.pastille.marine { background: var(--marine); color: var(--papier); }
.pastille.rouge { background: var(--danger-pale); color: #6f1719; }

.compteur {
  display: inline-grid; place-items: center; min-width: 1.5rem; height: 1.5rem; padding: 0 0.4rem;
  border-radius: var(--r-pilule); background: var(--cuivre); color: #fff;
  font-size: 0.8rem; font-weight: 800; line-height: 1;
}

/* Légende manuscrite : l'écriture au dos des photos de famille */
.manuscrit {
  font-family: var(--f-main); font-weight: 300; font-size: 0.95rem; line-height: 1.5; letter-spacing: 0;
}

/* Tirage photo : marge crème et ombre portée */
.tirage {
  background: var(--papier); padding: 7px; border-radius: var(--r-photo); box-shadow: var(--ombre-photo);
}
.tirage img, .tirage video { border-radius: 1px; width: 100%; height: auto; }

/* ------------------------------------------------------------------ Fenêtre modale */
dialog.modale {
  width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
  padding: 0; border: 0; border-radius: var(--r-l);
  background: var(--papier); color: var(--texte); box-shadow: var(--ombre-flottant);
  overflow: auto;
}
dialog.modale::backdrop { background: rgba(15, 37, 50, 0.6); backdrop-filter: blur(3px); }
dialog.modale[open] { animation: modale-entre var(--moyen) var(--courbe); }
@keyframes modale-entre { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.modale-tete {
  display: flex; align-items: center; justify-content: space-between; gap: var(--e-4);
  padding: var(--e-5) var(--e-5) 0;
}
.modale-corps { padding: var(--e-5); }
.modale-fermer {
  flex: none; display: grid; place-items: center; width: var(--cible); height: var(--cible);
  border: 0; border-radius: 50%; background: var(--sable); color: var(--marine); cursor: pointer;
}
.modale-fermer:hover { background: var(--marine); color: var(--papier); }

/* Messages éphémères (confirmation d'une action) */
.toasts {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem); transform: translateX(-50%);
  z-index: 90; display: grid; gap: var(--e-2); width: min(30rem, calc(100vw - 2rem)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; gap: var(--e-3); align-items: center;
  padding: var(--e-3) var(--e-4); border-radius: var(--r-m);
  background: var(--marine); color: var(--papier); font-weight: 600; box-shadow: var(--ombre-flottant);
  animation: toast-entre var(--moyen) var(--courbe);
}
.toast.erreur { background: var(--danger); }
@keyframes toast-entre { from { opacity: 0; transform: translateY(10px); } }

@media (min-width: 900px) {
  .toasts { bottom: var(--e-6); }
}

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