/* Layout: one CRT monitor, centred; status bar, navbar, view, then the command line at the bottom (desktop only). */
:root {
  color-scheme: dark;
  --bg: #0a0603;          /* warm black behind the monitor */
  --screen: #140c05;      /* phosphor glass at rest */
  --amber: #ffb03b;       /* P3 amber phosphor */
  --amber-dim: #a86818;   /* low-intensity phosphor */
  --amber-hi: #ffe0a3;    /* high-intensity phosphor */
  --rule: rgba(255, 176, 59, .32);
  --font: "VT323", "IBM Plex Mono", "Courier New", ui-monospace, monospace;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--amber);
  font-family: var(--font);
  font-size: 22px;
  line-height: 1.25;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px;
  height: 100%;
  display: flex;
  justify-content: center;
}
html { height: 100%; }
::selection { background: var(--amber); color: var(--bg); }

/* ---------- Monitor + CRT effects ---------- */
.monitor {
  position: relative;
  width: 100%;
  max-width: 1080px;
  height: 100%;
  border-radius: 26px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 45%, #1d1207 0%, var(--screen) 55%, #090502 100%);
  box-shadow:
    0 0 0 2px #2b1b0b,
    0 0 0 10px #120b05,
    0 0 0 11px #2b1b0b,
    0 0 60px rgba(255, 140, 20, .10),
    inset 0 0 90px rgba(0, 0, 0, .85);
  text-shadow:
    0 0 1px currentColor,
    0 0 7px rgba(255, 150, 30, .45),
    1px 0 0 rgba(255, 60, 20, .22),
    -1px 0 0 rgba(90, 170, 255, .10);
  animation: poweron .7s ease-out both;
}
.inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
  padding: 22px 30px 18px;
}
/* scanlines */
.monitor::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 6;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.30) 0 1px, transparent 1px 3px);
}
/* vignette + flicker */
.monitor::after {
  content: "";
  position: absolute; inset: 0;
  z-index: 7;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(0,0,0,.6) 100%);
  animation: flicker 4s steps(1) infinite;
}
.roll {
  position: absolute; left: 0; right: 0;
  height: 140px; top: -140px;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(255, 176, 59, .055), transparent);
  animation: roll 8s linear infinite;
}
.monitor.flat { text-shadow: none; animation: none; }
.monitor.flat::before, .monitor.flat::after, .monitor.flat .roll { display: none; }

