/* ── Design tokens ──────────────────────────────────────────────
   A monsoon night in the Pink City: deep indigo-green dark, lit by
   marigold garlands, gulal pink, and a teal glow standing in for the
   voice itself. Display: Fraunces. Devanagari: Tiro Devanagari Hindi.
   Body/UI: Work Sans.
------------------------------------------------------------------ */
:root {
  --bg: #0A0E12;
  --bg-deep: #060809;
  --panel: #12181E;
  --panel-raised: #171F27;
  --ink: #F3EFE4;
  --muted: #8FA0A2;
  --line: rgba(243, 239, 228, 0.09);
  --line-strong: rgba(243, 239, 228, 0.16);

  --marigold: #F6A93B;
  --marigold-deep: #D98A1F;
  --gulal: #FF4F86;
  --gulal-deep: #E8266A;
  --teal: #2FE6B8;
  --violet: #9B7BFF;

  --radius: 16px;
  --radius-sm: 10px;

  --font-display: 'Fraunces', serif;
  --font-deva: 'Tiro Devanagari Hindi', serif;
  --font-body: 'Work Sans', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  position: relative;
  overflow-x: hidden;
}

a { color: var(--teal); }

/* ── Ambient rain ──────────────────────────────────────────────── */
.rain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(60% 50% at 15% 0%, rgba(155,123,255,0.14) 0%, transparent 60%),
    radial-gradient(50% 40% at 100% 10%, rgba(255,79,134,0.10) 0%, transparent 60%),
    repeating-linear-gradient(100deg, rgba(243,239,228,0.035) 0 1px, transparent 1px 46px);
  opacity: 0.9;
}
@media (prefers-reduced-motion: no-preference) {
  .rain { animation: drift 10s linear infinite; }
}
@keyframes drift {
  from { background-position: 0 0, 0 0, 0 0; }
  to   { background-position: 0 0, 0 0, -46px 70px; }
}

/* ── App shell — grid on desktop, stack on mobile ─────────────── */
.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0;
}

/* ── Hero / left rail ──────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 100% at 0% 0%, #1A2A24 0%, var(--bg-deep) 65%);
  color: var(--ink);
  padding: 14px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.hero-glow {
  position: absolute;
  inset: -20% -10% auto -10%;
  height: 280px;
  background: radial-gradient(closest-side, rgba(246,169,59,0.16), transparent 70%);
  pointer-events: none;
}
.hero-top { position: relative; z-index: 2; }
.countdown-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
  color: var(--marigold);
  background: rgba(246,169,59,0.10);
  border: 1px solid rgba(246,169,59,0.28);
  border-radius: 999px;
  padding: 5px 10px 5px 8px;
}
.dot-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gulal);
  box-shadow: 0 0 0 3px rgba(255,79,134,0.22);
  flex-shrink: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .dot-live { animation: blink 1.8s ease-in-out infinite; }
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.hero-mid { position: relative; z-index: 2; margin-top: 8px; max-width: 46ch; }
.hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.4rem, 5.5vw, 2rem);
  margin: 0 0 4px;
  letter-spacing: -0.01em;
  background: linear-gradient(100deg, var(--ink) 30%, var(--marigold) 65%, var(--gulal) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero h1 .devanagari {
  font-family: var(--font-deva);
  font-weight: 400;
  font-size: 0.6em;
  margin-left: 10px;
  color: var(--violet);
  -webkit-text-fill-color: var(--violet);
}
.hero-sub {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}
.hero-bottom { position: relative; z-index: 2; margin-top: 16px; }
.persona-line {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.persona-line strong { color: var(--teal); font-weight: 600; }

/* Signature: the jhoola (Teej swing) — decorative, so it steps aside on
   small screens where the map/photo/voice UI needs the room instead. */
.swing-signature {
  position: relative;
  z-index: 2;
  width: min(90px, 22vw);
  height: auto;
  margin: 8px auto 0;
  opacity: 0.95;
  display: block;
}
.swing-signature .branch { stroke: var(--marigold-deep); stroke-width: 4; stroke-linecap: round; }
.swing-signature .rope { stroke: rgba(243,239,228,0.35); stroke-width: 2; }
.swing-signature .seat { fill: var(--marigold); }
.swing-signature .swing-rig { transform-origin: 160px 14px; }
.swing-signature .pulse-ring { fill: none; stroke: var(--teal); stroke-width: 1.5; opacity: 0; }
@media (prefers-reduced-motion: no-preference) {
  .swing-signature .swing-rig { animation: sway 3.8s ease-in-out infinite; }
  .swing-signature .pulse-ring { animation: pulse 2.6s ease-out infinite; }
  .swing-signature .pulse-ring--delay { animation-delay: 1.3s; }
}
@keyframes sway {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}
@keyframes pulse {
  0% { r: 12; opacity: 0.5; }
  100% { r: 30; opacity: 0; }
}

