@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/static/polices/atkinson-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible Mono";
  src: url("/static/polices/atkinson-mono.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --fond: #06070b;
  --carte: #0f1118;
  --bord: #1a1d2e;
  --texte: #e0e2ea;
  --texte2: #6b7089;
  --accent: #ff3b3b;
  --accent2: #ff6b6b;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, sans-serif;
}

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

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 400 1rem/1.55 var(--sans);
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

.page {
  max-width: 66rem;
  margin: 0 auto;
  padding: 4rem 1.25rem 3rem;
  padding-top: calc(4rem + env(safe-area-inset-top, 0px));
}

/* ---------- En-tête ---------- */
.entete {
  text-align: center;
  margin-bottom: 3rem;
}

.accroche {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  opacity: 0;
  animation: glisser 0.7s 0.1s both;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 1.4rem + 3vw, 3.6rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--texte);
  opacity: 0;
  animation: glisser 0.8s 0.3s both;
}

.sous-titre {
  margin: 1rem auto 0;
  max-width: 50ch;
  font-size: 1.1rem;
  color: var(--texte2);
  opacity: 0;
  animation: glisser 0.8s 0.6s both;
}
.sous-titre em { color: var(--texte); font-style: normal; font-weight: 600; }

/* ---------- Grille de cartes ---------- */
.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.875rem;
}

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.carte.visible {
  opacity: 1;
  transform: none;
}
.carte.accent { border-color: #2a1520; background: linear-gradient(135deg, #110a10 0%, var(--carte) 100%); }

.carte .label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--texte2);
  margin-bottom: 0.4rem;
}

.carte .valeur {
  display: block;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  color: var(--texte);
}
.carte.accent .valeur { color: var(--accent2); font-weight: 600; }

.carte .valeur a {
  color: var(--accent2);
  text-underline-offset: 0.15em;
}

.carte .attente { color: var(--texte2); font-style: italic; font-family: var(--sans); }

/* ---------- Section GPS ---------- */
.carte.gps { grid-column: 1 / -1; }
.carte.gps .valeur { font-size: 1rem; }

/* ---------- État et pied ---------- */
.etat {
  text-align: center;
  margin: 2.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--texte2);
  opacity: 0;
  transition: opacity 0.5s;
}
.etat.visible { opacity: 1; }

.pied {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bord);
  text-align: center;
  font-size: 0.8125rem;
  color: var(--texte2);
}
.pied p { margin: 0; }

