/* =====================================================================
   CTSD Lab: shared styles for the four experiments and the Lab index.
   Live mode draws on a fixed canvas behind the page. Still mode
   (reduced motion, no WebGL, or ?still=1) hides the canvas and shows a
   designed static version with the same content and links.
   ===================================================================== */

.lab-body { background: var(--navy-950); color: var(--ivory); }
.lab-body #main { position: relative; }
.lab-canvas {
  position: fixed; inset: 0; z-index: 0;
  width: 100vw; height: 100vh; display: block;
  touch-action: pan-y;
}
.lab-ui { position: relative; z-index: 1; }
.lab-still { display: none; }
html.lab-static .lab-canvas, html.lab-static .lab-live { display: none !important; }
html.lab-static .lab-still { display: block; }

.lab-back {
  position: fixed; z-index: 5; left: max(20px, env(safe-area-inset-left)); top: calc(var(--header-h) + 16px);
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px;
  font: 500 .875rem/1 var(--font-body, Inter), sans-serif; color: var(--ivory);
  text-decoration: none; border-radius: 999px;
  background: rgba(10, 19, 34, .72); border: 1px solid rgba(242, 162, 58, .28);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.lab-back:hover { border-color: var(--ember); }
.lab-back:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; }

.lab-kicker {
  font: 500 .8125rem/1 Inter, sans-serif; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ember); margin: 0 0 18px;
}
.lab-title {
  font: 700 clamp(2.4rem, 5vw, 4.6rem)/1.03 Montserrat, sans-serif; letter-spacing: -.02em;
  margin: 0; color: var(--ivory);
}
.lab-title em { font-style: normal; color: var(--ember); }
.lab-lead { font: 400 clamp(1.05rem, 1.6vw, 1.35rem)/1.55 Inter, sans-serif; color: var(--ivory-muted); max-width: 40ch; margin: 22px 0 0; }
.lab-hint {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 34px;
  font: 500 .8125rem/1 Inter, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--ember);
}
.lab-hint i { width: 1px; height: 34px; background: linear-gradient(var(--ember), transparent); animation: lab-drip 1.8s ease-in-out infinite; }
@keyframes lab-drip { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* Full-height scroll chapters with a caption pinned near the bottom-left. */
.lab-chapter { min-height: 100vh; display: flex; align-items: flex-end; padding: 0 0 12vh; }
.lab-chapter--center { align-items: center; padding: 0; }
.lab-cap > * { max-width: 34rem; }
.lab-cap > .lab-title { max-width: 13ch; }
.lab-cap h2 { font: 700 clamp(1.9rem, 4vw, 3.2rem)/1.08 Montserrat, sans-serif; margin: 0; color: var(--ivory); letter-spacing: -.01em; }
.lab-cap p { font: 400 1.125rem/1.55 Inter, sans-serif; color: var(--ivory-muted); margin: 14px 0 0; }
.lab-cap .lab-kicker { margin-bottom: 14px; }
.lab-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 30px; }
.lab-body .btn--ghost { --btn-fg: var(--ivory); --btn-bd: rgba(247, 244, 238, .38); }
.lab-body .btn--ghost:hover { --btn-bd: var(--ivory); --btn-bg: rgba(247, 244, 238, .06); color: var(--ivory); }

/* Still versions share a simple editorial layout. */
.lab-still__hero { padding-block: 120px 64px; }
.lab-still__grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); margin: 40px 0 96px; }
.lab-still__card {
  padding: 26px; border-radius: 18px; background: rgba(247, 244, 238, .05);
  border: 1px solid rgba(148, 170, 204, .2);
}
.lab-still__card h3 { font: 700 1.25rem/1.2 Montserrat, sans-serif; margin: 0 0 8px; color: var(--ivory); }
.lab-still__card p { margin: 0; color: var(--ivory-muted); }
.lab-still__art { display: block; margin: 0 auto; width: min(320px, 60vw); filter: drop-shadow(0 0 60px rgba(242, 162, 58, .35)); }
.lab-note { font: 400 .875rem/1.5 Inter, sans-serif; color: var(--ivory-muted); }

@media (max-width: 640px) {
  .lab-back { top: calc(var(--header-h) + 10px); }
  .lab-chapter { padding-bottom: 10vh; }
}

.lab-body .link-inline { color: var(--ember); text-decoration: underline; text-underline-offset: 3px; white-space: nowrap; }
.lab-body .link-inline:hover { color: var(--ivory); }
.lab-body .link-inline::after { content: " →"; }

/* Captions stay readable when particles or 3D pass behind them. */
.lab-cap > *:not(.lab-actions) { text-shadow: 0 2px 18px rgba(30, 19, 16, .95), 0 0 2px rgba(30, 19, 16, .8); }

