/* Out of the Noise: one dark room, one canvas, one accent.
   Layout: the film/canvas fills the viewport; UI sits in thin layers above it. */
:root {
  --bg: #0e0f11;
  --bg-2: #16181b;
  --ink: #e9edf0;
  --muted: rgba(233, 237, 240, 0.62);
  --faint: rgba(233, 237, 240, 0.14);
  --accent: #93e4ee;
  --accent-dim: rgba(147, 228, 238, 0.36);
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--mono);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
canvas#gl, canvas#ui { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
canvas#ui { pointer-events: none; }
button { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.screen { position: fixed; inset: 0; pointer-events: none; }
.screen > * { pointer-events: auto; }

/* ---------- landing ---------- */
#landing {
  display: grid;
  grid-template-rows: 1fr auto auto auto;
  padding: calc(24px + var(--safe-t)) clamp(16px, 4vw, 56px) calc(28px + var(--safe-b));
  gap: 18px;
  background: linear-gradient(to top, rgba(14,15,17,0.92) 0%, rgba(14,15,17,0.55) 30%, rgba(14,15,17,0) 55%);
  transition: opacity 0.6s ease;
}
#landing.gone { opacity: 0; pointer-events: none; }
#landing.gone > * { pointer-events: none; }
.land-copy { grid-row: 2; display: grid; gap: 6px; }
h1 {
  margin: 0;
  font-weight: 500;
  font-size: clamp(30px, 5.4vw, 64px);
  letter-spacing: -0.02em;
  line-height: 1.02;
  text-wrap: balance;
}
.sub { margin: 0; color: var(--muted); font-size: clamp(13px, 1.5vw, 17px); letter-spacing: 0.01em; }
.land-actions { grid-row: 3; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; }
.btn {
  border: 1px solid var(--faint);
  background: rgba(233, 237, 240, 0.04);
  border-radius: 999px;
  padding: 14px 22px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}
.btn:hover { background: rgba(233, 237, 240, 0.08); }
.btn:active { transform: scale(0.98); }
.btn.primary { border-color: var(--accent-dim); }
.btn:disabled { opacity: 0.45; cursor: progress; }
.btn.primary .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.btn .muted { color: var(--muted); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); padding-inline: 4px; }
.btn.ghost:hover { color: var(--ink); }
.loading { grid-row: 4; margin: 0; color: var(--muted); font-size: 12px; min-height: 18px; }

/* ---------- film controls (visitors only; film mode shows nothing) ---------- */
.film-ui {
  position: fixed; right: clamp(12px, 3vw, 28px); bottom: calc(14px + var(--safe-b));
  display: flex; gap: 8px; transition: opacity 0.5s ease;
}
.film-ui.idle { opacity: 0; }
.chip {
  border: 1px solid var(--faint); background: rgba(14, 15, 17, 0.6); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 999px; padding: 9px 14px; font-size: 13px; cursor: pointer; min-height: 40px;
}
.chip:hover { border-color: var(--accent-dim); }

.tap { position: fixed; inset: 0; display: grid; place-items: center; cursor: pointer; }
.tap span { color: var(--muted); font-size: 14px; letter-spacing: 0.04em; border: 1px solid var(--faint); border-radius: 999px; padding: 12px 20px; }
body.film-mode, body.film-mode * { cursor: none !important; }

@media (prefers-reduced-motion: reduce) {
  .btn, #landing, .film-ui { transition: none; }
}

