/* ============ Limited Stop ============ */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Manjari", "Noto Sans Malayalam", system-ui, sans-serif;
  background: #0d0f12;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- the paintings ----------
   All four are stacked; body.mode-* / body.monsoon picks which one
   shows. app.js pins them (and everything over them) with cover-fit. */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #0d0f12;
  animation: bus-bump 7.3s linear infinite;
}

/* the bus is running: sharp irregular jolts — potholes, not a swing.
   (layout() overscans the art a few px so the edges never show) */
@keyframes bus-bump {
  0%   { transform: translateY(0); }
  8%   { transform: translateY(-2.5px); }
  15%  { transform: translateY(1px); }
  26%  { transform: translateY(-1.5px); }
  34%  { transform: translateY(0); }
  47%  { transform: translateY(-3px); }
  55%  { transform: translateY(1px); }
  63%  { transform: translateY(0); }
  74%  { transform: translateY(-2px); }
  81%  { transform: translateY(0.5px); }
  90%  { transform: translateY(-1px); }
  100% { transform: translateY(0); }
}

.art {
  position: absolute;
  opacity: 0;
  transition: opacity 1.8s ease;
  user-select: none;
  -webkit-user-drag: none;
}

body.mode-noon #art-noon { opacity: 1; }
body.mode-morning #art-golden { opacity: 1; }
body.mode-evening #art-golden { opacity: 1; }
body.mode-night #art-night { opacity: 1; }

/* the rain takes whatever hour it wants */
body.monsoon #art-noon,
body.monsoon #art-golden,
body.monsoon #art-night { opacity: 0; }
body.monsoon #art-monsoon { opacity: 1; }

/* the drive footage: revealed only once genuinely playing, so we never
   fade up onto a black or half-buffered frame */
#drive {
  position: absolute;
  opacity: 0;
  transition: opacity 900ms ease;
  pointer-events: none;
  object-fit: fill;
  /* the clip's edges melt into the still above and below */
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 8%, #000 92%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 8%, #000 92%, transparent 100%);
}
#drive.is-playing { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  #drive { display: none; }
}

/* ---------- rain, over the art, behind the glass frames ---------- */

#fx {
  position: absolute;
  pointer-events: none;
}
#fx .rain { opacity: 0; transition: opacity 1.2s; }
body.monsoon #fx .rain { opacity: 0.5; }
/* the monsoon clip carries its own rain — ours bows out while it plays */
body.monsoon #drive.is-playing ~ #fx .rain { opacity: 0; }
.rainband line { stroke: #e8f1f7; stroke-width: 2; stroke-linecap: round; }
.rainband.r1 { animation: fall 0.8s linear infinite; }
.rainband.r2 { animation: fall 1.1s linear infinite; animation-delay: -0.4s; }
@keyframes fall { from { transform: translateY(-540px); } to { transform: translateY(0); } }

/* ---------- the whistle button (invisible, over the painted whistle) ---------- */

#whistle {
  position: absolute;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
}
#whistle:focus-visible { outline: 2px dashed #f2a93b; outline-offset: 2px; }
#whistle::after {
  content: "";
  position: absolute;
  inset: 20%;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.85);
  opacity: 0;
  transform: scale(0.4);
}
#whistle.blown::after { animation: whistleping 0.55s ease-out; }
@keyframes whistleping {
  0% { opacity: 0.75; transform: scale(0.4); }
  100% { opacity: 0; transform: scale(1.5); }
}

/* ---------- UI ---------- */

#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 20px 16px;
  z-index: 30;
}

/* the whistle lives in the painting on big screens; phones crop the
   doorway away, so they get it as a button instead */
#whistle-btn { display: none; }
#whistle-btn.blown { animation: btnblow 0.45s ease-out; }
@keyframes btnblow {
  30% { transform: scale(1.18) rotate(-8deg); }
  65% { transform: scale(0.95) rotate(5deg); }
}

.tinboard {
  background: #1d4038;
  color: #f2dcb8;
  border: 2px solid rgba(242, 220, 184, 0.22);
  border-radius: 8px;
  padding: 8px 14px 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 4px 14px rgba(0, 0, 0, 0.35);
  line-height: 1.25;
}

#slotboard #slot-hint {
  display: block;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: none;
  opacity: 0.65;
}

#riders {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 7px;
}
#riders-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.9);
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.45; } }
#riders.shifting b { opacity: 0.2; transition: opacity 0.3s; }

#actions { display: flex; gap: 10px; }
#actions a[hidden] { display: none; }
#actions a, #actions button {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(18, 30, 26, 0.6);
  color: #f2dcb8;
  border: 1px solid rgba(242, 220, 184, 0.2);
  cursor: pointer;
  transition: transform 0.15s, background 0.3s, color 0.3s;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
