/* ─────────────────────────────────────────────────────────────
   Hornokplaylist
   The artwork carries all the colour. Everything the app draws
   on top is neutral glass, so it sits on any background image.
   ───────────────────────────────────────────────────────────── */

:root {
  --edge: clamp(1rem, 2.2vw, 1.75rem);
  --glass: rgba(255, 255, 255, 0.1);
  --glass-line: rgba(255, 255, 255, 0.2);
  --shadow-glass: 0 8px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  --text-shadow: 0 1px 6px rgba(0, 0, 0, 0.55);

  /* Baloo 2 is the Devanagari member of the family — "Baloo Bhai 2" is the
     Gujarati one and carries no U+0900–097F, so it silently fell back to a
     system font. The fallbacks below are the Devanagari faces that ship with
     macOS, Windows and Android, for the moment before the webfont lands. */
  --body: "Baloo 2", "Kohinoor Devanagari", "Nirmala UI", "Noto Sans Devanagari",
    ui-rounded, system-ui, sans-serif;

  /* Baloo is a heavy display face — right for the wordmark, too shouty for
     small chrome. The top bar uses the platform UI face instead: lighter,
     crisper at 13px, and free. */
  --ui: ui-sans-serif, -apple-system, "Segoe UI Variable Text", "Segoe UI",
    system-ui, sans-serif;

  /* Motion. One vocabulary, used everywhere — mismatched curves are what
     make an interface feel assembled rather than designed.
     `swift` for pointer feedback, `glide` for anything that travels,
     `settle` for entrances that should decelerate into place. */
  --swift: 140ms cubic-bezier(0.4, 0, 0.2, 1);
  --glide: 320ms cubic-bezier(0.4, 0, 0.2, 1);
  --settle: 620ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-settle: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
}

/* Available to crawlers and screen readers, invisible on screen. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--body);
  color: #fff;
  background: #0a1416;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ── Entrance ───────────────────────────────────────────────
   Everything rises into place once, slightly staggered, instead of
   snapping in as the CSS parses. */

@keyframes rise {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.topbar,
.dock {
  animation: rise var(--settle) both;
}

.topbar {
  animation-delay: 0.28s;
}
.dock {
  animation-delay: 0.16s;
}

/* ── Background ─────────────────────────────────────────────── */

/* Looping windshield POV, dashboard mandir lit up. background-color is what
   shows for the instant before the poster frame paints. */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-color: #0a1416;
  overflow: hidden;
}

.bg__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  /* cover, not contain — always fills the viewport edge to edge, no
     pillarboxing. Trims whatever sliver doesn't match the video's aspect
     ratio, off the top/bottom rather than the sides. */
  object-fit: cover;
  object-position: center;
}

/* Keeps white text legible over a bright photograph. */
.bg__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.28) 0%,
    rgba(0, 0, 0, 0.06) 26%,
    rgba(0, 0, 0, 0.1) 58%,
    rgba(0, 0, 0, 0.48) 100%
  );
  pointer-events: none;
}

.yt-host {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

main {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* .dock is the only child now the wordmark's gone. space-between had
     nothing left to push it away from, which shoved it to the top —
     flex-end keeps it pinned where it always sat, at the bottom. */
  justify-content: flex-end;
  padding: max(var(--edge), env(safe-area-inset-top)) var(--edge)
    max(var(--edge), env(safe-area-inset-bottom));
}

/* ── Corner chrome ──────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: max(1.15rem, env(safe-area-inset-top));
  left: var(--edge);
  right: var(--edge);
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  text-shadow: var(--text-shadow);
}

.clock {
  justify-self: start;
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.92);
}

.presence {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.92);
}

/* Author display: overrides the UA [hidden] rule at equal specificity —
   without this, app.js setting .hidden=true had no visible effect and
   the placeholder "42" just sat there permanently, looking like fake
   live data. */
.presence[hidden] {
  display: none;
}

.presence__dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.9);
}

.presence__dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #4ade80;
  opacity: 0.75;
  animation: ping 1.9s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.presence__count {
  font-variant-numeric: tabular-nums;
}

.presence__label {
  font-weight: 400;
  color: rgba(255, 255, 255, 0.62);
}

.odometer {
  grid-column: 1; /* row 2 falls under the clock, not the centre pill */
  justify-self: start;
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-top: 0.2rem;
  font-family: var(--ui);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.62);
}

.odometer__count {
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.85);
}

