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

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

@font-face {
  font-family: 'Manrope';
  src: url('../assets/fonts/manrope.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #19110c;
  --cream: #f5ead8;
  --cream-dim: #c8b49b;
  --accent: #f1bc7b;
  --accent-deep: #d89b5b;
  --glass: rgba(35, 24, 17, 0.66);
  --line: rgba(245, 234, 215, 0.14);
  --serif: 'Instrument Serif', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --sans: 'Manrope', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

::selection {
  background: rgba(241, 188, 123, 0.28);
  color: #fff7eb;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(circle at 60% 40%, #a86f4e 0%, #2b1c14 70%);
}

#scene {
  position: absolute;
  inset: 0;
}

#scene canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  outline: none;
}

/* ---------- Atmosphere overlays ---------- */

.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 53% 43%, transparent 38%, rgba(26, 14, 8, 0.22) 78%, rgba(16, 9, 5, 0.52) 100%),
    linear-gradient(to bottom, rgba(22, 13, 8, 0.28) 0%, transparent 23%, transparent 68%, rgba(18, 10, 6, 0.4) 100%);
}

.grain {
  position: absolute;
  inset: -20%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.7'/%3E%3C/svg%3E");
  background-size: 220px 220px;
}

/* ---------- Editorial header ---------- */

.masthead {
  position: absolute;
  top: clamp(28px, 5.2vw, 62px);
  left: clamp(24px, 5vw, 66px);
  z-index: 4;
  width: min(430px, 38vw);
  pointer-events: none;
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 1.1s ease 0.15s,
    transform 1.1s cubic-bezier(0.22, 1, 0.36, 1) 0.15s;
}

.masthead::before {
  content: '';
  position: absolute;
  inset: -46px -72px -28px -58px;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(ellipse at 24% 38%, rgba(26, 14, 8, 0.5), transparent 70%);
  filter: blur(18px);
}

.is-ready .masthead {
  opacity: 1;
  transform: translateY(0);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.26em;
  line-height: 1;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.62);
}

.eyebrow-rule {
  display: inline-block;
  width: 34px;
  height: 1px;
  background: rgba(241, 188, 123, 0.75);
}

.title {
  margin: 22px 0 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(68px, 8.4vw, 122px);
  line-height: 0.76;
  letter-spacing: -0.032em;
  text-wrap: balance;
  color: var(--cream);
  text-shadow: 0 12px 50px rgba(30, 15, 7, 0.28);
}

.title em {
  display: inline-block;
  padding-right: 0.06em;
  font-style: italic;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: -0.042em;
}

.deck {
  max-width: 28ch;
  margin: 26px 0 0;
  font-size: 13.5px;
  font-weight: 300;
  line-height: 1.72;
  letter-spacing: 0.012em;
  color: rgba(245, 234, 215, 0.82);
  text-shadow: 0 2px 22px rgba(24, 12, 6, 0.85);
}

.meta {
  display: flex;
  gap: 14px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.4);
}

.meta li {
  position: relative;
}

.meta li + li::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -8px;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(241, 188, 123, 0.7);
  transform: translateY(-50%);
}

/* ---------- Loop status ---------- */

.loop-badge {
  position: absolute;
  top: clamp(26px, 5vw, 58px);
  right: clamp(24px, 4.5vw, 58px);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  border: 1px solid rgba(245, 234, 215, 0.16);
  border-radius: 999px;
  background: rgba(31, 21, 15, 0.24);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.21em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.66);
  pointer-events: none;
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 1s ease 0.55s,
    transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.55s;
}

.is-ready .loop-badge {
  opacity: 1;
  transform: translateY(0);
}

.status-dot {
  position: relative;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(241, 188, 123, 0.5);
  animation: pulse 2.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes pulse {
  0%,
  65% {
    box-shadow: 0 0 0 0 rgba(241, 188, 123, 0.38);
    opacity: 0.9;
  }
  80% {
    box-shadow: 0 0 0 6px rgba(241, 188, 123, 0);
    opacity: 1;
  }
  100% {
    box-shadow: 0 0 0 0 rgba(241, 188, 123, 0);
    opacity: 0.9;
  }
}

/* ---------- Dock ---------- */

.dock-wrap {
  position: absolute;
  bottom: clamp(20px, 4vh, 38px);
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  width: max-content;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition:
    opacity 1s ease 0.35s,
    transform 1s cubic-bezier(0.22, 1, 0.36, 1) 0.35s;
}

.is-ready .dock-wrap {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dock {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px 9px 9px;
  border: 1px solid rgba(245, 234, 215, 0.15);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(52, 37, 27, 0.68), rgba(27, 18, 13, 0.74));
  box-shadow:
    0 22px 70px rgba(12, 7, 4, 0.34),
    inset 0 1px 0 rgba(255, 246, 230, 0.08);
  backdrop-filter: blur(22px) saturate(135%);
  -webkit-backdrop-filter: blur(22px) saturate(135%);
}

.play-button {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 0;
  padding: 0 10px 0 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.85);
}

