/* ==========================================================================
   Listening page: three-version player, sign-in and course library.
   Builds on the tokens in styles.css.
   ========================================================================== */

.listen-page { background: #2b2350; }
.listen-page [hidden] { display: none !important; }
.listen {
  min-height: calc(100dvh - 72px);
  padding: clamp(24px, 5vw, 64px) 0 clamp(48px, 8vw, 96px);
}

.listen-grid { display: grid; gap: 24px; align-items: start; }
@media (min-width: 960px) {
  .listen-grid { grid-template-columns: minmax(0, 1.45fr) minmax(320px, 1fr); gap: 40px; }
  .player { position: sticky; top: 96px; }
}

.demo-banner {
  grid-column: 1 / -1; justify-self: start; margin: 0;
  background: var(--peach); color: var(--ink);
  font-size: 0.875rem; font-weight: 500; padding: 8px 16px; border-radius: 999px;
}

/* ---------- Player card ---------- */
.player {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: clamp(22px, 4.5vw, 48px);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  container-type: inline-size;
}
.np-eyebrow { margin-bottom: 1rem; font-size: 0.75rem; }
.np-title { font-size: clamp(2rem, 4.6vw, 3.25rem); margin-bottom: 0.3em; }
.np-desc { color: var(--on-dark-muted); max-width: 34em; margin-bottom: 0; }
.player[data-state="empty"] .versions,
.player[data-state="empty"] .wave,
.player[data-state="empty"] .times { opacity: 0.45; }

/* Version switch: the heart of the player */
.versions {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px;
  margin: clamp(24px, 4vw, 36px) 0 0;
  padding: 4px; border-radius: 22px;
  background: rgb(0 0 0 / 0.22); border: 1px solid var(--glass-border);
}
.versions button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 64px; padding: 10px 6px;
  font: 500 0.875rem/1.2 var(--font); text-align: center; min-width: 0;
  color: var(--on-dark-muted); background: transparent;
  border: 0; border-radius: 18px; cursor: pointer;
  transition: background 0.25s, color 0.25s;
}
.versions button:hover:not([disabled]):not([aria-checked="true"]) { background: var(--glass-strong); color: var(--on-dark); }
.versions button[aria-checked="true"] { background: #fff; color: var(--ink); }
.versions button[disabled] { cursor: not-allowed; opacity: 0.5; }
.v-num {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  font-size: 0.75rem; font-weight: 600; font-variant-numeric: tabular-nums;
  border: 1px solid currentColor;
}
.versions button[aria-checked="true"] .v-num { background: var(--forest); border-color: var(--forest); color: #fff; }
/* Side by side with the number only when all three labels fit on one line */
@container (max-width: 360px) { .versions button { font-size: 0.8125rem; padding-inline: 4px; } }
@container (min-width: 500px) {
  .versions { border-radius: 999px; }
  .versions button { flex-direction: row; gap: 10px; min-height: 56px; border-radius: 999px; font-size: 0.9375rem; white-space: nowrap; }
}

/* Waveform with an invisible range input on top for keyboard and screen readers */
.wave {
  position: relative; height: clamp(72px, 12vw, 104px);
  margin-top: clamp(24px, 4vw, 36px); border-radius: 12px;
}
.wave-layer { position: absolute; inset: 0; pointer-events: none; }
.wave-layer svg { width: 100%; height: 100%; display: block; }
.wave-layer rect {
  transform-box: fill-box; transform-origin: center;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.wave-base rect { fill: rgb(255 255 255 / 0.26); }
.wave-played rect { fill: #fff; }
.wave-played { clip-path: inset(0 100% 0 0); }
.wave.is-flat .wave-layer rect { transform: scaleY(0.08); }
.scrub {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  opacity: 0; cursor: pointer; touch-action: none;
}
.scrub:disabled { cursor: default; }
.wave:has(.scrub:focus-visible) { outline: 3px solid var(--mint); outline-offset: 6px; }

.times {
  display: flex; justify-content: space-between; margin-top: 10px;
  font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--on-dark-faint);
}

/* Transport */
.transport { display: flex; align-items: center; justify-content: center; gap: clamp(20px, 6vw, 40px); margin: 20px 0 4px; }
.t-play, .t-skip {
  position: relative; display: grid; place-items: center;
  border-radius: 50%; cursor: pointer; padding: 0;
  transition: transform 0.2s, background 0.2s, opacity 0.2s;
}
.t-play { width: 84px; height: 84px; background: #fff; color: var(--ink); border: 0; }
.t-play svg { width: 34px; height: 34px; grid-area: 1 / 1; }
.t-play .i-pause, .player[data-playing="true"] .t-play .i-play { display: none; }
.player[data-playing="true"] .t-play .i-pause { display: block; }
.t-play:hover:not([disabled]) { transform: scale(1.04); }
.t-skip { width: 56px; height: 56px; background: transparent; color: var(--on-dark); border: 1px solid var(--glass-border); }
.t-skip svg { width: 30px; height: 30px; grid-area: 1 / 1; }
.t-skip span { grid-area: 1 / 1; font-size: 0.625rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.t-skip:hover:not([disabled]) { background: var(--glass-strong); }
.t-play[disabled], .t-skip[disabled] { opacity: 0.45; cursor: default; }

/* A ring that breathes while the session plays */
.t-ring {
  position: absolute; inset: -10px; border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.28); pointer-events: none;
}
.player[data-playing="true"] .t-ring { animation: ring-breathe var(--breath-cycle) ease-in-out infinite; }
.player[data-buffering="true"][data-playing="true"] .t-ring {
  border-color: rgb(255 255 255 / 0.18); border-top-color: var(--mint);
  animation: ring-spin 0.9s linear infinite;
}
@keyframes ring-breathe { 0%, 100% { transform: scale(1); opacity: 0.5; } 45%, 55% { transform: scale(1.16); opacity: 1; } }
@keyframes ring-spin { to { transform: rotate(360deg); } }

.player-msg { min-height: 1.5em; margin: 16px 0 0; text-align: center; color: var(--peach); font-size: 0.9375rem; }
.player-msg:empty { min-height: 0; margin: 0; }
.kbd-hint { margin: 16px 0 0; text-align: center; font-size: 0.8125rem; color: var(--on-dark-faint); }
@media (hover: none), (max-width: 760px) { .kbd-hint { display: none; } }

/* ---------- Side column ---------- */
.side { display: grid; gap: 24px; }
.side h2 { font-size: 1.375rem; margin-bottom: 0.6em; }

.auth {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: clamp(22px, 3.5vw, 32px);
}
.auth[hidden] { display: none; }
.auth-lead { color: var(--on-dark-muted); font-size: 0.9375rem; }
.auth .field { margin-bottom: 16px; }
.auth .field[hidden] { display: none; }
.auth label { font-size: 0.9375rem; font-weight: 500; color: var(--on-dark); }
.auth input[type="password"], .auth input[type="email"] {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid transparent; border-radius: 14px; padding: 13px 16px;
}
.auth input:focus { outline: 3px solid var(--mint); outline-offset: 2px; box-shadow: none; border-color: transparent; }
.auth-msg { font-size: 0.9375rem; margin: 0 0 14px; }
.auth-msg:empty { display: none; }
.auth-msg[data-tone="error"] { color: var(--error-on-dark); }
.auth-msg[data-tone="ok"] { color: var(--mint); }
.auth-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-top: 12px; }
.link-btn {
  background: none; border: 0; padding: 10px 0; min-height: 44px; cursor: pointer;
  font: inherit; font-size: 0.9375rem; color: var(--on-dark-muted);
  text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--on-dark); }
.link-btn[hidden] { display: none; }

.signed-in { margin: 0; font-size: 0.9375rem; color: var(--on-dark-faint); overflow-wrap: anywhere; }

/* Library */
.library-note { font-size: 0.9375rem; color: var(--on-dark-muted); background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius-sm); padding: 14px 18px; }
.library-note a, .player-msg a { color: var(--mint); }
.tracks { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.track {
  width: 100%; display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto 1.75rem; align-items: center; gap: 12px;
  min-height: 60px; padding: 12px 16px; text-align: left;
  font: inherit; color: var(--on-dark); cursor: pointer;
  background: rgb(255 255 255 / 0.04); border: 1px solid transparent; border-radius: var(--radius-sm);
  transition: background 0.2s, border-color 0.2s;
}
.track:hover { background: var(--glass-strong); }
.track[aria-current="true"] { background: var(--glass-strong); border-color: rgb(255 255 255 / 0.32); }
.track-n, .track-dur { font-size: 0.875rem; font-variant-numeric: tabular-nums; color: var(--on-dark-faint); }
.track-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-status { display: grid; place-items: center; color: var(--on-dark-faint); }
.track-status svg { width: 18px; height: 18px; }
.track[data-state="locked"] .track-title { color: var(--on-dark-faint); font-weight: 400; }
.track[data-state="playing"] .track-status, .track[data-state="current"] .track-status { color: var(--mint); }
.tag { font-size: 0.6875rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mint); }

.eq rect { transform-box: fill-box; transform-origin: bottom; animation: eq 1.1s ease-in-out infinite; }
.eq .eq2 { animation-delay: -0.35s; }
.eq .eq3 { animation-delay: -0.7s; }
@keyframes eq { 0%, 100% { transform: scaleY(0.45); } 50% { transform: scaleY(1); } }

.back-home { margin: 0; }
.back-home a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--on-dark-muted); text-decoration: none; font-size: 0.9375rem; }
.back-home a:hover { color: var(--on-dark); }
.back-home svg { width: 18px; height: 18px; }

