/* realityDebug() — site flow redesign
   Ported from new_site/design_handoff_site_flow (Site Flow.dc.html is the
   primary reference). One dark surface: hero -> menu -> reel / lab / email. */

@font-face {
  /* Fallback for platforms without system Helvetica Neue. */
  font-family: 'Helvetica';
  src: url('../fonts/helvetica.ttf') format('truetype');
  font-weight: normal;
  font-display: swap;
}

:root {
  --not-black: #1e1e1e;
  --bg-colour: #dfddd1;
  --overlay-bg: #1b1b1b;
  --menu-text: #e9e9de;
  --ink: #141311;
  --error: #ff6b5e;

  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-entrance: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-cube: cubic-bezier(0.34, 1.2, 0.4, 1);

  --font: 'Helvetica Neue', 'Helvetica', Helvetica, Arial, sans-serif;

  --frame-pad-y: 34px;
  --frame-pad-x: 40px;
  --pane-inset-x: 60px;
  --pane-inset-y: 70px;
  --logo-size: 70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg-colour);
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Custom cursor replaces the native one on fine-pointer devices only. */
@media (hover: hover) and (pointer: fine) {
  body, a, button, input, textarea, [role="button"] { cursor: none; }
}

button {
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
}

/* ---------------------------------------------------------------- hero */

.hero-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.hero-bg canvas { display: block; }

.hero-content {
  position: fixed;
  inset: 0;
  z-index: 2;
  padding: var(--frame-pad-y) var(--frame-pad-x);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.hero-logo-spacer {
  width: var(--logo-size);
  height: var(--logo-size);
}

.hero-headline {
  font-weight: 900;
  font-size: clamp(38px, 6.6vw, 66px);
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* ------------------------------------------------------------ logo box */

/* Sits above the overlay (z-index) — must never hide behind the wipe. */
.logo-box {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 30;
  width: var(--logo-size);
  height: var(--logo-size);
  background: var(--not-black);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(1);
  transform-origin: top left;
  transition: transform 0.8s var(--ease-bounce),
              background-color 0.4s var(--ease-smooth);
}

.logo-box svg {
  width: 60%;
  height: auto;
  fill: var(--bg-colour);
  transition: fill 0.4s var(--ease-smooth);
}

body.menu-open .logo-box {
  background: var(--bg-colour);
  transform: scale(0.6);
}

body.menu-open .logo-box svg { fill: var(--not-black); }

/* ----------------------------------------------------------- hamburger */

.hamburger {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 30;
  width: 34px;
  height: 34px;
}

.hamburger span {
  position: absolute;
  left: 50%;
  width: 20px;
  height: 2px;
  background: var(--ink);
  transition: all 0.3s var(--ease-smooth);
}

.hamburger span:nth-child(1) { top: 30%; transform: translateX(-50%); }
.hamburger span:nth-child(2) { top: 50%; transform: translateX(-50%) translateY(-50%); }
.hamburger span:nth-child(3) { bottom: 30%; transform: translateX(-50%); }

body.menu-open .hamburger span { background: var(--menu-text); }
body.menu-open .hamburger span:nth-child(1) {
  top: 50%;
  bottom: auto;
  transform: translateX(-50%) translateY(-50%) rotate(45deg);
}
body.menu-open .hamburger span:nth-child(2) {
  opacity: 0;
  transform: translateX(-50%) translateY(-50%) scaleX(0);
}
body.menu-open .hamburger span:nth-child(3) {
  top: 50%;
  bottom: auto;
  transform: translateX(-50%) translateY(-50%) rotate(-45deg);
}

/* -------------------------------------------------------- menu overlay */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--overlay-bg);
  color: var(--menu-text);
  clip-path: circle(0% at var(--wipe-x, 92%) var(--wipe-y, 6%));
  -webkit-clip-path: circle(0% at var(--wipe-x, 92%) var(--wipe-y, 6%));
  transition: clip-path 0.6s var(--ease-bounce), -webkit-clip-path 0.6s var(--ease-bounce);
  pointer-events: none;
}

body.menu-open .overlay {
  clip-path: circle(150% at var(--wipe-x, 92%) var(--wipe-y, 6%));
  -webkit-clip-path: circle(150% at var(--wipe-x, 92%) var(--wipe-y, 6%));
  pointer-events: auto;
}

/* Panes morph in place on the shared dark surface: outgoing slides up and
   out, incoming rises from below with a 0.15s stagger. */
.pane {
  position: absolute;
  left: var(--pane-inset-x);
  right: var(--pane-inset-x);
  top: var(--pane-inset-y);
  bottom: var(--pane-inset-y);
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.3s ease, transform 0.3s var(--ease-smooth);
  pointer-events: none;
}

.pane.is-active {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease 0.15s, transform 0.5s var(--ease-smooth) 0.15s;
  pointer-events: auto;
}

.pane.is-exiting {
  opacity: 0;
  transform: translateY(-30px);
}

