/* ---------- Tokens ---------- */
:root {
  --bg: #050505;
  --fg: #ecebe6;
  --fg-2: #b9b8b2;
  --dim: rgba(236, 235, 230, 0.42);
  --faint: rgba(236, 235, 230, 0.14);
  --hair: rgba(236, 235, 230, 0.09);
  --accent: #6ef2a0;
  --accent-dim: rgba(110, 242, 160, 0.35);

  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --gutter: max(16px, env(safe-area-inset-left));
  --ease: cubic-bezier(0.2, 0.7, 0, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.js body.is-running { overflow: hidden; }

button { font: inherit; color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.accent { color: var(--accent); }

/* ---------- Ambient FX: scanlines, slow scan band, vignette ---------- */
.fx {
  position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 3px);
}
.fx__scan {
  position: absolute; left: 0; right: 0; top: 0; height: 28vh;
  background: linear-gradient(to bottom, transparent, rgba(236, 235, 230, 0.022), transparent);
  transform: translateY(-30vh);
  animation: scan 9s linear infinite;
  will-change: transform;
}
@keyframes scan { to { transform: translateY(130vh); } }

/* ---------- HUD ---------- */
.hud {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--dim);
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-left: var(--gutter);
  padding-right: max(16px, env(safe-area-inset-right));
  z-index: 20;
  white-space: nowrap;
  transition: opacity 0.8s ease;
}
.hud--top {
  position: absolute; top: 0; left: 0; right: 0;
  padding-top: max(18px, env(safe-area-inset-top));
}
.hud--bottom {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}
.hud__item { display: inline-flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.hud__agent { transition: color 0.6s ease; }
.hud__agent.is-live { color: var(--fg-2); }
.is-blackout .hud { opacity: 0; }

.dot {
  width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--faint);
  transition: background-color 0.4s ease, box-shadow 0.4s ease;
}
.dot[data-state="search"] { background: var(--dim); animation: blink 0.9s steps(1) infinite; }
.dot[data-state="live"]   { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); animation: pulse 2.4s ease-in-out infinite; }
.dot[data-state="done"]   { background: var(--accent); box-shadow: 0 0 8px var(--accent-dim); }
@keyframes pulse { 50% { opacity: 0.45; } }

.skip {
  background: none; border: 0; padding: 10px 0 10px 16px; margin: -10px 0;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--dim);
  cursor: pointer; transition: color 0.2s ease;
}
.skip:hover, .skip:focus-visible { color: var(--fg); }
.skip:focus-visible, .access__btn:focus-visible, .restart:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

/* ---------- Terminal ---------- */
.terminal {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  padding: 0 var(--gutter);
  transition: opacity 0.9s ease;
}
.terminal.is-out { opacity: 0; pointer-events: none; }

.term {
  width: min(40rem, 100%);
  transition: opacity 0.5s ease;
}
.is-blackout .term { opacity: 0; }

/* Scrolling log: prints top-down, then scrolls up once the window is full */
.log {
  position: relative;
  height: min(64vh, 30rem);
  height: min(64dvh, 30rem);
  overflow: hidden;
  font-family: var(--mono);
  font-size: clamp(10.5px, 2.9vw, 13px);
  line-height: 1.8;
  color: var(--fg-2);
}
.log.is-scrolled {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 30%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 30%);
}
.log__inner { transition: transform 0.35s var(--ease); }

.ln {
  --ls: 0.02em;
  --hang: 2;
  min-height: 1.8em;
  letter-spacing: var(--ls);
  /* wrapped lines hang under the text, not under the prompt / status box */
  padding-left: calc(var(--hang) * (1ch + var(--ls)));
  text-indent: calc(var(--hang) * -1 * (1ch + var(--ls)));
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: lnIn 0.18s ease-out both;
}
@keyframes lnIn { from { opacity: 0; } }

.ln--cmd { --ls: 0.08em; color: var(--fg); text-shadow: 0 0 12px rgba(236, 235, 230, 0.14); }
.ln--case { --ls: 0.03em; }
.ln--shell { --ls: 0.03em; color: var(--fg-2); text-shadow: none; }
.ln--shell .ln__p { color: var(--accent); }
.ln--hi { font-weight: 500; }
.ln__p { color: var(--dim); }

.ln--out { --ls: 0em; --hang: 9; color: var(--dim); }
.st { color: var(--fg-2); }
.st b {
  display: inline-block; width: 4ch; text-indent: 0; text-align: center;
  font-weight: 400; color: var(--fg-2);
}
.st.is-ok b { color: var(--accent); }
.ln__r { color: var(--fg-2); }

/* ASCII progress bar: [#########·········]  47% */
.ln__bar b { font-weight: 400; color: var(--accent); text-shadow: 0 0 4px rgba(110, 242, 160, 0.22); }
.ln__bar i { font-style: normal; color: var(--faint); }
.ln__bar em { font-style: normal; color: var(--fg-2); }

