/* ==========================================================================
   दिल का सफर — cinematic Indian-street music player
   Design tokens first, then layout, then components, then responsive rules.
   ========================================================================== */

@media (prefers-color-scheme: light) {
  /* App is intentionally always dark/cinematic — no light-mode branch needed,
     this query exists only so the intent is explicit for future editors. */
}

:root {
  /* ---- palette (named, per reference: brick / maroon / burnt-orange / cream) ---- */
  --color-cream: #f3e7d3;
  --color-brick: #a6402f;
  --color-maroon: #4a1712;
  --color-maroon-deep: #200b09;
  --color-burnt-orange: #d97a2e;
  --color-charcoal: #17100e;
  --color-olive: #5b6b49;
  --color-gold: #e3a94c;

  /* ---- semantic / configurable tokens (mentioned in the brief) ---- */
  --background-overlay: linear-gradient(
    180deg,
    rgba(32, 11, 9, 0.1) 0%,
    rgba(32, 11, 9, 0.38) 55%,
    rgba(15, 6, 5, 0.72) 100%
  );
  --player-bg-rgb: 43, 16, 14;
  --player-opacity: 0.8;
  --player-background: rgba(var(--player-bg-rgb), var(--player-opacity));
  --accent-color: var(--color-gold);
  --text-primary: #f8f1e4;
  --text-secondary: rgba(248, 241, 228, 0.62);
  --progress-color: var(--color-gold);

  /* ---- type ---- */
  --font-display: "Yatra One", "Noto Serif Devanagari", "Kohinoor Devanagari", "Nirmala UI", serif;
  --font-ui: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* ---- shape / shadow ---- */
  --player-radius: 60px;
  --shadow-soft: 0 20px 55px rgba(8, 3, 2, 0.5);
  --shadow-btn: 0 8px 20px rgba(8, 3, 2, 0.35);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-maroon-deep);
  font-family: var(--font-ui);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

button:focus-visible,
a:focus-visible,
.progress-track:focus-visible,
.volume-slider:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
  border-radius: 4px;
}

img {
  -webkit-user-drag: none;
  user-select: none;
}

/* ==========================================================================
   BACKGROUND LAYER
   ========================================================================== */

.bg-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  overflow: hidden;
}

.bg-illustration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.skyline-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.string-bulbs circle {
  filter: drop-shadow(0 0 4px rgba(255, 217, 138, 0.85));
}

/* configurable static background photo (CONFIG.backgroundImage) */
.bg-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 900ms ease;
}

.bg-photo.is-visible {
  opacity: 1;
}

/* dynamic per-song wash, sits above the static photo/illustration */
.bg-photo--dynamic {
  filter: blur(38px) saturate(1.15) brightness(0.6);
  transform: scale(1.15);
  opacity: 0;
  transition: opacity 1100ms ease;
}

.bg-photo--dynamic.is-visible {
  opacity: 0.65;
}

.bg-overlay {
  position: absolute;
  inset: 0;
  background: var(--background-overlay);
}

.bg-grain {
  position: absolute;
  inset: -10%;
  width: 120%;
  height: 120%;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  animation: grainShift 8s steps(6) infinite;
}

@keyframes grainShift {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-2%, 2%); }
  40% { transform: translate(2%, -1%); }
  60% { transform: translate(-1%, -2%); }
  80% { transform: translate(1%, 1%); }
  100% { transform: translate(0, 0); }
}

/* ==========================================================================
   TOP-LEFT CLOCK
   ========================================================================== */

.clock {
  position: fixed;
  top: 26px;
  left: 28px;
  z-index: 10;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ==========================================================================
   TOP-RIGHT SERVICE NAV
   ========================================================================== */

.service-nav {
  position: fixed;
  top: 24px;
  right: 28px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
}

.online-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-weight: 500;
}

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6cd67a;
  box-shadow: 0 0 0 0 rgba(108, 214, 122, 0.6);
  animation: pulseDot 2.2s ease-out infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(108, 214, 122, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(108, 214, 122, 0); }
  100% { box-shadow: 0 0 0 0 rgba(108, 214, 122, 0); }
}

.service-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  opacity: 0.85;
  transition: opacity 180ms ease, transform 180ms ease;
}

.service-link:hover {
  opacity: 1;
  transform: translateY(-1px);
}

.ext-arrow {
  font-size: 11px;
  opacity: 0.7;
}

/* ==========================================================================
   HERO TITLE
   ========================================================================== */

.hero-title {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.6rem, 9vw, 6.2rem);
  color: rgba(248, 241, 228, 0.92);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  user-select: none;
  transition: opacity 400ms ease;
}

.hero-title.is-hidden {
  display: none;
}

/* ==========================================================================
   STATUS / LOADING / ERROR BANNER
   ========================================================================== */