/* ---------- Animations ---------- */
@keyframes glisser {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Mobile ---------- */
@media (max-width: 520px) {
  .page { padding: 2.5rem 1rem 2rem; }
  .entete { margin-bottom: 2rem; }
  .grille { grid-template-columns: 1fr; }
  .carte.gps { grid-column: auto; }
}

/* ---------- Registre des visites ---------- */
.registre-grille {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: minmax(16rem, 22rem) 1fr;
  gap: 2rem;
  align-items: start;
}
.liste-visites { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow-y: auto; }
.liste-visites ul { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--texte, #e0e2ea); }
.liste-visites li { border-bottom: 1px solid var(--bord, #1a1d2e); }
.liste-visites a {
  display: grid; gap: 0.1rem; padding: 0.7rem 0.6rem;
  text-decoration: none; color: var(--texte, #e0e2ea);
}
.liste-visites a:hover { background: var(--carte, #0f1118); }
.liste-visites a[aria-current="true"] { background: var(--carte, #0f1118); box-shadow: inset 3px 0 0 var(--accent, #ff3b3b); }
.vide-liste { padding: 0.8rem 0.6rem; color: var(--texte2, #6b7089); }
.visite-quand, .visite-lieu { font-size: 0.875rem; color: var(--texte2, #6b7089); }
.visite-appareil { font-weight: 600; }
.marque { font-size: 0.75rem; font-weight: 700; color: var(--accent, #ff3b3b); margin-left: 0.45rem; white-space: nowrap; }
.marque.publique { color: #5b8aff; }

.titre-visite { margin: 0; font-size: 1.75rem; line-height: 1.15; }
.detail-meta { padding: 1rem 0 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.9rem 1.5rem; }
.detail-meta dt { font-size: 0.875rem; color: var(--texte2, #6b7089); }
.detail-meta dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.actions-visite { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1.25rem 0 0; }

.bouton {
  font: inherit; font-weight: 600;
  color: var(--texte, #e0e2ea);
  background: transparent;
  border: 1.5px solid var(--texte, #e0e2ea);
  border-radius: 4px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.bouton:hover { background: var(--texte, #e0e2ea); color: var(--fond, #06070b); }
.bouton.danger { border-color: var(--accent, #ff3b3b); color: var(--accent, #ff3b3b); }
.bouton.danger:hover { background: var(--accent, #ff3b3b); color: var(--fond, #06070b); }

.examen { margin-top: 3rem; }
.examen h2 { margin: 0; font-size: 1.5rem; font-weight: 700; line-height: 1.2; padding-bottom: 0.4rem; border-bottom: 2px solid var(--texte, #e0e2ea); }
.intro { margin: 0.75rem 0 1rem; max-width: 72ch; color: var(--texte2, #6b7089); }
.defile { overflow-x: auto; }

.valeurs { width: 100%; border-collapse: collapse; }
.valeurs tbody tr { border-bottom: 1px solid var(--bord, #1a1d2e); }
.valeurs th[scope="row"], .valeurs td { padding: 0.55rem 0.75rem; text-align: left; vertical-align: top; }
.valeurs th[scope="row"] { width: 34%; font-weight: 600; }
.valeurs td { overflow-wrap: anywhere; }

.trace-registre { display: block; max-width: 100%; height: auto; background: var(--carte, #0f1118); border: 1px solid var(--bord, #1a1d2e); }

.chapo { margin: 0.75rem 0 0; max-width: 60ch; font-size: 1.125rem; color: var(--texte2, #6b7089); }

.lien-registre { font-size: 0.9375rem; font-weight: 600; color: var(--accent2, #ff6b6b); }

.resume { margin: 0; padding: 1.25rem 1.5rem; display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.9rem 1.5rem; }
.resume dt { font-size: 0.875rem; color: var(--texte2, #6b7089); }
.resume dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.vide { color: var(--texte2, #6b7089); }
.paires { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.75rem; }
.paires dt { color: var(--texte2, #6b7089); font-weight: 400; }
.paires dd { margin: 0; }

a { color: var(--accent2, #ff6b6b); text-underline-offset: 0.15em; }
code { font-family: var(--mono); font-size: 0.875em; }

@media (max-width: 760px) {
  .registre-grille { grid-template-columns: 1fr; }
  .liste-visites { position: static; max-height: 22rem; }
  .valeurs th[scope="row"] { width: 40%; }
}

/* ---------- Groupes d'appareils (registre) ---------- */
.groupe { border-bottom: 1px solid var(--bord, #1a1d2e); }
.groupe-entete {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 0.6rem; cursor: pointer; user-select: none;
  background: var(--carte, #0f1118); border-bottom: 1px solid var(--bord, #1a1d2e);
}
.groupe-entete:hover { background: #161825; }
.groupe-nom { font-weight: 700; font-size: 0.9375rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groupe-badge {
  font-size: 0.75rem; font-weight: 700; min-width: 1.5em; text-align: center;
  background: var(--accent, #ff3b3b); color: var(--fond, #06070b);
  border-radius: 999px; padding: 0.1em 0.5em; line-height: 1.4;
}
.groupe-renommer {
  font: inherit; font-size: 0.75rem; color: var(--texte2, #6b7089);
  background: none; border: none; cursor: pointer; padding: 0.15em 0.35em;
  opacity: 0; transition: opacity 0.15s;
}
.groupe-entete:hover .groupe-renommer { opacity: 1; }
.groupe-renommer:hover { color: var(--texte, #e0e2ea); }
.groupe.replie .groupe-visites { display: none; }
.groupe-visites a {
  display: grid; gap: 0.1rem; padding: 0.55rem 0.6rem 0.55rem 1.4rem;
  text-decoration: none; color: var(--texte, #e0e2ea); font-size: 0.875rem;
}
.groupe-visites a:hover { background: var(--carte, #0f1118); }
.groupe-visites a[aria-current="true"] { background: var(--carte, #0f1118); box-shadow: inset 3px 0 0 var(--accent, #ff3b3b); }

.champ-renommer {
  font: inherit; font-size: inherit; font-weight: 700;
  background: var(--fond, #06070b); color: var(--texte, #e0e2ea);
  border: 1.5px solid var(--accent, #ff3b3b); border-radius: 3px;
  padding: 0.15em 0.4em; width: 100%;
}
.bouton.petit { font-size: 0.75rem; padding: 0.3rem 0.6rem; margin-left: 0.5rem; vertical-align: middle; }

.photo-capture {
  display: block; max-width: 320px; border-radius: 8px;
  border: 2px solid var(--accent, #ff3b3b); margin-top: 0.75rem;
}

[hidden] { display: none !important; }
