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

html { background: var(--espresso); color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  /* Sit a little above centre: the optical middle, not the geometric one. */
  padding: var(--pad) var(--pad) calc(var(--pad) + 4vh);
  background: var(--scanlines), var(--espresso);
  color: var(--bone);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
}

main { position: relative; z-index: 5; display: grid; justify-items: start; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Boot log ---------------------------------------------------- */

/* The widest line that must never wrap is the 33-character header,
   so the font shrinks until 34 characters fit the column. */
.log {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(11px, calc((100vw - 2 * var(--pad)) / (34 * var(--mono-advance))), 22px);
  line-height: 1.5;
  white-space: pre;
  color: var(--bone);
  /* Phosphor: text carries a faint bloom of its own light. */
  text-shadow: 0 0 12px rgba(232, 223, 207, 0.09);
}

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

/* The deck's ident: a hardware label under the mark, not a second title. */
.ident {
  font-size: 0.64em;
  letter-spacing: 0.16em;
  color: var(--ash-hi);
  vertical-align: 0.2em;
}

/* Readouts that passed ("ok") sit back, so "lit" is the one word that glows. */
[data-status]:not(.lit) { color: var(--ash-hi); --print-to: var(--ash-hi); }

/* Body copy may wrap on narrow screens; status lines may not. */
.prose { white-space: pre-wrap; }

.lit { color: var(--filament); text-shadow: 0 0 6px rgba(255, 196, 110, 0.9), 0 0 18px var(--filament-glow), 0 0 48px rgba(245, 158, 11, 0.35); }

.cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 0.15em;
  vertical-align: -0.2em;
  background: var(--bone);
  animation: blink 1.06s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

@keyframes ignite {
  0%   { color: var(--ash); text-shadow: none; }
  35%  { color: #c98a2c; text-shadow: 0 0 4px rgba(245, 158, 11, 0.2); }
  100% { color: var(--filament); text-shadow: 0 0 6px rgba(255, 196, 110, 0.9), 0 0 18px var(--filament-glow), 0 0 48px rgba(245, 158, 11, 0.35); }
}

/* ---- Call to action ---------------------------------------------- */

.cta {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  margin-top: 1.25rem;
  padding: 0 22px;
  border: 1px solid var(--bronze-hi);
  color: var(--bone);
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.02em;
  text-decoration: none;
  background: rgba(30, 25, 21, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition:
    border-color var(--dur-warm) var(--ease-settle),
    color var(--dur-warm) var(--ease-settle),
    box-shadow var(--dur-warm) var(--ease-settle),
    opacity var(--dur-fade) var(--ease-settle),
    visibility 0s;
}

/* Hover warms like a filament, in bone: amber is reserved for "lit". */
/* Pilot light: a small lamp in the button that warms with it. */
.cta::before {
  content: "";
  width: 6px;
  height: 6px;
  margin-right: 14px;
  background: var(--ash);
  transition: background-color var(--dur-warm) var(--ease-settle), box-shadow var(--dur-warm) var(--ease-settle);
}
.cta:hover::before,
.cta:focus-visible::before { background: var(--bone-hi); box-shadow: 0 0 10px rgba(251, 243, 228, 0.7); }

.cta:hover {
  border-color: var(--bone);
  color: var(--bone-hi);
  box-shadow: 0 0 0 1px var(--bone-glow), 0 0 28px var(--bone-glow);
}

.cta:focus-visible {
  outline: 2px solid var(--bone);
  outline-offset: 4px;
  border-color: var(--bone);
  color: var(--bone-hi);
}

/* ---- Boot states -------------------------------------------------
   html.boot is set before first paint (index.html) unless the user
   prefers reduced motion. Without JS nothing is hidden. */

.boot [data-type]:not(.armed),
.boot [data-status]:not(.on),
.boot [data-last]:not(.on) { visibility: hidden; }

.boot .typed-rest { visibility: hidden; }

.boot [data-print] .ln:not(.on),
.boot .cta:not(.on) { visibility: hidden; }

/* Console print: a line lands whole, flares like fresh phosphor, settles. */
.boot [data-status].on:not(.lit) { animation: print 520ms var(--ease-settle) both; }
.boot .cta.on { animation: print-box 520ms var(--ease-settle) both; }

@keyframes print {
  0%   { color: #fffaf0; text-shadow: 0 0 10px rgba(255, 248, 236, 0.75); }
  100% { color: var(--print-to, var(--bone)); text-shadow: 0 0 14px rgba(232, 223, 207, 0.14); }
}
@keyframes print-box {
  0%   { border-color: var(--bone); box-shadow: 0 0 18px rgba(255, 248, 236, 0.35); }
  100% { border-color: var(--bronze-hi); box-shadow: 0 0 0 rgba(255, 248, 236, 0); }
}

.boot .lit.on { animation: ignite var(--dur-ignite) var(--ease-settle) both; }

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .cta { transition: none; }
}

/* A skip (click, key, scroll) lands on the finished state with no tweening. */
.skipped .lit.on,
.skipped .ln.on,
.skipped [data-last].on,
.skipped [data-status].on,
.skipped .cta.on { animation: none; }

/* ---- The room ------------------------------------------------------
   Layers behind the log, each tied to one stage of the boot:
   signal -> the scope trace locks; static -> the grain settles;
   light -> the room warms from the word "lit" outward.
   With no classes at all (no JS) the room shows its finished state. */

.room,
.scope,
.vignette,
.grain { position: fixed; pointer-events: none; }

.room {
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at var(--lx, 32%) var(--ly, 46%),
      rgba(245, 158, 11, 0.21) 0,
      rgba(196, 104, 38, 0.10) 14%,
      rgba(120, 62, 28, 0.04) 32%,
      rgba(22, 19, 17, 0) 58%);
  transition: opacity 2200ms var(--ease-settle);
}
.boot:not(.stage-lit) .room { opacity: 0; }

.scope { inset: 0; z-index: 2; width: 100%; height: 100%; }

.vignette {
  inset: 0;
  z-index: 3;
  background: radial-gradient(ellipse 85% 75% at 42% 50%, transparent 55%, rgba(8, 6, 5, 0.6) 100%);
}

.grain {
  inset: -50%;
  z-index: 4;
  width: 200%;
  height: 200%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .91 0 0 0 0 .87 0 0 0 0 .81 0 0 0 1.2 -.25'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.06;
}

/* The storm: heavy, flickering static that dissolves away at
   "filtering static... ok", leaving the still grain beneath it. */
.grain.storm {
  opacity: 0;
  visibility: hidden;
  animation: grain 0.42s steps(3) infinite;
  transition: opacity 2000ms var(--ease-dissolve), visibility 0s 2000ms;
}
.boot:not(.stage-filtered) .grain.storm { opacity: 0.18; visibility: visible; transition: none; }

@keyframes grain {
  0%   { transform: translate(0, 0); }
  33%  { transform: translate(-6%, 4%); }
  66%  { transform: translate(5%, -7%); }
  100% { transform: translate(-3%, 6%); }
}

/* ---- Bezel: the instrument frame ------------------------------------ */

.bezel {
  position: fixed;
  inset: var(--bezel);
  z-index: 6;
  border: 1px solid var(--bronze);
  pointer-events: none;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ash);
  transition: border-color 2200ms var(--ease-settle), color 2200ms var(--ease-settle);
}
.bezel { border-color: #4f3f31; }
.boot:not(.stage-lit) .bezel { border-color: var(--bronze); }

.tick { position: absolute; width: 14px; height: 14px; border: 0 solid #8a7059; }
.tick.tl { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
.tick.tr { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
.tick.bl { bottom: -1px; left: -1px; border-bottom-width: 1px; border-left-width: 1px; }
.tick.br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

.mark {
  position: absolute;
  padding: 0 10px;
  line-height: 1;
  background: var(--espresso);
  white-space: nowrap;
}
.mark.tl { top: -0.5em; left: 28px; }
.mark.tr { top: -0.5em; right: 28px; }
.mark.bl { bottom: -0.5em; left: 28px; }
.mark.br { bottom: -0.5em; right: 28px; }
.mark [data-sys] { color: var(--bone); }

@media (max-width: 480px) {
  .mark.tl { left: 16px; } .mark.tr { right: 16px; }
  .mark.bl { left: 16px; } .mark.br { right: 16px; }
}

.skipped .room,
.skipped .grain.storm,
.skipped .bezel { transition: none; }

@media (prefers-reduced-motion: reduce) {
  .grain.storm { display: none; }
}

/* ---- Masthead: the mark ---------------------------------------------
   One column, one reading order. The mark heads it: the legend over the
   monitor (drawn by ambient.js into .monitor's box). Until "lit" the mark is
   dim, so the typing leads; when the light arrives it warms and wakes. */
.masthead { margin-bottom: clamp(24px, 4.5vh, 48px); }
.legend {
  display: inline-block;
  font-family: var(--font-mark);
  font-size: clamp(14px, 1.5vw, 23px);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--bone);
  text-shadow: 0 0 14px rgba(232, 223, 207, 0.14);
  transition: color 1400ms var(--ease-settle), text-shadow 1400ms var(--ease-settle), opacity 1400ms var(--ease-settle);
}
.boot .legend:not(.warm) { color: var(--ash); opacity: 0.6; }
.legend.warm {
  color: var(--bone-hi);
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.3), 0 0 28px rgba(245, 158, 11, 0.14);
}
.monitor { height: clamp(48px, 8vh, 76px); }

/* ---- Caret ------------------------------------------------------------
   One block caret travels the whole session: it sits where the unseen
   operator is typing, waits after each readout, then drops to the next
   line. Zero width, so it never pushes the text. */
.caret { position: relative; display: inline-block; width: 0; height: 1em; }
.caret::before {
  content: "";
  position: absolute;
  left: 0.1em;
  bottom: -0.22em;
  width: 0.58em;
  height: 1.1em;
  background: var(--bone);
  box-shadow: 0 0 10px rgba(232, 223, 207, 0.3);
}
.caret.wait::before { animation: blink 1.06s steps(1) infinite; }
.boot [data-last] .cursor { display: none; }
.boot [data-last].done .cursor { display: inline-block; }

/* The cursor warp (boot.js): above the text, like the terminal's. */
.warp { position: fixed; inset: 0; z-index: 6; width: 100%; height: 100%; pointer-events: none; }

/* The second pulse: "lit" flares as it sends the light that fixes the mark. */
.lit.surge { animation: surge 1.4s var(--ease-settle); }
@keyframes surge {
  0%   { color: #fff1d6; text-shadow: 0 0 8px #fff1d6, 0 0 26px rgba(245, 158, 11, 1), 0 0 80px rgba(245, 158, 11, 0.7); }
  100% { color: var(--filament); text-shadow: 0 0 6px rgba(255, 196, 110, 0.9), 0 0 18px var(--filament-glow), 0 0 48px rgba(245, 158, 11, 0.35); }
}