.status-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  padding: 10px 20px;
  border-radius: 30px;
  background: rgba(20, 8, 7, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13.5px;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-banner.is-visible {
  opacity: 1;
}

.status-banner.is-error {
  background: rgba(90, 20, 15, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid rgba(248, 241, 228, 0.3);
  border-top-color: var(--color-gold);
  animation: spin 800ms linear infinite;
  flex: none;
}

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

/* ==========================================================================
   YOUTUBE PLAYER — functional but invisible
   ========================================================================== */

.yt-hidden {
  position: fixed;
  width: 2px;
  height: 2px;
  overflow: hidden;
  opacity: 0.01;
  pointer-events: none;
  bottom: 0;
  left: 0;
  z-index: -1;
}

/* ==========================================================================
   FLOATING PLAYER
   ========================================================================== */

.player {
  position: fixed;
  left: 50%;
  bottom: 32px;
  z-index: 20;
  width: min(700px, 92vw);
  min-height: 118px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 26px 14px 14px;
  border-radius: var(--player-radius);
  background: var(--player-background);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
  transform: translate(-50%, 40px);
  opacity: 0;
  animation: playerEnter 700ms cubic-bezier(0.16, 1, 0.3, 1) 200ms forwards;
}

@keyframes playerEnter {
  to {
    transform: translate(-50%, 0);
    opacity: 1;
  }
}

.player:hover {
  box-shadow: 0 24px 65px rgba(8, 3, 2, 0.58);
}

/* ---- album art ---- */

.player-art-ring {
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  padding: 4px;
  background: conic-gradient(from 180deg, rgba(227, 169, 76, 0.7), rgba(227, 169, 76, 0));
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-art {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-maroon);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  animation: rotateArt 16s linear infinite;
  animation-play-state: paused;
}

.player.is-playing .player-art {
  animation-play-state: running;
}

@keyframes rotateArt {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ---- song info + progress ---- */

.player-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.track-meta {
  min-width: 0;
}

.track-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.track-artist {
  margin: 2px 0 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.time-label {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  flex: none;
  width: 34px;
}

#durationTime {
  text-align: right;
}

.progress-track {
  position: relative;
  flex: 1 1 auto;
  height: 14px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.progress-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 4px;
  background: rgba(248, 241, 228, 0.18);
}

.progress-fill {
  position: absolute;
  left: 0;
  height: 4px;
  width: 0%;
  border-radius: 4px;
  background: var(--progress-color);
  transition: width 120ms linear;
}

.progress-handle {
  position: absolute;
  left: 0%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(227, 169, 76, 0.25);
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 150ms ease;
}

.progress-track:hover .progress-handle,
.progress-track:focus-visible .progress-handle {
  opacity: 1;
}

/* ---- controls ---- */

.player-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ctrl-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  opacity: 0.85;
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.ctrl-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
  transform: scale(1.06);
}

.ctrl-btn:active {
  transform: scale(0.94);
}

.play-btn {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-cream);
  color: var(--color-charcoal);
  box-shadow: var(--shadow-btn);
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 160ms ease;
}

.play-btn svg {
  margin-left: 1px;
}

#iconPause {
  margin-left: 0;
}

.play-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 10px 26px rgba(8, 3, 2, 0.45);
}

.play-btn:active {
  transform: scale(0.95);
}

.volume-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 70px;
  height: 3px;
  border-radius: 3px;
  background: rgba(248, 241, 228, 0.22);
  outline: none;
  cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
}

.volume-slider::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border: none;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
}

/* ==========================================================================
   RESPONSIVE — TABLET
   ========================================================================== */

@media (max-width: 900px) {
  .player {
    width: 88vw;
  }

  .hero-title {
    font-size: clamp(2.6rem, 10vw, 5.5rem);
  }
}

/* ==========================================================================
   RESPONSIVE — MOBILE
   ========================================================================== */

@media (max-width: 620px) {
  .clock {
    top: 16px;
    left: 16px;
    font-size: 11.5px;
  }

  .service-nav {
    top: 15px;
    right: 16px;
    gap: 12px;
  }

  .online-pill span:last-child {
    display: none;
  }

  .service-link span:first-of-type {
    display: none;
  }

  .hero-title {
    font-size: clamp(2.2rem, 13vw, 3.4rem);
    top: 36%;
  }

  .player {
    bottom: 16px;
    width: 94vw;
    min-height: 0;
    border-radius: 32px;
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  .player-art-ring {
    width: 52px;
    height: 52px;
  }

  .track-title {
    font-size: 14.5px;
  }

  .track-artist {
    font-size: 11.5px;
  }

  .player-body {
    flex: 1 1 auto;
    order: 2;
    gap: 6px;
  }

  .player-controls {
    order: 3;
    width: 100%;
    justify-content: center;
    gap: 18px;
    padding-top: 4px;
  }

  .volume-wrap {
    display: none;
  }

  .play-btn {
    width: 50px;
    height: 50px;
  }
}

@media (max-width: 360px) {
  .hero-title {
    font-size: clamp(1.8rem, 14vw, 2.6rem);
  }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .player-art,
  .bg-grain,
  .online-dot,
  .player {
    animation: none !important;
  }

  .player {
    opacity: 1;
    transform: translate(-50%, 0);
  }

  * {
    transition-duration: 0.01ms !important;
  }
}