@keyframes ping {
  75%,
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* Pinned directly to the corner instead of relying on the grid's third
   column — simpler to reason about and immune to track-sizing edge cases. */
.links {
  position: absolute;
  right: 0;
  top: 50%;
  translate: 0 -50%;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.link {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  transition: background var(--swift), transform var(--swift), color var(--swift);
}

.link:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.link:active {
  transform: scale(0.95);
}

/* ── Player dock ────────────────────────────────────────────── */

.dock {
  position: relative;
  width: 100%;
  max-width: 30rem;
  margin-bottom: clamp(0.5rem, 7vh, 4.5rem);
}

.player {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0.9rem 0.4rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  box-shadow: var(--shadow-glass);
}

/* Album art as a spinning record */
.disc {
  position: relative;
  width: 3.25rem;
  height: 3.25rem;
  flex: none;
}

.disc__ring {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  outline: 1px solid rgba(255, 255, 255, 0.2);
  outline-offset: -1px;
  background: #1a1a1a;
  animation: spin 8s linear infinite;
  animation-play-state: paused;
}

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

.disc__art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* iTunes art is square and needs no help. YouTube thumbnails are 4:3 with
   letterbox bars around a 16:9 frame, so those get scaled past the bars. */
.disc__art.is-letterboxed {
  transform: scale(1.35);
}

.disc__hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

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

.meta {
  flex: 1;
  min-width: 0;
}

/* Titles crossfade on track change instead of snapping. */
.meta__title,
.meta__artist {
  transition: opacity 220ms ease;
}

.player.is-swapping .meta__title,
.player.is-swapping .meta__artist {
  opacity: 0;
}

/* The artwork eases up to speed rather than jerking into rotation. */
.disc {
  transition: transform var(--glide);
}

.player.is-playing .disc {
  transform: scale(1.03);
}

.meta__title {
  margin: 0;
  font-weight: 700;
  font-size: 0.84rem;
  line-height: 1.25;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta__artist {
  margin: 0;
  font-size: 0.71rem;
  font-weight: 600;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.7);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seek {
  position: relative;
  height: 10px;
  margin-top: 0.2rem;
  cursor: pointer;
  touch-action: none;
}

.seek__rail {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.2);
}

/* Driven by scaleX rather than width — width is a layout property and
   janks; a transform rides the compositor at 60fps. */
.seek__fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

/* Positioned by transform in the rAF loop, so `left` stays at 0. */
.seek__knob {
  position: absolute;
  top: 50%;
  left: 0;
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--swift);
  will-change: transform;
}

.seek:hover .seek__knob,
.seek:focus-visible .seek__knob {
  opacity: 1;
}

.time {
  margin-top: 0.05rem;
  font-size: 0.62rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.6);
}

/* ── Controls ───────────────────────────────────────────────── */

.controls {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  flex: none;
}

.btn {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: background var(--swift), color var(--swift), transform var(--swift);
}

/* Overrides the width/height attributes on the inline SVGs. */
.btn svg {
  width: 15px;
  height: 15px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}
.btn:active {
  transform: scale(0.92);
}

.btn--play {
  width: 2.25rem;
  height: 2.25rem;
  background: #fff;
  color: #000;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.btn--play svg {
  width: 17px;
  height: 17px;
}

/* The play/pause swap is pure CSS off .player.is-playing. Don't reach for
   `svg.hidden = true` here — `hidden` is an HTMLElement property, so on an
   SVG element it silently sets a JS expando and never reflects to the
   attribute, leaving the icon stuck. */
.i-pause,
.player.is-playing .i-play {
  display: none;
}

.player.is-playing .i-pause {
  display: block;
}

.btn--play:hover {
  background: #fff;
  color: #000;
  transform: scale(1.06);
}

.btn--play:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}

.btn--toggle.is-on {
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

/* ── Playlist ───────────────────────────────────────────────── */

/* Pops up over the artwork so the dock never moves. */
.list {
  position: absolute;
  bottom: calc(100% + 0.7rem);
  left: 0;
  right: 0;
  z-index: 5;
  max-height: min(48dvh, 24rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 1.35rem;
  border: 1px solid var(--glass-line);
  background: rgba(20, 20, 22, 0.55);
  backdrop-filter: blur(28px) saturate(150%);
  -webkit-backdrop-filter: blur(28px) saturate(150%);
  box-shadow: var(--shadow-glass);

  /* Animated open/close. `hidden` alone pops; this glides and stays
     interactive-safe because visibility is part of the transition. */
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 10px, 0) scale(0.985);
  transform-origin: bottom center;
  transition:
    opacity var(--glide),
    transform var(--glide),
    visibility 0s linear 320ms;
}

.list.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity var(--glide),
    transform 420ms var(--ease-settle),
    visibility 0s;
}

/* Thin, unobtrusive scrollbar — the default chrome one breaks the glass. */
.list {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.28) transparent;
}

.list::-webkit-scrollbar {
  width: 6px;
}

.list::-webkit-scrollbar-track {
  background: transparent;
}

.list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
}

.list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.list ol {
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  counter-reset: t;
}

.list li {
  counter-increment: t;
}

.list button {
  width: 100%;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  padding: 0.45rem 0.7rem;
  border: none;
  border-radius: 0.7rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  font-family: var(--body);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.list button::before {
  content: counter(t);
  flex: none;
  width: 1.4rem;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.4);
}

.list button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.list li.is-current button {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 800;
}

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

.list .t-artist {
  font-size: 0.74rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sits outside #listItems so renderList()'s innerHTML wipe never touches
   it — a static line after the last track, not part of the playlist. */
.list__credit {
  margin: 0.2rem 0.4rem 0.5rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--glass-line);
  text-align: center;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.5);
}

.list__credit-link {
  display: inline-flex;
  vertical-align: -0.15em;
  margin-left: 0.35em;
  color: inherit;
  transition: color var(--swift);
}

.list__credit-link:hover {
  color: #fff;
}

/* ── Focus ──────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
  border-radius: 8px;
}

/* ── Small screens ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .presence__label {
    display: none;
  }

  .player {
    flex-wrap: wrap;
    padding: 0.75rem;
    border-radius: 1.5rem;
    row-gap: 0.6rem;
  }

  .controls {
    width: 100%;
    justify-content: center;
    gap: 0.35rem;
  }

  .disc {
    width: 3.75rem;
    height: 3.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* Kill travel and looping decoration; keep opacity so nothing that was
     animating in ends up invisible. */
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .disc__ring,
  .presence__dot::after {
    animation: none !important;
  }

  .player.is-playing .disc {
    transform: none;
  }
}
