/* ============================================================
   Tapri FM — design tokens
   ============================================================ */
:root {
  /* palette sampled from the chai-tapri illustration */
  --soot:        #1a1310;   /* warm dark ground / dock glass */
  --soot-2:      #241a13;   /* raised warm dark */
  --amber:       #bb3d2f;   /* signboard red — accent: needle, active, readout */
  --amber-dim:   #8e2c22;
  --blue:        #2f5d6b;   /* stall teal */
  --sky:         #7cb9d6;   /* sky blue */
  --brick:       #bb3d2f;   /* signboard red */
  --tin:         #8a5a3c;   /* rusted tin / wood */
  --white:       #f0e7d1;   /* signboard cream — text */
  --white-dim:   rgba(240, 231, 209, 0.62);
  --white-faint: rgba(240, 231, 209, 0.32);
  --line:        rgba(240, 231, 209, 0.16);

  --disp:  "Yatra One", "Rozha One", Georgia, serif;   /* signboard display */
  --disp2: "Rozha One", Georgia, serif;
  --mono:  "Space Mono", "SF Mono", ui-monospace, monospace;
  --sans:  "Mukta", system-ui, sans-serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--soot);
  color: var(--white);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ============================================================
   Atmospherics — kept quiet, all behind the stage
   ============================================================ */
.atmos { position: fixed; inset: 0; z-index: 0; pointer-events: none; }

/* original hand-built tapri illustration, anchored to the ground line */
.scene {
  position: absolute; inset: 0;
  background: var(--soot) url("assets/background.jpeg") center center / cover no-repeat;
  opacity: 1;
}

.glow {
  position: absolute; left: 50%; top: 46%;
  width: 120vmax; height: 120vmax; transform: translate(-50%, -50%);
  background: radial-gradient(circle at center,
    rgba(187,61,47,0.16) 0%,
    rgba(187,61,47,0.06) 22%,
    rgba(58,95,107,0.05) 45%,
    transparent 62%);
  transition: opacity 1.2s var(--ease);
}
body.locked .glow { opacity: 1.25; }

.vignette {
  position: absolute; inset: 0;
  background:
    linear-gradient(to bottom, rgba(22,19,17,0.60) 0%, rgba(22,19,17,0) 20%),
    linear-gradient(to top, rgba(22,19,17,0.92) 0%, rgba(22,19,17,0.35) 20%, rgba(22,19,17,0) 40%),
    radial-gradient(ellipse 100% 92% at 50% 46%, transparent 58%, rgba(0,0,0,0.36) 100%);
}

/* film grain */
.grain {
  position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/></svg>");
  opacity: 0.05;
  mix-blend-mode: overlay;
  animation: grainshift 0.6s steps(2) infinite;
}
@keyframes grainshift {
  0%{transform:translate(0,0)} 50%{transform:translate(-2%,1%)} 100%{transform:translate(1%,-1%)}
}

/* ============================================================
   Stage layout
   ============================================================ */
.stage {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  padding: clamp(16px, 3vw, 30px) clamp(16px, 4vw, 48px) clamp(16px, 2.4vh, 26px);
  max-width: 1180px; margin: 0 auto;
}

/* left control column, floated in the sky's negative space */
.leftcol {
  margin: auto 0;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: clamp(18px, 4vh, 38px);
  max-width: min(48vw, 440px);
}
.dock {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 16px; width: 100%;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--white); text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.clock { min-width: 90px; }
.presence { display: flex; align-items: center; gap: 8px; }
.pulse {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 8px var(--amber);
  animation: breathe 2.4s var(--ease) infinite;
}
@keyframes breathe { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.45;transform:scale(.8)} }
.presence .count { color: var(--white); font-weight: 700; }
.presence-label { color: var(--white-faint); }
.links { display: flex; gap: 18px; }
.links a {
  color: var(--white-dim); text-decoration: none; font-family: var(--mono);
  transition: color .25s var(--ease);
}
.links a:hover { color: var(--amber); }
.links .arr { opacity: .6; }