.no-anim, .no-anim * { transition: none !important; }

/* ------------------------------------------------------------ menu list */

.menu-item {
  display: block;
  width: fit-content;
  text-align: left;
  text-decoration: none;
  font-weight: bold;
  font-size: clamp(46px, 9.5vh, 88px);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: var(--menu-text);
  margin: 6px 0;
  transition: color 0.8s ease, -webkit-text-stroke 0.8s ease;
  -webkit-text-stroke: 0 var(--menu-text);
}

.menu-item:hover {
  color: transparent;
  -webkit-text-stroke: 1px var(--menu-text);
}

.menu-item.is-inert {
  opacity: 0.35;
  pointer-events: none;
}

/* --------------------------------------------------------- back chevron */

.back-chevron {
  position: absolute;
  bottom: 20px;
  left: 24px;
  z-index: 40;
  font-size: 26px;
  font-weight: 200;
  color: var(--menu-text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 4px 10px;
  mix-blend-mode: difference;
}

.back-chevron.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ----------------------------------------------------------------- reel */

.reel-gate { max-width: 420px; }

.reel-error-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--error);
  margin-bottom: 14px;
  display: none;
}

.reel-headline {
  font-weight: 900;
  font-size: clamp(26px, 4vw, 34px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: #f8f8f4;
  margin-bottom: 24px;
}

.reel-input-row {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(242, 242, 238, 0.3);
  padding-bottom: 12px;
  transition: border-color 0.25s ease;
}

.reel-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #f2f2ee;
  font-family: var(--font);
  font-size: 16px;
  letter-spacing: 0.05em;
}

.reel-input-row input::placeholder { color: rgba(233, 233, 222, 0.35); }

.reel-submit {
  font-size: 20px;
  opacity: 0.6;
  color: #f2f2ee;
  transition: opacity 0.2s ease;
}

.reel-submit:hover { opacity: 1; }

.pane-reel[data-state="error"] .reel-error-label { display: block; }
.pane-reel[data-state="error"] .reel-input-row { border-bottom-color: var(--error); }
.pane-reel[data-state="error"] .reel-input-row input { color: var(--error); }

.reel-gate.shake { animation: gate-shake 0.4s var(--ease-smooth); }

@keyframes gate-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

.reel-player-wrap {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.pane-reel[data-state="unlocked"] .reel-gate { display: none; }
.pane-reel[data-state="unlocked"] .reel-player-wrap { display: flex; }

.reel-player {
  position: relative;
  width: min(100%, calc((100vh - 220px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: var(--ink);
  border: 1px solid rgba(242, 242, 238, 0.15);
}

.reel-player video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--ink);
}

.reel-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(242, 242, 238, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, background 0.2s ease;
  z-index: 2;
}

.reel-play:hover { background: rgba(242, 242, 238, 0.2); }

.reel-play::after {
  content: '';
  width: 0;
  height: 0;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  border-left: 18px solid #f2f2ee;
  margin-left: 4px;
}

.reel-player.is-playing .reel-play { opacity: 0; pointer-events: none; }

.reel-progress {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  height: 3px;
  background: rgba(242, 242, 238, 0.15);
  z-index: 2;
}

.reel-progress-fill {
  width: 0;
  height: 100%;
  background: #f2f2ee;
}

.reel-session-note {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--menu-text);
  opacity: 0.5;
  align-self: flex-end;
}

/* ------------------------------------------------------------------ lab */

/* The lab grid scrolls inside a full-overlay shell so the shared-element
   tile expansion can fill the whole frame without being clipped. */
.lab-shell {
  position: absolute;
  inset: 0;
  display: block;
  justify-content: flex-start;
}

.lab-scroller {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--pane-inset-x) var(--pane-inset-y);
  scrollbar-width: none;
  touch-action: pan-y;
}

.lab-scroller::-webkit-scrollbar { display: none; }

@media (hover: hover) and (pointer: fine) {
  .lab-scroller { cursor: none; }
}

.lab-chrome {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--overlay-bg);
  /* Clears the (scaled-down) logo box pinned at 24px/24px. */
  padding: calc(24px + var(--logo-size) * 0.6 + 12px) 0 16px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.lab-title {
  font-weight: 900;
  font-size: 26px;
  letter-spacing: -0.01em;
  color: #efece4;
}

.lab-count {
  font-size: 11px;
  letter-spacing: 0.1em;
  opacity: 0.45;
  color: #efece4;
  text-transform: uppercase;
}

.lab-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 22px;
  padding-top: 6px;
  transition: opacity 0.35s ease;
}

.lab-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform-origin: center center;
}

.lab-tile-mount {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}

.lab-tile-mount canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.lab-tile-num {
  font-size: 9px;
  letter-spacing: 0.1em;
  opacity: 0.4;
  color: #efece4;
}

.lab-tile-title {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.005em;
  color: #f4f2eb;
}

