/* =====================================================================
 * Audible Wallpaper · /play
 * Full-bleed audio-reactive WebGL canvas with minimal floating chrome.
 * The wall is the page. Controls fade out on idle and lift back on
 * any pointer movement. Color/typography stay close to the splash so
 * /play and / read as the same project.
 * ===================================================================== */

* {
  box-sizing: border-box;
}

:root {
  --ink: rgba(255, 255, 255, .92);
  --ink-soft: rgba(255, 255, 255, .68);
  --ink-mute: rgba(255, 255, 255, .42);
  --line: rgba(255, 255, 255, .14);
  --gold: #d9b46f;
  --bg: #0a0d1a;
  --chrome-fade: 700ms cubic-bezier(.22, .61, .36, 1);
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body {
  position: fixed;
  inset: 0;
}

#wallpaper {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  /* The wall responds to touch; the cursor confirms it's a surface. */
  cursor: crosshair;
}

/* While locked the gate covers the canvas; we don't want the canvas
   to consume pointer events meant for the gate. */
.is-locked #wallpaper {
  pointer-events: none;
}

/* =====================================================================
 * Tap-to-begin gate
 * ===================================================================== */

.gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-rows: 1fr auto auto 1fr;
  align-items: center;
  justify-items: center;
  gap: 0;
  padding: clamp(40px, 8vh, 96px) 24px;
  background: radial-gradient(ellipse at center, #1a1c30 0%, #050614 75%);
  cursor: pointer;
  transition: opacity 900ms ease, transform 1100ms cubic-bezier(.22, .61, .36, 1), filter 900ms ease;
  outline: none;
}

.gate.is-gone {
  opacity: 0;
  transform: scale(1.04);
  filter: blur(6px);
  pointer-events: none;
}

.gate-mark {
  grid-row: 2;
  width: min(56vw, 380px);
  max-width: 92vw;
  animation: gateBreath 6.4s ease-in-out infinite;
}

.gate-mark img {
  display: block;
  width: 100%;
  height: auto;
}

@keyframes gateBreath {
  0%, 100% {
    opacity: .96;
    transform: translateY(0) scale(1);
  }
  50% {
    opacity: .82;
    transform: translateY(-2px) scale(1.005);
  }
}

.gate-meta {
  grid-row: 3;
  text-align: center;
  margin-top: clamp(28px, 5vh, 48px);
}

.gate-album {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .92;
}

.gate-prompt {
  margin: 16px 0 0;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 300;
  letter-spacing: -.02em;
  color: var(--ink);
}

.gate-prompt span {
  font-weight: 600;
  position: relative;
  display: inline-block;
  animation: gatePulse 2.4s ease-in-out infinite;
}

@keyframes gatePulse {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50% { opacity: .6; transform: translateY(2px); }
}

.gate-hint {
  margin: clamp(20px, 3vh, 30px) 0 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

@media (prefers-reduced-motion: reduce) {
  .gate-mark,
  .gate-prompt span {
    animation: none;
  }
}

/* =====================================================================
 * Floating chrome (top + bottom)
 * Fades out after a few seconds of inactivity, fades back on movement.
 * ===================================================================== */

.chrome {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  pointer-events: none;
  opacity: 0;
  transform: translateY(0);
  transition: opacity var(--chrome-fade), transform var(--chrome-fade);
}

.is-locked .chrome {
  opacity: 0 !important;
  pointer-events: none !important;
}

body:not(.is-locked) .chrome {
  opacity: 1;
  pointer-events: auto;
}

body.chrome-hidden .chrome {
  opacity: 0;
  pointer-events: none;
}

body.chrome-hidden .chrome-top {
  transform: translateY(-8px);
}

body.chrome-hidden .chrome-bottom {
  transform: translateY(10px);
}

.chrome-top {
  top: 0;
  padding: env(safe-area-inset-top) clamp(14px, 3vw, 28px) 0;
  padding-top: max(env(safe-area-inset-top), 14px);
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.chrome-bottom {
  bottom: 0;
  padding: 14px clamp(14px, 3vw, 28px) calc(env(safe-area-inset-bottom) + 18px);
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, 0) 100%);
}

