/* A · Coffret : le calendrier est une boîte violette percée de 25 portes.
   Valeurs : tokens.css uniquement. Maquette : artefact Design, page « A · Coffret — écrans ». */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font-family: var(--police-texte); font-size: var(--t-corps); line-height: 1.5;
}
p, h1, h2, blockquote { margin: 0; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
sup { line-height: 0; }
cite { font-style: normal; }
:focus-visible { outline: var(--focus-trait) solid var(--focus); outline-offset: var(--focus-trait); }
.coffret :focus-visible, .case__bandeau :focus-visible { outline-color: var(--on-coffret); }

/* Échelle typographique fermée */
.titre-hero { font: 700 var(--t-hero)/1 var(--police-titre); text-transform: uppercase; }
.titre-section { font: 700 var(--t-section)/1.05 var(--police-titre); text-transform: uppercase; }
.sous-titre { font: 700 var(--t-sous)/1.15 var(--police-titre); text-transform: uppercase; }
.legende { font: 700 var(--t-legende)/1.3 var(--police-titre); letter-spacing: 0.04em; text-transform: uppercase; }
.intro { font-size: var(--t-intro); line-height: 1.38; }
.corps { font-size: var(--t-corps); line-height: 1.5; }
.petit { font-size: var(--t-petit); line-height: 1.43; }

.cadre { width: 100%; max-width: calc(var(--largeur) + 2 * var(--page-pad)); margin-inline: auto; padding-inline: var(--page-pad); }

/* En-tête : logo et sélecteur de thème */
.entete { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding-block: var(--space-3); }
.logo { display: block; width: var(--logo-w); height: var(--logo-h); }
.logo--blanc, html.dark .logo--violet { display: none; }
html.dark .logo--blanc { display: block; }

/* Pill de thème 3 positions (regles/composants/theme-toggle.md) */
.theme-switch {
  position: relative; display: flex; flex: none;
  padding: var(--pill-pad); border-radius: var(--radius-pill);
  background: var(--surface); user-select: none;
}
.theme-switch__knob {
  position: absolute; top: var(--pill-pad); left: var(--pill-pad);
  width: var(--pill-option); height: var(--pill-h);
  border-radius: var(--radius-pill); background: var(--text);
  transition: transform var(--dur-indicateur) var(--ease-indicateur);
}
.theme-switch[data-mode='auto'] .theme-switch__knob { transform: translateX(var(--pill-option)); }
.theme-switch[data-mode='dark'] .theme-switch__knob { transform: translateX(calc(2 * var(--pill-option))); }
.theme-switch__option {
  position: relative; z-index: 1;
  width: var(--pill-option); height: var(--pill-h); padding: 0;
  border: 0; border-radius: var(--radius-pill); background: transparent; cursor: pointer;
  font-size: var(--t-petit); color: var(--text-2);
  transition: color var(--dur-indicateur) var(--ease-indicateur);
}
.theme-switch__option[aria-checked='true'] { color: var(--bg); }
.theme-switching :not(.theme-switch, .theme-switch *),
.theme-switching :not(.theme-switch, .theme-switch *)::before,
.theme-switching :not(.theme-switch, .theme-switch *)::after { transition: none !important; }

/* Le coffret */
.coffret {
  margin-inline: var(--coffret-marge);
  padding: var(--coffret-pad); border-radius: var(--radius-fenetre);
  background: var(--coffret); color: var(--on-coffret);
  display: grid; gap: var(--space-3); align-items: start;
}
.coffret__gauche { display: flex; flex-direction: column; gap: var(--space-3); }

.vedette {
  display: flex; align-items: stretch; justify-content: space-between; gap: var(--space-3);
  min-height: var(--vedette-min); padding: var(--space-3);
  border: 0; border-radius: var(--radius-porte);
  background: var(--action-sur-coffret); color: var(--on-action);
  text-align: left; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-productif);
}
.vedette__texte { display: flex; flex-direction: column; justify-content: space-between; gap: var(--space-2); }
.vedette__numero {
  align-self: flex-end;
  font: 700 var(--t-vedette)/0.8 var(--police-titre); font-variant-numeric: tabular-nums;
}