.lab-tile.tile-zooming {
  z-index: 30;
  transition: transform 0.56s cubic-bezier(0.65, 0, 0.35, 1);
}

.lab-tile.tile-zooming .lab-tile-num,
.lab-tile.tile-zooming .lab-tile-title { opacity: 0; transition: opacity 0.2s ease; }

.lab-tile.tile-scatter {
  transition: opacity 0.35s ease var(--scatter-delay, 0ms),
              transform 0.4s var(--ease-smooth) var(--scatter-delay, 0ms);
}

.lab-shell.grid-hidden .lab-scroller { opacity: 0; pointer-events: none; }

/* Lab detail: 3D cube carousel filling the whole overlay. */
.lab-detail {
  position: absolute;
  inset: 0;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.lab-detail.is-active {
  opacity: 1;
  pointer-events: auto;
}

.cube-scene {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  overflow: hidden;
}

.cube {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.55s var(--ease-cube);
}

.cube-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--overlay-bg);
  overflow: hidden;
}

.cube-face canvas { display: block; }

.lab-detail-nav {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 3;
}

.lab-detail-nav.prev { left: 0; }
.lab-detail-nav.next { right: 0; }

.lab-detail-title {
  position: absolute;
  left: 40px;
  bottom: 30px;
  z-index: 5;
  color: #f2f2ee;
  font-weight: bold;
  font-size: 22px;
  pointer-events: none;
  /* Inverts over light sketch faces (e.g. foliage), stays cream over dark. */
  mix-blend-mode: difference;
}

/* ---------------------------------------------------------------- email */

.email-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  align-items: center;
  width: 100%;
}

.email-headline {
  font-weight: bold;
  font-size: clamp(34px, 4.6vw, 52px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: #f8f8f4;
}

.email-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.em-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.45;
  margin-bottom: 6px;
  display: block;
  color: #f2f2ee;
}

.em-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(242, 242, 238, 0.25);
  color: #f2f2ee;
  font-family: var(--font);
  font-size: 16px;
  padding: 8px 0;
  width: 100%;
  outline: none;
  resize: none;
  transition: border-color 0.25s ease;
}

.em-input:focus { border-bottom-color: var(--menu-text); }

textarea.em-input {
  padding-bottom: 26px;
  overflow: hidden;
  line-height: 1.4;
}

.email-submit {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  align-self: flex-start;
  transition: opacity 0.2s ease;
}

.email-submit:hover { opacity: 0.7; }

.email-submit[disabled] { opacity: 0.4; pointer-events: none; }

.email-submit .label {
  font-weight: bold;
  font-size: 15px;
  color: #f2f2ee;
}

.email-submit .arrow {
  font-size: 18px;
  color: #f2f2ee;
}

.email-status {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--menu-text);
  opacity: 0;
  transition: opacity 0.3s ease;
  min-height: 14px;
}

.email-status.is-visible { opacity: 0.8; }
.email-status.is-error { color: var(--error); }

/* Staggered entrance — replayed every time the pane becomes active. */
.pane-email [data-reveal] {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease var(--d, 0s),
              transform 0.5s var(--ease-entrance) var(--d, 0s);
}

.pane-email [data-reveal="headline"] { transform: translateY(-20px); transition-duration: 0.6s, 0.6s; }

.pane-email.revealed [data-reveal] {
  opacity: 1;
  transform: translateY(0);
}

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

.cursor {
  position: fixed;
  left: 0;
  top: 0;
  width: 40px;
  height: 40px;
  border: 2px solid var(--not-black);
  border-radius: 50%;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transform: translate(-50%, -50%);
  transition: opacity 0.3s ease, width 0.2s ease, height 0.2s ease;
  mix-blend-mode: difference;
  will-change: left, top;
}

.cursor.is-visible { opacity: 0.6; }
.cursor.is-clicking { width: 30px; height: 30px; }

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 860px) {
  :root {
    --pane-inset-x: 32px;
    --pane-inset-y: 56px;
    --frame-pad-y: 24px;
    --frame-pad-x: 24px;
    --logo-size: 56px;
  }

  .lab-grid { grid-template-columns: repeat(2, 1fr); }
  .menu-item { font-size: clamp(40px, 8.5vh, 72px); }
}

@media (max-width: 720px) {
  .email-split {
    grid-template-columns: 1fr;
    gap: 26px;
    align-items: start;
  }

  /* Keep the email pane usable with the on-screen keyboard, and start it
     below the logo box. */
  .pane-email {
    justify-content: flex-start;
    padding-top: 20px;
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  :root {
    --pane-inset-x: 24px;
    --pane-inset-y: 48px;
  }

  .lab-grid { grid-template-columns: 1fr; }
  .lab-detail-title { left: 24px; bottom: 24px; font-size: 18px; }
  .hero-headline { font-size: clamp(30px, 9.5vw, 44px); }
  .menu-item { font-size: clamp(36px, 7vh, 56px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
