/* Protocole : styles propres au jeu. S'appuie sur les variables de /css/locost.css, sans nouvelles couleurs. */

/* ---------- Fiche d'archive ---------- */
.fiche {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 16px calc(96px + env(safe-area-inset-bottom));
}
.fiche-tete { text-align: center; margin-bottom: 28px; }
.fiche-tete .terminal { min-height: 1.7em; }
.point.archive { color: var(--fg-dim); }
.point.archive::before { color: var(--red); }

.tampon {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(255, 42, 79, 0.55);
  color: var(--red);
  font-size: 0.62rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  transform: rotate(-2deg);
}

/* Compte à rebours figé */
.compteur {
  margin: 0 0 32px;
  padding: 18px 12px 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}
.compteur-cases { display: flex; justify-content: center; gap: clamp(10px, 5vw, 28px); }
.compteur-case { display: flex; flex-direction: column; align-items: center; min-width: 2.6em; }
.compteur-nombre { font-size: clamp(1.6rem, 9vw, 2.4rem); font-weight: 600; color: #e6e6e6; font-variant-numeric: tabular-nums; }
.compteur-unite { color: var(--fg-faint); font-size: 0.65rem; letter-spacing: 0.3em; }
.compteur-legende { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 14px 0 0; color: var(--fg-dim); font-size: 0.72rem; }
.compteur.derive .compteur-nombre { color: var(--fg-dim); text-shadow: 2px 0 var(--red), -2px 0 var(--cyan); }

/* Rappels dépliables */
.rappels { border-top: 1px solid var(--line); }
.rappel { border-bottom: 1px solid var(--line); }
.rappel > summary,
.doc > summary,
.semaine > summary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.rappel > summary::-webkit-details-marker,
.doc > summary::-webkit-details-marker,
.semaine > summary::-webkit-details-marker { display: none; }
.rappel > summary { padding: 16px 4px; text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.8rem; }
.rappel > summary::after,
.doc > summary::after,
.semaine > summary::after { content: "+"; margin-left: auto; color: var(--fg-faint); }
.rappel[open] > summary::after,
.doc[open] > summary::after,
.semaine[open] > summary::after { content: "−"; color: var(--green); }
.rappel > summary:hover .rappel-titre { color: #fff; }
.rappel > summary:focus-visible,
.doc > summary:focus-visible,
.semaine > summary:focus-visible { outline: 1px solid var(--green); outline-offset: 2px; }
.rappel-num { color: var(--fg-faint); }
.rappel-corps { padding: 0 4px 20px; font-size: 0.85rem; }

/* Transmission */
.log { min-height: 6em; }
.log-ligne { margin: 0 0 10px; color: var(--fg); }
.log-ligne.systeme { color: var(--fg-dim); }
.log-prefixe { color: var(--fg-faint); }
.log-ligne.phaco .log-prefixe { color: var(--green); }
.lien-console {
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg-dim);
  font: 0.72rem var(--mono);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.lien-console::before { content: "> "; text-decoration: none; }
.lien-console:hover { color: var(--fg); }

/* Documents */
.doc { border-left: 1px solid var(--line); margin: 0 0 8px; padding: 0 0 0 12px; }
.doc > summary { padding: 8px 0; color: var(--fg); }
.doc h3 { margin: 14px 0 4px; color: var(--fg-dim); font-size: 0.7rem; font-weight: 400; letter-spacing: 0.18em; text-transform: uppercase; }
.doc p, .doc ul { margin: 0 0 10px; color: var(--fg); }
.doc ul { padding-left: 1.2em; }
.doc li { margin-bottom: 4px; }
.note { margin: 16px 0 0; color: var(--fg-faint); font-size: 0.7rem; }

/* Passages censurés */
.caviar {
  display: inline;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  background: #1d1d1d;
  color: transparent;
  font: inherit;
  line-height: inherit;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  transition: background 0.25s, color 0.25s;
}
.caviar:hover { background: #262626; }
.caviar.leve { background: transparent; color: var(--green); cursor: text; }
.caviar.definitif { cursor: not-allowed; user-select: none; letter-spacing: -0.05em; }
.caviar.definitif.refuse { animation: tressaille 0.3s steps(2) 1; background: rgba(255, 42, 79, 0.25); }

/* Dossier d'étude */
.semaine { border-left: 1px solid var(--line); margin: 0 0 8px; padding: 0 0 0 12px; }
.semaine > summary { padding: 8px 0; }
.semaine-num { color: var(--fg-faint); }
.semaine.vide .semaine-nom { color: var(--fg-faint); }
.semaine.execute { border-left-color: rgba(255, 42, 79, 0.4); }
.semaine-coord { margin: 0 0 8px; color: var(--fg-dim); font-size: 0.75rem; letter-spacing: 0.08em; }
.semaine dl { margin: 0 0 12px; }
.semaine dt { color: var(--fg-dim); font-size: 0.68rem; letter-spacing: 0.18em; text-transform: uppercase; }
.semaine dd { margin: 0 0 8px; }

/* Fragments */
.fragments { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.fragment {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 6px 10px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--fg);
  font: 0.72rem var(--mono);
  cursor: pointer;
}
.fragment:hover { border-color: var(--fg-faint); }
.fragment.refuse { border-color: rgba(255, 42, 79, 0.5); animation: tressaille 0.3s steps(2) 1; }
.silhouette { width: 52px; height: 60px; fill: var(--fg-faint); }
.fragment:hover .silhouette { animation: silhouette 0.25s steps(2) 1; }
@keyframes silhouette { 50% { transform: translateX(2px) skewX(-6deg); fill: var(--fg-dim); } }
.fragment-code { letter-spacing: 0.12em; }
.fragment-purge { color: var(--fg-faint); font-size: 0.58rem; text-transform: uppercase; letter-spacing: 0.08em; text-align: center; }
.fragments-refus { min-height: 1.4em; margin: 12px 0 0; color: var(--red); opacity: 0.8; font-size: 0.72rem; }

/* Rejouer : refusé */
.fiche-pied { display: flex; flex-direction: column; align-items: center; margin-top: 40px; }
.bouton.rejouer { width: 100%; max-width: 320px; cursor: pointer; }
.bouton.rejouer:hover { border-color: var(--fg-dim); }
.bouton.rejouer.refuse { border-color: rgba(255, 42, 79, 0.5); color: var(--red); animation: tressaille 0.3s steps(2) 1; }
.rejouer-refus { min-height: 1.4em; margin: 12px 0 0; color: var(--red); opacity: 0.8; font-size: 0.7rem; letter-spacing: 0.15em; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .caviar.definitif.refuse, .fragment.refuse, .bouton.rejouer.refuse, .fragment:hover .silhouette { animation: none; }
}

/* ---------- La Terre (/jeu/) ---------- */
.page-terre { overflow: hidden; height: 100vh; height: 100svh; }
.terre {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.terre:active { cursor: grabbing; }
.terre.glitch-fond { filter: drop-shadow(2px 0 rgba(255, 42, 79, 0.45)) drop-shadow(-2px 0 rgba(0, 229, 255, 0.45)); }
.page-terre .barre { position: relative; z-index: 2; background: rgba(5, 5, 5, 0.6); }
.terre-coord { font-variant-numeric: tabular-nums; }
.terre-titre {
  position: relative;
  z-index: 2;
  margin-top: 18px;
  text-align: center;
  pointer-events: none;
}
.terre-titre .glitch { margin: 0.2em 0 0; font-size: clamp(1.1rem, 4.5vw, 1.6rem); }

/* Liste des destinations, en bas : même rôle que les points sur la Terre */
.destinations {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(56px + env(safe-area-inset-bottom));
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
}
.destination-lien {
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.7);
  color: var(--fg-dim);
  font: 0.72rem var(--mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  cursor: pointer;
}
.destination-lien:hover, .destination-lien.actif { border-color: var(--fg-faint); color: var(--fg); }
.destination-lien.verrouille { color: var(--fg-faint); }
.destination-lien.verrouille.actif { color: var(--red); border-color: rgba(255, 42, 79, 0.4); }

/* Fiche de la destination choisie */
.destination {
  position: fixed;
  left: 50%;
  bottom: calc(108px + env(safe-area-inset-bottom));
  z-index: 3;
  width: min(340px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 16px 18px 18px;
  border: 1px solid var(--fg-faint);
  background: rgba(5, 5, 5, 0.88);
  text-align: left;
  animation: apparition 0.25s steps(3) 1;
}
.destination[hidden] { display: none; }
@keyframes apparition { from { opacity: 0; transform: translate(-50%, 6px); } }
.destination-fermer {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--fg-dim);
  font: 1rem var(--mono);
  cursor: pointer;
}
.destination-lieu { margin: 4px 0 2px; color: #e6e6e6; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.04em; }
.destination-coord { color: var(--fg-dim); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.destination-etat { margin: 10px 0 14px; color: var(--fg-dim); font-size: 0.72rem; }
.destination-refus { margin: 10px 0 0; color: var(--red); opacity: 0.8; font-size: 0.72rem; letter-spacing: 0.1em; }
.destination .bouton { padding: 12px 18px; font-size: 0.75rem; }

@media (prefers-reduced-motion: reduce) {
  .destination { animation: none; }
}

/* Carte des missions (fiche d'archive) */
.carte { display: block; width: 100%; height: auto; margin: 0 0 12px; border: 1px solid var(--line); background: var(--bg-2); }
.carte-grille { stroke: var(--line); stroke-width: 1; }
.carte-riviere { fill: none; stroke: #2a2a2a; stroke-width: 14; stroke-linecap: round; stroke-linejoin: round; }
.carte-trajet { fill: none; stroke: var(--fg-faint); stroke-width: 2; stroke-dasharray: 6 8; }
.carte-point { cursor: pointer; outline: none; }
.carte-zone { fill: transparent; }
.carte-anneau { fill: none; stroke: var(--fg-dim); stroke-width: 1.5; }
.carte-coeur { fill: #e6e6e6; }
.carte-num { fill: var(--fg-dim); font: 22px var(--mono); }
.carte-point.verrouille .carte-anneau { stroke: var(--red); stroke-dasharray: 4 4; }
.carte-point.verrouille .carte-coeur { fill: var(--red); }
.carte-point:hover .carte-anneau, .carte-point:focus-visible .carte-anneau { stroke: var(--fg); }
.carte-point.actif .carte-anneau { stroke: var(--green); stroke-width: 2.5; }
.carte-point.actif .carte-num { fill: var(--green); }
.carte-detail { min-height: 4.5em; }
.carte-detail-tete { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: #e6e6e6; }
.carte-detail-code { color: var(--fg-dim); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; }
.carte-detail p { margin: 6px 0 0; }

/* Archive déclassifiée */
.point.archive.valide::before { color: var(--green); }
.tampon.valide { border-color: rgba(0, 255, 65, 0.45); color: var(--green); }
.recit { margin: 0 0 14px; }
.recit h3 { margin: 0 0 4px; color: var(--fg-dim); font-size: 0.7rem; font-weight: 400; letter-spacing: 0.18em; text-transform: uppercase; }
.recit p, .recit ul { margin: 0 0 6px; }
.recit ul { padding-left: 1.2em; }
.recit li { margin-bottom: 4px; }
.semaine-ligne { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; padding: 8px 0 8px 12px; border-left: 1px solid var(--line); margin-bottom: 6px; }
.semaine-lieu { color: #e6e6e6; }
.semaine-code { color: var(--fg-dim); font-size: 0.75rem; }

/* Fragments : analyse et taupe démasquée */
.fragments-message { min-height: 1.4em; margin: 12px 0 6px; color: var(--fg-dim); font-size: 0.72rem; }
.fragment { transition: border-color 0.15s, opacity 0.4s; }
.fragment.scan { border-color: var(--green); }
.fragment.scan .silhouette { fill: var(--fg-dim); }
.fragment.loyal { opacity: 0.55; }
.fragment.loyal .fragment-purge { color: var(--fg-dim); }
.fragment.taupe { border-color: rgba(255, 42, 79, 0.7); opacity: 1; }
.fragment.taupe .silhouette { fill: var(--red); animation: taupe 2.4s steps(1) infinite; }
.fragment.taupe .fragment-code, .fragment.taupe .fragment-purge { color: var(--red); }
@keyframes taupe {
  0%, 86%, 100% { transform: none; filter: none; }
  88% { transform: translateX(-3px) skewX(8deg); filter: drop-shadow(3px 0 var(--cyan)); }
  92% { transform: translateX(2px); filter: drop-shadow(-3px 0 var(--cyan)); }
}
@media (prefers-reduced-motion: reduce) {
  .fragment.taupe .silhouette { animation: none; }
}
.semaine-ligne.valide { border-left-color: rgba(0, 255, 65, 0.45); }
.semaine-ligne .tampon { margin-left: auto; }

/* ---------- Fiche d'archive sur ordinateur : poste de consultation ---------- */
.index { display: none; }
@media (min-width: 1024px) {
  .fiche {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 56px;
    max-width: 1240px;
    padding: 48px 32px 96px;
  }
  .fiche-cote { position: sticky; top: 24px; align-self: start; }
  .fiche-tete { text-align: left; margin-bottom: 20px; }
  .compteur { margin-bottom: 24px; padding: 14px 0 12px; }
  .compteur-cases { justify-content: space-between; gap: 8px; }
  .compteur-nombre { font-size: 1.9rem; }
  .compteur-legende { flex-direction: row; justify-content: space-between; align-items: center; }
  .compteur-legende .tampon { white-space: nowrap; }
  .compteur-date { text-align: right; }

  .index { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
  .index-entree {
    display: flex;
    gap: 12px;
    padding: 12px 10px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-left: 1px solid transparent;
    background: none;
    color: var(--fg-dim);
    font: 0.75rem var(--mono);
    letter-spacing: 0.14em;
    text-align: left;
    text-transform: uppercase;
    cursor: pointer;
  }
  .index-entree:hover { color: var(--fg); }
  .index-entree:focus-visible { outline: 1px solid var(--green); outline-offset: -1px; }
  .index-entree.actif { border-left-color: var(--green); color: #e6e6e6; background: var(--bg-2); }
  .index-entree.actif .rappel-num { color: var(--green); }

  .fiche-cote .fiche-pied { align-items: stretch; margin-top: 28px; }
  .fiche-cote .bouton.rejouer { max-width: none; }
  .fiche-cote .rejouer-refus { text-align: left; }

  /* Zone de lecture : seul le rappel choisi est affiché, son titre sert d'en-tête */
  .rappels { border-top: 0; }
  .rappel { display: none; border-bottom: 0; }
  .rappel.courant { display: block; animation: apparition-lecture 0.2s steps(3) 1; }
  .rappel > summary { pointer-events: none; padding: 0 0 14px; margin-bottom: 20px; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
  .rappel > summary::after, .rappel[open] > summary::after { content: none; }
  .rappel-corps { padding: 0; font-size: 0.9rem; max-width: 760px; }

  .rappel-recit .rappel-corps { columns: 2; column-gap: 40px; max-width: none; }
  .rappel-recit .recit { break-inside: avoid; }
  .rappel-carte .rappel-corps { display: grid; grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: auto 1fr; gap: 0 28px; align-items: start; max-width: none; }
  .rappel-carte .carte { grid-row: 1 / span 2; max-height: calc(100vh - 160px); object-fit: contain; }
  .rappel-carte .carte-detail + .note { margin-top: 20px; }
  .rappel-fragments .rappel-corps { max-width: none; }
  .fragments { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
  .fragment { padding: 22px 8px 14px; }
  .silhouette { width: 72px; height: 84px; }
}
@keyframes apparition-lecture { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  .rappel.courant { animation: none; }
}
