/* ===== Template « Terminal CRT » — moniteur rétro, phosphore & scanlines =====
 * Les couleurs du tube sont pilotées par les variables --fg/--bg/--dim/--halo,
 * redéfinies par [data-theme="…"] sur le <body> (commande `theme`).
 */

:root {
  --case-1: #2b2a27;
  --case-2: #1c1b19;
  --case-3: #131211;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

/* --- Thèmes du tube (phosphores) --- */

body,
body[data-theme="vert"] {
  --bg: #031007;
  --bg-lift: #0a2412;
  --fg: #4dff88;
  --dim: #2fa15c;
  --halo: rgba(77, 255, 136, 0.5);
  --ambient: rgba(77, 255, 136, 0.14);
}

body[data-theme="ambre"] {
  --bg: #140c00;
  --bg-lift: #2b1d03;
  --fg: #ffb000;
  --dim: #a97a10;
  --halo: rgba(255, 176, 0, 0.45);
  --ambient: rgba(255, 176, 0, 0.13);
}

body[data-theme="bleu"] {
  --bg: #020b16;
  --bg-lift: #0a2036;
  --fg: #9fd6ff;
  --dim: #52799c;
  --halo: rgba(159, 214, 255, 0.45);
  --ambient: rgba(120, 190, 255, 0.13);
}

body[data-theme="papier"] {
  --bg: #101010;
  --bg-lift: #242422;
  --fg: #eae7da;
  --dim: #8d8b7f;
  --halo: rgba(234, 231, 218, 0.35);
  --ambient: rgba(234, 231, 218, 0.10);
}

body[data-theme="rose"] {
  --bg: #14020f;
  --bg-lift: #2b0721;
  --fg: #ff7ad9;
  --dim: #a04487;
  --halo: rgba(255, 122, 217, 0.45);
  --ambient: rgba(255, 122, 217, 0.13);
}

/* Cyberpunk : texte cyan, accents magenta (--dim), halo magenta autour du boîtier */
body[data-theme="cyberpunk"] {
  --bg: #0d0221;
  --bg-lift: #24104d;
  --fg: #00f0ff;
  --dim: #b44fd0;
  --halo: rgba(0, 240, 255, 0.5);
  --ambient: rgba(255, 43, 214, 0.15);
}

/* --- Pièce sombre --- */

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(1100px 700px at 50% 18%, #131318, #07070a 72%),
    #07070a;
  font-family: var(--mono);
  overflow-x: hidden;
}

.room {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 30px 16px 26px;
}

/* --- Le moniteur --- */

.monitor {
  width: min(880px, 100%);
  background: linear-gradient(180deg, var(--case-1), var(--case-2) 55%, var(--case-3));
  border-radius: 26px;
  padding: 24px 24px 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 -2px 6px rgba(0, 0, 0, 0.5),
    0 34px 90px -12px rgba(0, 0, 0, 0.75),
    0 0 110px -10px var(--ambient);
  transition: box-shadow 0.5s ease;
}

.monitor.off { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07), inset 0 -2px 6px rgba(0, 0, 0, 0.5), 0 34px 90px -12px rgba(0, 0, 0, 0.75); }

/* Enfoncement de la dalle dans le plastique */
.bezel {
  background: #0a0a09;
  border-radius: 18px;
  padding: 12px;
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

/* La dalle : coins très arrondis + vitre = effet bombé */
.screen {
  position: relative;
  border-radius: 26px / 30px;
  overflow: hidden;
  background: var(--bg);
  height: min(58svh, 560px);
  box-shadow: inset 0 0 46px rgba(0, 0, 0, 0.6);
  cursor: text;
  transition: background 0.35s ease;
}

.screen-inner { position: absolute; inset: 0; }

/* --- Calques CRT --- */

.fx { position: absolute; inset: 0; pointer-events: none; }

.fx-scanlines {
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply;
}

.fx-band {
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.045) 45%, rgba(255, 255, 255, 0.02) 55%, transparent);
  height: 120px;
  inset: auto 0;
  top: -140px;
  animation: sweep 7s linear infinite;
}

@keyframes sweep {
  from { transform: translateY(0); }
  to { transform: translateY(calc(100svh + 300px)); }
}

.fx-flicker {
  background: var(--fg);
  opacity: 0.015;
  animation: flicker 3.4s steps(1) infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 0.015; }
  31% { opacity: 0.03; }
  33% { opacity: 0.012; }
  74% { opacity: 0.028; }
  76% { opacity: 0.015; }
}

