:root {
  --ink: #0d0d0f;
  --panel: #16161a;
  --panel-2: #1e1e24;
  --line: #2c2c34;
  --text: #f3f0e9;
  --muted: #a09a8e;
  --gold: #e8b84b;
  --gold-dim: #b88f2e;
  --film: #e8b84b;
  --tv: #5fb0c9;
  --permit: #e2574c;
  --shadow: 0 18px 50px rgba(0,0,0,0.55);
  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  height: 100dvh;
}

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 22px;
  background: linear-gradient(180deg, #131316, #0f0f12);
  border-bottom: 1px solid var(--line);
  z-index: 600;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  border: 3px solid var(--gold);
  position: relative;
  box-shadow: inset 0 0 0 4px #0d0d0f;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
}
.brand-text h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 21px;
  line-height: 1;
  margin: 0 0 3px;
  letter-spacing: -0.01em;
}
.tagline { margin: 0; font-size: 12.5px; color: var(--muted); letter-spacing: 0.02em; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.search { position: relative; }
.search input {
  width: 320px; max-width: 42vw;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  padding: 10px 16px 10px 38px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search::before {
  content: ""; position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; border: 2px solid var(--muted); border-radius: 50%;
  box-shadow: 7px 7px 0 -5px var(--muted);
}
.search input:focus { border-color: var(--gold-dim); box-shadow: 0 0 0 3px rgba(232,184,75,.15); }
.search input::placeholder { color: #6f6a60; }

.ghost-btn {
  background: transparent; color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 18px; font-family: var(--sans); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: border-color .15s, color .15s;
}
.ghost-btn:hover { border-color: var(--gold-dim); color: var(--gold); }
.toggle-btn { display: inline-flex; align-items: center; gap: 8px; }
.toggle-dot { width: 8px; height: 8px; border-radius: 50%; background: #524d44; transition: background .15s, box-shadow .15s; }
.toggle-btn[aria-pressed="true"] { border-color: var(--permit, #e2574c); color: #f0a59d; }
.toggle-btn[aria-pressed="true"] .toggle-dot { background: var(--permit, #e2574c); box-shadow: 0 0 8px rgba(226,87,76,.7); }

/* ---- Stage ---- */
.stage { position: relative; overflow: hidden; }
#map { position: absolute; inset: 0; background: #0a0a0c; }

/* Markers */
.loc-marker {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.55);
  box-shadow: 0 0 0 2px rgba(255,255,255,.08), 0 2px 6px rgba(0,0,0,.5);
  transition: transform .12s;
}
.loc-marker.film { background: var(--film); }
.loc-marker.tv { background: var(--tv); }
.loc-marker:hover { transform: scale(1.45); z-index: 500; }

.leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--text);
  border-radius: 12px; border: 1px solid var(--line);
  box-shadow: var(--shadow);
  overflow: hidden; padding: 0;
}
.leaflet-popup-tip { background: var(--panel); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 0; font-family: var(--sans); width: 270px !important; }
.popup { padding: 0 0 14px; }
.popup-img { position: relative; margin: 0 0 10px; border-radius: 11px 11px 0 0; overflow: hidden; line-height: 0; background: #0a0a0c; }
.popup-img img { width: 100%; height: 150px; object-fit: cover; display: block; }
.popup-img-credit {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 10px; color: #cfc7b8; line-height: 1.2;
  padding: 10px 10px 5px; text-align: right;
  background: linear-gradient(0deg, rgba(0,0,0,.75), rgba(0,0,0,0));
}
.popup > .popup-title, .popup > .popup-place, .popup > .popup-addr, .popup > .popup-scene, .popup > .popup-note { margin-left: 16px; margin-right: 16px; }
.popup:not(:has(.popup-img)) > .popup-title { margin-top: 14px; }
.popup-title { font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.15; margin: 0 0 2px; }
.popup-year { color: var(--gold); font-weight: 600; font-size: 13px; }
.popup-type { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-left: 6px; }
.popup-place { font-size: 13.5px; font-weight: 600; margin: 8px 0 1px; }
.popup-addr { font-size: 12.5px; color: var(--muted); margin: 0 0 8px; }
.popup-scene { font-size: 13px; line-height: 1.45; color: #ddd6c9; margin: 0; }
.popup-note { font-size: 11.5px; color: #8a8478; font-style: italic; margin: 8px 0 0; }

/* ---- Era panel ---- */
.era-panel {
  position: absolute; top: 18px; left: 18px; z-index: 500;
  width: 300px; max-width: calc(100vw - 36px);
  background: rgba(20,20,24,.86);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.era-kicker { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.era-title { font-family: var(--serif); font-weight: 700; font-size: 27px; line-height: 1.05; margin: 6px 0 9px; letter-spacing: -0.01em; }
.era-blurb { font-size: 13.5px; line-height: 1.5; color: #d8d1c4; margin: 0 0 12px; }
.era-stat { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 11px; }
.era-stat b { color: var(--text); font-family: var(--serif); font-size: 16px; }

/* ---- Legend ---- */
.legend {
  position: absolute; bottom: 16px; right: 16px; z-index: 500;
  display: flex; gap: 16px;
  background: rgba(20,20,24,.86); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px; font-size: 12.5px; color: var(--muted);
}
.legend-item { display: flex; align-items: center; gap: 7px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.film { background: var(--film); }
.dot.tv { background: var(--tv); }
.dot.permit { background: var(--permit); }

/* ---- Search results ---- */
.results {
  position: absolute; top: 18px; right: 18px; z-index: 550;
  width: 330px; max-width: calc(100vw - 36px); max-height: calc(100% - 36px);
  display: flex; flex-direction: column;
  background: rgba(20,20,24,.94); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden;
}
.results[hidden] { display: none; }
.results-head { display: flex; justify-content: space-between; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); }
.text-btn { background: none; border: none; color: var(--gold); font-family: var(--sans); font-size: 12.5px; cursor: pointer; padding: 0; }
#results-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.result-row { padding: 10px 12px; border-radius: 9px; cursor: pointer; transition: background .12s; }
.result-row:hover { background: var(--panel-2); }
.result-row .r-title { font-weight: 600; font-size: 14px; }
.result-row .r-year { color: var(--gold); font-weight: 600; font-size: 12.5px; margin-left: 6px; }
.result-row .r-place { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ---- Timeline ---- */
.timeline {
  background: linear-gradient(0deg, #0c0c0f, #131316);
  border-top: 1px solid var(--line);
  padding: 14px 22px 18px;
  z-index: 600;
}
.timeline-controls { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; }
.play-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%;
  background: var(--gold); border: none; cursor: pointer;
  display: grid; place-items: center;
  transition: transform .12s, background .15s;
}
.play-btn:hover { transform: scale(1.06); }
.play-icon { width: 0; height: 0; border-left: 14px solid var(--ink); border-top: 9px solid transparent; border-bottom: 9px solid transparent; margin-left: 3px; }
.play-btn.is-playing .play-icon { border: none; width: 13px; height: 14px; margin: 0; border-left: 4px solid var(--ink); border-right: 4px solid var(--ink); }

.timeline-readout { flex: 1; min-width: 0; }
.readout-decade { font-family: var(--serif); font-weight: 700; font-size: 22px; letter-spacing: -0.01em; }
.readout-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.filters { display: flex; gap: 8px; }
.chip {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 7px 15px; font-family: var(--sans); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all .14s;
}
.chip:hover { color: var(--text); }
.chip.is-active { background: var(--gold); border-color: var(--gold); color: var(--ink); }

/* Scrubber */
.scrubber { position: relative; padding: 8px 4px 2px; }
.scrubber-track { position: relative; display: flex; justify-content: space-between; height: 56px; }
.tick {
  position: relative; flex: 1; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding-bottom: 22px;
}
.tick-bar {
  width: 70%; max-width: 46px; border-radius: 4px 4px 0 0;
  background: var(--panel-2); border: 1px solid var(--line); border-bottom: none;
  transition: background .15s, border-color .15s, opacity .15s;
  min-height: 4px;
}
.tick.is-active .tick-bar { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 16px rgba(232,184,75,.4); }
.tick:hover .tick-bar { border-color: var(--gold-dim); }
.tick-label {
  position: absolute; bottom: 0; font-size: 11.5px; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: .01em;
}
.tick.is-active .tick-label { color: var(--gold); font-weight: 600; }
.tick.all-tick .tick-bar { background: transparent; border-style: dashed; }
.tick.all-tick.is-active .tick-bar { background: var(--gold); border-style: solid; }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(6,6,8,.7); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 24px;
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: min(640px, 100%); max-height: 85vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 30px 34px; box-shadow: var(--shadow);
}
.modal-close { position: absolute; top: 14px; right: 18px; background: none; border: none; color: var(--muted); font-size: 30px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-card h2 { font-family: var(--serif); font-weight: 700; font-size: 28px; margin: 0 0 14px; }
.modal-body { font-size: 14.5px; line-height: 1.6; color: #ddd6c9; }
.modal-body h3 { font-family: var(--serif); font-size: 18px; color: var(--text); margin: 22px 0 6px; }
.modal-body p { margin: 0 0 12px; }
.modal-body a { color: var(--gold); }
.modal-body ul { margin: 0 0 12px; padding-left: 20px; }
.modal-body li { margin-bottom: 5px; }

/* ---- Responsive ---- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .brand-text h1 { font-size: 18px; }
  .search input { width: 100%; max-width: none; }
  .search { flex: 1; }
  .topbar-actions { width: 100%; }
  .era-panel { width: calc(100vw - 24px); top: 12px; left: 12px; padding: 14px 16px; }
  .era-title { font-size: 22px; }
  .era-blurb { display: none; }
  .results { width: calc(100vw - 24px); top: auto; bottom: 12px; right: 12px; max-height: 50%; }
  .legend { display: none; }
  .timeline { padding: 12px 14px 16px; }
  .timeline-controls { gap: 12px; flex-wrap: wrap; }
  .readout-decade { font-size: 19px; }
  .tick-label { font-size: 9.5px; transform: rotate(-35deg); transform-origin: center; }
  .scrubber-track { height: 48px; }
}