.grille {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--grille-gap);
}
.porte {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 1; min-width: var(--cible); padding: 0;
  border: 0; border-radius: var(--radius-porte); overflow: hidden; cursor: pointer;
  font: 700 var(--t-chiffre)/1 var(--police-titre); font-variant-numeric: tabular-nums;
  transition: transform var(--dur-fast) var(--ease-productif);
}
.porte[data-etat='a-ouvrir'] { background: var(--action-sur-coffret); color: var(--on-action); }
.porte[data-etat='fermee'] { background: var(--surface); color: var(--text-2); cursor: not-allowed; }
.porte[data-etat='vue'] { background: var(--surface-2); color: var(--text); }
.porte__vignette { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.porte[data-etat='vue'] .porte__numero {
  position: absolute; left: var(--space-1); bottom: var(--space-1);
  min-width: var(--pastille-min); padding: var(--pastille-pad); border-radius: var(--radius-control);
  background: var(--surface-2); color: var(--text);
  font-size: var(--t-pastille); text-align: center;
}
.porte__cadenas {
  position: absolute; top: var(--cadenas-marge); right: var(--cadenas-marge); width: var(--cadenas); height: var(--cadenas);
  color: var(--verrou); fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round;
}
.porte:active, .vedette:active, .case__fermer:active, .bouton:active { transform: scale(var(--appui)); }
.porte.tremble { animation: tremble var(--dur-tremble) var(--ease-productif); }
@keyframes tremble {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(calc(-1 * var(--tremble))); }
  40% { transform: translateX(var(--tremble)); }
  60% { transform: translateX(calc(-0.75 * var(--tremble))); }
  80% { transform: translateX(calc(0.75 * var(--tremble))); }
}

.statut { padding-top: var(--space-20); color: var(--text-2); }
.statut[data-erreur] { color: var(--danger); }

.pied { margin-top: auto; padding-block: var(--space-6) var(--space-5); display: flex; flex-direction: column; gap: var(--space-12); color: var(--text-2); }

/* Fenêtre d'une case */
.case {
  width: calc(100% - 2 * var(--space-2)); max-width: var(--fenetre-max);
  max-height: calc(100dvh - 2 * var(--space-2));
  margin: var(--space-2) auto auto; padding: 0;
  border: 0; border-radius: var(--radius-fenetre); overflow: auto;
  background: var(--bg); color: var(--text);
}
.case::backdrop { background: var(--voile); }
.case__bandeau {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-20);
  background: var(--coffret); color: var(--on-coffret);
}
.case__fermer {
  display: flex; align-items: center; justify-content: center;
  width: var(--cible); height: var(--cible); padding: 0;
  border: 0; border-radius: var(--radius-control); background: transparent; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-productif);
}
.case__fermer svg, .bouton svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.case__fermer svg { width: var(--icone); height: var(--icone); }
.case__image { display: block; width: 100%; height: auto; aspect-ratio: 1376 / 768; object-fit: cover; background: var(--surface); }
.case__texte { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.case__date, .case__qui, .case__mention, .case__citation footer { color: var(--text-2); }
.case__titre { color: var(--marque); }
.case__citation { display: flex; flex-direction: column; gap: var(--space-2); }
.case__mention { padding: 0 var(--space-4) var(--space-4); }
.bouton {
  display: inline-flex; align-self: flex-start; align-items: center; gap: var(--space-2);
  min-height: var(--bouton-h); padding: 0 var(--space-20); border-radius: var(--radius-control);
  background: var(--action); color: var(--on-action); text-decoration: none;
  font: 700 var(--t-sous)/1 var(--police-titre); text-transform: uppercase;
  transition: transform var(--dur-fast) var(--ease-productif);
}
.bouton svg { width: var(--icone-petite); height: var(--icone-petite); }

/* Voile de la fenêtre : il apparaît et disparaît avec elle (la fenêtre elle-même est animée par app.js) */
.case[open]::backdrop { animation: voile-entre var(--dur-slow) var(--ease-expressif); }
.case.se-ferme::backdrop { animation: voile-sort var(--dur-slow) var(--ease-expressif) forwards; }
@keyframes voile-entre { from { opacity: 0; } }
@keyframes voile-sort { to { opacity: 0; } }

@media (min-width: 768px) {
  .coffret { gap: var(--space-4); }
  .coffret__gauche { gap: var(--space-4); }
  .vedette { padding: var(--space-4); }
  .case { margin-top: var(--space-6); max-height: calc(100dvh - 2 * var(--space-6)); }
  .case__texte { padding: var(--space-5); }
  .case__mention { padding: 0 var(--space-5) var(--space-5); }
}
@media (min-width: 1024px) {
  .coffret {
    width: calc(100% - 2 * var(--space-5)); max-width: var(--largeur); margin-inline: auto;
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); column-gap: var(--space-6);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-delay: 0s !important; transition-delay: 0s !important; transition-duration: 0s !important; }
  .porte.tremble { animation: none; }
  .porte:active, .vedette:active, .case__fermer:active, .bouton:active { transform: none; }
  .case[open]::backdrop, .case.se-ferme::backdrop { animation-duration: var(--dur-base); }
}
@media print { .theme-switch { display: none; } }
