/* Compléments à design.css (le design system, repris tel quel de la
   maquette) : seulement ce qui manque pour l'appli réelle. Les écrans joueur
   portent body.joueur ; l'admin charge aussi cette feuille, d'où la portée. */

/* View Transitions entre pages, navigation native comme navigation Turbo. */
@view-transition {
  navigation: auto;
}

/* Petites capitales avec des chiffres alignés (voir « Chiffres » dans
   polices.css) : codes de carton, gabarits, barre d'écran. */
:root {
  --f-cap: "Chiffres", "Spectral SC", "Spectral", Georgia, serif;
}

html {
  height: 100%;
}

/* viewport-fit=cover : le contenu évite l'encoche et la barre d'accueil. */
body {
  min-height: 100%;
  min-height: 100dvh;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

/* ── Gabarit des écrans joueur ────────────────────────────────────────── */

.joueur {
  display: flex;
  flex-direction: column;
}
.joueur [hidden] { display: none !important; }

.joueur .ecran {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: 30rem;
  margin-inline: auto;
}
@media (min-width: 760px) {
  .joueur .ecran { padding-top: var(--e-6); }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.barre__equipe { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Le retour est un lien dans l'appli (un bouton dans la maquette). */
a.ecran__retour {
  display: inline-flex;
  align-items: center;
  min-height: var(--cible);
  text-decoration: none;
}
a.enigme { text-decoration: none; }

.texte-recit { display: flex; flex-direction: column; gap: var(--e-3); }

/* Introduction écrite lettre à lettre (ecriture_controller.js) : les lettres
   gardent leur place dès le départ, la mise en page ne bouge pas. */
.ecriture { cursor: pointer; }
.ecriture .lettre { opacity: 0; }
.ecriture .lettre.vue { animation: encre-lettre .45s ease-out both; }
.ecriture .lettre.vue--d-un-coup { animation-duration: .25s; }
@keyframes encre-lettre {
  from { opacity: 0; filter: blur(3px); color: var(--laiton-clair); }
  to { opacity: 1; filter: blur(0); }
}
.ecriture--finie { cursor: auto; }
/* Fin : le carton se pose une fois le texte écrit. */
.carton--fin { transition: opacity .9s ease, transform .9s cubic-bezier(.2, .7, .3, 1); }
.ecran__corps:has(.ecriture:not(.ecriture--finie)) .carton--fin { opacity: 0; transform: translateY(8px); }

.lien-discret {
  min-height: var(--cible);
  padding: 0 var(--e-3);
  border: 0;
  background: none;
  color: var(--os-2);
  font: var(--t-s) var(--f-texte);
  text-decoration: underline;
  text-decoration-color: var(--nuit-3);
  text-underline-offset: 4px;
  cursor: pointer;
}
.ecran__pied--discret { align-items: center; }

/* Le voile du pied couvre toute la largeur de l'écran : pas d'arête visible
   sur les côtés quand la colonne est plus étroite que la fenêtre. */
.joueur { overflow-x: clip; }
.joueur .ecran__pied { background: none; isolation: isolate; }
.joueur .ecran__pied::before {
  content: "";
  position: absolute;
  inset: 0 calc(50% - 50vw);
  z-index: -1;
  background: linear-gradient(to bottom, transparent, var(--nuit) 35%);
}

/* ── Ambiance : lueur de bougie et poussière spectrale ────────────────── */

.ambiance {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  view-transition-name: ambiance;
}
.ambiance__lueur {
  position: absolute;
  left: 50%;
  top: -48vmax;
  width: 120vmax;
  height: 120vmax;
  translate: -50% 0;
  border-radius: 50%;
  background: radial-gradient(closest-side,
    color-mix(in srgb, var(--laiton) 13%, transparent),
    color-mix(in srgb, var(--laiton) 4%, transparent) 55%,
    transparent);
  animation: respiration 7s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
.ambiance__lueur--vacille {
  top: -30vmax;
  width: 80vmax;
  height: 80vmax;
  background: radial-gradient(closest-side,
    color-mix(in srgb, var(--laiton-clair) 10%, transparent),
    transparent 70%);
  animation: vacille 3.7s steps(1, end) infinite, respiration 5.3s ease-in-out infinite alternate-reverse;
}
.ambiance__poussiere { position: absolute; inset: 0; width: 100%; height: 100%; }

@keyframes respiration {
  from { opacity: .75; transform: scale(.97); }
  to   { opacity: 1;   transform: scale(1.03); }
}
/* Une flamme ne bat pas en mesure : paliers irréguliers. */
@keyframes vacille {
  0%   { opacity: .9; }
  9%   { opacity: .7; }
  14%  { opacity: 1; }
  31%  { opacity: .82; }
  38%  { opacity: .95; }
  52%  { opacity: .66; }
  57%  { opacity: .9; }
  74%  { opacity: 1; }
  81%  { opacity: .78; }
  90%  { opacity: .93; }
}

/* ── Entrées ──────────────────────────────────────────────────────────── */

.apparition { animation: apparaitre .55s cubic-bezier(.2, .7, .3, 1) both .05s; }
.cascade > li { animation: apparaitre .5s cubic-bezier(.2, .7, .3, 1) both; animation-delay: calc(var(--i, 0) * 55ms + 120ms); }

@keyframes apparaitre {
  from { opacity: 0; transform: translateY(10px); }
}

/* ── Pression ─────────────────────────────────────────────────────────── */

.joueur .btn { transition: background-color .15s, border-color .15s, color .15s, transform .12s ease-out; }
.joueur .btn:active:not(:disabled) { transform: scale(.97); }
.joueur .enigme { transition: border-color .15s, background-color .15s, transform .12s ease-out; }
.joueur a.enigme:active { transform: scale(.985); }
.enigme--suggeree .enigme__etat { animation: appel 2.4s ease-in-out infinite; }

@keyframes appel {
  50% { opacity: .55; }
}

/* ── Gabarit : case active, envoi, verdicts ───────────────────────────── */

.case { position: relative; }
/* Un caractère fixe s'écrit comme dans le texte (« 11 h 45 »), pas en petite capitale. */
.case--fixe { font-family: var(--f-texte); font-weight: 400; }
.case--active::after {
  content: "";
  position: absolute;
  inset: auto 0 -3px;
  height: 3px;
  background: var(--laiton-clair);
  box-shadow: 0 0 10px var(--laiton);
  animation: battement 1.1s ease-in-out infinite alternate;
}
@keyframes battement {
  from { opacity: .35; }
  to   { opacity: 1; }
}

.saisie--envoi { animation: attente 1s ease-in-out infinite alternate; }
@keyframes attente {
  to { opacity: .55; }
}

.gabarit::before, .champ--libre::before {
  content: "";
  position: absolute;
  inset: -24px -8px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--spectre) 22%, transparent), transparent);
  opacity: 0;
  pointer-events: none;
}
.saisie--juste::before { animation: eclore 1.4s ease-out both; }
@keyframes eclore {
  0%   { opacity: 0; transform: scale(.7); }
  35%  { opacity: 1; transform: scale(1.05); }
  100% { opacity: .55; transform: scale(1); }
}

.champ--libre { position: relative; }
.champ--libre.saisie--refus { animation: tremble .45s ease; }
.champ--libre.saisie--refus .champ__saisie { border-bottom-color: var(--rose); }
.champ--libre.saisie--juste .champ__saisie { border-bottom-color: var(--spectre); color: var(--spectre); }

/* Le sceau de cire qui se pose sur le coin du gabarit. */
.sceau--tampon {
  position: absolute;
  right: -2px;
  top: -18px;
  width: 52px;
  height: 52px;
  transform: rotate(-12deg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cire) 35%, transparent), 0 6px 18px -6px #000;
  font-size: var(--t-xl);
  pointer-events: none;
}

