/* ═══════════════════════════════════════════════════════════
   BusDriver.rocks — Redesign v2
   Full-bleed bus image + glassmorphism dock
   Inspired by hornokplease.xyz
   ═══════════════════════════════════════════════════════════ */

:root {
  --edge: clamp(1rem, 2.5vw, 1.75rem);

  /* Glass system */
  --glass:       rgba(10, 5, 0, 0.45);
  --glass-light: rgba(255, 255, 255, 0.10);
  --glass-line:  rgba(255, 255, 255, 0.18);
  --shadow:      0 8px 40px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.18);

  /* Accent — marigold / amber */
  --amber:       #F5A623;
  --amber-glow:  rgba(245, 166, 35, 0.4);
  --route-green: #00FF41;

  /* Typography */
  --font-body:   "Baloo 2", "Kohinoor Devanagari", "Noto Sans Devanagari", system-ui, sans-serif;
  --font-display:"Teko", "Baloo 2", sans-serif;
  --font-led:    "VT323", monospace;
  --font-ui:     ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;

  /* Motion vocabulary */
  --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);
}

/* ─── Accessibility ─────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ─── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: var(--font-body);
  color: #fff;
  background: #0a0500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  /* Anti-scraping and copy prevention */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

img {
  -webkit-user-drag: none;
  user-drag: none;
  pointer-events: none;
}

/* ─── Entrance animations ───────────────────────────────── */
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 16px, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes rise-left {
  from { opacity: 0; transform: translate3d(-18px, 0, 0); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes ping {
  75%, 100% { transform: scale(2.4); opacity: 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
@keyframes wordmark-shake {
  0%  { transform: translate3d(0,0,0) rotate(0); }
  10% { transform: translate3d(-5px, 2px, 0) rotate(-1.2deg); }
  22% { transform: translate3d(5px, -2px, 0) rotate(0.9deg); }
  34% { transform: translate3d(-3px, 1px, 0) rotate(-0.7deg); }
  46% { transform: translate3d(3px, -1px, 0) rotate(0.5deg); }
  58% { transform: translate3d(-2px, 1px, 0) rotate(-0.35deg); }
  72% { transform: translate3d(2px, 0, 0) rotate(0.2deg); }
  86% { transform: translate3d(-1px, 0, 0) rotate(-0.1deg); }
  100%{ transform: none; }
}

@keyframes bus-drive {
  0%   { transform: scale(1.04) translate3d(0, 0, 0); }
  25%  { transform: scale(1.04) translate3d(1.5px, -1.5px, 0); }
  50%  { transform: scale(1.04) translate3d(-1.5px, 1px, 0); }
  75%  { transform: scale(1.04) translate3d(-1px, -1.5px, 0); }
  100% { transform: scale(1.04) translate3d(0, 0, 0); }
}

@keyframes bus-horn-shake {
  0%   { transform: scale(1.04) translate3d(0, 0, 0) rotate(0deg); }
  8%   { transform: scale(1.07) translate3d(-14px, 7px, 0) rotate(-2.2deg); }
  18%  { transform: scale(1.07) translate3d(14px, -7px, 0) rotate(2deg); }
  28%  { transform: scale(1.05) translate3d(-10px, 5px, 0) rotate(-1.5deg); }
  38%  { transform: scale(1.05) translate3d(9px, -4px, 0) rotate(1.2deg); }
  50%  { transform: scale(1.04) translate3d(-6px, 3px, 0) rotate(-0.8deg); }
  64%  { transform: scale(1.04) translate3d(4px, -2px, 0) rotate(0.4deg); }
  78%  { transform: scale(1.04) translate3d(-2px, 1px, 0) rotate(-0.2deg); }
  90%  { transform: scale(1.04) translate3d(1px, 0, 0) rotate(0.1deg); }
  100% { transform: scale(1.04) translate3d(0, 0, 0) rotate(0deg); }
}

.topbar { animation: rise var(--settle) 0.28s both; }
.wordmark { animation: rise var(--settle) 0.06s both; }
.route-board { animation: rise var(--settle) 0.12s both; }
.bumper { animation: rise var(--settle) 0.16s both; }
.dock { animation: rise var(--settle) 0.20s both; }
.bell-rail { animation: rise-left var(--settle) 0.34s both; }

/* ─── Background ────────────────────────────────────────── */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg__img {
  position: absolute;
  inset: -20px;
  background-image: url("Bus Image-clean.png");
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transform: scale(1.04);
  animation: fade-in 1.2s ease both, bus-drive 0.32s ease-in-out infinite;
  will-change: transform;
}

.bg__img.is-shaking {
  animation: bus-horn-shake 850ms cubic-bezier(0.36, 0.07, 0.19, 0.97) !important;
}

/* Multi-layer gradient scrim — upper & lower vignettes, clear vivid center */
.bg__scrim {
  position: absolute;
  inset: 0;
  background:
    /* Top bar readable */
    linear-gradient(to bottom, rgba(5,2,0,0.7) 0%, rgba(5,2,0,0.2) 16%, transparent 32%),
    /* Bottom dock & sayari readable */
    linear-gradient(to top, rgba(5,2,0,0.88) 0%, rgba(5,2,0,0.45) 25%, transparent 50%);
  pointer-events: none;
}

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

/* ─── Top bar ───────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: max(1rem, 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.5rem;
}

.clock {
  justify-self: start;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
}

.presence {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.88);
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  white-space: nowrap;
}

.presence__dot {
  position: relative;
  width: 9px; height: 9px;
  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 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

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

.topbar__links { justify-self: end; }

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

/* ─── Horn rail (pushed slightly left) ──────────────────── */
.horn-rail {
  position: fixed;
  left: max(0.4rem, calc(var(--edge) * 0.4));
  top: 50%;
  translate: 0 -50%;
  z-index: 20;
}

.horn-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.28rem 0.65rem 0.28rem 0.28rem;
  border: 1px solid var(--glass-line);
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 6px 22px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.18);
  color: #fff;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background var(--swift), transform var(--swift), border-color var(--swift);
}
.horn-btn:hover {
  background: rgba(245,166,35,0.2);
  border-color: rgba(245,166,35,0.5);
}
.horn-btn:active { transform: scale(0.94); }

.horn-btn.is-blaring { animation: wordmark-shake 0.5s cubic-bezier(0.36,0.07,0.19,0.97) both; }

.horn-btn__icon {
  display: grid; place-items: center;
  width: 1.6rem; height: 1.6rem; flex: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.14);
  color: #fff;
}
.horn-btn.is-blaring .horn-btn__icon {
  background: var(--amber);
  color: #1a0800;
}

.horn-btn__text {
  display: flex; flex-direction: column;
  line-height: 1.1; text-align: left;
}
.horn-btn__deva {
  font-size: 0.75rem; font-weight: 700;
}
.horn-btn__en {
  font-size: 0.56rem; font-weight: 600;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.58);
}

