/* RELUMA
   Layout: every screen is one 1440 × 900 composition — note top-left, data top-right,
   the image centred, a 100px display line bottom-left, one action bottom-right.
   Dark only: the light on the photograph is the one luminous element. */
:root {
  color-scheme: dark;
  --bg: #080808;
  --panel: #101010;
  --fg: #ece8e1;
  --white: #ffffff;
  --muted: #8b8780;
  --dim: #55524d;
  --line: rgba(236, 232, 225, 0.1);
  --line-2: rgba(236, 232, 225, 0.2);
  --light: #fff1de;
  --scrim: rgba(8, 8, 8, 0.88);
  --scrim-0: rgba(8, 8, 8, 0);

  --display: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --gutter: 40px;
  --pad-l: max(var(--gutter), env(safe-area-inset-left, 0px));
  --pad-r: max(var(--gutter), env(safe-area-inset-right, 0px));
  --top: 120px;
  --bottom: 40px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--display);
  font-size: 13px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }
button { font: inherit; color: inherit; }
p { margin: 0; }
:focus-visible { outline: 1px solid var(--light); outline-offset: 3px; }

/* ---------- type system: five styles, nothing else ---------- */
.mono, .note, .label, .caption, .readout, .controls, .hint, .cta, .rail, .plabel {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
/* display line, bottom-left of every screen */
.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(48px, 6.95vw, 100px);
  line-height: 0.9;
  letter-spacing: -0.045em;
  text-wrap: balance;
}
/* short statement, top-left */
.note {
  max-width: 192px;
  font-size: 12px;
  line-height: 16.5px;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: var(--white);
}
/* section index: 01  Input */
.label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line-2);
  font-size: 11px;
  line-height: 16.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.label span { color: var(--fg); }
/* technical caption above the display line */
.caption {
  max-width: 240px;
  font-size: 10px;
  line-height: 16.5px;
  text-transform: uppercase;
  color: var(--muted);
}
.mono { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- composition anchors ---------- */
.corner-tl { position: absolute; top: var(--top); left: var(--pad-l); }
.corner-tr { position: absolute; top: var(--top); right: var(--pad-r); width: 260px; }
.corner-bl { position: absolute; bottom: var(--bottom); left: var(--pad-l); }
.corner-br { position: absolute; bottom: var(--bottom); right: var(--pad-r); }
.stack { display: grid; gap: 20px; justify-items: start; }
.stack-lg { display: grid; gap: 28px; justify-items: start; }

/* ---------- button: outline (header, footer) and solid (stage action) ---------- */
.cta {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: 12px;
  line-height: 16.5px;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
  color: var(--fg);
  transition: border-color 0.3s, background 0.3s var(--ease), color 0.3s var(--ease);
}
.cta:hover { border-color: var(--fg); }
.cta-dot { width: 22px; height: 22px; margin: -7px; flex: none; }
.cta--solid { background: var(--white); color: var(--bg); }
.cta--solid:hover { background: var(--fg); border-color: var(--line-2); }

/* ---------- header ---------- */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  padding: calc(28px + env(safe-area-inset-top, 0px)) var(--pad-r) 0 var(--pad-l);
  height: calc(63px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.site-header::before {
  content: "";
  position: absolute; inset: 0 0 -28px;
  background: linear-gradient(to bottom, var(--scrim), var(--scrim) 45%, var(--scrim-0));
  pointer-events: none;
  z-index: -1;
}
.site-header > * { pointer-events: auto; }
.brand img { width: 94px; height: auto; }
.header-right { display: flex; align-items: center; gap: 64px; }
.nav { display: flex; gap: 28px; }
.nav a {
  font-size: 13px; line-height: 19.5px; letter-spacing: 0.02em;
  text-decoration: none; color: var(--fg);
  opacity: 0.82; transition: opacity 0.3s;
}
.nav a:hover { opacity: 1; }

/* ---------- stage (hero + technology) ---------- */
.stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--bg);
}
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- reveals ---------- */
/* before the intro runs, nothing in the hero shows (removed by script, with a timed fallback) */
.intro .site-header, .intro #heroUI .display, .intro #heroUI .note, .intro #heroUI .readout,
.intro #heroUI .frame-tags, .intro #heroUI .hint, .intro #stageCta { visibility: hidden; }
.rv-w { display: inline-block; will-change: transform, opacity, filter; }
.rv-ln { display: block; overflow: hidden; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.rv-li { display: inline-block; transform-origin: 0% 100%; will-change: transform, opacity; }
.hero-ui, .tech-ui { position: absolute; inset: 0; pointer-events: none; }
.hero-ui a, .tech-ui a, .tech-ui button, .stage > .cta { pointer-events: auto; }
.stage > .cta { z-index: 5; }

/* the image frame: 528 × 660 at 1440 × 900, centred */
.frame {
  --fh: min(660px, calc(100svh - 240px));
  --fw: calc(var(--fh) * 0.8);
  position: absolute;
  top: 50%; left: 50%;
  width: var(--fw);
  height: var(--fh);
  transform: translate(-50%, -50%);
}
.frame-tags {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; justify-content: space-between; gap: 12px;
  color: var(--muted);
  pointer-events: none;
}
/* hero tags step back so the headline and image lead */
#heroUI .frame-tags span { opacity: 0.5; }
.frame-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); transition: opacity 0.6s; }
.stage.is-ready .frame-loading { opacity: 0; }
.hint {
  position: absolute; right: 0; top: calc(100% + 12px);
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; line-height: 12px; color: var(--fg);
  white-space: nowrap;
}
.hint img { width: 22px; height: 22px; margin: -7px; }