/* Workshop: a tall scroll track with captions fixed over the 3D scene. */
.ws-track { height: 720vh; }
.ws-cap {
  position: fixed; left: 0; right: 0; bottom: 11vh; z-index: 2;
  opacity: 0; visibility: hidden; transition: none;
}
.ws-cap.is-on { visibility: visible; }
.ws-still { display: grid; grid-template-columns: 3fr 1fr; gap: 20px; align-items: end; margin-top: 40px; }
.ws-still img { width: 100%; height: auto; border-radius: 16px; box-shadow: 0 30px 80px -30px rgba(0,0,0,.6); }
@media (max-width: 640px) { .ws-still { grid-template-columns: 1fr; } .ws-still img:last-child { width: 60%; justify-self: center; } }

/* Liquid gallery: scroll moves through 12 designs; the UI is pinned over the WebGL canvas. */
.gl-track { position: relative; height: calc(12 * 70vh + 100vh); margin-top: calc(-1 * var(--header-h)); }
.gl-ui { position: sticky; top: 0; height: 100vh; pointer-events: none; }
.gl-ui a, .gl-ui button { pointer-events: auto; }
.gl-top { text-shadow: 0 1px 14px rgba(20, 12, 10, .95), 0 0 2px rgba(20, 12, 10, .9); position: absolute; left: max(24px, 4vw); right: max(24px, 4vw); top: calc(var(--header-h) + 74px); display: flex; justify-content: space-between; align-items: baseline; }
.gl-h1 { font: 500 .8125rem/1 Inter, sans-serif; letter-spacing: .22em; text-transform: uppercase; color: var(--ember); margin: 0; }
.gl-count { font: 700 1rem/1 Montserrat, sans-serif; color: var(--ivory); margin: 0; letter-spacing: .08em; font-variant-numeric: tabular-nums; }
.gl-caption { position: absolute; left: max(24px, 4vw); right: max(24px, 4vw); bottom: 9vh; text-shadow: 0 2px 30px rgba(20, 12, 10, .8); }
.gl-cat { font: 500 .8125rem/1 Inter, sans-serif; letter-spacing: .22em; text-transform: uppercase; color: var(--ember); margin: 0 0 10px; }
.gl-title { margin: 0; font: 700 clamp(2.4rem, 10.5vw, 10rem)/.92 Montserrat, sans-serif; letter-spacing: -.035em; color: var(--ivory); white-space: nowrap; overflow: hidden; padding-bottom: .06em; }
.gl-title .ch { display: inline-block; transform: translateY(105%); animation: gl-up .7s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes gl-up { to { transform: translateY(0); } }
.gl-tag { font: 400 clamp(1rem, 1.5vw, 1.25rem)/1.5 Inter, sans-serif; color: var(--ivory-muted); margin: 14px 0 0; max-width: 40ch; }
.gl-links { display: flex; flex-wrap: wrap; align-items: center; gap: 22px; margin-top: 26px; }
.gl-help { font: 500 .8125rem/1 Inter, sans-serif; color: var(--ivory-muted); letter-spacing: .06em; }
.gl-progress { position: absolute; left: max(24px, 4vw); right: max(24px, 4vw); bottom: 4vh; height: 2px; background: rgba(247, 244, 238, .14); }
.gl-progress i { display: block; height: 100%; width: 0; background: var(--ember); }
.gl-end { position: absolute; left: 0; right: 0; bottom: 0; height: 100vh; display: flex; flex-direction: column; justify-content: center; }
.gl-ring {
  position: fixed; left: 0; top: 0; z-index: 3; width: 92px; height: 92px; margin: -46px 0 0 -46px;
  border-radius: 50%; border: 1.5px solid rgba(247, 244, 238, .85); display: grid; place-items: center;
  pointer-events: none; opacity: 0; transition: opacity .3s, transform .35s cubic-bezier(.2, .8, .2, 1);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.gl-ring span { font: 600 .8125rem/1 Montserrat, sans-serif; letter-spacing: .14em; text-transform: uppercase; color: var(--ivory); }
.gl-ring.is-on { opacity: 1; }
html.lab-static .gl-ring { display: none; }
.gl-still { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); margin: 44px 0; }
.gl-still a { display: block; color: var(--ivory); text-decoration: none; }
.gl-still img { width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 14px; display: block; }
.gl-still b { display: block; font: 700 1.125rem/1.3 Montserrat, sans-serif; margin-top: 12px; }
.gl-still span { color: var(--ivory-muted); font-size: .9375rem; }
@media (max-width: 640px) {
  .gl-top { top: calc(var(--header-h) + 64px); flex-direction: column; gap: 12px; }
  .gl-help { display: none; }
  .gl-caption { bottom: 8vh; }
}
@media (pointer: coarse) { .gl-ring { display: none; } }
.gl-concept { display: inline-block; margin-left: 14px; font: 500 .75rem/1 Inter, sans-serif; letter-spacing: .08em; color: var(--ivory); padding: 7px 12px; border-radius: 999px; background: rgba(10, 19, 34, .72); vertical-align: middle; text-shadow: none; }

/* Physics playground: the pieces are real elements positioned by Matter.js every frame. */
.pg-stage { position: relative; height: max(100vh, 640px); margin-top: calc(-1 * var(--header-h)); overflow: hidden;
  background: radial-gradient(60% 55% at 70% 30%, rgba(94, 128, 176, .24), rgba(10, 19, 34, 0) 70%), var(--navy-950); }
.pg-intro { position: relative; z-index: 2; padding-top: calc(var(--header-h) + 84px); pointer-events: none; }
.pg-intro a, .pg-intro button { pointer-events: auto; }
.pg-h1 { font: 700 clamp(2rem, 4.2vw, 3.6rem)/1.05 Montserrat, sans-serif; margin: 0; color: var(--ivory); letter-spacing: -.02em; }
.pg-h1 em { font-style: normal; color: var(--ember); }
.pg-lead { color: var(--ivory-muted); font-size: 1.0625rem; max-width: 34ch; margin: 14px 0 0; }
.pg-controls { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.pg-pieces { position: absolute; inset: 0; z-index: 1; }
.pg-piece { position: absolute; left: 0; top: 0; visibility: hidden; user-select: none; -webkit-user-select: none;
  touch-action: none; will-change: transform; white-space: nowrap; cursor: grab; }
.pg-piece:active { cursor: grabbing; }
.pg-piece.is-in { visibility: visible; }
.pg-word { font: 700 clamp(4.5rem, 13vw, 13rem)/.9 Montserrat, sans-serif; letter-spacing: -.04em; color: var(--ivory); padding: 0 .04em; }
.pg-word--ember { color: var(--ember); }
.pg-pill { display: inline-flex; align-items: center; font: 600 clamp(.95rem, 1.45vw, 1.35rem)/1 Montserrat, sans-serif;
  padding: 1em 1.5em; border-radius: 999px; text-decoration: none; color: var(--ivory);
  background: rgba(247, 244, 238, .06); border: 1.5px solid rgba(242, 162, 58, .55); }
.pg-pill--ember { background: var(--ember); color: var(--navy-950); border-color: var(--ember); }
.pg-pill--ivory { background: var(--ivory); color: var(--navy); border-color: var(--ivory); }
.pg-pill--tan { background: var(--ember); color: var(--navy-950); border-color: var(--ember); }
.pg-piece:focus-visible { outline: 3px solid var(--ember); outline-offset: 4px; }
.pg-cta { font-size: clamp(1rem, 1.5vw, 1.25rem); }
/* Still version: the same pieces, laid out in normal flow. */
html.lab-static .pg-stage { height: auto; overflow: visible; padding-bottom: 96px; }
html.lab-static .pg-pieces { position: static; display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 40px var(--gutter) 0; max-width: calc(var(--container) + 2 * var(--gutter)); margin: 0 auto; }
html.lab-static .pg-piece { position: static; visibility: visible; transform: none !important; cursor: pointer; }
html.lab-static .pg-word { width: auto; }
html.lab-static .pg-controls { display: none; }

/* Lab index */
.lab-index__hero { padding: 96px var(--gutter) 40px; }
.lab-index__grid { display: grid; gap: 28px; grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 40px; }
.lab-card { display: flex; flex-direction: column; text-decoration: none; color: var(--ivory); border-radius: 22px; overflow: hidden;
  background: rgba(247, 244, 238, .04); border: 1px solid rgba(148, 170, 204, .2); transition: transform .35s cubic-bezier(.2, .8, .2, 1), border-color .35s; }
.lab-card:hover { transform: translateY(-4px); border-color: rgba(242, 162, 58, .6); }
.lab-card:focus-visible { outline: 3px solid var(--ember); outline-offset: 4px; }
.lab-card__media { aspect-ratio: 16 / 10; overflow: hidden; background: #1e1310; }
.lab-card__media video { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s cubic-bezier(.2, .8, .2, 1); }
.lab-card:hover video { transform: scale(1.03); }
.lab-card__body { padding: 26px 28px 30px; display: grid; gap: 8px; }
.lab-card__num { font: 700 .8125rem/1 Montserrat, sans-serif; letter-spacing: .18em; color: var(--ember); }
.lab-card h2 { font: 700 clamp(1.4rem, 2.2vw, 1.9rem)/1.15 Montserrat, sans-serif; margin: 0; color: var(--ivory); }
.lab-card p { margin: 0; color: var(--ivory-muted); }
.lab-card__go { margin-top: 8px; font: 600 .9375rem/1 Montserrat, sans-serif; color: var(--ember); }
.lab-index__cta { padding: 64px var(--gutter) 120px; }
.lab-index__cta h2 { font: 700 clamp(1.8rem, 3.4vw, 2.8rem)/1.1 Montserrat, sans-serif; margin: 0 0 12px; color: var(--ivory); }
.lab-index__cta p { color: var(--ivory-muted); max-width: 46ch; margin: 0; }
@media (max-width: 820px) { .lab-index__grid { grid-template-columns: 1fr; } .lab-index__hero { padding-top: 64px; } }
