@font-face {
  font-family: 'Instrument Sans';
  src: url(fonts/instrument-sans-regular.woff2) format('woff2');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url(fonts/instrument-serif-regular.woff2) format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Instrument Serif';
  src: url(fonts/instrument-serif-italic.woff2) format('woff2');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --paper: #f4f0e8;
  --paper-2: #ebe5da;
  --ink: #1f1c18;
  --muted: #6c6459;
  --line: #ddd5c7;
  --accent: #a4532c;
  --room-tint: #d8cbb6;
  --on-stage: #fffaf2;
  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --bar-h: 56px;
  --exploration-footer-bg: var(--paper);
  --exploration-footer-ink: var(--ink);
  --exploration-footer-border: var(--line);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14120f;
    --paper-2: #1f1b17;
    --ink: #efe8dc;
    --muted: #a99f90;
    --line: #342e27;
    --accent: #e08a5c;
  }
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header */
.bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--bar-h);
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 5;
}
.bar-home {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  text-decoration: none;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.bar-home:hover { color: var(--ink); }
.bar-logo { width: 20px; height: 20px; fill: currentColor; stroke-width: 1.4; }
.bar-brand { font-weight: 600; color: var(--ink); }
.bar-slash { opacity: 0.5; }
.bar-title {
  margin: 0 auto 0 4px;
  font: 400 24px/1 var(--serif);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.bar-title em { color: var(--accent); }
.bar-actions { display: flex; align-items: center; gap: 8px; }
.bar-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.bar-action:hover { background: var(--paper-2); }
.bar-make { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.bar-make:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Stage */
.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 300px;
  overflow: hidden;
  background: var(--room-sky, #f4f4f5);
  isolation: isolate;
}
.poster, .room-canvas, .walk-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.poster, .walk-video { object-fit: cover; }
.poster { transition: opacity 0.6s ease; }
.poster:not(.is-current) { opacity: 0; }
.room-canvas { display: block; touch-action: none; cursor: grab; outline: none; opacity: 0; transition: opacity 0.7s ease; }
.stage[data-mode='3d'] .room-canvas { opacity: 1; }
.room-canvas.is-over-prop { cursor: pointer; }
.room-canvas.is-dragging, .room-canvas.is-grabbing { cursor: grabbing; }
.room-canvas:focus-visible { outline: 2px solid var(--on-stage); outline-offset: -6px; }
.scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  pointer-events: none;
  background: linear-gradient(to top, rgb(18 14 10 / 0.62), rgb(18 14 10 / 0.18) 55%, transparent);
}
.stage-top {
  position: absolute;
  inset: 0 0 auto 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 14px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  pointer-events: none;
}
.stage-top > * { pointer-events: auto; }
.status {
  margin: 0;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgb(255 252 246 / 0.82);
  color: #2a241d;
  font-size: 13px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  max-width: min(440px, 62vw);
}
.stage-tools { display: flex; gap: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 999px;
  background: rgb(255 252 246 / 0.86);
  color: #2a241d;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  white-space: nowrap;
}
.pill:hover:not(:disabled) { background: #fff; }
.pill:disabled { opacity: 0.55; cursor: default; }
.pill-icon { width: 40px; padding: 0; }
.pill-solid { background: #2a241d; color: #fffaf2; border-color: #2a241d; }
.pill-solid:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill svg { width: 16px; height: 16px; }
#tour .i-play { fill: currentColor; }
#tour .i-stop { display: none; fill: currentColor; }
#tour[aria-pressed='true'] .i-play { display: none; }
#tour[aria-pressed='true'] .i-stop { display: block; }
#sound .i-wave { display: none; }
#sound[aria-pressed='true'] .i-wave { display: block; }
#sound[aria-pressed='true'] .i-mute { display: none; }

.caption {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  right: 18px;
  bottom: 18px;
  max-width: 560px;
  color: var(--on-stage);
  pointer-events: none;
  text-shadow: 0 1px 14px rgb(0 0 0 / 0.35);
}
.caption-kicker {
  margin: 0 0 4px;
  font: 500 11px/1.4 var(--sans);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.9;
}
.caption-title {
  margin: 0;
  font: 400 clamp(38px, 6.4vw, 76px)/0.95 var(--serif);
  letter-spacing: -0.015em;
}
.caption-line { margin: 8px 0 0; font-size: 15px; max-width: 46ch; opacity: 0.95; }
.caption.is-changing .caption-title,
.caption.is-changing .caption-line { animation: caption-in 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
@keyframes caption-in {
  from { opacity: 0; transform: translateY(10px); filter: blur(4px); }
  to { opacity: 1; transform: none; filter: none; }
}

.hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 12px 18px;
  border-radius: 14px;
  background: rgb(24 19 14 / 0.58);
  color: #fffaf2;
  font-size: 13px;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.5s ease;
}
.hint.is-leaving { opacity: 0; }
.hint-drag { font-weight: 600; }
.hint.is-grab-only > :not(.hint-grab) { display: none; }
.hint.is-grab-only .hint-grab { font-weight: 600; }

.progress {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.progress.is-active { opacity: 1; }
.progress span {
  display: block;
  height: 100%;
  width: calc(var(--p, 0) * 100%);
  background: var(--accent);
  transition: width 0.2s linear;
}

.notice {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: rgb(20 16 12 / 0.7);
  color: #fffaf2;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 3;
}
.notice-title { margin: 0; font: 400 30px/1.1 var(--serif); }
.notice-text { margin: 0; max-width: 42ch; opacity: 0.9; }
.notice-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.noscript {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgb(24 19 14 / 0.7);
  color: #fffaf2;
  text-align: center;
}

/* Dock */
.dock {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--paper);
  border-top: 1px solid var(--line);
}
.styles {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  padding: 2px;
  min-width: 0;
  flex: 1 1 auto;
}
/* A soft edge says the row scrolls; it lifts at the end of the row. */
.styles.is-clipped { mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
.styles.is-clipped.at-end { mask-image: linear-gradient(to left, #000 calc(100% - 36px), transparent); }
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 4px 13px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  scroll-snap-align: start;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.chip img { width: 52px; height: 39px; border-radius: 8px; object-fit: cover; display: block; }
.chip:hover { background: var(--paper-2); }
.chip[aria-checked='true'] {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}
.chip.is-loading::after {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.walk {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.walk-step {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
}
.walk-step:hover:not(:disabled) { background: var(--paper-2); }
.walk-step:disabled, .walk-text:disabled { opacity: 0.45; cursor: default; }
.walk-step { touch-action: none; -webkit-user-select: none; user-select: none; }
.walk-text {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.walk-text:hover:not(:disabled) { background: var(--paper-2); }

/* Touch stick: shown on touch screens once the 3D room is live. */
.stick {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: none;
  place-items: center;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgb(24 19 14 / 0.28);
  border: 1px solid rgb(255 250 242 / 0.45);
  touch-action: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.stick span {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgb(255 250 242 / 0.85);
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.25);
  transition: transform 0.12s ease-out;
}
@media (pointer: coarse) {
  .stage[data-mode='3d'] .stick { display: grid; }
  .stage[data-mode='3d'] .caption { padding-right: 132px; }
  .hint-keys { display: none; }
}
@media (pointer: fine) {
  .hint-touch { display: none; }
}

/* Footer (shared runtime mounts its links here) */
.site-footer { flex-shrink: 0; }
.footer-resources { display: flex; flex-wrap: wrap; gap: 0 18px; }
.footer-resources a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* How it's made */
.modal-how {
  width: min(980px, calc(100vw - 24px));
  max-height: min(90dvh, 980px);
  padding: 26px clamp(18px, 4vw, 40px) 30px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 40px 120px rgb(0 0 0 / 0.35);
}
.modal-how::backdrop { background: rgb(20 16 12 / 0.55); backdrop-filter: blur(6px); }
.modal-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kicker { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.modal-close {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
}
.how-title { margin: 12px 0 8px; font: 400 clamp(32px, 4.6vw, 52px)/1 var(--serif); letter-spacing: -0.01em; }
.how-title em { color: var(--accent); }
.how-lede { margin: 0 0 22px; max-width: 66ch; color: var(--muted); }
.how-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px 16px; }
.how-steps li { display: flex; flex-direction: column; gap: 10px; }
.how-steps figure { margin: 0; }
.how-steps img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; border-radius: 10px; background: var(--paper-2); }
.how-steps h3 { margin: 0 0 4px; font: 400 22px/1.15 var(--serif); display: flex; align-items: baseline; gap: 8px; }
.step-n { font: 600 11px/1 var(--sans); color: var(--accent); }
.how-steps p { margin: 0; font-size: 14px; color: var(--muted); }
.how-downloads { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-top: 26px; }
.card {
  display: block;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  text-decoration: none;
  background: var(--paper-2);
}
.card:hover { border-color: var(--ink); }
.card-type { margin: 0; font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.card h3 { margin: 6px 0 10px; font: 400 22px/1.15 var(--serif); }
.card b { font-size: 13px; font-weight: 600; }
.card-make { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.card-make .card-type { color: inherit; opacity: 0.7; }
.how-note { margin: 18px 0 0; font-size: 13px; color: var(--muted); }

/* Phones and narrow windows */
@media (max-width: 760px) {
  .bar { gap: 10px; }
  .bar-brand, .bar-slash { display: none; }
  .bar-section { font-size: 12px; }
  .bar-title { font-size: 21px; margin-left: 0; }
  .bar-how span { display: none; }
  .bar-how { width: 40px; padding: 0; justify-content: center; }
  .bar-make { padding: 0 12px; font-size: 12px; }
  .dock { flex-direction: column; align-items: stretch; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .walk { flex: 0 0 auto; min-width: 0; flex-wrap: wrap; }
  .stick { width: 96px; height: 96px; right: 12px; bottom: 12px; }
  .caption { bottom: 14px; }
  .caption-line { font-size: 13px; }
  .status { font-size: 12px; }
  .tour-label { display: none; }
  #tour { width: 40px; padding: 0; }
}
@media (max-width: 380px) {
  .bar-section { display: none; }
  .chip img { width: 44px; height: 33px; }
}
/* Short screens: keep a usable room and let the page scroll for the controls. */
@media (max-height: 560px) {
  .stage { flex: 0 0 auto; height: max(240px, calc(100dvh - var(--bar-h) - 20px)); }
  .caption-line { display: none; }
  .caption-title { font-size: 34px; }
  .stick { width: 84px; height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .poster { transition-duration: 0.01s; }
  .caption.is-changing .caption-title,
  .caption.is-changing .caption-line { animation: none; }
  .chip.is-loading::after { animation-duration: 2.4s; }
}