.readout { margin: 0; }
.readout div { padding: 11px 0 14px; border-top: 1px solid var(--line-2); display: grid; gap: 4px; }
.readout dt { font-size: 10px; line-height: 16.5px; text-transform: uppercase; color: var(--muted); }
.readout dd { margin: 0; font-size: 10px; line-height: 12px; color: var(--fg); }

/* technology screens (opacity driven by scroll progress) */
.t-stage { position: absolute; inset: 0; opacity: 0; visibility: hidden; transform: translateY(var(--shift, 0px)); }
.tech-ui .corner-tl { top: 150px; }

.rail {
  position: absolute;
  right: var(--pad-r);
  top: 50%;
  transform: translateY(-50%);
  margin: 0; padding: 0 0 0 16px;
  list-style: none;
  display: grid; gap: 9px;
  width: 88px;
  opacity: 0;
}
.rail button {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 10px; line-height: 14px; text-align: left;
  color: var(--muted);
  transition: color 0.3s;
}
.rail button[aria-current="step"], .rail button:hover { color: var(--white); }
.rail-track { position: absolute; left: 3px; top: 7px; bottom: 7px; width: 2px; background: var(--line-2); }
.rail-fill { position: absolute; left: 0; top: 0; width: 2px; height: 0; background: var(--white); }
.rail-fill img { position: absolute; left: -10px; bottom: -11px; width: 22px; height: 22px; max-width: none; }

.plabel {
  position: absolute; left: 0; top: 0;
  font-size: 10px; line-height: 16.5px; text-transform: uppercase;
  color: var(--fg);
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity;
  padding-left: 10px;
  border-left: 1px solid var(--line-2);
}
.plabel--scan { color: var(--light); border-left-color: rgba(255, 241, 222, 0.5); }
.plabel--light { color: var(--light); border: 0; padding-left: 14px; }

/* ---------- cursor light ---------- */
.cursor-light { position: fixed; left: 0; top: 0; z-index: 60; width: 0; height: 0; pointer-events: none; opacity: 0; transition: opacity 0.35s; }
.cursor-light.is-on { opacity: 1; }
.cl-dot, .cl-halo { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
.cl-dot { width: 7px; height: 7px; background: #fffaf2; box-shadow: 0 0 6px 1px rgba(255, 244, 228, 0.9); }
.cl-halo { width: 46px; height: 46px; background: radial-gradient(circle, rgba(255, 241, 222, 0.22) 0%, rgba(255, 241, 222, 0.06) 45%, rgba(255, 241, 222, 0) 70%); }
.cl-halo::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; border: 1px solid rgba(255, 241, 222, 0.22); }
.stage.is-lighting { cursor: none; }
.stage.is-lighting a, .stage.is-lighting button { cursor: pointer; }

/* ---------- playground: same composition ---------- */
.playground {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 760px;
  background: var(--bg);
}
.playground .corner-tl { top: 150px; }
.frame--pg { background: var(--panel); cursor: crosshair; }
/* touch: a held finger moves the light (js/ui/holdToLight.js), so no text selection, image callout or tap flash */
.stage, .playground { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.stage img, .playground img { -webkit-user-drag: none; }
.frame--pg canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* Playground on wide screens: everything hangs off the image edges.
   --fh is the frame height (same formula as .frame), --edge the gap from the
   section's top/bottom to the image. Bottoms use `bottom`, not transforms,
   because the reveal animates transform. */
@media (min-width: 1101px) {
  .playground { --fh: min(660px, calc(100svh - 240px)); --edge: calc(50% - var(--fh) / 2); }
  .playground .corner-tl { top: var(--edge); }
  .playground .corner-bl { bottom: var(--edge); }
  .pg-cta { position: absolute; left: calc(100% - var(--pad-r) - 260px); bottom: var(--edge); }
  /* sliders on one line (as in Studio), so the controls clear the button on 800px-tall screens */
  .playground .controls .row.slider { grid-template-columns: 92px 1fr 34px; grid-template-areas: "term input val"; gap: 0 12px; }
  .playground .controls .row.slider .term { grid-area: term; }
  .playground .controls .row.slider > input { grid-area: input; grid-column: auto; }
  .playground .controls .row.slider .val { grid-area: val; text-align: right; }
}

.controls { display: grid; }
.controls .row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px 12px;
  padding: 11px 0 13px;
  border-top: 1px solid var(--line-2);
}
.term { font-size: 10px; line-height: 16.5px; text-transform: uppercase; color: var(--muted); }
.val { font-size: 10px; line-height: 12px; color: var(--fg); }
.controls .row > :not(.term):not(.val) { grid-column: 1 / -1; }
#fps { color: var(--light); }

.presets { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 4px 9px; background: transparent; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 999px;
  font-family: var(--mono); font-size: 10px; line-height: 14px; color: var(--muted);
  transition: background 0.3s, color 0.3s, border-color 0.3s;
}
.chip:hover { color: var(--fg); border-color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--white); color: var(--bg); border-color: var(--white); }