.term__dots i { font-style: normal; opacity: 0; }
.term__dots.is-run i { animation: dot 1.4s infinite both; }
.term__dots.is-run i:nth-child(2) { animation-delay: 0.2s; }
.term__dots.is-run i:nth-child(3) { animation-delay: 0.4s; }
.term__dots.is-done i { opacity: 1; }
@keyframes dot { 0% { opacity: 0; } 20%, 70% { opacity: 1; } 100% { opacity: 0; } }

.cursor {
  display: inline-block; width: 0.62em; height: 1.05em; margin-left: 0.18em;
  vertical-align: -0.16em; text-indent: 0;
  background: var(--fg);
  box-shadow: 0 0 10px rgba(236, 235, 230, 0.25);
  animation: blink 1.05s steps(1) infinite;
}
.is-typing .cursor { animation: none; }
@keyframes blink { 50% { opacity: 0; } }

.flicker { animation: flicker 0.6s linear 1; }
@keyframes flicker {
  0%, 100% { opacity: 1; }
  8% { opacity: 0.35; } 12% { opacity: 1; } 22% { opacity: 0.6; }
  26% { opacity: 1; } 55% { opacity: 0.85; } 58% { opacity: 1; }
}

/* ---------- The reveal ---------- */
.reveal {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 22px;
  padding: 0 var(--gutter);
  pointer-events: none; visibility: hidden;
}
.reveal::before { /* single exposure flash */
  content: ""; position: absolute; inset: 0; background: var(--fg); opacity: 0;
}
.reveal.is-on { visibility: visible; }
.reveal.is-on::before { animation: flash 0.7s ease-out 1 both; }
@keyframes flash { 0% { opacity: 0; } 6% { opacity: 0.09; } 100% { opacity: 0; } }