/* ── Fragment : l'encre qui remonte ───────────────────────────────────── */

.fragment { position: relative; }
.fragment--revele .fragment__heure { animation: encre 1s ease both .15s; }
.fragment--revele .fragment__texte span { animation-delay: calc(var(--i, 0) * 70ms + 500ms); }
.fragment--revele::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 60px -6px color-mix(in srgb, var(--spectre) 60%, transparent);
  opacity: 0;
  pointer-events: none;
  animation: halo-fragment 2.6s ease-out both;
}
@keyframes halo-fragment {
  30% { opacity: 1; }
  100% { opacity: 0; }
}
.souvenir__note { font-size: var(--t-s); }

/* ── Supports trouvés (écran d'énigme) ────────────────────────────────── */

.supports-trouves { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--e-1) var(--e-3); }
.supports-trouves__compte { font-family: var(--f-cap); font-size: var(--t-s); letter-spacing: .06em; color: var(--os-2); }
.supports-trouves__liste { display: flex; flex-wrap: wrap; gap: var(--e-2); margin: 0; padding: 0; list-style: none; }
.supports-trouves__liste a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 var(--e-2);
  border: 1px solid color-mix(in srgb, var(--spectre) 35%, transparent);
  border-radius: var(--rayon);
  color: var(--spectre);
  font-size: var(--t-s);
  text-decoration: none;
}

/* ── Support scanné : la page qui se révèle ───────────────────────────── */

.support {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--e-4);
  margin-top: var(--e-3); /* place pour le sceau, qui déborde de 24px */
  padding: 40px var(--e-4) var(--e-5);
  border: 1px solid color-mix(in srgb, var(--spectre) 30%, transparent);
  border-radius: 3px;
  background: color-mix(in srgb, var(--spectre) 6%, var(--nuit-2));
  box-shadow: 0 0 40px -12px color-mix(in srgb, var(--spectre) 45%, transparent);
  text-align: center;
}
.support__titre { font-size: var(--t-2xl); }
.support__trouve { font-family: var(--f-cap); letter-spacing: .08em; color: var(--spectre); }
.support__image { display: block; max-width: 100%; height: auto; border-radius: 2px; }
/* Au milieu du bord haut, comme le cachet d'une lettre : à son plus grand
   (début de l'animation), il reste dans la largeur de l'écran. */