input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 14px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: linear-gradient(to right, var(--fg) 0 var(--fill, 50%), var(--line-2) var(--fill, 50%) 100%);
}
input[type="range"]::-moz-range-track { height: 1px; background: var(--line-2); }
input[type="range"]::-moz-range-progress { height: 1px; background: var(--fg); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 8px; height: 8px; margin-top: -3.5px; border-radius: 50%;
  background: var(--white); border: 0;
  box-shadow: 0 0 6px 1px rgba(255, 244, 228, 0.9);
}
input[type="range"]::-moz-range-thumb { width: 8px; height: 8px; border: 0; border-radius: 50%; background: var(--white); box-shadow: 0 0 6px 1px rgba(255, 244, 228, 0.9); }

.swatches { display: flex; gap: 10px; }
.swatch {
  width: 16px; height: 16px; border-radius: 50%; padding: 0; cursor: pointer;
  background: var(--c); border: 0;
  outline: 1px solid transparent; outline-offset: 3px;
  transition: outline-color 0.25s;
}
.swatch[aria-checked="true"] { outline-color: var(--fg); }

.toggles { grid-template-columns: auto auto auto !important; justify-content: start; gap: 18px !important; }
.toggles .term { margin-right: auto; }
.switch {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font-family: var(--mono); font-size: 10px; line-height: 12px; color: var(--muted);
}
.switch[aria-pressed="true"] { color: var(--fg); }
.switch-knob { position: relative; width: 22px; height: 12px; border-radius: 999px; border: 1px solid var(--line-2); transition: border-color 0.3s; }
.switch-knob::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); transition: transform 0.3s var(--ease), background 0.3s, box-shadow 0.3s;
}
.switch[aria-pressed="true"] .switch-knob { border-color: var(--fg); }
.switch[aria-pressed="true"] .switch-knob::after { transform: translateX(10px); background: var(--white); box-shadow: 0 0 6px 1px rgba(255, 244, 228, 0.9); }

/* ---------- footer ---------- */
.site-footer {
  padding-block: 32px 40px;
  padding-left: var(--pad-l);
  padding-right: var(--pad-r);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
}
.site-footer .caption { max-width: 560px; }
.site-footer .caption a { color: var(--fg); text-underline-offset: 3px; }

/* ---------- smaller screens ---------- */
@media (max-width: 1100px) {
  .corner-tr { display: none; }
  .playground { height: auto; min-height: 0; padding-block: 150px 40px; display: grid; gap: 32px; padding-left: var(--pad-l); padding-right: var(--pad-r); }
  .playground > * { position: static !important; transform: none !important; }
  .playground .frame--pg { width: min(100%, 528px); height: auto; aspect-ratio: 4 / 5; justify-self: center; position: relative !important; left: auto; top: auto; }
  .playground .controls { display: grid !important; width: 100%; max-width: 528px; justify-self: center; }
  .playground .corner-tl { position: absolute !important; top: 96px; }
  .playground .hint { position: absolute; }
  .playground .pg-cta { justify-self: center; }
}

@media (max-width: 820px) {
  :root { --gutter: 16px; --top: 84px; --bottom: 28px; }
  .site-header { padding-top: calc(16px + env(safe-area-inset-top, 0px)); height: calc(56px + env(safe-area-inset-top, 0px)); }
  .nav { display: none; }
  .frame { --fw: min(calc(100vw - 32px), calc((100svh - 330px) * 0.8)); --fh: calc(var(--fw) * 1.25); top: calc(50% - 20px); }
  .hero-ui .note { display: none; }
  .stage > .cta { display: none; }
  .tech-ui .corner-tl { top: 84px; }
  .tech-ui .note, .tech-ui .caption { display: none; }
  .rail, .plabel--scan { display: none; }
  .display { font-size: clamp(40px, 11.5vw, 60px); }
  .playground .corner-tl { top: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage-canvas { transition: none; }
}