/* Exit button */
.exit {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-top: 8px;
  border-radius: 999px;
  color: var(--ink-soft);
  background: rgba(0, 0, 0, .25);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  transition: color 240ms ease, background 240ms ease, transform 240ms ease;
}

.exit svg {
  width: 18px;
  height: 18px;
}

.exit:hover,
.exit:focus-visible {
  color: var(--ink);
  background: rgba(0, 0, 0, .42);
  transform: scale(1.04);
  outline: none;
}

/* Now playing label */
.now-playing {
  text-align: right;
  margin-top: 10px;
  text-shadow: 0 1px 12px rgba(0, 0, 0, .5);
}

.np-track {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  font-weight: 500;
  letter-spacing: -.01em;
  color: var(--ink);
}

.np-album {
  margin: 2px 0 0;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

/* Track strip */
.track-strip {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.track-chip {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-soft);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .18em;          /* slightly tighter so longer titles fit */
  text-transform: uppercase;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;            /* keep each title on one line */
  transition: color 220ms ease, background 220ms ease, border-color 220ms ease;
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 540px) {
  .track-chip {
    font-size: 10px;
    letter-spacing: .14em;
    padding: 7px 12px;
  }
}

.track-chip:hover,
.track-chip:focus-visible {
  color: var(--ink);
  border-color: rgba(255, 255, 255, .3);
  outline: none;
}

.track-chip.is-active {
  color: #1a1410;
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 4px 22px rgba(217, 180, 111, .25);
}

/* Transport */
.transport {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.ctl {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, .3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 220ms ease, transform 220ms ease, border-color 220ms ease;
  -webkit-tap-highlight-color: transparent;
}

.ctl svg {
  width: 18px;
  height: 18px;
}

.ctl-play {
  width: 56px;
  height: 56px;
  background: rgba(255, 255, 255, .12);
  border-color: rgba(255, 255, 255, .28);
}

.ctl-play svg {
  width: 22px;
  height: 22px;
}

.ctl:hover,
.ctl:focus-visible {
  transform: scale(1.05);
  background: rgba(255, 255, 255, .15);
  border-color: rgba(255, 255, 255, .3);
  outline: none;
}

.ctl-play:hover {
  background: rgba(255, 255, 255, .2);
}

.ctl-play .ico-pause { display: none; }
.ctl-play[data-state="playing"] .ico-play { display: none; }
.ctl-play[data-state="playing"] .ico-pause { display: block; }

/* Scrub bar. The visible runner is 3px tall but the click/touch
   target is much taller (via padding) so it's easy to grab on
   phones. The track is a positioned wrapper so the fill can grow
   inside it without affecting the hit area. */
.scrub {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .12em;
  color: var(--ink-mute);
  font-variant-numeric: tabular-nums;
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 0 4px;
}

.scrub-track {
  flex: 1;
  position: relative;
  height: 22px;                        /* generous hit area */
  padding: 10px 0;                     /* visible track centered inside */
  cursor: pointer;
  touch-action: none;                  /* prevent page scroll while scrubbing */
  -webkit-tap-highlight-color: transparent;
}

/* Visible track */
.scrub-track::before {
  content: "";
  display: block;
  height: 2px;
  background: rgba(255, 255, 255, .14);
  border-radius: 999px;
  transition: height 220ms ease, background-color 220ms ease;
}

.scrub-track:hover::before,
.scrub-track:focus-visible::before,
.scrub-track.is-scrubbing::before {
  height: 4px;
  background: rgba(255, 255, 255, .22);
}

.scrub-track:focus-visible {
  outline: none;
}

/* Fill is absolutely positioned so it sits on top of the visible
   track regardless of the surrounding padding hit area. */
.scrub-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 2px;
  width: 0%;
  background: linear-gradient(to right, var(--gold), rgba(255, 255, 255, .8));
  border-radius: 999px;
  transition: width 160ms linear, height 220ms ease;
  pointer-events: none;
}

.scrub-track:hover .scrub-fill,
.scrub-track:focus-visible .scrub-fill,
.scrub-track.is-scrubbing .scrub-fill {
  height: 4px;
  transition: width 0ms linear, height 220ms ease;  /* snap during drag */
}


/* Palette picker — a row of color dots, each a gradient preview of
   the palette's mid → peak colors. Tap to select. The Mood and Depth
   sliders below operate within whichever palette is active. */
.palette-picker {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  align-items: center;
}

.palette-dot {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255, 255, 255, .18);
  width: 26px;
  height: 26px;
  border-radius: 999px;
  cursor: pointer;
  padding: 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
  -webkit-tap-highlight-color: transparent;
}

