/* Xbot — console. Noir et or : un noir chaud et profond, des lueurs dorées
   qui montent des coins, un réticule gravé en filigrane dans les zones vides.
   Ce qui est armé brille en or ; ce qui dort reste couleur cendre.
   Polices servies localement (SIL Open Font License). */
@font-face { font-family: "Barlow SC"; src: url("/fonts/barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow SC"; src: url("/fonts/barlow-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  --noir: #0E0C09;                      /* fond */
  --ebene: rgba(24, 20, 14, 0.84);      /* panneaux : translucides, les lueurs passent */
  --creux: #0A0806;                     /* champs de saisie */
  --trait: #3A2F1C;                     /* lignes entre panneaux */
  --ligne: #262015;                     /* lignes fines dans un panneau */
  --texte: #F2EADB;                     /* ivoire */
  --brume: #A89A80;                     /* texte secondaire */
  --cendre: #6B6152;                    /* arrêté */
  --or: #D4AF37;                        /* armé, action principale */
  --or-clair: #F3D27A;                  /* cœur d'une cible armée */
  --or-sombre: #8C6D2C;
  --rouge: #E06A4F;                     /* retirer, erreurs */
  --lingot: linear-gradient(90deg, #5C4519 0%, #D4AF37 28%, #F3D27A 50%, #D4AF37 72%, #5C4519 100%);
  --reflet: linear-gradient(180deg, rgba(212, 175, 55, 0.05), transparent 160px);
  --ui: "Barlow SC", "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: "Plex Mono", "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden; /* la page ne défile jamais : seules les listes longues défilent */
  color: var(--texte);
  font: 500 13px/1.4 var(--ui);
  -webkit-font-smoothing: antialiased;
  /* les nuances : des lueurs dorées qui montent des coins de l'écran */
  background:
    radial-gradient(1100px 620px at 8% -12%, rgba(212, 175, 55, 0.13), transparent 62%),
    radial-gradient(900px 560px at 108% 112%, rgba(212, 175, 55, 0.09), transparent 60%),
    radial-gradient(700px 420px at 55% 120%, rgba(140, 109, 44, 0.08), transparent 70%),
    var(--noir);
}
[hidden] { display: none !important; }
h1, h2, p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--or); outline-offset: 1px; }
.masque { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
main { min-height: 0; }

/* ---------------------------------------------------------------- barre */
.barre { position: relative; display: flex; align-items: center; gap: 18px; height: 46px; padding: 0 16px; background: rgba(10, 8, 6, 0.55); }
/* la signature : un seul reflet doré, comme sur un lingot */
.barre::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--lingot); }
.marque { display: flex; align-items: center; gap: 9px; color: var(--texte); text-decoration: none; font-weight: 600; font-size: 19px; letter-spacing: 0.02em; }
.marque:hover span { color: var(--or-clair); }
.rubrique { color: var(--brume); font-size: 14px; padding-left: 14px; border-left: 1px solid var(--trait); }
.releves { display: flex; align-items: center; gap: 22px; margin-left: auto; color: var(--brume); font-size: 13px; }
.releve b { color: var(--texte); font-weight: 600; }
.releve.chaud { color: var(--or); }
.voyant { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--cendre); margin-right: 7px; vertical-align: 1px; }
.releve.chaud .voyant { background: var(--or-clair); box-shadow: 0 0 7px var(--or); }