/* ---------- Buying ---------- */
.purchase-banner {
  grid-column: 1 / -1; margin: 0;
  background: var(--glass-strong); border: 1px solid var(--glass-border); color: var(--on-dark);
  font-size: 0.9375rem; font-weight: 500; padding: 12px 20px; border-radius: var(--radius-sm);
}
.purchase-banner[data-tone="ok"] { background: rgb(69 141 104 / 0.35); border-color: rgb(154 237 195 / 0.45); }

.shop {
  background: var(--glass); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: clamp(22px, 3.5vw, 32px); display: grid; gap: 14px;
}
.shop h2 { margin: 0; }
.offer {
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  padding: 16px; display: grid; gap: 10px;
}
.offer-main { background: rgb(255 255 255 / 0.08); border-color: rgb(255 255 255 / 0.28); }
.offer-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.offer-head h3 { margin: 0; font-size: 1.125rem; }
.offer-price { margin: 0; font-size: 1.25rem; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.offer-desc { margin: 0; color: var(--on-dark-muted); font-size: 0.9375rem; }
.consent { display: flex; gap: 12px; align-items: flex-start; font-size: 0.9375rem; color: var(--on-dark-muted); cursor: pointer; }
.consent input { flex: none; width: 20px; height: 20px; margin-top: 2px; accent-color: var(--mint); }
.consent a { color: var(--mint); }
.shop-msg { margin: 0; color: var(--error-on-dark); font-size: 0.9375rem; }
.shop-msg:empty { display: none; }
.shop-methods { margin: 0; color: var(--on-dark-faint); font-size: 0.8125rem; }
.test-mode {
  margin: 0; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--peach); color: var(--ink); font-size: 0.875rem; line-height: 1.5;
}
.test-mode strong { font-weight: 600; white-space: nowrap; }

/* Under the transparent header (js/header.js) */
.has-overlay-header .listen { min-height: 100dvh; padding-top: calc(clamp(24px, 5vw, 64px) + 72px); }
