/* ============================================================
   WE ARE LIVING IN A STIMULATION — book microsite
   Hand-rolled. No frameworks. Edit freely.
   Two voices: mono (OCR-B stand-in) for the system, serif
   (Freight Text Pro stand-in) for the human testimony.
   ============================================================ */

:root {
  /* True fonts first (Adobe Fonts kit fwq7yfr), Google Fonts as the failsafe fallback. */
  --font-mono: 'ocr-b-std', 'IBM Plex Mono', ui-monospace, "SF Mono", Menlo, monospace;
  --font-serif: 'freight-text-pro', 'Source Serif 4', Georgia, serif;

  --bg: #0d0d0d;
  --bg-raise: #151515;
  --ink: #f2efe9;
  --ink-2: #9a9790;
  --line: #2a2a28;
  --signal: #ff2ea6;

  --maxw: 1180px;
  --maxw-narrow: 760px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
h1, h2, h3, p, ul, blockquote, figure { margin: 0; }

.mono { font-family: var(--font-mono); }

/* ---------- orphan / widow control (no hanging single words, any width) ----------
   balance = even line lengths for short display text; pretty = no lone last word in body. */
.hero-title, .hero-sub, .hero-line, .close-line, .review-line,
.intro-serif, .caption-serif, .sticky-title { text-wrap: balance; }
.body-serif p, .who-list li, .cycle-cell p, .col p, .hero-proof, .footer p { text-wrap: pretty; }

.label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 14px;
}

/* ---------- reveal-on-scroll (subtle, no libraries) ---------- */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .7s ease, transform .7s ease;
}
.reveal.in-view { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  background: rgba(13, 13, 13, .82);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-name {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .1em;
}
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .08em;
}
.topbar-nav a:not(.btn) { color: var(--ink-2); }
.topbar-nav a:not(.btn):hover { color: var(--ink); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: .08em;
  padding: 14px 22px;
  border: 1px solid var(--ink);
  white-space: nowrap;
  transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}
.btn-signal {
  background: var(--signal);
  border-color: var(--signal);
  color: #120608;
}
.btn-signal:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--ink); }
.btn-small { padding: 9px 16px; font-size: 11px; }

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 28px;
}
.cta-center { justify-content: center; }

/* ---------- hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  min-height: 92vh;
  align-items: center;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px 28px;
}
.hero-copy { padding-right: 40px; }
.hero-title {
  font-family: var(--font-mono);
  font-size: clamp(2rem, 4.4vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -.01em;
  margin: 18px 0 22px;
}
.hero-sub {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--ink);
  max-width: 46ch;
  margin-bottom: 14px;
}
.hero-line {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-2);
  font-size: 1.05rem;
}
.hero-proof {
  margin-top: 18px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--ink-2);
}
.hero-media img { border: 1px solid var(--line); }

/* ---------- sections ---------- */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 100px 28px;
}
.section-narrow { max-width: var(--maxw-narrow); }
.section-wide { max-width: 1320px; }
.section + .section { border-top: 1px solid var(--line); }

/* Two-voice balance: literary section headlines in Freight (human voice); the framework
   headline (THE ECHO CYCLE) and the hero title stay OCR-B (machine voice). */
.head-serif {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  line-height: 1.3;
  margin-bottom: 26px;
  max-width: 22ch;
  text-wrap: balance;
}
.head-mono {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  letter-spacing: .06em;
  margin-bottom: 18px;
  text-wrap: balance;
}
.intro-serif {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  color: var(--ink-2);
  max-width: 60ch;
  margin-bottom: 48px;
}
.body-serif p { margin-bottom: 18px; font-size: 1.05rem; }
.body-serif p:last-child { margin-bottom: 0; }
.body-serif em { font-style: italic; }
.inline-mono { font-size: .95em; }

.caption-serif {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-2);
  margin-top: 20px;
}

/* ---------- trailer ---------- */
.video-frame {
  border: 1px solid var(--line);
  background: #000;
}
.video-frame video { width: 100%; aspect-ratio: 16/9; }

