/* ============================================================
   The Brew Lab — Effects
   Custom cursor, hero/WebGL, REPL terminal, page transitions,
   cinematics. All effects are pointer/motion gated for mobile + a11y.
   ============================================================ */

/* ---------- custom cursor (pointer-fine only) ---------- */
.cursor-dot, .cursor-ring { display: none; }

@media (hover: hover) and (pointer: fine) {
  body.has-cursor { cursor: none; }
  body.has-cursor a, body.has-cursor button, body.has-cursor .magnetic { cursor: none; }

  .cursor-dot, .cursor-ring {
    display: block; position: fixed; top: 0; left: 0; z-index: 999;
    pointer-events: none; border-radius: 50%;
    transform: translate3d(-50%, -50%, 0);
    will-change: transform; mix-blend-mode: difference;
  }
  .cursor-dot { width: 7px; height: 7px; background: #fff; }
  .cursor-ring {
    width: 34px; height: 34px; border: 1px solid #fff;
    transition: width var(--t-base) var(--ease), height var(--t-base) var(--ease),
                background var(--t-base) ease, opacity var(--t-base) ease;
  }
  .cursor-ring.hot { width: 54px; height: 54px; background: rgba(255, 255, 255, 0.12); }
}
@media (prefers-reduced-motion: reduce) {
  body.has-cursor { cursor: auto; }
  .cursor-dot, .cursor-ring { display: none !important; }
}

.magnetic { will-change: transform; }

/* ---------- hero ---------- */
.hero { padding: clamp(48px, 9vw, 84px) 0 clamp(48px, 8vw, 72px); position: relative; }
.hero-grid { display: grid; grid-template-columns: 1fr; gap: 36px; align-items: center; }
@media (min-width: 920px) { .hero-grid { grid-template-columns: 1.02fr 1.18fr; gap: 56px; } }

h1.title {
  font-size: var(--fs-h1); font-weight: 800; letter-spacing: -0.035em;
  line-height: 1.02; margin-bottom: 18px; text-wrap: balance;
}
.mantra { font-size: clamp(18px, 4.6vw, 22px); font-weight: 600; color: var(--text); margin-bottom: 10px; letter-spacing: -0.01em; }
.sub { font-size: clamp(14px, 3.6vw, 16px); color: var(--muted); margin-bottom: 30px; font-family: var(--font-mono); letter-spacing: 0.01em; }

/* WebGL canvas mounts behind the hero panel; hidden until ready */
.hero-canvas {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
}
.hero-canvas.ready { opacity: 1; }
.hero-canvas canvas { width: 100% !important; height: 100% !important; display: block; }
.hero .wrap { z-index: 2; }

/* ---------- REPL terminal ---------- */
.cursor-blink {
  display: inline-block; width: 8px; height: 16px; background: var(--lavender);
  margin-left: 1px; vertical-align: -2px; animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.repl-stream {
  font-family: var(--font-mono); font-size: 13px; line-height: 1.7;
  padding: 4px 16px 10px; max-height: 232px; overflow-y: auto;
  border-top: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.repl-stream:empty { display: none; }
.repl-line { color: var(--muted); white-space: pre-wrap; word-break: break-word; }
.repl-line .ok { color: var(--cyan); }
.repl-line .accent { color: var(--lavender); }
.repl-line .warn { color: var(--champagne); }
.repl-line .you { color: var(--text); }
.repl-line .you::before { content: "› "; color: var(--lavender); }

.repl-input-row { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.repl-prompt { font-family: var(--font-mono); color: var(--lavender); font-size: 13px; flex: none; }
.repl-input {
  flex: 1; background: transparent; border: none; color: var(--text);
  font-family: var(--font-mono); font-size: 13px; min-height: 24px;
}
.repl-input:focus { outline: none; }
.repl-input::placeholder { color: var(--muted); opacity: 0.7; }

/* tappable command chips — the no-keyboard / mobile path */
.repl-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 14px 14px; }
.repl-chip {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--muted);
  background: var(--editor); border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 8px 13px; cursor: pointer; min-height: 36px;
  transition: color var(--t-base) ease, border-color var(--t-base) ease, transform var(--t-fast) ease;
}
.repl-chip:hover, .repl-chip:focus-visible { color: var(--text); border-color: var(--lavender); }
.repl-chip:active { transform: scale(0.96); }

.run {
  cursor: pointer; color: var(--on-accent); background: var(--cyan);
  padding: 7px 13px; border-radius: var(--r-sm); border: none;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  display: inline-flex; gap: 6px; align-items: center; min-height: 34px;
  transition: transform var(--t-fast) ease, box-shadow var(--t-base) ease;
}
.run:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(125, 211, 252, 0.3); }

/* ---------- page transitions (View Transitions API + fallback) ---------- */
@keyframes vt-fade-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes vt-fade-out { to { opacity: 0; transform: translateY(-8px); } }
::view-transition-old(root) { animation: vt-fade-out 0.3s var(--ease) both; }
::view-transition-new(root) { animation: vt-fade-in 0.42s var(--ease) both; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
/* JS fallback for browsers without the View Transitions API */
body.page-leaving { opacity: 0; transition: opacity 0.28s ease; }

/* ---------- cinematics ---------- */
.scene { position: relative; }
.parallax { will-change: transform; }
.count { font-variant-numeric: tabular-nums; }

/* progress rail used by the brew-journey scene */
.brew-rail {
  position: relative; height: 3px; border-radius: 2px;
  background: var(--line); overflow: hidden; margin: 28px 0 8px;
}
.brew-rail .fill { position: absolute; inset: 0; width: 0; background: var(--grad); border-radius: 2px; }

/* manifesto */
.manifesto { text-align: center; }
.manifesto h2 { max-width: 820px; margin: 0 auto 10px; }
.manifesto .big {
  font-size: var(--fs-display); font-weight: 300; letter-spacing: -0.02em;
  line-height: 1.4; color: var(--muted); max-width: 760px; margin: 0 auto; text-wrap: balance;
}
.manifesto .big b { font-weight: 700; color: var(--text); }
.manifesto .seq b:nth-of-type(1) { color: var(--lavender); }
.manifesto .seq b:nth-of-type(2) { color: var(--cyan); }
.manifesto .seq b:nth-of-type(3) { color: var(--champagne); }
.manifesto .seq b:nth-of-type(4) { color: var(--rose); }