/* ---- signboard headline ---- */
.marquee { text-align: center; }
.signboard {
  margin: 0;
  font-family: var(--disp);
  font-weight: 400;
  font-size: clamp(40px, 7.5vw, 92px);
  line-height: 0.9;
  color: var(--white);
  text-shadow: 0 2px 12px rgba(0,0,0,0.65), 0 0 40px rgba(187,61,47,0.2);
  letter-spacing: 0.01em;
}
.signboard .fm {
  color: var(--brick);
  -webkit-text-stroke: 0;
}
.tagline {
  margin: 8px 0 0;
  font-family: var(--mono); font-size: clamp(8px, 0.9vw, 10px);
  letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--white); text-indent: 0.26em;
  text-shadow: 0 1px 5px rgba(0,0,0,0.65), 0 0 2px rgba(0,0,0,0.5);
}

/* ============================================================
   THE TUNER — round dial
   ============================================================ */
.tuner {
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
}

.rdial {
  position: relative;
  width: clamp(200px, 27vw, 280px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 36%, rgba(255,255,255,0.05), rgba(0,0,0,0) 62%),
    radial-gradient(circle at 50% 60%, rgba(18,13,10,0.10), rgba(18,13,10,0.10));
  border: 1.5px solid rgba(187,61,47,0.55);
  box-shadow:
    inset 0 2px 18px rgba(0,0,0,0.3),
    inset 0 0 0 5px rgba(187,61,47,0.10),
    0 0 22px rgba(187,61,47,0.14),
    0 16px 42px rgba(0,0,0,0.4);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  cursor: grab; touch-action: none;
}
.rdial:active, .rdial.dragging { cursor: grabbing; }
.rdial:focus-visible { outline: 2px solid var(--amber); outline-offset: 4px; }

.rdial-face { position: absolute; inset: 0; }

/* radial ticks */
.tick { position: absolute; width: 1.5px; height: 8px; background: var(--white-faint); }
.tick.major { height: 13px; width: 2px; background: var(--white-dim); }
.tick.minor { opacity: 0.7; }
.tick-label {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--mono); font-size: 10px; color: var(--white-faint); letter-spacing: 0.03em;
}

/* station pips around the rim */
.pip {
  position: absolute; transform: translate(-50%, -50%);
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tin); border: 1px solid rgba(0,0,0,0.4);
  transition: all .25s var(--ease);
}
.pip.active {
  background: var(--amber); box-shadow: 0 0 10px var(--amber), 0 0 3px #fff;
  transform: translate(-50%, -50%) scale(1.5);
}

/* rotating pointer hand */
.rdial-hand {
  position: absolute; left: 50%; bottom: 50%;
  width: 3px; height: 41%; border-radius: 3px;
  background: linear-gradient(to top, var(--amber-dim), var(--amber) 55%, #fff);
  box-shadow: 0 0 10px rgba(187,61,47,0.9), 0 0 2px #fff;
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(225deg);
  z-index: 3;
}

/* centre hub with the readout */
.rdial-hub {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 58%; height: 58%; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: radial-gradient(circle at 50% 40%, rgba(26,19,14,0.44), rgba(18,13,10,0.52));
  border: 1px solid var(--line);
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.35), 0 3px 12px rgba(0,0,0,0.3);
  z-index: 2;
}
.freq {
  display: inline-flex; align-items: baseline; gap: 4px;
  font-family: var(--mono); font-weight: 700; color: var(--white);
  font-size: clamp(20px, 2.8vw, 28px);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7), 0 0 2px rgba(0,0,0,0.5);
  font-variant-numeric: tabular-nums;
  transition: opacity .3s var(--ease);
}
body:not(.locked) .freq { opacity: 0.7; }
.freq .mhz { font-size: 0.34em; letter-spacing: 0.2em; color: var(--white-dim); font-weight: 400; }
.badge {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.18em;
  padding: 2px 7px; border: 1px solid var(--line); border-radius: 3px;
  color: var(--white-faint); transition: all .3s var(--ease);
}
body.locked .badge {
  color: var(--white); background: var(--amber); border-color: var(--amber);
  box-shadow: 0 0 12px rgba(187,61,47,0.5);
}