#actions a:hover, #actions button:hover { transform: translateY(-2px); }
#actions a:active, #actions button:active { transform: scale(0.94); }

#monsoon-btn .mb-drop { opacity: 0; transition: opacity 0.3s; }
body.monsoon #monsoon-btn { background: #3e6b8c; color: #eaf4fb; border-color: rgba(234, 244, 251, 0.35); }
body.monsoon #monsoon-btn .mb-drop { opacity: 1; }

/* ---------- the ticket ---------- */

#dock {
  position: fixed;
  bottom: calc(30px + env(safe-area-inset-bottom)); left: 0; right: 0;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  z-index: 30;
}

#ticket {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(620px, 100%);
  background: #fbf4de;
  background-image: repeating-linear-gradient(0deg, rgba(160, 140, 90, 0.05) 0 1px, transparent 1px 3px);
  border: 1px solid #d8c69a;
  border-radius: 10px;
  padding: 10px 14px 12px 12px;
  transform: rotate(-0.6deg);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.5);
}
#ticket::after {
  content: "LTD · STOP · KL";
  position: absolute;
  top: 5px; right: 12px;
  font-size: 8.5px;
  letter-spacing: 0.22em;
  color: #a08e5f;
}

#stub {
  border-right: 2px dashed #c9b583;
  padding-right: 13px;
  flex-shrink: 0;
  display: flex;
}
#thumb {
  width: 56px; height: 56px;
  border-radius: 6px;
  object-fit: cover;
  background: #e4d6b4;
  box-shadow: inset 0 0 0 1px rgba(120, 100, 60, 0.25);
}

#ticket-main { flex: 1 1 0; min-width: 0; overflow: hidden; }
#meta { display: flex; flex-direction: column; min-width: 0; }
#song-title {
  font-weight: 700;
  font-size: 15px;
  color: #33303b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#song-sub {
  font-size: 12px;
  color: #7a7361;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.boarding #song-title { animation: boarding 1.4s ease-in-out infinite; }
@keyframes boarding { 50% { opacity: 0.45; } }

#seekrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 10.5px;
  color: #8a8069;
  font-variant-numeric: tabular-nums;
}
#seek {
  flex: 1 1 0;
  min-width: 0;
  height: 4px;
  accent-color: #6b4fa3;
  cursor: pointer;
}

#controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
#controls button {
  display: grid;
  place-items: center;
  width: 36px; height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: #33303b;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
}
#controls button svg { width: 17px; height: 17px; }
#controls button:hover { background: rgba(51, 48, 59, 0.08); }
#controls button:active { transform: scale(0.92); }
#btn-play {
  width: 46px !important; height: 46px !important;
  background: #33303b !important;
  color: #fbf4de !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
#btn-play svg { width: 20px; height: 20px; }
#btn-play .icon-pause { display: none; }
body.rolling #btn-play .icon-pause { display: block; }
body.rolling #btn-play .icon-play { display: none; }

/* ---------- footer ---------- */

#credit {
  position: fixed;
  bottom: calc(6px + env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.92);
  z-index: 25;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85), 0 0 12px rgba(0, 0, 0, 0.35);
}
#credit a { color: #ffffff; }

/* the hidden engine room */
#yt-hide {
  position: fixed;
  bottom: 0; right: 0;
  width: 2px; height: 2px;
  opacity: 0.01;
  overflow: hidden;
  pointer-events: none;
}

:focus-visible { outline: 2px dashed #f2a93b; outline-offset: 2px; }

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  #topbar {
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    padding: calc(10px + env(safe-area-inset-top)) 10px 10px;
  }
  .tinboard { font-size: 11px; padding: 6px 9px 4px; }
  #slotboard #slot-hint { display: none; }
  #riders { position: static; transform: none; }
  #actions { margin-left: auto; }
  #actions a, #actions button { width: 44px; height: 44px; }
  #whistle-btn { display: grid; }
  #credit { font-size: 10px; padding: 0 12px; }
  #dock { bottom: calc(24px + env(safe-area-inset-bottom)); padding: 0 10px; }
  #ticket { gap: 8px; padding: 9px 10px 10px; }
  #thumb { width: 46px; height: 46px; }
  #stub { padding-right: 8px; }
  #controls { gap: 4px; }
  #controls button { width: 40px; height: 40px; }
  #controls button svg { width: 19px; height: 19px; }
  #btn-play { width: 48px !important; height: 48px !important; }
  #btn-play svg { width: 22px; height: 22px; }
  #seek { height: 24px; }
  #t-total { display: none; }
  #ticket::after { display: none; }
}

/* ---------- calm mode ---------- */

@media (prefers-reduced-motion: reduce) {
  .rainband.r1, .rainband.r2, #riders-dot, #stage { animation: none !important; }
  .art { transition: none; }
}