/* ---------- echo cycle ---------- */
.plate {
  border: 1px solid var(--line);
  background: #f2efe9;
  padding: 32px;
  margin-bottom: 20px;
}
.plate img { margin: 0 auto; }
.plate figcaption { margin-top: 16px; color: #6b6b66; }

.cycle-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  margin-top: 44px;
}
.cycle-cell {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  transition: border-color .2s ease;
}
.cycle-cell:hover { border-color: var(--signal); }
.cycle-cell h3 {
  font-size: .95rem;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
/* Force Menlo specifically for the Breach glyph — it's the exact character/font
   used in the book's diagram (page 21). Other glyphs (⇌ ↻ ⇒) already match via
   the normal mono stack, so only this one needs pinning. Falls back to the
   regular mono stack on systems without Menlo (Windows/Android/Linux). */
.glyph-menlo {
  font-family: 'Menlo', var(--font-mono);
}
.cycle-cell p { color: var(--ink-2); font-size: .95rem; }

/* ---------- glitch motion panel (contained, plays in view only) ---------- */
.glitch-panel { max-width: 360px; margin: 48px auto 0; }
.glitch-panel .glitch-vid {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
  background: #000;
}
.glitch-panel figcaption { margin-top: 12px; text-align: center; }

/* ---------- three col (what kind of book) ---------- */
.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}
.col h3 {
  font-size: .85rem;
  letter-spacing: .06em;
  margin-bottom: 12px;
  color: var(--signal);
}
.col p { font-family: var(--font-serif); color: var(--ink); }

/* ---------- who it's for ---------- */
.who-list { list-style: none; padding: 0; }
.who-list li {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.who-list li:last-child { border-bottom: 1px solid var(--line); }

/* ---------- reviews ---------- */
.review-line {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.2rem;
  max-width: 50ch;
}
.review-stars { margin-top: 18px; color: var(--signal); font-size: 13px; letter-spacing: .04em; }
.review { border-left: 2px solid var(--signal); padding-left: 20px; margin-bottom: 24px; }
.review p { font-family: var(--font-serif); font-style: italic; font-size: 1.1rem; }
.review cite { display: block; margin-top: 8px; font-style: normal; }

/* ---------- gallery ---------- */
.gallery-cap { margin-bottom: 44px; }
.g-wide { margin-bottom: 20px; }
.g-wide img { width: 100%; object-fit: cover; }
.g-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.g-pair img { width: 100%; height: 100%; object-fit: cover; aspect-ratio: 4/5; }

/* ---------- author ---------- */
.author-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 48px;
  align-items: start;
}
.author-photo img { border: 1px solid var(--line); }
.author-links { display: flex; gap: 20px; margin-top: 24px; font-size: 11px; letter-spacing: .06em; }
.author-links a { color: var(--ink-2); border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.author-links a:hover { color: var(--signal); border-color: var(--signal); }

/* ---------- final cta ---------- */
.section-close { text-align: center; padding-top: 60px; padding-bottom: 100px; }
.close-line {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(1.4rem, 3vw, 2rem);
  max-width: 22ch;
  margin: 0 auto;
}
.close-proof { margin-top: 22px; }

/* ---------- footer ---------- */
.footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 11px;
  letter-spacing: .04em;
}
.footer a { border-bottom: 1px solid var(--line); }

/* ---------- sticky mobile cta ---------- */
.sticky-cta {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(13, 13, 13, .95);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  transform: translateY(100%);
  transition: transform .25s ease;
}
.sticky-cta.is-visible { transform: translateY(0); }
.sticky-title {
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 32px;
  }
  .hero-media { order: -1; margin-bottom: 28px; }
  .hero-copy { padding-right: 0; }
  .section { padding: 72px 22px; }
  .cycle-grid { grid-template-columns: repeat(2, 1fr); }
  .three-col { grid-template-columns: 1fr; gap: 40px; }
  .author-grid { grid-template-columns: 1fr; }
  .author-photo { max-width: 220px; }
  .g-pair { grid-template-columns: 1fr; }
  .topbar-nav a:not(.btn) { display: none; }
  .sticky-cta { display: flex; }
  body { padding-bottom: 64px; } /* clear space for sticky bar */
}

@media (max-width: 520px) {
  .topbar { padding: 14px 18px; }
  .cycle-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
}

/* ================================================================
   DECODE MODE — easter-egg "see the code underneath". Toggled by
   .decode-toggle (js/decode.js), which also generates the ASCII.
   ================================================================ */
.topbar-left { display: flex; align-items: center; gap: 18px; }
.topbar-divider { color: var(--line); font-size: 12px; }
.decode-toggle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: normal; /* brackets in a mono face already read wide; extra tracking fights the name */
  color: var(--ink-2);
  background: transparent;
  border: none;
  padding: 4px 2px;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}
.decode-toggle .bracket { color: var(--line); }
.decode-toggle:hover { color: var(--signal); }
.decode-toggle:hover .bracket { color: var(--signal); }

.ascii-art { display: none; }