.play-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #32200f;
  background:
    radial-gradient(circle at 35% 25%, #ffe2b4, transparent 46%),
    linear-gradient(145deg, #f4c488, #d59755);
  box-shadow:
    0 7px 18px rgba(10, 5, 2, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  transition:
    transform 0.24s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.24s ease;
}

.play-button:hover .play-icon {
  transform: scale(1.055);
  box-shadow:
    0 9px 22px rgba(10, 5, 2, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.play-button:active .play-icon {
  transform: scale(0.97);
}

.play-icon .icon {
  width: 18px;
  height: 18px;
  overflow: visible;
}

.icon-pause {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
}

.icon-play {
  display: none;
  fill: currentColor;
  stroke: none;
  transform: translateX(1px);
}

.is-paused .icon-pause {
  display: none;
}

.is-paused .icon-play {
  display: block;
}

#play-label {
  min-width: 40px;
  text-align: left;
}

.dock-rule {
  width: 1px;
  height: 27px;
  margin: 0 3px;
  background: linear-gradient(to bottom, transparent, rgba(245, 234, 215, 0.16), transparent);
}

.tempo {
  width: 148px;
  padding: 0 7px 1px;
}

.tempo-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.47);
}

.tempo-head output {
  font-size: 10px;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  color: var(--accent);
}

input[type='range'] {
  --fill: 44%;
  display: block;
  width: 100%;
  height: 14px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input[type='range']::-webkit-slider-runnable-track {
  width: 100%;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) var(--fill),
    rgba(245, 234, 215, 0.17) var(--fill),
    rgba(245, 234, 215, 0.17) 100%
  );
}

input[type='range']::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: #f8e9d3;
  box-shadow:
    0 0 0 3px rgba(241, 188, 123, 0.14),
    0 2px 6px rgba(10, 5, 2, 0.4);
  -webkit-appearance: none;
  appearance: none;
  transition: transform 0.15s ease;
}

input[type='range']:hover::-webkit-slider-thumb {
  transform: scale(1.18);
}

input[type='range']::-moz-range-track {
  height: 2px;
  border-radius: 2px;
  background: rgba(245, 234, 215, 0.17);
}

input[type='range']::-moz-range-progress {
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

input[type='range']::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: #f8e9d3;
  box-shadow:
    0 0 0 3px rgba(241, 188, 123, 0.14),
    0 2px 6px rgba(10, 5, 2, 0.4);
}

input[type='range']:focus-visible {
  outline: 1px solid rgba(241, 188, 123, 0.7);
  outline-offset: 6px;
  border-radius: 4px;
}

.view-button {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 3px 5px 3px 8px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--cream);
  text-align: left;
}

.view-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.view-eyebrow {
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.42);
}

#view-name {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.07em;
  color: rgba(245, 234, 215, 0.88);
}

.chevron {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: rgba(245, 234, 215, 0.45);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.view-button:hover .chevron {
  transform: translateX(3px);
  stroke: var(--accent);
}

button:focus-visible,
a:focus-visible {
  outline: 1px solid rgba(241, 188, 123, 0.8);
  outline-offset: 4px;
  border-radius: 6px;
}

.hint {
  margin: 0;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.34);
  text-shadow: 0 1px 8px rgba(12, 7, 4, 0.4);
}

.hint span {
  margin: 0 4px;
  color: rgba(245, 234, 215, 0.2);
}

kbd {
  display: inline-block;
  padding: 2px 5px;
  border: 1px solid rgba(245, 234, 215, 0.18);
  border-radius: 4px;
  font-family: var(--sans);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: rgba(245, 234, 215, 0.52);
  background: rgba(245, 234, 215, 0.035);
}

.credit {
  position: absolute;
  right: clamp(24px, 4.5vw, 58px);
  bottom: clamp(26px, 4.5vh, 44px);
  z-index: 4;
  margin: 0;
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(245, 234, 215, 0.3);
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease 0.7s;
}

.is-ready .credit {
  opacity: 1;
}

/* ---------- Loader ---------- */

.loader {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(61, 41, 28, 0.7) 0%, transparent 48%),
    linear-gradient(145deg, #1e150f 0%, #120c08 62%, #0c0805 100%);
  transition:
    opacity 0.9s ease,
    visibility 0.9s ease;
}

