/* ==========================================================================
   Design tokens — 80s/90s terminal.

   The reference is a phosphor CRT and early-90s software chrome: amber and
   cyan on near-black, hairline rules, beveled panels, chunky monospace. The
   restraint that keeps it from being a costume: one accent per section, real
   type hierarchy, and animation that respects reduced-motion.
   ========================================================================== */

:root {
  /* Surfaces */
  --bg:          #07090c;
  --bg-raise:    #0d1117;
  --bg-panel:    #10161f;
  --bg-inset:    #05070a;

  /* Phosphor palette */
  --amber:       #ffb000;
  --amber-dim:   #a86f00;
  --cyan:        #22d3ee;
  --cyan-dim:    #0e7490;
  --magenta:     #ff2e88;
  --green:       #39ff88;

  /* Text */
  --fg:          #d7e0ea;
  --fg-mute:     #8b9bb0;
  --fg-faint:    #56657a;

  /* Structure */
  --rule:        #1e2a38;
  --rule-bright: #2c3e52;

  /* Type */
  --mono: "Berkeley Mono", "JetBrains Mono", "IBM Plex Mono", ui-monospace,
          SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --display: var(--mono);

  --step--1: clamp(0.72rem, 0.68rem + 0.18vw, 0.82rem);
  --step-0:  clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
  --step-1:  clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  --step-2:  clamp(1.4rem, 1.2rem + 1vw, 2rem);
  --step-3:  clamp(1.9rem, 1.5rem + 2vw, 3.2rem);
  --step-4:  clamp(2.4rem, 1.7rem + 3.6vw, 5.5rem);

  /* Rhythm */
  --gutter: clamp(1rem, 4vw, 3rem);
  --section-y: clamp(4rem, 10vh, 9rem);
  --measure: 62ch;

  --radius: 2px;      /* era-appropriate: almost square */
  --border: 1px solid var(--rule);

  --speed: 0.4s;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Light mode is deliberately not offered: the whole design is a lit phosphor
   tube on a dark room. A light variant would be a different design, not a
   recolour. The scheme is declared so form controls and scrollbars match. */
:root { color-scheme: dark; }

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

html {
  scroll-behavior: smooth;
  /* Anchors from agent buttons must clear the fixed header. */
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- CRT overlays --------------------------------------------------------
   Two fixed layers over everything: scanlines and a vignette. Both are
   pointer-events:none and aria-hidden, so they are pure atmosphere. */

.crt-scanlines,
.crt-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
}

.crt-scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgb(255 255 255 / 0.025) 0px,
    rgb(255 255 255 / 0.025) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.6;
}

.crt-vignette {
  background: radial-gradient(
    ellipse at center,
    transparent 55%,
    rgb(0 0 0 / 0.45) 100%
  );
}

/* --- Typography ---------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.6em;
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }

p { margin: 0 0 1em; max-width: var(--measure); text-wrap: pretty; }

a { color: var(--cyan); text-underline-offset: 3px; }
a:hover { color: var(--amber); }

:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

/* Small-caps label, the workhorse of the era's UI chrome. */
.label {
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.kicker {
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--amber);
  display: block;
  margin-bottom: 0.8rem;
}

.kicker::before { content: "▐ "; color: var(--amber-dim); }

/* --- Panels — the beveled box of 90s software ---------------------------- */

.panel {
  background: var(--bg-panel);
  border: var(--border);
  border-radius: var(--radius);
  padding: clamp(1rem, 3vw, 1.75rem);
  position: relative;
}

.panel::before {
  /* Single-pixel highlight along the top edge: cheap bevel, no gradients. */
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: var(--rule-bright);
}

/* --- Buttons ------------------------------------------------------------- */

.btn {
  --btn-accent: var(--amber);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font: inherit;
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--btn-accent);
  background: transparent;
  border: 1px solid var(--btn-accent);
  border-radius: var(--radius);
  padding: 0.6rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

.btn:hover:not(:disabled),
.btn:focus-visible {
  background: var(--btn-accent);
  color: var(--bg);
}

.btn:disabled {
  --btn-accent: var(--fg-faint);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn--cyan { --btn-accent: var(--cyan); }
.btn--ghost { --btn-accent: var(--fg-mute); }

/* --- Blinking cursor ----------------------------------------------------- */

.cursor-block {
  display: inline-block;
  width: 0.6em;
  height: 1.05em;
  background: var(--amber);
  vertical-align: text-bottom;
  animation: blink 1.05s steps(1) infinite;
}

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

/* --- Motion -------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  /* Content animated in by GSAP must be visible when GSAP is told to stand
     down, so nothing is left at opacity 0 forever. */
  [data-anim] { opacity: 1 !important; transform: none !important; }

  .crt-scanlines { display: none; }
  .cursor-block { animation: none; }
}