@keyframes poweron {
  0%   { transform: scale(1, .004); filter: brightness(4); }
  45%  { transform: scale(1, .004); filter: brightness(4); }
  70%  { transform: scale(1, 1.02); filter: brightness(1.6); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  23% { opacity: .86; }
  24% { opacity: 1; }
  61% { opacity: .93; }
  62% { opacity: 1; }
}
@keyframes roll { to { top: 110%; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes reveal { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Status bar ---------- */
.status {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px 18px;
  color: var(--amber-dim);
  font-size: .9em;
  letter-spacing: .04em;
}
.status .id { color: var(--amber); }
.status .right { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; }
.langs { display: flex; gap: 2px; }
.chip {
  font: inherit; color: var(--amber-dim);
  background: none; border: 0; padding: 0 5px; cursor: pointer;
  text-shadow: inherit;
}
.chip:hover { color: var(--amber-hi); }
.chip[aria-pressed="true"] { color: var(--bg); background: var(--amber-dim); text-shadow: none; }
.clock { font-variant-numeric: tabular-nums; }

/* ---------- Navbar ---------- */
nav {
  display: flex; flex-wrap: wrap; gap: 4px 6px;
  padding-bottom: 12px;
  border-bottom: 3px double var(--rule);
}
.nav-btn {
  font: inherit; font-size: 1.05em; color: var(--amber);
  background: none; border: 0; padding: 2px 8px; cursor: pointer;
  text-transform: uppercase; letter-spacing: .06em;
  text-shadow: inherit;
}
.nav-btn::before { content: "[ "; color: var(--amber-dim); }
.nav-btn::after  { content: " ]"; color: var(--amber-dim); }
.nav-btn:hover { color: var(--amber-hi); }
.nav-btn[aria-current="page"] { background: var(--amber); color: var(--bg); text-shadow: none; }
.nav-btn[aria-current="page"]::before, .nav-btn[aria-current="page"]::after { color: var(--bg); }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 1px dashed var(--amber-hi); outline-offset: 2px; }

/* ---------- View ---------- */
#view {
  flex: 1; min-width: 0; min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto; overscroll-behavior: contain;
  padding-right: 8px;
  scrollbar-width: thin; scrollbar-color: var(--amber-dim) transparent;
}
#view > * { flex-shrink: 0; }
.status, nav, .term { flex-shrink: 0; }
#view > * { animation: reveal .22s steps(3) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
.banner {
  margin: 4px 0 0; font-family: "Courier New", ui-monospace, monospace; font-size: 1.15em;
  line-height: 1.05; color: var(--amber-hi); overflow-x: auto; white-space: pre;
}
h1 {
  margin: 0; font-weight: 400; font-size: 2.05em; line-height: 1.05;
  color: var(--amber-hi); text-wrap: balance; max-width: 26ch;
}
h1::before { content: "> "; color: var(--amber-dim); }
h2 { margin: 6px 0 0; font-weight: 400; font-size: 1em; color: var(--amber-dim); text-transform: uppercase; letter-spacing: .1em; }
p { margin: 0; max-width: 62ch; }
.dim { color: var(--amber-dim); }
.hi { color: var(--amber-hi); }
kbd { font: inherit; color: var(--amber-hi); }
a { color: var(--amber-hi); text-decoration: underline dashed; text-underline-offset: 4px; text-shadow: inherit; }
a:hover { background: var(--amber); color: var(--bg); text-decoration: none; text-shadow: none; }
a:focus-visible { outline: 1px dashed var(--amber-hi); outline-offset: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; max-width: 70ch; }
.list li { display: grid; grid-template-columns: 2.2ch 1fr; gap: 0 6px; }
.list .mark { color: var(--amber-dim); }
.list strong { font-weight: 400; color: var(--amber-hi); text-transform: uppercase; letter-spacing: .04em; }

.steps { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: s; max-width: 70ch; }
.steps li { display: grid; grid-template-columns: 4ch 1fr; counter-increment: s; }
.steps li::before { content: counter(s, decimal-leading-zero) "."; color: var(--amber-dim); }
.steps strong { font-weight: 400; color: var(--amber-hi); letter-spacing: .06em; }

.cmds { display: grid; grid-template-columns: max-content 1fr; gap: 6px 22px; margin: 0; max-width: 70ch; }
.cmds dt { color: var(--amber-hi); }
.cmds dd { margin: 0; }

.goto { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.goto .nav-btn { font-size: 1em; }

/* contact form */
form { display: grid; gap: 12px; max-width: 640px; }
.field { display: grid; grid-template-columns: 10ch 1fr; align-items: baseline; gap: 4px 10px; }
.field label { color: var(--amber-dim); text-transform: uppercase; }
input[type="text"], input[type="email"], textarea {
  font: inherit; color: var(--amber-hi); text-shadow: inherit;
  background: transparent; border: 0; border-bottom: 1px dashed var(--amber-dim);
  padding: 2px 4px; min-width: 0; width: 100%; border-radius: 0;
  caret-color: var(--amber-hi);
}
textarea { border: 1px dashed var(--amber-dim); resize: vertical; min-height: 5.2em; }
input:focus, textarea:focus { background: rgba(255, 176, 59, .07); outline: none; }
.actions { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.submit {
  font: inherit; font-size: 1.05em; cursor: pointer;
  color: var(--bg); background: var(--amber); border: 0; padding: 2px 14px;
  text-transform: uppercase; letter-spacing: .06em;
}
.submit:hover { background: var(--amber-hi); }
#form-status { min-height: 1.25em; }

/* ---------- Terminal ---------- */
.term { border-top: 1px dashed var(--rule); padding-top: 10px; display: grid; gap: 2px; }
#log { display: grid; gap: 2px; color: var(--amber-dim); }
#log .echo { color: var(--amber); }
#log .err { color: var(--amber-hi); }
#log div { overflow-wrap: anywhere; }
.prompt { position: relative; display: flex; flex-wrap: wrap; cursor: text; min-height: 1.3em; }
.ps1 { color: var(--amber-hi); margin-right: 1ch; white-space: nowrap; }
#typed { white-space: pre-wrap; overflow-wrap: anywhere; }
.cursor { display: inline-block; width: .6em; background: var(--amber); animation: blink 1s steps(1) infinite; box-shadow: 0 0 6px rgba(255,150,30,.6); }
.cursor.off { background: transparent; box-shadow: none; outline: 1px solid var(--amber-dim); outline-offset: -1px; }
#cmd {
  position: absolute; inset: 0; opacity: 0; width: 100%;
  font: inherit; border: 0; background: none; color: transparent;
}
.hint { color: var(--amber-dim); font-size: .85em; }
.touch-only { display: none; }

/* ---------- Phones / touch ---------- */
@media (max-width: 759px), (pointer: coarse) {
  body { font-size: 20px; }
  .monitor { border-radius: 16px; }
  .inner { padding: 16px 14px 14px; gap: 14px; }
  nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 8px; }
  nav .nav-btn { min-height: 46px; border: 1px solid var(--rule); padding: 6px 4px; }
  .term { display: none; }
  .touch-only { display: block; }
  .chip { min-height: 36px; min-width: 36px; padding: 0 8px; }
  h1 { font-size: 1.75em; }
  .banner { font-size: .9em; }
  .field { grid-template-columns: 1fr; }
  .cmds { grid-template-columns: 1fr; gap: 0; }
  .cmds dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .monitor, .monitor::after, .roll, #view > *, .cursor { animation: none !important; }
  .roll { display: none; }
}

/* ---------- Jeu caché (pong) ---------- */
.cmd-link {
  font: inherit; color: var(--amber-hi); text-shadow: inherit;
  background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline dashed; text-underline-offset: 4px;
}
.cmd-link:hover { background: var(--amber); color: var(--bg); text-decoration: none; text-shadow: none; }
#view > .pong-wrap { flex: 1 1 0; min-height: 180px; display: flex; justify-content: center; align-items: flex-start; }
.pong-canvas { display: block; max-width: 100%; touch-action: none; cursor: none; outline: none; }
body.gaming #log { display: none; }
.touch-only-inline { display: none; }
@media (max-width: 759px), (pointer: coarse) {
  .desktop-only { display: none; }
  .touch-only-inline { display: inline; }
  .pong-canvas { cursor: auto; }
}