/* Reflet de vitre en haut à gauche */
.fx-glare {
  background:
    radial-gradient(38% 26% at 26% 12%, rgba(255, 255, 255, 0.09), transparent 70%),
    radial-gradient(30% 20% at 78% 88%, rgba(255, 255, 255, 0.03), transparent 70%);
}

/* Vignette : les bords s'assombrissent comme un tube */
.fx-vignette {
  background: radial-gradient(ellipse at center, transparent 52%, rgba(0, 0, 0, 0.32) 86%, rgba(0, 0, 0, 0.62));
  border-radius: inherit;
}

/* --- Zone texte du terminal --- */

.term {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 22px 26px 26px;
  color: var(--fg);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0.03em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  text-shadow: 0 0 1.5px currentColor, 0 0 9px var(--halo);
  scrollbar-width: thin;
  scrollbar-color: var(--dim) transparent;
  transition: color 0.35s ease;
}

.term::-webkit-scrollbar { width: 6px; }
.term::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 3px; }
.term::-webkit-scrollbar-track { background: transparent; }

.row { min-height: 1.5em; }

/* Dessins ASCII : pas de repli de ligne, débordement coupé (petits écrans) */
.row.art { white-space: pre; overflow-x: hidden; }

.dim { color: var(--dim); }

.inv { background: var(--fg); color: var(--bg); padding: 0 0.35em; text-shadow: none; }

.host { color: var(--dim); }

/* Pastilles de couleur des thèmes (commande `theme` / neofetch) */
.sw { display: inline-block; width: 1.6em; height: 0.85em; vertical-align: -0.08em; border-radius: 2px; }
.sw-1 { background: #4dff88; }
.sw-2 { background: #ffb000; }
.sw-3 { background: #9fd6ff; }
.sw-4 { background: #eae7da; }
.sw-5 { background: #ff7ad9; }
.sw-6 { background: linear-gradient(90deg, #00f0ff, #ff2bd6); }

/* Curseur bloc */
.cursor {
  display: inline-block;
  width: 0.62em;
  height: 1.18em;
  vertical-align: -0.22em;
  background: var(--fg);
  animation: blink 1.06s steps(1) infinite;
}

.cursor.idle { background: transparent; box-shadow: inset 0 0 0 1px var(--fg); animation: none; }

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* --- Allumage / extinction du tube --- */

.screen-inner.on { animation: crt-on 0.7s cubic-bezier(0.23, 1, 0.32, 1) both; }

@keyframes crt-on {
  0% { transform: scale(1, 0.004); filter: brightness(9); }
  38% { transform: scale(1, 0.004); filter: brightness(9); }
  62% { transform: scale(1.02, 1); filter: brightness(2.4); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}

.monitor.off .screen-inner { animation: crt-off 0.45s cubic-bezier(0.755, 0.05, 0.855, 0.06) both; }

@keyframes crt-off {
  0% { transform: scale(1, 1); filter: brightness(1); }
  55% { transform: scale(1.1, 0.006); filter: brightness(6); opacity: 1; }
  100% { transform: scale(0.001, 0.004); filter: brightness(50); opacity: 0; }
}

.monitor.off .screen { background: #050505; }

/* --- Pied du moniteur --- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 6px;
}

.brand {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: #86837c;
  text-transform: uppercase;
}

.brand-model { color: #5c5a54; font-weight: 400; }

.controls { display: flex; align-items: center; gap: 14px; }

.knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #4a4843, #21201d 70%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.05);
}

.led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-left: 6px;
  background: #63e086;
  box-shadow: 0 0 9px rgba(99, 224, 134, 0.9);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.monitor.off .led { background: #3c3a35; box-shadow: none; }

/* --- Légende sous le moniteur --- */

.hint {
  margin: 0;
  color: #6a6862;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-align: center;
}

.hint em { color: #969288; font-style: normal; }

/* --- Champ clavier invisible (16px : évite le zoom iOS au focus) --- */

#kbd {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 2px;
  height: 2px;
  font-size: 16px;
  opacity: 0;
  border: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  pointer-events: none;
}

/* --- Mobile --- */

@media (max-width: 700px) {
  .room { gap: 16px; padding: 18px 10px 20px; }

  .monitor { border-radius: 18px; padding: 12px 12px 0; }

  .bezel { padding: 8px; border-radius: 12px; }

  .screen { height: min(62svh, 520px); border-radius: 16px / 18px; }

  .term { padding: 14px 14px 18px; font-size: 12.5px; }

  .foot { height: 42px; }

  .brand { font-size: 10px; letter-spacing: 0.26em; }

  .hint { font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .fx-band, .fx-flicker { animation: none; display: none; }
  .cursor { animation: none; }
  .screen-inner.on, .monitor.off .screen-inner { animation-duration: 0.01s; }
}
