@font-face {
  font-family: "Space Grotesk";
  src: url("./fonts/space-grotesk-medium.ttf") format("truetype");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: "Space Grotesk";
  src: url("./fonts/space-grotesk-bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("./fonts/dm-sans-regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("./fonts/dm-sans-semibold.ttf") format("truetype");
  font-style: normal;
  font-weight: 600;
  font-display: swap;
}

:root {
  --ink-950: oklch(0.17 0.005 255);
  --paper-50: oklch(0.99 0.003 90);
  --signal-500: oklch(0.63 0.257 29.23);
  --surface: var(--ink-950);
  --text: var(--paper-50);
  --accent: var(--signal-500);
  --line: oklch(0.99 0.003 90 / 0.28);
  --glass: oklch(0.17 0.005 255 / 0.82);
  --page-gutter: clamp(20px, 3.2vw, 52px);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--surface);
}

body {
  color: var(--text);
  font-family: "DM Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.player-shell {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--surface);
}

.video {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--surface);
}

.shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: oklch(0.17 0.005 255 / 0.12);
}

.grain {
  position: absolute;
  inset: -30%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
}

.interface {
  transition: opacity 220ms ease, transform 220ms var(--ease-out);
}

.controls-hidden .interface {
  opacity: 0;
  pointer-events: none;
}

.controls-hidden {
  cursor: none;
}

.masthead {
  position: absolute;
  z-index: 4;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: calc(24px + env(safe-area-inset-top)) var(--page-gutter) 24px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
}

.brand,
.edition {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  letter-spacing: -0.04em;
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
}

.opening {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: 100%;
  padding: 0 var(--page-gutter);
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 240ms ease, transform 240ms var(--ease-out);
}

.opening p {
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.36em;
}

.opening h1,
.gate-content h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(72px, 14vw, 210px);
  font-weight: 700;
  line-height: 0.82;
  letter-spacing: -0.075em;
}

.opening h1 span,
.gate-content h2 span {
  color: var(--accent);
}

.opening.is-hidden {
  opacity: 0;
  transform: translate(-50%, -48%) scale(0.98);
}

.lyrics {
  position: absolute;
  z-index: 4;
  right: var(--page-gutter);
  bottom: calc(118px + env(safe-area-inset-bottom));
  left: var(--page-gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  text-align: center;
}

.lyric-line {
  max-width: 1100px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(28px, 4.2vw, 68px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -0.045em;
  text-wrap: balance;
  text-shadow: 0 3px 24px oklch(0.17 0.005 255 / 0.9);
}

.lyric-progress {
  width: 56px;
  height: 2px;
  margin-top: 20px;
  overflow: hidden;
  background: var(--line);
}

.lyric-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
}

.instrumental {
  position: absolute;
  z-index: 4;
  bottom: calc(132px + env(safe-area-inset-bottom));
  left: 50%;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.34em;
  pointer-events: none;
  transform: translateX(-50%);
}

.sound-gate,
.error-state {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: oklch(0.17 0.005 255 / 0.82);
  backdrop-filter: blur(14px);
}

.gate-content {
  position: absolute;
  bottom: clamp(96px, 18vh, 190px);
  left: clamp(24px, 8vw, 128px);
  max-width: 720px;
  padding-right: 24px;
}

.gate-kicker,
.error-state > p {
  margin-bottom: 24px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3em;
}

.gate-content h2 {
  font-size: clamp(72px, 11vw, 160px);
}

.gate-copy {
  max-width: 420px;
  margin-top: 28px;
  font-size: clamp(16px, 1.5vw, 20px);
  line-height: 1.6;
}

.gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.button {
  min-height: 48px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease, transform 180ms var(--ease-out);
}

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

.button-primary {
  background: var(--accent);
  color: var(--text);
}

.button-primary:hover {
  background: oklch(0.7 0.23 29.23);
}

.button-secondary {
  border-color: var(--line);
  background: transparent;
}

.button-secondary:hover {
  border-color: var(--text);
  background: oklch(0.99 0.003 90 / 0.08);
}

.error-state {
  display: grid;
  place-content: center;
  padding: 32px;
  text-align: center;
}

.error-state h2 {
  margin-bottom: 28px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(28px, 4vw, 48px);
}

.controls {
  position: absolute;
  z-index: 6;
  right: var(--page-gutter);
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: var(--page-gutter);
  padding: 12px 16px 10px;
  background: var(--glass);
  backdrop-filter: blur(12px);
}

.seek {
  --progress: 0%;
  display: block;
  width: 100%;
  height: 20px;
  appearance: none;
  background: transparent;
}

.seek::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--accent) 0 var(--progress), var(--line) var(--progress) 100%);
}

