/* Lorecast — tap anywhere, hear everywhere */
:root {
  --ink: #080b16;
  --card: rgba(14, 19, 38, 0.94);
  --line: rgba(255, 255, 255, 0.10);
  --text: #eef1ff;
  --muted: #96a0c4;
  --amber: #ffb54d;
  --amber-deep: #ff9e1f;
  --violet: #b06bff;
  --blue: #5b6cff;
  --grad: linear-gradient(135deg, #5b6cff, #b06bff);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--ink);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.map { position: absolute; inset: 0; background: #070a12; z-index: 1; }
.leaflet-container { background: #070a12; font: inherit; outline: none; cursor: crosshair; }
.leaflet-control-attribution {
  background: rgba(8, 11, 22, .72) !important; color: #667 !important; font-size: 10px !important;
}
.leaflet-control-attribution a { color: #88a !important; }

/* ---------- top bar ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 14px 14px;
  background: linear-gradient(180deg, rgba(8,11,22,.92) 25%, transparent);
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 34px; height: 34px; filter: drop-shadow(0 3px 12px rgba(255,158,31,.45)); }
.brand-text { font-family: 'Fraunces', serif; font-weight: 900; font-size: 23px; letter-spacing: -.02em; }
.brand-text em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.top-actions { display: flex; gap: 8px; }
.top-btn {
  padding: 10px 14px; border-radius: 11px; cursor: pointer; white-space: nowrap;
  font: 600 13.5px 'Inter', sans-serif; color: var(--text);
  background: rgba(20, 27, 52, .86); border: 1px solid var(--line); backdrop-filter: blur(10px);
}
.top-btn:hover { background: rgba(32, 42, 78, .92); border-color: var(--muted); }
@media (max-width: 560px) { .top-btn span { display: none; } .top-btn { padding: 10px 12px; font-size: 16px; } }

/* ---------- hints ---------- */
.hint, .zoom-note {
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 480;
  padding: 10px 18px; border-radius: 999px; white-space: nowrap;
  font: 600 13px 'Inter', sans-serif; backdrop-filter: blur(10px);
  transition: opacity .35s; pointer-events: none;
}
.hint {
  top: 78px; color: var(--text);
  background: rgba(20, 27, 52, .88); border: 1px solid var(--line);
}
.zoom-note {
  bottom: 22px; color: var(--muted); font-size: 12px;
  background: rgba(20, 27, 52, .8); border: 1px solid var(--line);
}
.hint.hide, .zoom-note.hide { opacity: 0; }

/* ---------- curated spot pins ---------- */
.spot-pin {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd27d, var(--amber-deep));
  box-shadow: 0 0 12px rgba(255,158,31,.85), 0 0 26px rgba(255,158,31,.35);
  cursor: pointer; transition: transform .15s;
}
.spot-pin:hover { transform: scale(1.6); }
.spot-label {
  position: absolute; left: 16px; top: -4px; white-space: nowrap;
  font: 700 11.5px 'Inter', sans-serif; color: #fff; text-shadow: 0 1px 4px #000;
  pointer-events: none; opacity: 0; transition: opacity .18s;
}
.spot-marker:hover .spot-label, .spot-marker.show-label .spot-label { opacity: 1; }

/* the "you tapped here" marker */
.tap-pin {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--violet); border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(176,107,255,.28), 0 0 22px rgba(176,107,255,.9);
  animation: tappulse 2s ease-in-out infinite;
}
@keyframes tappulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(176,107,255,.28), 0 0 22px rgba(176,107,255,.9); }
  50% { box-shadow: 0 0 0 14px rgba(176,107,255,0), 0 0 22px rgba(176,107,255,.9); }
}