/* ── Main column ───────────────────────────────────────────────── */
main {
  padding: 10px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: linear-gradient(180deg, var(--panel-raised), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 15px 16px;
  box-shadow: 0 18px 40px -26px rgba(0,0,0,0.6);
  min-width: 0;
}
.panel-eyebrow {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.62rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 6px;
}
.eyebrow--voice { color: var(--teal); background: rgba(47,230,184,0.12); border: 1px solid rgba(47,230,184,0.3); }
.eyebrow--finder { color: var(--marigold); background: rgba(246,169,59,0.12); border: 1px solid rgba(246,169,59,0.3); }
.eyebrow--chat { color: var(--violet); background: rgba(155,123,255,0.12); border: 1px solid rgba(155,123,255,0.3); }

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--ink);
}
.panel-hint {
  color: var(--muted);
  font-size: 0.84rem;
  margin: 0 0 14px;
}
.loading { color: var(--muted); font-size: 0.9rem; }

/* ── Voice panel (primary) ────────────────────────────────────── */
.panel--voice {
  border-color: rgba(47,230,184,0.22);
  background: linear-gradient(165deg, rgba(47,230,184,0.07), var(--panel) 40%);
}

.voice-stage {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.voice-call-btn {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  background: linear-gradient(160deg, var(--marigold), var(--gulal-deep));
  color: var(--bg-deep);
  box-shadow: 0 10px 26px -8px rgba(255,79,134,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}
.voice-call-btn:hover { box-shadow: 0 14px 30px -6px rgba(255,79,134,0.55); }
.voice-call-btn:active { transform: scale(0.95); }
.voice-call-btn[disabled] { opacity: 0.55; cursor: default; }
.voice-call-btn .icon-mic,
.voice-call-btn .icon-stop {
  width: 25px; height: 25px;
  position: relative; z-index: 2;
}
.voice-call-btn .icon-stop { display: none; }
.voice-call-btn.live { background: linear-gradient(160deg, var(--teal), var(--violet)); color: var(--bg-deep); }
.voice-call-btn.live .icon-mic { display: none; }
.voice-call-btn.live .icon-stop { display: block; }

.voice-call-btn .ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid rgba(47,230,184,0.5);
  opacity: 0;
}
.voice-call-btn.live .ring { opacity: 1; }
@media (prefers-reduced-motion: no-preference) {
  .voice-call-btn.live .ring--1 { animation: ripple 2.2s ease-out infinite; }
  .voice-call-btn.live .ring--2 { animation: ripple 2.2s ease-out infinite 1.1s; }
}
@keyframes ripple {
  0% { transform: scale(1); opacity: 0.55; }
  100% { transform: scale(1.6); opacity: 0; }
}

.voice-readout { flex: 1; min-width: 200px; }
.voice-status { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--muted); margin-bottom: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.live { background: var(--teal); box-shadow: 0 0 0 3px rgba(47,230,184,0.2); }

.waveform {
  width: 100%;
  max-width: 420px;
  height: 56px;
  display: block;
  border-radius: 8px;
}

.voice-last-heard {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  margin-top: 14px;
  background: rgba(243,239,228,0.02);
}
.voice-last-heard .label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 3px;
}
.voice-last-heard p { margin: 0; font-size: 0.86rem; font-style: italic; color: var(--teal); }

.voice-feed { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; min-width: 0; }
.voice-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--panel-raised);
  animation: card-in 0.35s ease forwards;
  min-width: 0;
  overflow: hidden;
}
@keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.voice-card-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--marigold);
  margin: 0 0 4px;
  font-weight: 600;
}
.voice-card-title { font-family: var(--font-display); font-size: 1.05rem; margin: 0 0 4px; color: var(--ink); }
.voice-card-caption { font-size: 0.86rem; color: var(--muted); margin: 6px 0 0; }
.voice-card audio {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 6px;
}
.voice-card-img { width: 100%; border-radius: 8px; display: block; cursor: zoom-in; }
.voice-card-img:hover { opacity: 0.92; }
.voice-card .map-wrap iframe { height: 180px; border-radius: 8px 8px 0 0; }

