/* ASMR Machine — 3D viewer. Typography and palette follow doroszenko.com:
   Space Grotesk (400/500), Old Standard TT italic for emphasis, black on white. */

:root {
  --fg: #000;
  --mute: #999;
  --soft: #6b6b6b;
  --bg: #f4f4f2;
  --panel: #fff;
  --line: rgba(0, 0, 0, .14);
  --pad: clamp(18px, 2.8vw, 40px);
  --ease: cubic-bezier(.2, .75, .5, 1);
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.dark { --fg: #fff; --mute: #8a8a8a; --soft: #bdbdbd; --line: rgba(255, 255, 255, .22); }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--fg); }
body { transition: color .6s var(--ease); }
em, i.it { font-family: 'Old Standard TT', Georgia, serif; font-style: italic; font-size: 1.06em; letter-spacing: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
#stage.grab { cursor: grab; } #stage.grabbing { cursor: grabbing; } #stage.point { cursor: pointer; } #stage.stir { cursor: crosshair; }

/* ------------------------------------------------------------------ header */
.top { position: fixed; top: var(--pad); left: var(--pad); right: var(--pad); display: flex; justify-content: space-between; align-items: baseline; pointer-events: none; z-index: 5; }
.top > * { pointer-events: auto; }
.brand { font-size: 32px; line-height: 32px; font-weight: 500; text-decoration: none; letter-spacing: -.01em; }
.top-nav { display: flex; gap: 26px; align-items: baseline; }
.txt { font-size: 15px; line-height: 1; position: relative; }
.txt::after { content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px; background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .35s var(--ease); }
.txt:hover::after, .txt.active::after { transform: scaleX(1); }
.icon { font-size: 18px; }

.hint { position: fixed; top: calc(var(--pad) + 52px); left: 50%; transform: translateX(-50%); margin: 0; font-size: 12px; color: var(--soft); letter-spacing: .02em; white-space: nowrap; z-index: 4; transition: opacity .5s; pointer-events: none; max-width: calc(100vw - 40px); overflow: hidden; text-overflow: ellipsis; }

/* ----------------------------------------------------------------- caption */
.caption { position: fixed; left: var(--pad); bottom: var(--pad); max-width: 440px; z-index: 4; transition: opacity .5s; }
.caption h1, .intro h1 { font-size: 32px; line-height: 38px; font-weight: 500; margin: 0 0 8px; letter-spacing: -.01em; }
.meta { font-size: 13px; line-height: 1.5; color: var(--soft); margin: 0; }

/* ------------------------------------------------------------------- modes */
.modes { position: fixed; right: var(--pad); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: flex-end; gap: 14px; z-index: 4; }
.modes > button, .spk { font-size: 20px; line-height: 1; font-weight: 500; color: var(--mute); transition: color .3s; display: flex; align-items: baseline; gap: 10px; }
.modes > button:hover, .modes > button.active, .spk.active { color: var(--fg); }
.modes .n { font-size: 11px; font-weight: 400; letter-spacing: .04em; }
.spk { flex-direction: column; align-items: flex-end; gap: 10px; }
.spk > span:not(.n) { order: 0; }
.spk { display: grid; grid-template-columns: auto auto; justify-items: end; column-gap: 10px; row-gap: 10px; }
.spk-row { grid-column: 1 / -1; display: flex; gap: 6px; }
.spk-row button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 50%; font-size: 12px; font-weight: 500; color: var(--fg); transition: background .3s, color .3s, border-color .3s; position: relative; }
.spk-row button:hover { border-color: var(--fg); }
.spk-row button.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
body.dark .spk-row button.active { color: #000; }

/* --------------------------------------------------------------- transport */
.transport { position: fixed; right: var(--pad); bottom: var(--pad); display: flex; flex-direction: column; align-items: flex-end; gap: 10px; z-index: 4; text-align: right; }
.row { display: flex; align-items: baseline; gap: 14px; font-size: 13px; }
.lbl { color: var(--mute); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.seg { display: flex; gap: 0; }
.seg button { color: var(--mute); padding: 2px 0; transition: color .3s; }
.seg button + button::before { content: '/'; color: var(--mute); margin: 0 8px; opacity: .6; }
.seg button.active, .seg button:hover { color: var(--fg); }
.seg button.disabled { opacity: .35; pointer-events: none; }
.play { font-size: 20px; font-weight: 500; display: flex; align-items: baseline; gap: 10px; }
.play .glyph { font-size: 12px; display: inline-block; width: 12px; transform: translateY(-2px); }
.time { font-size: 12px; color: var(--mute); font-variant-numeric: tabular-nums; min-width: 78px; }
.note { margin: 0; max-width: 300px; font-size: 11px; line-height: 1.45; color: var(--soft); min-height: 1em; }
.play-row { align-items: center; }

/* ---------------------------------------------------------- 3D annotations */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 3; }
.lab { position: absolute; left: 0; top: 0; font-size: 11px; font-weight: 500; letter-spacing: .04em; color: var(--fg); pointer-events: auto; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; will-change: transform; transition: opacity .3s; }
.lab .bar { display: block; width: 26px; height: 1px; background: var(--line); position: relative; overflow: hidden; }
.lab .bar i { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: var(--fg); transform-origin: left; transform: scaleX(0); }
.lab:hover { text-decoration: underline; text-underline-offset: 3px; }
.lab.off { opacity: .35; }
.lab.dim { color: var(--soft); font-weight: 400; pointer-events: none; cursor: default; }
.hot { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--fg); will-change: transform; transition: opacity .4s; }
.hot b { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--fg); display: grid; place-items: center; font-weight: 400; font-size: 14px; line-height: 1; background: color-mix(in srgb, var(--bg) 60%, transparent); transition: background .3s, color .3s; }
.hot span { opacity: 0; transform: translateX(-4px); transition: opacity .3s, transform .3s var(--ease); }
.hot:hover b { background: var(--fg); color: var(--bg); }
.hot:hover span { opacity: 1; transform: none; }
.hidden { opacity: 0 !important; pointer-events: none !important; }

/* ------------------------------------------------------------ speaker panel */
.speaker-panel { position: fixed; left: var(--pad); top: 50%; transform: translate(-12px, -50%); width: 240px; opacity: 0; pointer-events: none; transition: opacity .5s, transform .6s var(--ease); z-index: 4; }
body.m-speaker .speaker-panel { opacity: 1; pointer-events: auto; transform: translate(0, -50%); }
body.m-speaker .caption { opacity: 0; pointer-events: none; }
.sp-title { font-size: 32px; line-height: 38px; font-weight: 500; margin: 0 0 12px; }
.sp-line { font-size: 13px; line-height: 1.5; margin: 0; color: var(--soft); }
.sp-line span:last-child { color: var(--fg); font-variant-numeric: tabular-nums; }
#scope { width: 220px; height: 45px; margin: 16px 0 12px; display: block; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.sp-ctrl { display: flex; gap: 16px; margin-bottom: 14px; }
.tog { font-size: 13px; color: var(--mute); }
.tog.on { color: var(--fg); }
.tog i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; border: 1px solid currentColor; margin-left: 2px; }
.tog.on i { background: currentColor; }
.sp-note { font-size: 11px; line-height: 1.45; color: var(--soft); margin: 0 0 18px; }
.back { font-size: 13px; }