.reveal__word {
  position: relative;
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(84px, 25vw, 300px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  color: var(--fg);
  opacity: 0;
  text-shadow: 0 0 60px rgba(236, 235, 230, 0.14);
}
.reveal.is-on .reveal__word {
  animation: poo 1.4s var(--ease) 1 both, jolt 0.18s steps(2) 1.6s 1;
}
@keyframes poo {
  0%   { opacity: 0; filter: blur(22px); transform: scale(1.14); letter-spacing: 0.18em; }
  7%   { opacity: 1; }
  100% { opacity: 1; filter: blur(0); transform: scale(1); letter-spacing: -0.045em; }
}
@keyframes jolt {
  0% { transform: translateX(-3px); text-shadow: 3px 0 rgba(110, 242, 160, 0.5), 0 0 60px rgba(236, 235, 230, 0.14); }
  100% { transform: translateX(2px); }
}

.reveal__rule {
  width: min(18rem, 60vw); height: 1px; background: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
  transform: scaleX(0); opacity: 0.8;
}
.reveal.is-on .reveal__rule { animation: rule 1s var(--ease) 0.7s 1 both; }
@keyframes rule { to { transform: scaleX(1); } }

.reveal__sub {
  font-family: var(--mono); font-size: clamp(10px, 2.6vw, 12px); letter-spacing: 0.22em;
  color: var(--dim); white-space: nowrap; opacity: 0;
}
.reveal__sub .sep { color: var(--faint); margin: 0 0.5em; }
.reveal.is-on .reveal__sub { animation: fadeUp 0.9s ease 1.1s 1 both; }

/* ---------- Access thesis ---------- */
.access {
  display: grid; place-items: center;
  margin-top: 18px; min-height: 52px;
}
.access > * { grid-area: 1 / 1; }

.access__btn {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 15px 24px;
  background: rgba(5, 5, 5, 0.6);
  border: 1px solid var(--faint); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.24em;
  color: var(--fg); white-space: nowrap; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity 0.9s ease, transform 0.9s var(--ease), visibility 0s linear 0.9s,
              border-color 0.3s ease, box-shadow 0.3s ease, text-shadow 0.3s ease;
}
.access__arrow { display: inline-block; transition: transform 0.3s var(--ease); }
.access__btn:hover, .access__btn:focus-visible {
  border-color: var(--accent-dim);
  box-shadow: 0 0 22px rgba(110, 242, 160, 0.1), inset 0 0 14px rgba(110, 242, 160, 0.05);
  text-shadow: 0 0 10px rgba(236, 235, 230, 0.35);
}
.access__btn:hover .access__arrow, .access__btn:focus-visible .access__arrow { transform: translateX(4px); }
.reveal.is-ready .access__btn {
  opacity: 1; visibility: visible; transform: none;
  transition-delay: 0s;
}
.reveal.is-accessed .access__btn {
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.5s ease, visibility 0s linear 0.5s;
}

.access__status {
  margin: 0;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.24em; color: var(--fg-2);
  white-space: nowrap;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.6s ease, transform 0.6s var(--ease);
}
.reveal.is-accessed .access__status { opacity: 1; transform: none; transition-delay: 0.45s; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Thesis ---------- */
.thesis { display: none; }
body.is-done .thesis, .no-js .thesis { display: block; }
body.is-done .terminal, body.is-done .hud--bottom, .no-js .terminal, .no-js .hud--bottom { display: none; }

.thesis__inner {
  width: min(42rem, 100%);
  margin: 0 auto;
  padding: clamp(104px, 18vh, 200px) var(--gutter) max(56px, env(safe-area-inset-bottom));
}

.thesis [style*="--i"] { opacity: 0; }
.thesis.is-in [style*="--i"], .no-js .thesis [style*="--i"] {
  animation: rise 1.1s var(--ease) both;
  animation-delay: calc(min(var(--i), 9) * 170ms + 150ms);
}
.no-js .thesis [style*="--i"] { animation: none; opacity: 1; }
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.thesis__head {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding-bottom: 20px; margin-bottom: clamp(40px, 7vh, 64px);
  border-bottom: 1px solid var(--hair);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.28em;
}
.thesis__label {
  margin: 0; font: inherit; color: var(--fg);
  display: inline-flex; align-items: center; gap: 12px;
}
.thesis__ref { color: var(--dim); letter-spacing: 0.18em; font-size: 10px; white-space: nowrap; }

.thesis__body p {
  margin: 0 0 0.9em;
  font-size: clamp(18px, 0.9vw + 14px, 23px);
  line-height: 1.6;
  color: var(--fg-2);
  letter-spacing: -0.005em;
  text-wrap: pretty;
}
.thesis__body .t-lead { color: var(--fg); }
.thesis__body .t-big {
  margin: 1.5em 0 0.25em;
  font-size: clamp(30px, 3.4vw + 16px, 54px);
  line-height: 1.1; font-weight: 600; letter-spacing: -0.03em; color: var(--fg);
}
.thesis__body .t-arrow {
  margin: 0 0 1.1em;
  font-size: clamp(52px, 7vw + 26px, 112px);
  line-height: 1.02; font-weight: 800; letter-spacing: -0.045em; color: var(--fg);
  white-space: nowrap;
}
.thesis__body .t-arrow .accent { font-weight: 400; display: inline-block; margin: 0 0.04em; }
.thesis__body .t-mid { margin-top: 1.4em; color: var(--fg); font-weight: 600; letter-spacing: -0.015em; }
.thesis__body .t-last { color: var(--fg); font-weight: 500; }
.thesis__body .t-gap { margin-top: 1.5em; }
.thesis__body .t-tight { margin-top: -0.5em; }
.thesis__body .t-final { margin: 0.45em 0 0; }

.thesis__sig {
  margin: clamp(48px, 8vh, 80px) 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--hair);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.26em; color: var(--dim);
}

.thesis__foot {
  margin-top: clamp(72px, 14vh, 140px);
  display: grid; justify-items: center; gap: 28px; text-align: center;
}
.logo {
  width: min(24rem, 86%);
  aspect-ratio: 1027 / 230;
  overflow: hidden;
  /* own blend group on the page colour, so the jpeg backdrop disappears regardless of parent stacking */
  background: var(--bg);
  isolation: isolate;
}
.logo img {
  display: block; width: 100%; height: 100%;
  object-fit: cover; object-position: 50% 49%;
  /* crush the jpeg's grey backdrop to black, then blend it into the page */
  filter: contrast(1.35) brightness(0.92);
  mix-blend-mode: lighten;
  opacity: 0.85;
}
.restart {
  background: none; border: 0; min-height: 44px; padding: 12px 14px; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em; color: var(--dim);
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
  transition: color 0.25s ease, text-shadow 0.25s ease;
}
.restart__icon { display: inline-block; transition: transform 0.6s var(--ease); }
.restart:hover, .restart:focus-visible { color: var(--fg); text-shadow: 0 0 10px rgba(236, 235, 230, 0.3); }
.restart:hover .restart__icon, .restart:focus-visible .restart__icon { transform: rotate(360deg); }
.disclaimer {
  margin: 0; font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; color: rgba(236, 235, 230, 0.28);
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .hud, .skip { letter-spacing: 0.12em; }
  .ln--cmd { --ls: 0.04em; }
  .ln--case, .ln--shell { --ls: 0.01em; }
  .thesis__ref { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .fx__scan, .dot, .ln { animation: none !important; }
  .reveal.is-on .reveal__word { animation: fadeUp 0.6s ease both; }
  .reveal.is-on::before { animation: none; }
  .thesis.is-in [style*="--i"] { animation-name: fadeUp; }
}