.seek::-moz-range-track {
  height: 2px;
  background: var(--line);
}

.seek::-moz-range-progress {
  height: 2px;
  background: var(--accent);
}

.seek::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -5px;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  transition: transform 160ms ease;
}

.seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

.seek:hover::-webkit-slider-thumb {
  transform: scale(1.35);
}

.control-row,
.control-group {
  display: flex;
  align-items: center;
}

.control-row {
  justify-content: space-between;
  gap: 16px;
}

.control-group {
  gap: 4px;
}

.icon-button,
.text-button {
  min-width: 44px;
  min-height: 44px;
  border: 0;
  background: transparent;
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.icon-button {
  display: grid;
  place-items: center;
}

.icon-button:hover,
.text-button:hover {
  color: var(--accent);
  background: oklch(0.99 0.003 90 / 0.06);
}

.icon-button:active,
.text-button:active {
  transform: scale(0.94);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.icon-pause,
.icon-muted,
.icon-collapse,
.is-playing .icon-play,
.is-muted .icon-volume,
.is-fullscreen .icon-expand {
  display: none;
}

.is-playing .icon-pause,
.is-muted .icon-muted,
.is-fullscreen .icon-collapse {
  display: block;
}

.text-button {
  padding: 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.time {
  display: flex;
  gap: 8px;
  margin-left: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.time-divider {
  opacity: 0.45;
}

@media (max-width: 640px) {
  .masthead {
    padding-top: calc(16px + env(safe-area-inset-top));
    font-size: 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .edition {
    gap: 8px;
    letter-spacing: 0.12em;
  }

  .opening h1 {
    font-size: clamp(68px, 24vw, 110px);
  }

  .lyrics {
    bottom: calc(124px + env(safe-area-inset-bottom));
  }

  .lyric-line {
    max-width: 34ch;
    font-size: clamp(26px, 8vw, 42px);
    line-height: 1.08;
  }

  .lyric-progress {
    margin-top: 16px;
  }

  .instrumental {
    bottom: calc(138px + env(safe-area-inset-bottom));
  }

  .controls {
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    left: 12px;
    padding: 8px 8px 6px;
  }

  .time {
    gap: 5px;
    margin-left: 4px;
    font-size: 11px;
  }

  .text-button {
    padding: 0 6px;
    font-size: 10px;
  }

  .gate-content {
    right: 24px;
    bottom: calc(104px + env(safe-area-inset-bottom));
    left: 24px;
    padding-right: 0;
  }

  .gate-content h2 {
    font-size: clamp(68px, 24vw, 110px);
  }

  .gate-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    min-height: 52px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .masthead {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .lyrics {
    bottom: 94px;
  }

  .lyric-line {
    font-size: clamp(24px, 5vw, 42px);
  }

  .controls {
    bottom: 8px;
  }

  .gate-content {
    bottom: 76px;
  }

  .gate-content h2 {
    font-size: 64px;
  }

  .gate-kicker,
  .gate-copy {
    margin-bottom: 12px;
  }

  .gate-copy,
  .gate-actions {
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}