.palette-dot:hover,
.palette-dot:focus-visible {
  transform: scale(1.08);
  border-color: rgba(255, 255, 255, .55);
  outline: none;
}

.palette-dot.is-active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .55), 0 0 0 4px rgba(255, 255, 255, .85), 0 4px 14px rgba(0, 0, 0, .45);
  transform: scale(1.06);
}

@media (max-width: 540px) {
  .palette-dot {
    width: 22px;
    height: 22px;
  }
}

/* Dials */
.dials {
  display: flex;
  gap: clamp(14px, 3vw, 30px);
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.dial {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dial-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--ink-mute);
  min-width: 38px;
  text-align: right;
}

.dial input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: clamp(100px, 22vw, 180px);
  height: 18px;
  background: transparent;
  cursor: pointer;
}

.dial input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: rgba(255, 255, 255, .14);
  border-radius: 999px;
}

.dial input[type="range"]::-moz-range-track {
  height: 2px;
  background: rgba(255, 255, 255, .14);
  border-radius: 999px;
  border: 0;
}

.dial input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(217, 180, 111, 0);
  border: 0;
  cursor: grab;
  transition: box-shadow 220ms ease, transform 220ms ease;
}

.dial input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  box-shadow: 0 0 0 8px rgba(217, 180, 111, .12);
}

.dial input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--gold);
  border: 0;
  cursor: grab;
}

/* Audio-react toggle pill. Lives next to mood/depth dials. Off by
   default so the wallpaper feels flowy on first impression; tap to
   bring audio reactivity in. */
.toggle-pill {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 7px 14px;
  color: rgba(255, 255, 255, .55);
  cursor: pointer;
  transition: border-color 220ms ease, background-color 220ms ease, color 220ms ease, transform 220ms ease;
  -webkit-tap-highlight-color: transparent;
}

.toggle-pill .toggle-name {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .3em;
  text-transform: uppercase;
}

.toggle-pill:hover,
.toggle-pill:focus-visible {
  border-color: rgba(255, 255, 255, .42);
  color: rgba(255, 255, 255, .8);
  outline: none;
}

.toggle-pill[aria-pressed="true"] {
  border-color: var(--gold);
  background: rgba(217, 180, 111, .14);
  color: var(--gold);
}

.toggle-pill[aria-pressed="true"]:hover {
  background: rgba(217, 180, 111, .22);
}

/* =====================================================================
 * Responsive nudges for narrow phones
 * ===================================================================== */

@media (max-width: 540px) {
  .chrome-bottom { gap: 10px; padding-bottom: calc(env(safe-area-inset-bottom) + 14px); }
  /* Scrub stays visible on mobile — Andy wants quick access to a
     favorite section. The 22px hit area in .scrub-track gives plenty
     of room for thumbs. */
  .scrub { padding: 0 8px; }
  .scrub-time { font-size: 10px; }
  .now-playing { display: none; }
  .dials { gap: 18px; }
  .dial-name { min-width: 30px; font-size: 9px; }
  .dial input[type="range"] { width: clamp(80px, 30vw, 140px); }
  .ctl { width: 42px; height: 42px; }
  .ctl-play { width: 54px; height: 54px; }
}

/* =====================================================================
 * Reduced motion
 * ===================================================================== */

@media (prefers-reduced-motion: reduce) {
  .chrome,
  .chrome-top,
  .chrome-bottom,
  .gate,
  .ctl,
  .exit,
  .track-chip {
    transition: none !important;
  }
}