/* --- the flip --- */
body.decoded { background: #060606; color: #ff3fab; }
body.decoded, body.decoded * { font-family: var(--font-mono) !important; }

/* Exit affordance must never be ambiguous: once inside, RESTORE becomes a
   solid chip (matches the original high-contrast treatment), not quiet text. */
body.decoded .decode-toggle {
  color: #060606 !important;
  background: var(--signal) !important;
  padding: 6px 12px !important;
  font-weight: 600;
}
body.decoded .decode-toggle .bracket { display: none; }

/* recolor the readout: dim magenta for body, bright for the "system" lines */
body.decoded .body-serif,
body.decoded .body-serif p,
body.decoded .who-list li,
body.decoded .cycle-cell p,
body.decoded .col p,
body.decoded .intro-serif,
body.decoded .hero-sub,
body.decoded .caption-serif,
body.decoded .label,
body.decoded .hero-proof,
body.decoded .review-line,
body.decoded .footer,
body.decoded .footer p { color: #b83d80 !important; }

body.decoded .head-serif,
body.decoded .head-mono,
body.decoded .hero-title,
body.decoded .hero-line,
body.decoded .close-line,
body.decoded .col h3,
body.decoded .cycle-cell h3,
body.decoded .review-stars {
  color: #ff5cbf !important;
  font-style: normal !important;
  text-shadow: 0 0 6px rgba(255, 46, 166, .35);
}

body.decoded .btn {
  background: transparent !important;
  border-color: var(--signal) !important;
  color: var(--signal) !important;
}
body.decoded .plate {
  background: #060606 !important;
  border-color: #3a0a24 !important;
}
body.decoded .topbar,
body.decoded .section + .section,
body.decoded .who-list li,
body.decoded .cycle-cell,
body.decoded .video-frame,
body.decoded .footer,
body.decoded .glitch-panel .glitch-vid { border-color: #3a0a24 !important; }
body.decoded .topbar { background: rgba(6, 6, 6, .85); }
body.decoded .sticky-cta { background: rgba(6, 6, 6, .95); border-color: #3a0a24; }

/* media -> ASCII: keep the box, hide the pixels, overlay the transcode */
body.decoded .hero-media,
body.decoded figure,
body.decoded .author-photo,
body.decoded .video-frame,
body.decoded .glitch-panel { position: relative; }

body.decoded .hero-media img,
body.decoded .plate img,
body.decoded .g-wide img,
body.decoded .g-pair img,
body.decoded .author-photo img,
body.decoded .video-frame video,
body.decoded .glitch-vid { opacity: 0; }

body.decoded .ascii-art {
  display: block;
  position: absolute;
  margin: 0;
  z-index: 2;
  white-space: pre;
  overflow: hidden;
  pointer-events: none;
  color: #ff3fab;
  letter-spacing: 0;
  text-shadow: 0 0 4px rgba(255, 46, 166, .3);
}

/* warp lens — a filtered clone of the ASCII under the pointer, revealed only
   in a soft circle that follows the cursor/finger. Decode mode only. */
body.decoded .warp-clone {
  position: absolute;
  margin: 0;
  white-space: pre;
  overflow: hidden;
  z-index: 3;
  pointer-events: none;
  color: #ff6cc6;
  letter-spacing: 0;
  filter: url(#decode-warp);
  -webkit-mask: radial-gradient(circle 165px at var(--mx, -999px) var(--my, -999px), #000 0%, rgba(0,0,0,.75) 35%, rgba(0,0,0,.3) 65%, transparent 100%);
  mask: radial-gradient(circle 165px at var(--mx, -999px) var(--my, -999px), #000 0%, rgba(0,0,0,.75) 35%, rgba(0,0,0,.3) 65%, transparent 100%);
}

/* live-video ASCII is clickable (play/pause); show a cue when paused */
body.decoded .ascii-video { pointer-events: auto; cursor: pointer; }
body.decoded .ascii-video.paused::after {
  content: '\25B6'; /* ▶ */
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 2.4rem;
  color: var(--signal);
  text-shadow: 0 0 10px rgba(255, 46, 166, .55);
}

/* CRT scanlines over the whole thing */
body.decoded::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
  background: repeating-linear-gradient(rgba(0, 0, 0, 0) 0 2px, rgba(0, 0, 0, .28) 2px 3px);
  mix-blend-mode: multiply;
  animation: scanline-drift 6s linear infinite;
}
@keyframes scanline-drift {
  to { background-position: 0 60px; }
}

@media (prefers-reduced-motion: reduce) {
  body.decoded::after { display: none; }
}