/* ---------- player ---------- */
.player {
  position: absolute; left: 50%; bottom: 0; z-index: 600;
  width: min(620px, 100%); transform: translate(-50%, 105%);
  background: var(--card); border: 1px solid var(--line); border-bottom: none;
  border-radius: 22px 22px 0 0; padding: 8px 20px max(18px, env(safe-area-inset-bottom));
  backdrop-filter: blur(18px); box-shadow: var(--shadow);
  transition: transform .4s cubic-bezier(.3, 1.05, .4, 1);
}
.player.open { transform: translate(-50%, 0); }
.player-grab { width: 42px; height: 4px; border-radius: 999px; background: rgba(255,255,255,.22); margin: 4px auto 12px; }
.np-head { display: flex; align-items: center; gap: 10px; }
.np-cat {
  font: 700 10.5px 'Inter', sans-serif; letter-spacing: .12em; text-transform: uppercase;
  color: var(--amber); background: rgba(255,181,77,.12); border: 1px solid rgba(255,181,77,.32);
  padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.np-place { color: var(--muted); font-size: 13px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-close {
  width: 32px; height: 32px; border-radius: 9px; cursor: pointer; flex-shrink: 0;
  background: transparent; color: var(--muted); border: 1px solid var(--line); font-size: 13px;
}
.np-close:hover { color: #ff8383; border-color: #ff8383; }
.np-title { font-family: 'Fraunces', serif; font-size: clamp(21px, 4.4vw, 28px); margin: 11px 0 8px; line-height: 1.16; }
.np-transcript {
  max-height: 19vh; overflow-y: auto; color: #c3caea; font-size: 14.5px; line-height: 1.62;
  padding-right: 6px; scrollbar-width: thin;
}
.np-progress { height: 5px; background: rgba(255,255,255,.09); border-radius: 999px; margin: 13px 0 12px; overflow: hidden; position: relative; }
.np-bar { height: 100%; width: 0%; background: var(--grad); border-radius: 999px; transition: width .3s linear; }
.np-controls { display: flex; align-items: center; justify-content: center; gap: 12px; }
.ctl {
  height: 50px; min-width: 62px; padding: 0 15px; border-radius: 14px; cursor: pointer;
  font: 700 14px 'Inter', sans-serif; color: var(--text);
  background: rgba(255,255,255,.07); border: 1px solid var(--line);
}
.ctl:hover { background: rgba(255,255,255,.13); }
.ctl.main {
  min-width: 78px; height: 60px; font-size: 23px; background: var(--grad); border: none;
  box-shadow: 0 10px 26px rgba(91,108,255,.45);
  display: flex; align-items: center; justify-content: center;
}
.ctl:disabled { opacity: .45; cursor: default; }
.ctl.main:disabled { opacity: 1; }
.np-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 11px; min-height: 15px; }
.np-queue, .np-count { font-size: 11.5px; color: var(--muted); }

/* loading state */
.spinner {
  display: inline-block; width: 23px; height: 23px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.28); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.player.loading .np-title, .player.loading .np-transcript { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.player.loading .np-progress::after {
  content: ""; position: absolute; inset: 0; border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(139,123,255,.85), transparent);
  animation: sweep 1.4s ease-in-out infinite;
}
@keyframes sweep { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ---------- filters sheet ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: 700; background: rgba(4, 6, 14, .6);
  backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .3s;
}
.backdrop.open { opacity: 1; pointer-events: auto; }
.filters {
  position: fixed; left: 50%; bottom: 0; z-index: 800;
  width: min(640px, 100%); transform: translate(-50%, 105%);
  max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-bottom: none;
  border-radius: 22px 22px 0 0; backdrop-filter: blur(18px); box-shadow: var(--shadow);
  transition: transform .38s cubic-bezier(.3, 1.05, .4, 1);
}
.filters.open { transform: translate(-50%, 0); }
.filters-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.filters-head strong { font-family: 'Fraunces', serif; font-size: 19px; }
.filters-body { overflow-y: auto; padding: 18px 20px max(20px, env(safe-area-inset-bottom)); }
.opt-group { margin-bottom: 22px; }
.opt-group h3 {
  font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px;
}
.opt-row { display: flex; gap: 16px; flex-wrap: wrap; }
.opt-row .half { flex: 1 1 240px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 9px 14px; border-radius: 999px; cursor: pointer;
  font: 600 13.5px 'Inter', sans-serif;
  background: rgba(255,255,255,.05); color: var(--muted);
  border: 1.5px solid var(--line); transition: all .15s;
}
.chip.on { background: rgba(91,108,255,.2); border-color: var(--blue); color: var(--text); }
.chip:hover { border-color: var(--violet); }
.seg { display: flex; background: rgba(7,10,20,.8); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  flex: 1; padding: 10px 6px; border: none; border-radius: 9px; cursor: pointer;
  font: 600 13.5px 'Inter', sans-serif; background: transparent; color: var(--muted); white-space: nowrap;
}
.seg button.on { background: var(--grad); color: #fff; box-shadow: 0 4px 14px rgba(91,108,255,.35); }
.narrator-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 9px; }
.narrator {
  padding: 12px 8px; border-radius: 13px; cursor: pointer; text-align: center;
  background: rgba(255,255,255,.04); border: 1.5px solid var(--line); color: var(--text);
  display: flex; flex-direction: column; gap: 3px; align-items: center; transition: all .15s;
}
.narrator span { font-size: 22px; }
.narrator strong { font-size: 13px; }
.narrator.on { border-color: var(--amber); background: rgba(255,181,77,.1); box-shadow: 0 0 0 3px rgba(255,181,77,.14); }
.filters-note { color: var(--muted); font-size: 12.5px; line-height: 1.55; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(120px);
  background: #1a2246; color: var(--text); border: 1px solid var(--line);
  padding: 12px 20px; border-radius: 12px; font-size: 14px; z-index: 950;
  transition: transform .3s ease; box-shadow: var(--shadow); max-width: calc(100vw - 40px);
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .np-transcript { max-height: 24vh; }
  .ctl { min-width: 54px; }
}
