/* ---------------------------------------------------------
   Quiet Hours — tokens
--------------------------------------------------------- */
:root {
  --ink: #14171f;
  --ink-deep: #0d0f15;
  --panel: #1c212b;
  --brass: #d9a15b;
  --brass-soft: #d9a15b66;
  --brass-dim: #d9a15b26;
  --parchment: #ede6d9;
  --dim: #8b8fa3;
  --font-display: "Fraunces", serif;
  --font-label: "Barlow Condensed", sans-serif;
  --font-body: "Manrope", sans-serif;

  /* Overlay tones — translucent surfaces layered on --panel/--ink.
     Flipped to dark-on-light in the [data-theme="light"] override below. */
  --line: #ffffff10;
  --line-soft: #ffffff0c;
  --line-strong: #ffffff12;
  --surface-1: #ffffff0d;
  --surface-hover: #ffffff08;
  --surface-strong: #ffffff22;
  --shadow-soft: #00000090;
  --shadow-deep: #000000b0;
  --shadow-medium: #00000066;
  --shadow-a0: #000000a0;
  --grain-opacity: 0.05;

  color-scheme: dark;
}

:root[data-theme="light"] {
  --ink: #f3ede1;
  --ink-deep: #e8ddc9;
  --panel: #fffcf6;
  --brass: #b5732a;
  --brass-soft: #b5732a55;
  --brass-dim: #b5732a1f;
  --parchment: #241f1a;
  --dim: #6b6459;

  --line: #00000016;
  --line-soft: #00000010;
  --line-strong: #0000001c;
  --surface-1: #00000012;
  --surface-hover: #0000000a;
  --surface-strong: #00000028;
  --shadow-soft: #00000030;
  --shadow-deep: #00000042;
  --shadow-medium: #00000020;
  --shadow-a0: #00000038;
  --grain-opacity: 0.035;

  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  background: var(--ink);
  color: var(--parchment);
  font-family: var(--font-body);
  overflow-x: hidden;
  overflow-y: auto;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------------------------------------------------------
   Scene — full-viewport stage, no page scroll
--------------------------------------------------------- */
.scene {
  position: relative;
  height: 100dvh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vh, 32px);
}

.scene__vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 45% at 50% 38%, var(--brass-dim), transparent 70%),
    radial-gradient(ellipse 90% 70% at 50% 100%, var(--shadow-medium), transparent 60%),
    var(--ink);
  z-index: 0;
}

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

/* ---------------------------------------------------------
   Console card
--------------------------------------------------------- */
.console {
  position: relative;
  z-index: 2;
  width: min(880px, 100%);
  height: min(720px, 100%);
  background: linear-gradient(180deg, var(--panel), var(--ink-deep));
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 40px 80px -30px var(--shadow-soft), inset 0 1px 0 var(--surface-1);
  display: grid;
  grid-template-columns: 40% 55%;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "brand   brand"
    "stage   info"
    "moods   moods";
  padding: clamp(20px, 3vw, 40px) clamp(24px, 4vw, 52px);
  gap: 8px 5%;
}

.console__brand { grid-area: brand; }

.eyebrow {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0;
}

.tagline {
  font-family: var(--font-label);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin: 2px 0 0;
}