/* ── Buttons / forms ───────────────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  border: none;
  border-radius: 9px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(120deg, var(--marigold), var(--gulal-deep)); color: #1A1206; }
.btn-primary:hover { box-shadow: 0 8px 20px -8px rgba(255,79,134,0.5); }
.btn-secondary { background: var(--panel-raised); color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { border-color: var(--teal); }
.btn-icon { background: transparent; border: 1px solid var(--line-strong); padding: 10px 12px; color: var(--muted); }
.btn-icon svg { width: 18px; height: 18px; display: block; }
.btn-icon.listening { background: var(--gulal); color: #1A1206; border-color: var(--gulal); }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-icon-svg { width: 17px; height: 17px; }

.finder-controls { display: flex; flex-direction: column; gap: 12px; }
.finder-or { text-align: center; font-size: 0.8rem; color: var(--muted); }
.text-form { display: flex; gap: 8px; }
.text-form input, .chat-form input[type="text"] {
  flex: 1;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 11px 13px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg-deep);
  color: var(--ink);
}
.text-form input::placeholder, .chat-form input::placeholder { color: var(--muted); }
.text-form input:focus, .chat-form input:focus,
.btn:focus-visible, .voice-call-btn:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.chat-form { display: flex; gap: 8px; margin-top: 12px; }

/* ── Finder result ─────────────────────────────────────────────── */
.finder-result { margin-top: 18px; }
.result-card {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-deep);
}
.result-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.result-head h3 { margin: 0 0 4px; font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); }
.result-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-raised);
  font-weight: 600;
  color: var(--ink);
}
.badge--crowd-Extreme, .badge--crowd-Very-Heavy { background: rgba(255,79,134,0.16); color: var(--gulal); }
.badge--crowd-Heavy, .badge--crowd-Moderate-Heavy { background: rgba(246,169,59,0.16); color: var(--marigold); }
.badge--crowd-Moderate, .badge--crowd-Light { background: rgba(47,230,184,0.14); color: var(--teal); }

.result-body { padding: 14px 16px; }
.result-body p { margin: 0 0 10px; font-size: 0.92rem; color: var(--ink); }
.result-body p:last-child { margin-bottom: 0; }
.result-tip { background: var(--panel); border-radius: 8px; padding: 10px 12px; font-size: 0.88rem; color: var(--muted); }

.map-wrap { position: relative; }
.teej-map-canvas { width: 100%; height: 360px; display: block; background: var(--panel); }
.voice-card .teej-map-canvas { height: 300px; border-radius: 8px 8px 0 0; }

@media (max-width: 640px) {
  .teej-map-canvas { height: 300px; }
  .voice-card .teej-map-canvas { height: 260px; }
}

.route-header {
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.route-header strong { color: var(--marigold); }

.origin-picker { padding: 4px 16px 16px; border-top: 1px solid var(--line); }
.origin-picker-label { font-size: 0.85rem; color: var(--muted); margin: 12px 0 8px; }
.origin-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.origin-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-raised);
  color: var(--ink);
  font-size: 0.82rem;
  cursor: pointer;
}
.origin-chip:hover { border-color: var(--marigold); color: var(--marigold); }
.origin-form { display: flex; gap: 8px; }
.origin-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.9rem;
}
.origin-form input:focus { outline: none; border-color: var(--marigold); }

.map-fullscreen-link {
  display: block;
  text-align: center;
  padding: 11px;
  background: var(--panel-raised);
  color: var(--teal);
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
}
.map-fullscreen-link:hover { background: var(--panel); }

/* ── Chat ──────────────────────────────────────────────────────── */
.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 2px;
}
.chat-msg { padding: 10px 13px; border-radius: 10px; font-size: 0.92rem; max-width: 88%; }
.chat-msg--bot { background: var(--panel-raised); color: var(--ink); align-self: flex-start; border: 1px solid var(--line); }
.chat-msg--user { background: linear-gradient(120deg, var(--violet), var(--gulal-deep)); color: #16111F; align-self: flex-end; }
.chat-msg--error { background: rgba(255,79,134,0.14); color: var(--gulal); align-self: flex-start; font-style: italic; }

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 20px;
  position: relative;
  z-index: 1;
}

/* On phones the swing illustration is pure decoration — cut it so the
   map/photo/voice UI sits higher up, closer to what's visible without
   scrolling. */
@media (max-width: 979px) {
  .swing-signature { display: none; }
}

/* ── Floating audio player ────────────────────────────────────────
   Docked at the bottom instead of an inline <audio> card in the feed,
   so a playing clip doesn't eat vertical space next to the map/photo. */
.floating-audio-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--panel-raised);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,0.6);
  max-width: 420px;
  margin: 0 auto;
}
.floating-audio-toggle {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(120deg, var(--marigold), var(--gulal-deep));
  color: #1A1206;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.floating-audio-info { flex: 1; min-width: 0; }
.floating-audio-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.floating-audio-caption {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.floating-audio-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

/* ── Desktop layout ───────────────────────────────────────────────
   Image/branding shifts to a sticky left rail; the interface
   (call → finder → chat) fills a wider right column. ────────────── */
@media (min-width: 980px) {
  .app-shell {
    display: grid;
    grid-template-columns: 380px 1fr;
    align-items: start;
    padding-top: 40px;
  }
  .hero {
    position: sticky;
    top: 40px;
    align-self: start;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    padding: 40px 32px 44px;
    margin-left: 24px;
  }
  .swing-signature { width: 144px; margin-top: 22px; }
  main { padding: 0 24px 48px 32px; gap: 16px; }
  .panel { padding: 22px 26px 26px; }
  .voice-stage { flex-wrap: nowrap; }
  .floating-audio-bar { left: auto; right: 32px; bottom: 24px; }
}

@media (min-width: 1180px) {
  .app-shell { grid-template-columns: 420px 1fr; }
}