/* ─── Main layout ───────────────────────────────────────── */
main {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding:
    max(4rem, env(safe-area-inset-top))
    var(--edge)
    max(1.2rem, env(safe-area-inset-bottom));
}

/* ─── Wordmark ──────────────────────────────────────────── */
.wordmark {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: clamp(3rem, 10vw, 6.5rem);
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: #fff;
  text-align: center;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.6),
    0 0 60px rgba(245,166,35,0.3);
  filter: drop-shadow(0 4px 28px rgba(0,0,0,0.55));
  user-select: none;
}

.wordmark.is-shaking .wordmark__line {
  animation: wordmark-shake 700ms cubic-bezier(0.36,0.07,0.19,0.97) both;
}

/* ─── Route board ───────────────────────────────────────── */
.route-board {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.5rem;
  background: rgba(0,0,0,0.4);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.1);
}

.route-board__text {
  font-family: var(--font-led);
  font-size: clamp(1rem, 3vw, 1.4rem);
  color: var(--route-green);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: opacity 0.3s ease;
}

.route-board__text.is-changing { opacity: 0; }

.route-board__blink {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--route-green);
  box-shadow: 0 0 6px rgba(0,255,65,0.8);
  animation: blink 1s step-end infinite;
  flex-shrink: 0;
}

/* ─── Bumper quote (floating right on top of song bar) ───── */
.bumper {
  margin: 0 0 0.55rem 0;
  text-align: center;
  max-width: 32rem;
  z-index: 5;
}

.bumper__text {
  font-size: clamp(0.8rem, 2.2vw, 1rem);
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 6px rgba(0,0,0,0.75);
  transition: opacity 0.25s ease;
}

.bumper__text.is-changing { opacity: 0; }

.bumper__next {
  display: inline-flex; align-items: center; justify-content: center;
  margin-left: 0.35rem;
  width: 1.4rem; height: 1.4rem;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.7);
  cursor: pointer; vertical-align: middle;
  transition: background var(--swift), color var(--swift), transform var(--swift);
}
.bumper__next:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
  transform: rotate(180deg);
}