/* ---------------------------------------------------------
   Stage — dial + vinyl
--------------------------------------------------------- */
.console__stage {
  grid-area: stage;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

.dial {
  position: relative;
  width: min(90%, 260px);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dial__ring {
  position: absolute;
  inset: -14%;
  width: 128%;
  height: 128%;
  transition: filter 0.4s ease;
}

.vinyl {
  position: relative;
  width: 90%;
  height: 90%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vinyl__grooves {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background:
    conic-gradient(from 240deg,
      transparent 26deg,
      transparent 334deg,
      rgba(255, 255, 255, 0.09) 360deg),
    conic-gradient(from 120deg,
      transparent 26deg,
      transparent 334deg,
      rgba(255, 255, 255, 0.09) 360deg),
    conic-gradient(from 0deg,
      transparent 26deg,
      transparent 334deg,
      rgba(255, 255, 255, 0.09) 360deg),
    repeating-radial-gradient(circle at 50% 50%,
      #05060a 0px, #05060a 2px,
      #14171f 3px, #14171f 5px);
  box-shadow:
    0 18px 40px -14px #000000b0,
    inset 0 0 0 1px #ffffff12,
    inset 0 0 30px #00000090;
  animation: spin 9s linear infinite;
  animation-play-state: paused;
}

.dial[data-playing="true"] .vinyl__grooves {
  animation-play-state: running;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.vinyl__label {
  position: relative;
  z-index: 1;
  width: 64%;
  height: 64%;
  border-radius: 50%;
  background: #05060a;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px var(--brass-soft), 0 4px 16px #000000a0;
}

.vinyl__screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.vinyl__screen iframe {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 178%;
  height: 100%;
  transform: translate(-50%, -50%);
  display: block;
  border: none;
  pointer-events: none;
}

/* ---------------------------------------------------------
   Info — mood name, description, elapsed
--------------------------------------------------------- */
.console__info {
  grid-area: info;
  position: absolute;
  top: 35%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.4vh, 14px);
  min-height: 0;
  min-width: 0;
}

.track-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.3vw, 30px);
  line-height: 1.3;
  color: var(--parchment);
  margin: 0;
  padding: 0 12px;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}

.track-title__text {
  display: inline-block;
  white-space: nowrap;
  will-change: transform;
}

.track-author {
  font-family: var(--font-label);
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--brass);
  margin: 0;
  padding-top: 10px;
  text-align: center;
}

.elapsed {
  font-family: "Barlow Condensed", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  font-size: 18px;
  color: var(--dim);
  margin: 0;
  padding-top: 5px;
  text-align: center;
}

/* ---------------------------------------------------------
   Controls — transport + volume, stacked under the track info
--------------------------------------------------------- */
.console__controls {
  grid-area: info;
  position: absolute;
  top: 65%;
  left: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.console__transport {
  display: flex;
  align-items: center;
  gap: 14px;
}

.btn {
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--parchment);
  transition: transform 0.15s ease, color 0.2s ease, background 0.2s ease;
}

.btn:hover { color: var(--brass); }
.btn:active { transform: scale(0.94); }
.btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

.btn--ghost {
  width: 44px;
  height: 44px;
  color: var(--dim);
}
.btn--ghost:hover { color: var(--parchment); background: var(--surface-hover); }

.btn--primary {
  width: 68px;
  height: 68px;
  background: radial-gradient(circle at 35% 30%, #eab876, var(--brass) 75%);
  color: #2a1b0c;
  box-shadow: 0 10px 26px -8px #d9a15b70, inset 0 1px 0 #ffffff60;
}
.btn--primary:hover { color: #2a1b0c; transform: translateY(-1px) scale(1.03); }
.btn--primary svg { margin-left: 2px; }
.btn--primary .icon-pause { margin-left: 0; }

.btn--toggle[aria-pressed="true"] {
  color: #2a1b0c;
  background: radial-gradient(circle at 35% 30%, #eab876, var(--brass) 75%);
  box-shadow: 0 6px 16px -6px #d9a15b70, inset 0 1px 0 #ffffff60;
}
.btn--toggle[aria-pressed="true"]:hover { color: #2a1b0c; }

/* ---------------------------------------------------------
   Volume — sits below transport
--------------------------------------------------------- */
.console__volume {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--dim);
  width: min(220px, 100%);
  padding-top: 30px;
}

.console__volume svg {
  flex: none;
}

.console__volume input[type="range"] {
  flex: 1;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: var(--surface-strong);
  outline: none;
}
.console__volume input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 1px var(--brass-soft);
  cursor: pointer;
}
.console__volume input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ink);
  cursor: pointer;
}

/* ---------------------------------------------------------
   Meta — attribution link
--------------------------------------------------------- */
.console__meta {
  grid-area: moods;
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid var(--line-strong);
}

.yt-link {
  font-family: var(--font-label);
  font-size: 14px;
  letter-spacing: 0.03em;
  color: var(--dim);
  text-decoration: none;
  transition: color 0.2s ease;
}

.yt-link:hover { color: var(--brass); }
.yt-link:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

/* ---------------------------------------------------------
   Theme toggle — day/night switch, pinned to the shared card
--------------------------------------------------------- */
.btn--theme {
  position: absolute;
  z-index: 3;
  width: 40px;
  height: 40px;
  background: var(--surface-1);
  color: var(--dim);
}

.btn--theme:hover { background: var(--surface-hover); color: var(--parchment); }

/* ---------------------------------------------------------
   Playlist — fixed 10-track list, sits below the fold
--------------------------------------------------------- */
.playlist {
  position: relative;
  z-index: 2;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 32px) 64px;
}

.playlist__header { padding: 0 2px; }

.playlist__title {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 6px;
}

.playlist__subtitle {
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.4;
  color: var(--dim);
  margin: 0;
}

.playlist__list,
.playlist__list li {
  list-style: none;
}

.playlist__list {
  margin: 18px 0 0;
  padding: 0;
  background: linear-gradient(180deg, var(--panel), var(--ink-deep));
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.playlist__list li { margin: 0; }
.playlist__list li + li { border-top: 1px solid var(--line-soft); }

.playlist__item {
  /* iOS Safari paints native chrome over buttons (ignoring flex/gap/bg)
     unless appearance is explicitly reset — this is what breaks the row
     layout on mobile if left unset. */
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--parchment);
  text-align: left;
  padding: 13px 18px;
  font: inherit;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.3;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease;
}