/* caption under the dial: signal + station name */
.rdial-caption {
  display: flex; align-items: center; gap: 10px; max-width: 280px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em; color: var(--white-dim);
}
.signal { display: inline-flex; align-items: flex-end; gap: 2px; height: 13px; flex: 0 0 auto; }
.signal i {
  width: 3px; background: var(--white-faint); border-radius: 1px; transition: all .18s var(--ease);
}
.signal i:nth-child(1){height:4px} .signal i:nth-child(2){height:6px}
.signal i:nth-child(3){height:8px} .signal i:nth-child(4){height:11px}
.signal i:nth-child(5){height:13px}
.signal.s1 i:nth-child(-n+1),
.signal.s2 i:nth-child(-n+2),
.signal.s3 i:nth-child(-n+3),
.signal.s4 i:nth-child(-n+4),
.signal.s5 i:nth-child(-n+5) { background: var(--amber); box-shadow: 0 0 6px rgba(187,61,47,0.6); }
.station-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--white-dim);
}

/* ============================================================
   Player pill — deliberately quiet
   ============================================================ */
.player {
  position: absolute; left: 50%; bottom: clamp(26px, 4.5vh, 46px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px 10px 10px;
  background:
    radial-gradient(circle at 28% 30%, rgba(255,255,255,0.05), rgba(0,0,0,0) 60%),
    rgba(18,13,10,0.10);
  border: 1.5px solid rgba(187,61,47,0.55);
  border-radius: 999px;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow:
    inset 0 0 0 4px rgba(187,61,47,0.09),
    0 0 26px rgba(187,61,47,0.14),
    0 14px 40px rgba(0,0,0,0.45);
  width: min(560px, 92vw); z-index: 4;
}
.cover {
  width: 52px; height: 52px; flex: 0 0 52px; border-radius: 8px; overflow: hidden;
  background: var(--soot); border: 1px solid var(--line);
  display: grid; place-items: center;
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-empty { color: var(--white-faint); font-size: 22px; }
.meta { flex: 1 1 auto; min-width: 0; }
.track-title {
  font-family: var(--disp2); font-size: 18px; line-height: 1.15; color: var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}
.track-artist {
  font-size: 12px; color: var(--white); margin-top: 2px; opacity: 0.82;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.55);
}
.scrub { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.scrub-bar {
  flex: 1 1 auto; height: 3px; background: var(--line); border-radius: 2px; cursor: pointer; position: relative;
}
.scrub-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: var(--amber); border-radius: 2px; box-shadow: 0 0 8px rgba(187,61,47,0.5);
}
.time { font-family: var(--mono); font-size: 10px; color: var(--white-dim); flex: 0 0 auto; font-variant-numeric: tabular-nums; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

.controls { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }
.ctrl {
  background: none; border: none; color: var(--white); cursor: pointer;
  font-size: 14px; padding: 8px; border-radius: 50%; line-height: 1;
  transition: color .2s var(--ease), background .2s var(--ease), transform .1s var(--ease);
}
.ctrl:hover:not(:disabled) { color: var(--white); }
.ctrl:active:not(:disabled) { transform: scale(0.9); }
.ctrl:disabled { opacity: 0.4; cursor: default; }
.ctrl.play {
  width: 42px; height: 42px; background: var(--amber); color: var(--white);
  font-size: 15px; box-shadow: 0 0 18px rgba(187,61,47,0.45);
}
.ctrl.play:hover:not(:disabled) { color: var(--soot); filter: brightness(1.08); }

/* ---- footer ---- */
.footer {
  text-align: center; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--white-faint);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 620px) {
  .presence-label { display: none; }
  .tagline { letter-spacing: 0.26em; }
  .leftcol { max-width: 100%; align-items: center; }
  .marquee { text-align: center; }
  .dock { align-items: center; }
  .tuner { align-items: center; }
  .rdial-caption { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .pulse, .dial-hint { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