/* -------------------------------------------------------------- boutons */
button, .bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  padding: 0 14px;
  border: 1px solid var(--trait);
  border-radius: 4px;
  background: transparent;
  color: var(--texte);
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
}
button:hover, .bouton:hover { border-color: var(--or-sombre); }
button:disabled { opacity: 0.5; cursor: progress; }
button.dore, .bouton.dore { background: var(--or); border-color: var(--or); color: #120E06; }
button.dore:hover, .bouton.dore:hover { background: var(--or-clair); border-color: var(--or-clair); }
button.discret { border-color: transparent; color: var(--brume); padding: 0 6px; }
button.discret:hover { color: var(--texte); }

/* --------------------------------------------------------------- champs */
input, textarea { width: 100%; height: 30px; padding: 5px 9px; border: 1px solid var(--trait); border-radius: 4px; background: var(--creux); font-size: 13px; }
input:focus, textarea:focus { border-color: var(--or); outline: none; }
textarea { height: auto; min-height: 50px; resize: none; font-family: var(--mono); font-weight: 400; font-size: 12px; line-height: 1.45; }
input[type="checkbox"], input[type="radio"] { width: 15px; height: 15px; padding: 0; margin: 0; accent-color: var(--or); flex: none; }
label { display: block; color: var(--brume); font-size: 12px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aide { color: var(--brume); font-size: 11.5px; margin-top: 2px; }

/* ---------------------------------------------------------------- accès */
.acces { max-width: 440px; margin: 16vh auto 0; padding: 0 24px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.acces h1 { font-size: 28px; font-weight: 600; line-height: 1.15; }
.acces p { color: var(--brume); font-size: 15px; }

/* ------------------------------------------------------- page d'accueil */
.accueil { height: 100%; overflow: auto; display: grid; align-content: center; justify-items: center; gap: 40px; padding: 28px 24px 36px; }
.heros {
  display: grid;
  justify-items: center;
  gap: 8px;
  width: min(440px, 100%); /* assez large pour que le filigrane ne soit jamais rogné */
  padding: 26px 0 10px;
  text-align: center;
  /* le réticule gravé, en grand, derrière le nom */
  background: url("/motif.svg") no-repeat center 30% / 340px 340px;
}
.heros img { filter: drop-shadow(0 0 22px rgba(212, 175, 55, 0.35)); }
.heros h1 {
  font-size: 64px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.06em;
  background: var(--lingot);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.heros p { color: var(--brume); font-size: 16px; }
.modules {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  width: min(1240px, 100%);
  border: 1px solid var(--trait);
  border-radius: 6px;
  overflow: hidden;
  background: var(--ebene);
}
.module { display: flex; flex-direction: column; gap: 8px; min-height: 196px; padding: 20px 18px 18px; border-right: 1px solid var(--trait); background: var(--reflet); }
.module:last-child { border-right: 0; }
.module.dispo { background: linear-gradient(180deg, rgba(212, 175, 55, 0.13), transparent 75%); box-shadow: inset 0 2px 0 var(--or); }
.module-tete { display: flex; align-items: center; gap: 9px; }
.module h2 { font-size: 20px; font-weight: 600; }
.module p { color: var(--brume); font-size: 13px; }
.module-statut { font-size: 12.5px; }
.module-statut.chaud { color: var(--or); }
.module .bouton { align-self: flex-start; margin-top: auto; height: 32px; padding: 0 20px; }
.bientot { margin-top: auto; color: var(--cendre); font-size: 12.5px; }

/* -------------------------------------------------------------- console */
.console { display: grid; grid-template-columns: 250px minmax(0, 1fr) 430px; height: 100%; }
.col { min-height: 0; display: flex; flex-direction: column; background: var(--reflet), var(--ebene); border-right: 1px solid var(--trait); }
.col:last-child { border-right: 0; }
.titre { display: flex; align-items: baseline; gap: 6px; font-size: 14px; font-weight: 600; }
.compte { color: var(--or); font-weight: 600; }
.tete { padding: 12px 14px 8px; }
.tete .aide { margin-top: 1px; }

/* --- setups */
.liste-setups { list-style: none; margin: 0; padding: 0 8px; flex: 1; min-height: 0; overflow-y: auto; }
.liste-setups .vide { color: var(--brume); padding: 8px 6px; }
.setup {
  width: 100%;
  height: auto;
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) auto;
  column-gap: 9px;
  row-gap: 1px;
  align-items: center;
  justify-content: stretch;
  padding: 7px 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  border-radius: 4px;
  text-align: left;
  font-weight: 500;
}
.setup:hover { border-color: var(--trait); }
.setup[aria-current="true"] { background: rgba(212, 175, 55, 0.07); border-color: var(--trait); }
.setup.arme { border-left-color: var(--or); }
.setup svg { grid-row: 1 / span 2; }
.setup-nom { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.setup-etat { font-size: 12px; color: var(--brume); }
.setup.arme .setup-etat { color: var(--or); }
.setup-resume { grid-column: 2 / span 2; font-size: 12px; color: var(--brume); }
.nouveau { padding: 10px 12px 12px; border-top: 1px solid var(--ligne); }
.saisie-ligne { display: flex; gap: 6px; }
.saisie-ligne input { flex: 1; min-width: 0; }

/* --- centre */
.centre { display: grid; grid-template-rows: auto minmax(0, 1fr); }
.entete { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--trait); }
.entete svg { flex: none; }
.entete-texte { flex: 1; min-width: 0; }
.entete h1 { font-size: 24px; font-weight: 600; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.etiquettes { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 4px; color: var(--brume); font-size: 13px; }
.pastille { padding: 1px 9px; border: 1px solid var(--trait); border-radius: 10px; font-size: 12px; font-weight: 600; color: var(--brume); }
.pastille.chaud { border-color: var(--or); color: var(--or); background: rgba(212, 175, 55, 0.08); }
.entete button { height: 34px; padding: 0 18px; font-size: 14px; }
.listes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-height: 0; }
.panneau-liste { display: flex; flex-direction: column; min-height: 0; }
.panneau-liste + .panneau-liste { border-left: 1px solid var(--trait); }
.adresses {
  list-style: none;
  margin: 0;
  padding: 0 6px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* le réticule gravé apparaît dans l'espace laissé libre par la liste */
  background: url("/motif.svg") no-repeat center 62% / 230px 230px;
}
.adresses li { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--ligne); background: rgba(14, 12, 9, 0.55); }
.adresses .vide { color: var(--brume); padding: 8px; border: 0; background: none; }
.adr { flex: 1; min-width: 0; justify-content: flex-start; height: 28px; padding: 0 8px; border: 0; font-family: var(--mono); font-weight: 400; font-size: 12.5px; letter-spacing: 0.01em; cursor: copy; }
.adr:hover { background: rgba(212, 175, 55, 0.08); color: var(--or-clair); }
.retirer { width: 26px; height: 26px; padding: 0; border: 0; color: var(--brume); font-size: 16px; line-height: 1; flex: none; }
.retirer:hover { color: var(--rouge); background: rgba(224, 106, 79, 0.1); }
.ajout { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: end; padding: 8px 10px 10px; border-top: 1px solid var(--ligne); }

/* --- réglages */
.reglages-col .tete { border-bottom: 1px solid var(--ligne); }
.reglages { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.reglages-corps { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px; display: grid; gap: 14px; align-content: start; }
.grille { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 8px; align-content: start; }
legend { font-size: 13px; font-weight: 600; padding: 0; margin-bottom: 6px; color: var(--or-clair); }
.choix { display: flex; gap: 14px; }
.case { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--texte); font-size: 12.5px; cursor: pointer; white-space: normal; }
.case-aide { margin: 1px 0 0 22px; }
.deux { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.champ-erreur input { border-color: var(--rouge); }
.barre-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--trait); }

.vide-centre { margin: auto; text-align: center; color: var(--brume); padding: 24px; display: grid; gap: 6px; }
.vide-centre b { color: var(--texte); font-size: 16px; }

/* ------------------------------------------------------------- réticule */
.reticule .anneau, .reticule .graduation { stroke: var(--cendre); }
.reticule.arme .anneau, .reticule.arme .graduation { stroke: var(--or); }
.reticule .point { fill: var(--or-clair); }
.reticule.arme { filter: drop-shadow(0 0 5px rgba(212, 175, 55, 0.55)); }
/* le seul mouvement de la page : la cible qui se verrouille au démarrage */
.reticule.verrouille .point { animation: verrou 420ms cubic-bezier(.2, .9, .3, 1.4); transform-origin: center; transform-box: fill-box; }
@keyframes verrou { from { transform: scale(0); } to { transform: scale(1); } }

/* ----------------------------------------------------------------- toast */
.toast { position: fixed; right: 16px; bottom: 16px; max-width: min(92vw, 420px); padding: 10px 14px; border: 1px solid var(--trait); border-left: 3px solid var(--or); border-radius: 4px; background: #18140E; font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 160ms; }
.toast.visible { opacity: 1; }
.toast.erreur { border-left-color: var(--rouge); }

/* ------------------------------------------------- écrans intermédiaires */
@media (max-width: 1280px) {
  .console { grid-template-columns: 220px minmax(0, 1fr) 380px; }
  .modules { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .module:nth-child(3) { border-right: 0; }
  .module:nth-child(-n + 3) { border-bottom: 1px solid var(--trait); }
  .module { min-height: 150px; }
  .heros h1 { font-size: 52px; }
}

/* ------------------------------------------- téléphone et petite fenêtre */
@media (max-width: 1050px) {
  body { display: block; height: auto; overflow: auto; font-size: 15px; }
  .barre { flex-wrap: wrap; height: auto; padding: 10px 14px 12px; row-gap: 4px; }
  .rubrique { display: none; }
  .releves { order: 3; width: 100%; margin-left: 0; gap: 16px; flex-wrap: wrap; }
  #sortir { margin-left: auto; }
  .accueil { height: auto; align-content: start; }
  .heros { padding: 18px 10px 4px; }
  .modules { grid-template-columns: minmax(0, 1fr); }
  .module, .module:nth-child(3) { border-right: 0; border-bottom: 1px solid var(--trait); min-height: 0; }
  .module:last-child { border-bottom: 0; }
  .console { grid-template-columns: minmax(0, 1fr); height: auto; }
  .col { border-right: 0; border-bottom: 1px solid var(--trait); }
  .listes, .grille { grid-template-columns: minmax(0, 1fr); }
  .panneau-liste + .panneau-liste { border-left: 0; border-top: 1px solid var(--trait); }
  .liste-setups, .adresses, .reglages-corps { overflow: visible; }
  input, textarea { font-size: 16px; } /* 16 px : iOS ne zoome pas à la saisie */
  input, button, .bouton { height: 38px; }
  .adr { height: 34px; }
  .retirer { width: 34px; height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .reticule.verrouille .point { animation: none; }
  .toast { transition: none; }
}