.playlist__item:hover { background: var(--surface-hover); }
.playlist__item:active { background: var(--line); }
.playlist__item:focus-visible { outline: 2px solid var(--brass); outline-offset: -2px; }

.playlist__index {
  flex: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-1);
  font-family: "Barlow Condensed", monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--dim);
}

.playlist__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playlist__item[aria-current="true"] {
  background: var(--brass-dim);
  color: var(--brass);
}

.playlist__item[aria-current="true"] .playlist__index {
  background: var(--brass);
  color: #2a1b0c;
}

/* ---------------------------------------------------------
   Desktop layout — one shared card, player left / playlist right
--------------------------------------------------------- */
@media (min-width: 721px) and (min-height: 621px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100dvh;
    overflow: hidden;
  }

  .layout {
    position: relative;
    display: flex;
    width: min(1180px, 96vw);
    height: min(760px, 94dvh);
    background: linear-gradient(180deg, var(--panel), var(--ink-deep));
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: 0 40px 80px -30px var(--shadow-soft), inset 0 1px 0 var(--surface-1);
    overflow: hidden;
  }

  .btn--theme {
    top: auto;
    right: auto;
    bottom: clamp(16px, 3vh, 28px);
    left: clamp(36px, 3vw, 48px);
  }

  .scene {
    position: relative;
    flex: 1 1 56%;
    height: 100%;
    width: auto;
    padding: clamp(20px, 3vw, 40px) clamp(24px, 4vw, 40px);
    border-right: 1px solid var(--line);
  }

  .console {
    width: 100%;
    height: 100%;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .playlist {
    flex: 1 1 44%;
    height: 100%;
    width: auto;
    margin: 0;
    padding: clamp(20px, 3vw, 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }

  .playlist__list {
    flex: 1;
    background: none;
    border: none;
    border-radius: 0;
    overflow: visible;
  }
}

/* ---------------------------------------------------------
   Mobile layout — stacked, still single viewport
--------------------------------------------------------- */
@media (max-width: 720px), (max-height: 620px) {
  :root {
    --mobile-gap: clamp(10px, 3.5vw, 20px);
  }

  body {
    height: auto;
    min-height: 100%;
    padding: var(--mobile-gap);
  }

  .layout {
    position: relative;
    display: flex;
    flex-direction: column;
    width: min(520px, 100%);
    margin: 0 auto;
    min-height: calc(100dvh - (var(--mobile-gap) * 2));
    background: linear-gradient(180deg, var(--panel), var(--ink-deep));
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: 0 40px 80px -30px var(--shadow-soft), inset 0 1px 0 var(--surface-1);
    overflow: hidden;
  }

  .btn--theme {
    top: clamp(12px, 3vw, 20px);
    right: clamp(12px, 3vw, 20px);
    bottom: auto;
    left: auto;
  }

  .scene {
    height: auto;
    flex: none;
    padding: clamp(16px, 4vw, 24px) clamp(16px, 4vw, 24px) clamp(8px, 2vh, 16px);
  }

  .console {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
    grid-template-areas:
      "brand"
      "stage"
      "info"
      "controls"
      "moods";
    width: 100%;
    height: auto;
    background: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    gap: clamp(6px, 1.6vh, 14px);
  }

  .console__stage { padding: clamp(2px, 1vh, 10px) 0; }

  .dial { width: clamp(140px, 42vw, 220px); }

  .console__info {
    position: static;
    top: auto;
    transform: none;
    align-items: center;
    text-align: center;
    gap: 4px;
  }

  .track-title { font-size: clamp(17px, 4.6vw, 21px); max-width: min(24ch, 100%); margin: 0 auto; }

  .console__controls {
    grid-area: controls;
    position: static;
    top: auto;
    transform: none;
    align-items: center;
    margin: 0;
    width: 100%;
    min-width: 0;
    gap: 12px;
    padding: 20px 0;
  }

  .console__transport {
    justify-content: center;
    width: 100%;
    min-width: 0;
    gap: clamp(6px, 2.6vw, 10px);
  }

  .btn--ghost {
    width: clamp(34px, 10vw, 44px);
    height: clamp(34px, 10vw, 44px);
  }

  .btn--primary {
    width: clamp(54px, 16vw, 68px);
    height: clamp(54px, 16vw, 68px);
  }

  .console__volume {
    width: min(240px, 90%);
    max-width: 100%;
    margin: 0 auto;
  }

  .console__meta { justify-content: center; }

  .playlist {
    width: 100%;
    margin: 0;
    padding: 16px clamp(16px, 4vw, 24px) 32px;
    border-top: 1px solid var(--line);
  }

  .playlist__list {
    background: none;
    border: none;
    border-radius: 0;
  }

  .playlist__item { padding: 12px 16px; font-size: 13px; }
}

/* ---------------------------------------------------------
   Motion & focus
--------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .vinyl__grooves { animation: none; }
  .btn, .yt-link { transition: none; }
}