/* ---------- playground ---------- */
.play {
  position: fixed; inset: 0; z-index: 5;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto auto auto 1fr;
  grid-template-areas: "top" "tabs" "chips" "stage" "panel";
  gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px calc(14px + var(--safe-b));
  max-width: 560px; margin: 0 auto;
}
.pl-top { grid-area: top; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; }
.pl-back { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px 0; font-size: 13px; }
.pl-back:hover { color: var(--ink); }
.pl-title { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; }
.pl-tabs { grid-area: tabs; display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--faint); border-radius: 12px; padding: 3px; gap: 3px; }
.pl-tabs button { border: 0; background: none; border-radius: 9px; padding: 9px 4px; font-size: 13px; color: var(--muted); cursor: pointer; min-height: 38px; }
.pl-tabs button[aria-selected="true"] { background: rgba(233,237,240,0.09); color: var(--ink); }
.pl-chips { grid-area: chips; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-inline: -16px; padding-inline: 16px; }
.pl-chips::-webkit-scrollbar { display: none; }
.pchip { flex: none; border: 1px solid var(--faint); background: none; border-radius: 999px; padding: 8px 13px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; min-height: 36px; }
.pchip[aria-checked="true"] { color: var(--accent); border-color: var(--accent-dim); background: rgba(147,228,238,0.07); }
.pl-stage { grid-area: stage; position: relative; width: min(100%, 52vh); aspect-ratio: 1; justify-self: center; }
.pl-canvas { position: absolute; inset: 0; border-radius: 6px; touch-action: none; }
.pl-status { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.pl-ghost { position: absolute; right: 8px; bottom: 8px; width: 30%; aspect-ratio: 1; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,0.6); pointer-events: none; }
.pl-ghost span { position: absolute; right: 0; top: -27px; font-size: 11px; line-height: 1; padding: 5px 9px; border-radius: 999px; color: var(--ink); white-space: nowrap; background: rgba(14,15,17,0.84); }
.pl-panel { grid-area: panel; display: grid; gap: 12px; align-content: start; padding-top: 6px; }
.pl-read { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pl-read b { color: var(--accent); font-weight: 500; }
.pl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pl-hint { color: var(--muted); font-size: 12px; min-width: 0; flex: 1 1 200px; }
.btn.small { min-height: 40px; padding: 9px 15px; font-size: 13px; }
.pl-slider { position: relative; height: 44px; cursor: grab; touch-action: none; --p: 0%; }
.pl-slider:active { cursor: grabbing; }
.pl-track { position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: var(--faint); transform: translateY(-50%); }
.pl-fill { position: absolute; left: 0; top: 50%; height: 2px; width: var(--p); background: var(--accent); transform: translateY(-50%); box-shadow: 0 0 10px var(--accent-dim); }
.pl-ticks i { position: absolute; top: calc(50% + 7px); width: 1px; height: 6px; background: rgba(233,237,240,0.28); }
.pl-ticks i.dec { height: 10px; background: var(--accent); width: 2px; }
.pl-thumb { position: absolute; top: 50%; left: var(--p); width: 22px; height: 22px; border-radius: 50%; background: var(--ink); transform: translate(-50%, -50%); box-shadow: 0 0 0 5px rgba(147,228,238,0.15); }
.pl-slider:focus-visible .pl-thumb { box-shadow: 0 0 0 3px var(--accent); }
.pl-dial { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.dstop { border: 1px solid var(--faint); background: none; border-radius: 12px; padding: 10px 4px 8px; display: grid; justify-items: center; gap: 2px; cursor: pointer; min-height: 64px; }
.dstop i { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.dstop span { font-size: 15px; font-variant-numeric: tabular-nums; }
.dstop em { font-style: normal; font-size: 10px; color: var(--muted); min-height: 13px; }
.dstop[aria-checked="true"] { border-color: var(--accent-dim); background: rgba(147,228,238,0.07); }
.dstop[aria-checked="true"] i { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.pl-own { display: flex; gap: 8px; }
.pl-own input { flex: 1; min-width: 0; border: 1px solid var(--faint); background: rgba(233,237,240,0.04); color: var(--ink); border-radius: 12px; padding: 11px 13px; font: inherit; font-size: 15px; }
.pl-own input:focus { outline: none; border-color: var(--accent-dim); }
.pl-doodlerow label { color: var(--muted); font-size: 12px; }
.pl-doodlerow input[type=range] { flex: 1; accent-color: var(--accent); }
.pl-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--faint); cursor: pointer; }
.swatch.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.pl-modal { position: fixed; inset: 0; background: rgba(8,9,10,0.82); display: grid; place-items: center; padding: 16px; z-index: 9; }
.pl-sheet { width: min(420px, 100%); display: grid; gap: 12px; }
.pl-sheet img { width: 100%; border-radius: 10px; border: 1px solid var(--faint); }
a.btn { text-decoration: none; color: inherit; }

@media (min-width: 900px) and (min-aspect-ratio: 1/1) {
  .play {
    max-width: 1200px;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "top top" "stage tabs" "stage chips" "stage panel";
    column-gap: 40px; padding-inline: 40px;
  }
  .pl-stage { width: min(100%, 78vh); align-self: center; }
  .pl-chips { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
  .pl-ghost { width: 27%; right: 12px; bottom: 12px; }
}