.loader::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.loader.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-content {
  position: relative;
  z-index: 1;
  width: min(420px, 84vw);
  text-align: center;
  animation: loader-in 1.1s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes loader-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loader-eyebrow {
  margin: 0 0 18px;
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.29em;
  text-transform: uppercase;
  color: rgba(241, 188, 123, 0.65);
}

.loader-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(54px, 8vw, 84px);
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--cream);
}

.loader-detail {
  margin: 22px auto 0;
  max-width: 380px;
  font-size: 10.5px;
  font-weight: 300;
  line-height: 1.9;
  letter-spacing: 0.04em;
  color: rgba(245, 234, 215, 0.46);
}

.loader-detail code {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(245, 234, 215, 0.07);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.92em;
  color: rgba(241, 188, 123, 0.9);
}

.loader-bar {
  position: relative;
  width: 168px;
  height: 2px;
  margin: 30px auto 0;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(245, 234, 215, 0.1);
}

.loader-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(216, 155, 91, 0.55), #f5d29d);
  box-shadow: 0 0 12px rgba(241, 188, 123, 0.35);
  animation: loading 1.5s cubic-bezier(0.4, 0, 0.2, 1) 0.15s forwards;
}

@keyframes loading {
  0% {
    width: 0;
  }
  55% {
    width: 68%;
  }
  100% {
    width: 100%;
  }
}

.loader.has-error .loader-title {
  color: var(--accent);
}

.loader.has-error .loader-bar {
  display: none;
}

.loader.has-error .loader-detail {
  font-size: 12px;
  line-height: 1.8;
  letter-spacing: 0.01em;
  text-transform: none;
  color: rgba(245, 234, 215, 0.62);
}

.loader.has-error .loader-eyebrow {
  color: rgba(245, 234, 215, 0.36);
}

/* ---------- Fallback ---------- */

.fallback {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #15100b;
  color: var(--cream);
  font-size: 14px;
  text-align: center;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .masthead {
    width: min(360px, 42vw);
  }

  .deck {
    max-width: 25ch;
  }

  .credit {
    display: none;
  }

  .tempo {
    width: 126px;
  }
}

@media (max-width: 760px) {
  .masthead {
    top: 26px;
    left: 24px;
    width: auto;
    max-width: 72vw;
  }

  .title {
    margin-top: 18px;
    font-size: clamp(58px, 15vw, 88px);
  }

  .deck,
  .meta {
    display: none;
  }

  .loop-badge {
    top: 24px;
    right: 20px;
    gap: 7px;
    padding: 8px 11px;
    font-size: 7.5px;
    letter-spacing: 0.14em;
  }

  .dock-wrap {
    bottom: 20px;
    width: calc(100vw - 24px);
  }

  .dock {
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px 8px 8px;
    border-radius: 20px;
  }

  .hint {
    display: none;
  }

  .tempo {
    flex: 1;
    width: auto;
    min-width: 0;
    padding: 0 5px 1px;
  }

  .dock-rule {
    display: none;
  }

  #play-label {
    display: none;
  }

  .play-button {
    padding: 0;
  }

  .view-button {
    gap: 7px;
    padding-right: 2px;
  }
}

@media (max-width: 460px) {
  .masthead {
    top: 22px;
    left: 18px;
    max-width: 76vw;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 0.2em;
  }

  .eyebrow-rule {
    width: 22px;
  }

  .title {
    font-size: 54px;
    margin-top: 16px;
  }

  .loop-badge {
    top: 18px;
    right: 14px;
    padding: 7px 9px;
    font-size: 0;
    gap: 0;
  }

  .loop-badge .status-dot {
    width: 6px;
    height: 6px;
  }

  .dock-wrap {
    width: calc(100vw - 16px);
    bottom: 14px;
  }

  .dock {
    border-radius: 18px;
    padding: 7px 8px;
  }

  .play-icon {
    width: 38px;
    height: 38px;
  }

  #view-name {
    font-size: 9.5px;
  }

  .view-eyebrow {
    font-size: 7px;
  }

  .tempo-head {
    font-size: 7.5px;
    letter-spacing: 0.13em;
  }

  .tempo-head output {
    font-size: 9px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .status-dot {
    animation: none;
  }

  .loader-content,
  .loader-bar span {
    animation-duration: 0.01ms;
    animation-delay: 0ms;
  }

  .masthead,
  .loop-badge,
  .dock-wrap,
  .credit {
    transition-duration: 0.01ms;
    transition-delay: 0ms;
  }
}
