@font-face {
  font-family: VT323;
  src: url(fonts/vt323-latin.woff2) format("woff2");
  font-display: swap;
}

:root {
  --phosphor: #39ff6a;
  --bg: #0a0c0a;
  color-scheme: dark;
}
:root[data-theme="ambre"] { --phosphor: #ffb000; }
:root[data-theme="blanc"] { --phosphor: #e6e6e6; }

html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  box-sizing: border-box;
  padding: max(32px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom));
  color: var(--phosphor);
  font-family: VT323, "Courier New", monospace;
  font-size: var(--fs, 24px);
  line-height: 1.25;
  font-variant-ligatures: none;
  text-shadow: 0 0 5px color-mix(in srgb, var(--phosphor) 45%, transparent);
}
/* Lignes de balayage, discrètes. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0 2px, rgb(0 0 0 / .18) 2px 3px);
}

/* VT323 n'a pas de caractères coréens ni japonais : polices de secours à chasse fixe. */
:lang(ko) body { font-family: VT323, "D2Coding", "Noto Sans Mono CJK KR", "Nanum Gothic Coding", monospace; }
:lang(ja) body { font-family: VT323, "Noto Sans Mono CJK JP", "Osaka-Mono", "MS Gothic", monospace; }

[hidden] { display: none !important; }
::selection { background: var(--phosphor); color: var(--bg); text-shadow: none; }

main { max-width: 1280px; }
#screen, #fs-files { display: flex; flex-direction: column; gap: 22px; }
#fs-files { margin-top: 22px; }
.js #fs-files { display: none; }
.blk { display: flex; flex-direction: column; gap: 4px; }
.banner { display: flex; flex-direction: column; gap: 18px; }
h1, h2, p, pre { margin: 0; font: inherit; }
pre, .pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.dim { opacity: .75; }
.err { opacity: .9; }

a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
/* Entrées du système de fichiers cliquables (générées par le terminal). */
.act {
  all: unset;
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}
a:hover, a:focus-visible, .act:hover, .act:focus-visible {
  background: var(--phosphor);
  color: var(--bg);
  text-shadow: none;
  outline: none;
}

.ls { display: grid; grid-template-columns: auto auto minmax(0, 1fr); column-gap: 24px; row-gap: 4px; }
.ls .row { display: contents; }
.ls.two { grid-template-columns: auto minmax(0, 1fr); }
.ls > * > :first-child { white-space: nowrap; }

/* Ligne de saisie : le champ réel est invisible, le texte et le curseur sont recopiés à côté. */
#prompt-line { position: relative; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
#prompt-line input {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  font: inherit;
  font-size: 16px; /* évite le zoom automatique sur iOS */
}
.cur { background: var(--phosphor); color: var(--bg); text-shadow: none; animation: blink 1s steps(1) infinite; }
#prompt-line.idle .cur { background: none; color: inherit; outline: 1px solid var(--phosphor); outline-offset: -1px; animation: none; }
#prompt-line.typing .cur { animation: none; }
@keyframes blink { 50% { background: none; color: inherit; } }

/* Doom en plein écran par-dessus le terminal. */
#doom { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; background: #000; }
#doom iframe { flex: 1; width: 100%; border: 0; }
#doom.loading { opacity: 0; pointer-events: none; }
#doom .bar {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
  padding: max(4px, env(safe-area-inset-top)) 12px 4px;
  font-size: 20px;
}
#doom button { all: unset; cursor: pointer; text-decoration: underline; }
#doom button:hover, #doom button:focus-visible { background: var(--phosphor); color: var(--bg); }
body.doom-on { overflow: hidden; }

/* sl : la locomotive passe sans retour à la ligne. */
.sl { overflow: hidden; }
.sl pre { width: max-content; white-space: pre; overflow-wrap: normal; }

/* snake, pong : grille de caractères, sans retour à la ligne ; le doigt joue au lieu de faire défiler. */
.game { white-space: pre; overflow-wrap: normal; overflow-x: auto; line-height: 1.1; touch-action: none; user-select: none; }

/* rm -rf / : l'écran grésille. */
.glitch body { animation: glitch .12s steps(2) infinite; }
@keyframes glitch {
  25% { transform: translate(-4px, 2px) skewX(4deg); }
  50% { transform: translate(3px, -2px); opacity: .8; }
  75% { transform: translate(-2px, 0) skewX(-3deg); }
}

/* reboot, shutdown : l'écran cathodique s'éteint (une ligne, puis un point). */
.off #term { animation: crt-off .5s ease-in forwards; }
@keyframes crt-off {
  60% { transform: scaleY(.005); }
  100% { transform: scale(0, .005); opacity: 0; }
}

/* Code Konami : écran cathodique d'époque (couleurs qui bavent, coins sombres, léger scintillement). */
.crt body {
  text-shadow: 0 0 6px var(--phosphor), 2px 0 1px rgb(255 0 0 / .35), -2px 0 1px rgb(0 160 255 / .35);
  animation: crt-flicker .12s steps(2) infinite;
}
.crt body::after {
  background: radial-gradient(ellipse at center, transparent 55%, rgb(0 0 0 / .65) 100%),
    repeating-linear-gradient(to bottom, transparent 0 1px, rgb(0 0 0 / .35) 1px 3px);
}
@keyframes crt-flicker { 50% { opacity: .96; } }

/* Pendant l'animation de démarrage, le contenu est rejoué par term.js. */
.boot #screen .blk, .boot #prompt-line { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  .cur, .crt body { animation: none; }
}
@media (max-width: 600px) {
  body { font-size: var(--fs, 20px); padding-left: 14px; padding-right: 14px; }
  #screen { gap: 18px; }
  .ls { column-gap: 14px; }
  .ls:not(.two) { grid-template-columns: auto minmax(0, 1fr); }
  .ls:not(.two) > .row > :first-child { display: none; }
}