.support__sceau {
  position: absolute;
  top: -24px;
  left: calc(50% - 24px);
  width: 48px;
  height: 48px;
  transform: rotate(-12deg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cire) 35%, transparent), 0 6px 18px -6px #000;
  font-size: var(--t-xl);
}
.support__note { font-size: var(--t-s); text-align: center; }

.support--revele { animation: support-revele 1.4s cubic-bezier(.2, .7, .3, 1) both .1s; }
.support--revele .support__titre,
.support--revele .support__trouve,
.support--revele .support__image { animation: encre 1.2s ease both .55s; }
.support--revele .support__sceau { animation: sceau-pose .55s cubic-bezier(.3, .7, .4, 1) both 1s; }
.support--revele::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 70px -4px color-mix(in srgb, var(--spectre) 65%, transparent);
  opacity: 0;
  pointer-events: none;
  animation: halo-fragment 2.8s ease-out both .2s;
}
@keyframes support-revele {
  from { opacity: 0; transform: scale(.96); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes sceau-pose {
  from { opacity: 0; transform: scale(2.6) rotate(-28deg); }
  70%  { opacity: 1; transform: scale(.92) rotate(-10deg); }
  to   { opacity: 1; transform: rotate(-12deg); }
}

/* ── Cadran ───────────────────────────────────────────────────────────── */

.cadran { overflow: visible; touch-action: manipulation; }
.cadran__heure { -webkit-tap-highlight-color: transparent; }
.cadran__graduations line { stroke: var(--nuit-3); stroke-width: 1; }
.cadran__graduations .cadran__trait--heure { stroke: var(--os-2); stroke-width: 1.4; }
.cadran__chiffre { transition: fill .3s; }
.cadran__ride, .cadran__halo, .cadran__ondes circle {
  transform-box: fill-box;
  transform-origin: center;
  pointer-events: none;
  opacity: 0;
}
.cadran__ride { fill: color-mix(in srgb, var(--spectre) 35%, transparent); }
.cadran__halo { fill: color-mix(in srgb, var(--spectre) 22%, transparent); }
.cadran__ondes circle { fill: none; stroke: var(--spectre); stroke-width: 1.5; }
.cadran--minuit .cadran__fond { stroke: var(--spectre); transition: stroke .6s; }
.cadran--minuit .cadran__aiguille--h, .cadran--minuit .cadran__axe { fill: var(--spectre); transition: fill .6s; }
.cadran--minuit .cadran__aiguille--m { stroke: var(--spectre); transition: stroke .6s; }
.horloge__heure { font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.suite__point { color: var(--os-2); }

/* L'éclair de minuit : un voile de lueur sur tout l'écran. */
.eclair {
  position: fixed;
  inset: 0;
  z-index: 5;
  background: radial-gradient(circle at 50% 45%, var(--spectre), transparent 75%);
  opacity: 0;
  pointer-events: none;
}

/* ── Carton (accueil, fin) ────────────────────────────────────────────── */

.carton__note { font-size: var(--t-s); }
.carton__code { font-family: var(--f-cap); letter-spacing: .12em; color: var(--os); }
.carton--fin { border-color: color-mix(in srgb, var(--spectre) 35%, transparent); box-shadow: 0 0 40px -14px color-mix(in srgb, var(--spectre) 50%, transparent); }
.fin__titre { animation: apparaitre 1.2s cubic-bezier(.2, .7, .3, 1) both; }

/* ── Transitions entre écrans : un souvenir qui se brouille ───────────── */

::view-transition-group(ambiance) { animation: none; }
::view-transition-old(ambiance) { display: none; }
::view-transition-new(ambiance) { animation: none; }

::view-transition-old(root) { animation: sortie-avant .2s cubic-bezier(.4, 0, 1, 1) both; }
::view-transition-new(root) { animation: entree-avant .34s cubic-bezier(0, 0, .2, 1) .08s both; }
html[data-sens="retour"]::view-transition-old(root),
html[data-turbo-visit-direction="back"]::view-transition-old(root) { animation-name: sortie-retour; }
html[data-sens="retour"]::view-transition-new(root),
html[data-turbo-visit-direction="back"]::view-transition-new(root) { animation-name: entree-retour; }
::view-transition-group(*) { animation-duration: .38s; animation-timing-function: cubic-bezier(.3, .7, .2, 1); }

@keyframes sortie-avant { to { opacity: 0; transform: translateY(-6px) scale(.99); filter: blur(3px); } }
@keyframes entree-avant { from { opacity: 0; transform: translateY(10px); filter: blur(3px); } }
@keyframes sortie-retour { to { opacity: 0; transform: translateY(8px); filter: blur(3px); } }
@keyframes entree-retour { from { opacity: 0; transform: translateY(-8px) scale(1.01); filter: blur(3px); } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}