/* ------------------------------------------------------------------ drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: #fff; color: #000; z-index: 20; transform: translateX(100%); transition: transform .7s var(--ease); display: flex; flex-direction: column; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: baseline; padding: var(--pad) var(--pad) 18px; }
.dh { font-size: 32px; line-height: 32px; font-weight: 500; }
.toc { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0 var(--pad) 18px; border-bottom: 1px solid rgba(0,0,0,.1); font-size: 12px; }
.toc a { text-decoration: none; color: #888; transition: color .3s; }
.toc a:hover, .toc a.active { color: #000; }
.drawer-body { overflow-y: auto; padding: 8px var(--pad) 80px; scroll-behavior: smooth; overscroll-behavior: contain; }
.ctx { padding: 28px 0 8px; border-bottom: 1px solid rgba(0,0,0,.08); }
.ctx h2 { font-size: 22px; line-height: 1.2; font-weight: 500; margin: 0 0 14px; display: flex; gap: 12px; align-items: baseline; }
.ctx h2 .n { font-size: 11px; color: #999; font-weight: 400; letter-spacing: .04em; }
.ctx p { font-size: 16px; line-height: 1.6; margin: 0 0 14px; }
.ctx p.src { font-size: 13px; }
.ctx p.src a { text-decoration: none; border-bottom: 1px solid currentColor; }
.ctx .act { font-size: 13px; color: #000; border-bottom: 1px solid #000; margin: 0 0 18px; }
.ctx.flash { animation: flash 1.6s var(--ease); }
@keyframes flash { 0% { background: #f1f1f1; } 100% { background: transparent; } }
.works { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 18px; margin: 6px 0 22px; }
.work { text-decoration: none; display: block; }
.work img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; filter: grayscale(1); transition: filter .5s; background: #eee; }
.work:hover img { filter: none; }
.work h3 { font-size: 14px; font-weight: 500; margin: 10px 0 4px; line-height: 1.3; }
.work h3 small { color: #999; font-weight: 400; margin-left: 6px; }
.work p { font-size: 12.5px !important; line-height: 1.5 !important; color: #555; margin: 0 !important; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0 22px; }
.photos a { display: block; aspect-ratio: 1; overflow: hidden; background: #eee; }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .8s var(--ease); }
.photos a:hover img { transform: scale(1.04); }

/* ------------------------------------------------------------------- intro */
.intro { position: fixed; inset: 0; z-index: 30; background: rgba(244, 244, 242, .82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); display: flex; align-items: flex-end; padding: var(--pad); transition: opacity .9s var(--ease), visibility .9s; color: #000; }
.intro.gone { opacity: 0; visibility: hidden; }
.intro-inner { max-width: 620px; }
.intro { --fg: #000; --soft: #555; --mute: #999; --line: rgba(0,0,0,.14); }
.intro-brand { font-size: 32px; line-height: 32px; font-weight: 500; margin: 0 0 18vh; }
.intro h1 { font-size: clamp(44px, 7vw, 96px); line-height: .95; letter-spacing: -.03em; margin-bottom: 16px; }
.intro .lead { font-size: 20px; line-height: 1.45; margin: 26px 0 12px; max-width: 560px; }
.intro .head { font-size: 13px; color: #555; margin: 0 0 34px; }
.phones { letter-spacing: -.2em; margin-right: 4px; }
.intro-actions { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.cta { font-size: 20px; font-weight: 500; padding: 14px 26px; border: 1px solid #000; border-radius: 999px; transition: background .3s, color .3s; }
.cta:hover { background: #000; color: #fff; }
.progress { margin-top: 26px; font-size: 12px; color: #555; display: none; align-items: center; gap: 12px; }
.progress.show { display: flex; }
.progress i { display: block; width: 160px; height: 1px; background: rgba(0,0,0,.15); position: relative; overflow: hidden; }
.progress i::after { content: ''; position: absolute; inset: 0; background: #000; transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform .2s; }

/* intro hides UI */
body.is-intro .top-nav, body.is-intro .modes, body.is-intro .transport, body.is-intro .caption, body.is-intro #labels, body.is-intro .hint { opacity: 0; pointer-events: none; }
.top-nav, .modes, .transport, #labels { transition: opacity .8s var(--ease); }

/* room switch veil */
.veil { position: fixed; inset: 0; background: var(--bg); z-index: 2; pointer-events: none; opacity: 0; transition: opacity .35s; }
.veil.on { opacity: 1; }

/* ------------------------------------------------------------------ mobile */
@media (max-width: 760px) {
  .brand { font-size: 22px; line-height: 24px; }
  .top-nav { gap: 16px; }
  .hint { top: calc(var(--pad) + 34px); font-size: 11px; white-space: normal; text-align: center; width: calc(100vw - 40px); }
  .modes { top: auto; bottom: calc(var(--pad) + 112px); transform: none; right: var(--pad); left: var(--pad); flex-direction: row; align-items: flex-end; justify-content: space-between; gap: 10px; }
  .modes > button, .spk { font-size: 15px; }
  .modes .n { display: none; }
  .spk { display: flex; flex-direction: column; align-items: flex-end; }
  .spk > span[data-t] { display: none; }
  .spk-row button { width: 26px; height: 26px; }
  .caption { bottom: auto; top: calc(var(--pad) + 76px); max-width: 70vw; }
  .caption h1 { font-size: 22px; line-height: 26px; }
  .caption .meta { display: none; }
  .transport { left: var(--pad); align-items: stretch; text-align: left; gap: 8px; }
  .row { justify-content: space-between; }
  .note { max-width: none; }
  .speaker-panel { top: calc(var(--pad) + 78px); bottom: auto; transform: none !important; width: auto; right: var(--pad); padding: 0; }
  .speaker-panel .sp-line:nth-of-type(3) { display: none; }
  .sp-ctrl { margin-bottom: 8px; }
  .back { display: none; }
  .sp-title { font-size: 22px; line-height: 26px; margin-bottom: 6px; }
  #scope, .sp-note { display: none; }
  .works { grid-template-columns: 1fr; }
  .intro .lead { font-size: 17px; }
  .intro-brand { margin-bottom: 10vh; font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01s !important; animation: none !important; }
}

/* ------------------------------------------------- Largo: details + sequencer */
.spk-row { flex-wrap: nowrap; }
.spk-row button { width: 30px; }
.spk-row button.wide { width: 38px; border-radius: 15px; font-size: 11px; }
.speaker-panel { width: 268px; }
.poi-ctrl { display: flex; flex-direction: column; gap: 12px; margin-bottom: 14px; }
.poi-ctrl .row-ctrl { display: flex; gap: 14px; flex-wrap: wrap; align-items: baseline; }
.poi-ctrl .lbl { display: block; margin-bottom: 6px; }
.seq { display: grid; grid-template-columns: 14px repeat(16, 1fr); gap: 3px; align-items: center; }
.seq .rl { font-size: 10px; color: var(--mute); }
.seq button { aspect-ratio: 1; border: 1px solid var(--line); border-radius: 2px; transition: background .15s, border-color .15s; }
.seq button.on { background: var(--fg); border-color: var(--fg); }
.seq button:nth-of-type(4n+1) { border-color: color-mix(in srgb, var(--fg) 40%, transparent); }
.seq button.on:nth-of-type(4n+1) { border-color: var(--fg); }
.seq button.now { box-shadow: 0 0 0 1px #ff3b2f; }
.seq .ix { font-size: 9px; color: var(--mute); text-align: center; }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; font-size: 12px; }
.slider span { color: var(--soft); }
.slider output { font-variant-numeric: tabular-nums; font-size: 12px; }
.slider input { grid-column: 1 / -1; width: 100%; accent-color: var(--fg); height: 14px; }
input[type=range] { -webkit-appearance: none; appearance: none; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 1px; background: var(--line); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 11px; height: 11px; border-radius: 50%; background: var(--fg); margin-top: -5px; }
input[type=range]::-moz-range-track { height: 1px; background: var(--line); }
input[type=range]::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--fg); }
.fire { font-size: 14px; font-weight: 500; border: 1px solid var(--fg); border-radius: 999px; padding: 6px 14px; align-self: flex-start; transition: background .2s, color .2s; }
.fire:hover, .fire.hit { background: var(--fg); color: var(--bg); }
body.dark .fire:hover, body.dark .fire.hit { color: #000; }
body.m-unit .speaker-panel, body.m-coil .speaker-panel, body.m-plate .speaker-panel { opacity: 1; pointer-events: auto; transform: translate(0, -50%); }
body.m-unit .caption, body.m-coil .caption, body.m-plate .caption { opacity: 0; pointer-events: none; }
body.m-unit #scope, body.m-coil #scope { display: none; }
body.m-unit #poiDistRow { display: none; }
@media (max-width: 760px) {
  .spk-row button { width: 26px; } .spk-row button.wide { width: 32px; }
  .speaker-panel { width: auto; max-height: 50vh; overflow: auto; left: 0; right: 0; padding: 12px var(--pad) 14px; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
  .modes { bottom: calc(var(--pad) + 132px); }
  .sp-note { display: none; }
  body.m-unit .speaker-panel, body.m-coil .speaker-panel, body.m-plate .speaker-panel { transform: none; }
  .seq { gap: 2px; }
}