/* ─── Dock ──────────────────────────────────────────────── */
.dock {
  position: relative;
  width: 100%;
  max-width: 32rem;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Playlist panel ────────────────────────────────────── */
.playlist-panel {
  position: absolute;
  bottom: calc(100% + 0.75rem);
  left: 0; right: 0;
  z-index: 10;
  max-height: min(50dvh, 26rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 1.25rem;
  border: 1px solid var(--glass-line);
  background: rgba(10, 5, 0, 0.65);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.22) transparent;

  /* Animated show/hide */
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 10px, 0) scale(0.98);
  transform-origin: bottom center;
  transition:
    opacity var(--glide),
    transform var(--glide),
    visibility 0s linear 320ms;
}

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

.playlist-panel ol {
  list-style: none;
  margin: 0; padding: 0.5rem;
}

.playlist-panel li button {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: none; border-radius: 0.75rem;
  background: transparent;
  color: rgba(255,255,255,0.75);
  font-family: var(--font-body);
  cursor: pointer;
  text-align: left;
  transition: background var(--swift), color var(--swift);
}

.playlist-panel li button:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.playlist-panel li.is-current button {
  background: rgba(245,166,35,0.18);
  color: var(--amber);
}

.pl-title { font-size: 0.82rem; font-weight: 700; line-height: 1.25; }
.pl-artist {
  font-size: 0.68rem; font-weight: 500;
  color: rgba(255,255,255,0.5);
}
.playlist-panel li.is-current .pl-artist { color: rgba(245,166,35,0.7); }

/* ─── Player pill ───────────────────────────────────────── */
.player {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.85rem 0.4rem 0.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(25px) saturate(195%);
  -webkit-backdrop-filter: blur(25px) saturate(195%);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* ─── Spinning disc ─────────────────────────────────────── */
.disc {
  position: relative;
  width: 3.5rem; height: 3.5rem; flex: none;
  transition: transform var(--glide);
}

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

.disc__ring {
  width: 100%; height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #1a0d00;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  outline: 1px solid rgba(255,255,255,0.18);
  outline-offset: -1px;
  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;
}

.disc__art.is-letterboxed { transform: scale(1.38); }

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

/* ─── Song meta ─────────────────────────────────────────── */
.meta {
  flex: 1; min-width: 0;
}

.meta__title,
.meta__artist {
  transition: opacity 200ms ease;
}

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

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

.meta__artist {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255,255,255,0.62);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Seek bar ──────────────────────────────────────────── */
.seek {
  position: relative;
  height: 10px;
  margin-top: 0.22rem;
  cursor: pointer;
  touch-action: none;
}

.seek__rail {
  position: absolute;
  inset-inline: 0; top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
  border: 0.5px solid rgba(255, 255, 255, 0.1);
}

/* scaleX — compositor thread, 60fps smooth, no layout jank */
.seek__fill {
  height: 100%; width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), #ffffff);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
}

.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.04rem;
  font-size: 0.6rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,0.5);
}

/* ─── Controls ──────────────────────────────────────────── */
.controls {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  flex: none;
}

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

.btn svg { width: 14px; height: 14px; }

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

.btn--play {
  width: 2.3rem; height: 2.3rem;
  background: #fff;
  color: #0a0500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

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

.btn--play:hover {
  background: #fff;
  color: #0a0500;
  transform: scale(1.07);
}

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

/* play/pause icon swap via CSS — avoids JS .hidden bug on SVG */
.i-pause,
.player.is-playing .i-play { display: none; }
.player.is-playing .i-pause { display: block; }

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

/* ─── Reduced motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── Desktop ───────────────────────────────────────────── */
@media (min-width: 640px) {
  .disc { width: 4rem; height: 4rem; }
  .meta__title { font-size: 0.92rem; }
  .meta__artist { font-size: 0.74rem; }
}

@media (min-width: 1024px) {
  .horn-rail { left: max(var(--edge), calc(50vw - 18rem - 8rem)); }
}

/* ─── Ultra-mobile and Narrow Devices ───────────────────── */
@media (max-width: 400px) {
  .player {
    padding: 0.35rem 0.6rem 0.35rem 0.35rem;
    gap: 0.45rem;
  }
  .disc {
    width: 2.8rem;
    height: 2.8rem;
  }
  .btn {
    width: 1.6rem;
    height: 1.6rem;
  }
  .btn svg {
    width: 12px;
    height: 12px;
  }
  .btn--play {
    width: 2rem;
    height: 2rem;
  }
  .btn--play svg {
    width: 14px;
    height: 14px;
  }
}
