/* Barriografía: hoja de estilos única (sin frameworks). Tokens del canvas de diseño. */

:root {
  --bg: #121212;
  --surface: #1e1e1e;
  --line: #333333;
  --border: #2a2a2a;
  --gold: #d4af37;
  --brick: #c0392b;       /* bordes, marcador activo */
  --brick-text: #e0604f;  /* texto: 5.3:1 sobre --bg */
  --text: #ededed;
  --soft: #c8c8c8;
  --muted: #a0a0a0;
  --photo: #2a2318;
  --serif: "Fraunces", Georgia, Cambria, serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, figure, ul { margin: 0; }
ul { padding: 0; list-style: none; }
img, svg { display: block; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- Mapa ---------- */
#map { position: fixed; inset: 0; width: 100%; height: 100%; background: #151515; }

.glass {
  background: rgba(18, 18, 18, 0.92);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

/* ---------- Encabezado ---------- */
.topbar {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { border-radius: 14px; padding: 10px 14px; }
.brand-name { font-family: var(--serif); font-size: 22px; line-height: 1.15; font-weight: 700; color: var(--gold); }
.brand-tagline { font-size: 12px; color: var(--muted); }

.lang-switch { display: flex; margin-left: auto; border-radius: 999px; padding: 4px; }
.lang-btn {
  min-width: 44px;
  height: 40px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.lang-btn:hover { color: var(--text); }
.lang-btn[aria-pressed="true"] { background: var(--gold); color: var(--bg); }
.lang-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Marcadores: área táctil 44px, punto 18px ---------- */
.marker { width: 44px; height: 44px; display: grid; place-items: center; }
.marker-dot {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 3px solid var(--bg);
  box-shadow: 0 0 0 2px var(--gold), 0 0 0 10px rgba(212, 175, 55, 0.18);
  transition: width 0.2s, height 0.2s;
}
.marker-dot::after {
  content: "";
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  animation: pulse 2.2s var(--ease) infinite;
}
.marker.is-active .marker-dot {
  width: 22px;
  height: 22px;
  background: var(--brick);
  box-shadow: 0 0 0 2px var(--brick), 0 0 0 10px rgba(192, 57, 43, 0.25);
}
.marker.is-active .marker-dot::after { border-color: var(--brick); }
.marker:focus-visible { outline: 3px solid #fff; outline-offset: -4px; border-radius: 50%; }

@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  100% { transform: scale(2.2); opacity: 0; }
}

/* ---------- Capas históricas ---------- */
/* Cada botón y marcador recibe su color en --layer-color (desde data/layers/*.json) */
.layer-bar {
  position: fixed;
  top: 88px;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
  pointer-events: none;
}
.layer-bar::-webkit-scrollbar { display: none; }
.layer-btn {
  flex: none;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  color: var(--soft);
  pointer-events: auto;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.layer-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--layer-color, var(--brick)); }
.layer-years { font-weight: 400; color: var(--muted); }
.layer-btn:hover { color: var(--text); }
.layer-btn[aria-pressed="true"] { background: var(--layer-color, var(--brick)); border-color: var(--layer-color, var(--brick)); color: #fff; }
.layer-btn[aria-pressed="true"] .layer-dot { background: #fff; }
.layer-btn[aria-pressed="true"] .layer-years { color: rgba(255, 255, 255, 0.85); }
.layer-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
body.panel-open .layer-bar { display: none; }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; max-width: calc(100% - 32px); margin: 0 16px; padding: 8px 14px; border-radius: 12px; font-size: 12px; color: var(--soft); pointer-events: auto; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 22px; height: 4px; border-radius: 2px; background: var(--layer-color, var(--brick)); }
.legend-line--dashed { height: 0; border-top: 3px dashed var(--layer-color, var(--brick)); background: none; border-radius: 0; }
.legend-point { width: 12px; height: 12px; border-radius: 3px; background: var(--layer-color, var(--brick)); border: 2px solid #fff; }

/* Puntos de capa: marcador cuadrado del color de la capa; activo en oro */
.marker--station .marker-dot { width: 16px; height: 16px; border-radius: 4px; background: var(--layer-color, var(--brick)); border: 2px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
.marker--station .marker-dot::after { display: none; }
.marker--station.is-active .marker-dot { width: 20px; height: 20px; background: var(--gold); border-color: var(--bg); box-shadow: 0 0 0 2px var(--gold), 0 0 0 9px rgba(212, 175, 55, 0.25); }

@media (min-width: 1024px) {
  .layer-bar { top: 116px; padding: 0 24px; flex-wrap: wrap; right: auto; max-width: 60vw; }
}

/* ---------- Inicio: pista + lista de historias ---------- */
.home-ui {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s var(--ease);
}
.home-ui.is-hidden { opacity: 0; transform: translateY(16px); }
.home-ui:not(.is-hidden) .hint,
.home-ui:not(.is-hidden) .stories-nav { pointer-events: auto; }
.hint { border-radius: 999px; padding: 10px 16px; font-size: 14px; margin: 0 16px; text-align: center; }
.stories-nav { width: 100%; }

.story-list {
  display: flex;
  gap: 12px;
  padding: 0 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.story-list::-webkit-scrollbar { display: none; }
.story-card {
  flex: none;
  width: 260px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  text-align: left;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  scroll-snap-align: start;
  transition: border-color 0.2s;
}
.story-card:hover, .story-card:focus-visible { border-color: var(--gold); outline: none; }
.story-card img { flex: none; width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--photo); }
.story-card-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.story-card-commune { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brick-text); }
.story-card-title { font-family: var(--serif); font-size: 16px; line-height: 20px; color: var(--gold); }
.story-card-hood { font-size: 12px; color: var(--muted); }

/* ---------- Panel: bottom sheet (móvil) ---------- */
.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  /* Altura completa 92 %; abre a media altura (60 %) para que el punto se vea en el mapa */
  --sheet-offset: 32vh;
  --sheet-offset: 32dvh;
  height: 92vh;
  height: 92dvh;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform: translateY(100%);
  transition: transform 0.35s var(--ease), visibility 0s linear 0.35s;
  visibility: hidden;
}
.panel.is-open { transform: translateY(var(--sheet-offset)); visibility: visible; transition: transform 0.35s var(--ease); }
.panel.is-open.is-expanded { transform: translateY(0); }
/* Con el panel abierto en el celular se oculta el logo para dejar ver el punto */
@media (max-width: 1023px) {
  body.panel-open .brand { display: none; }
}
.panel.is-dragging { transition: none; }
.panel-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; }

.sheet-handle {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  height: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: none;
  cursor: grab;
  background: linear-gradient(rgba(0, 0, 0, 0.55), transparent);
}
.sheet-handle span { width: 44px; height: 5px; border-radius: 999px; background: rgba(255, 255, 255, 0.75); }

.panel-close { position: absolute; top: 16px; right: 12px; z-index: 10; background: rgba(0, 0, 0, 0.6); }
.panel-close:hover { background: rgba(0, 0, 0, 0.8); }

.story-figure img { width: 100%; height: 220px; object-fit: cover; background: var(--photo); }
.story-figure figcaption { display: flex; flex-direction: column; gap: 2px; padding: 8px 20px 0; font-size: 12px; line-height: 17px; color: var(--muted); }
.caption-text { color: var(--soft); }
.caption-credit a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.caption-credit a:hover { color: var(--gold); }

/* Miniaturas: varias fotos por historia (ej. ayer / hoy) */
.story-thumbs { display: flex; gap: 8px; padding: 10px 20px 0; }
.story-thumbs:empty { display: none; }
.thumb-btn { position: relative; width: 64px; height: 48px; border-radius: 8px; overflow: hidden; border: 2px solid transparent; }
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; }
.thumb-btn[aria-pressed="true"] { border-color: var(--gold); }
.thumb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.thumb-year { position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 0; font-size: 10px; font-weight: 600; text-align: center; color: #fff; background: rgba(0, 0, 0, 0.65); }

/* Historia: línea de tiempo y fuentes */
.story-panel { display: flex; flex-direction: column; gap: 24px; }
.section-title { margin-bottom: 12px; font-family: var(--serif); font-size: 20px; font-weight: 500; color: var(--gold); }
.timeline { padding: 0; list-style: none; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li { position: relative; padding: 0 0 16px 20px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--gold);
}
.timeline-year { display: block; font-size: 13px; font-weight: 600; letter-spacing: 0.06em; color: var(--brick-text); }
.timeline-text { font-size: 15px; line-height: 22px; color: var(--soft); }

/* Videos: miniatura que se convierte en reproductor al tocarla */
.videos { display: flex; flex-direction: column; gap: 16px; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-facade { position: absolute; inset: 0; width: 100%; height: 100%; }
.video-facade img { width: 100%; height: 100%; object-fit: cover; opacity: 0.85; transition: opacity 0.2s; }
.video-facade:hover img { opacity: 1; }
.video-facade:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
.video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--gold);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}
.video-meta { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; }
.video-title { font-size: 15px; font-weight: 600; line-height: 21px; }
.video-note { font-size: 13px; line-height: 19px; color: var(--muted); }

.sources { border-top: 1px solid var(--line); padding-top: 12px; }
.sources summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--text); }
.sources summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.sources ul { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.sources li { font-size: 13px; line-height: 19px; color: var(--muted); }
.sources a { color: var(--soft); text-underline-offset: 2px; }
.sources a:hover { color: var(--gold); }

.panel-body { display: flex; flex-direction: column; gap: 16px; padding: 12px 20px 40px; }
.story-head { display: flex; flex-direction: column; gap: 4px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--brick-text); }
.story-title { font-family: var(--serif); font-size: 28px; line-height: 32px; font-weight: 700; color: var(--gold); }
.story-title:focus { outline: none; }
.story-short { margin-top: 4px; font-size: 15px; line-height: 22px; color: var(--soft); }
.story-full { max-width: 62ch; white-space: pre-line; font-size: 17px; line-height: 28px; }

/* ---------- Panel: sidebar (escritorio) ---------- */
@media (min-width: 1024px) {
  .topbar { top: 24px; left: 24px; right: 24px; }
  .brand { padding: 12px 18px; }
  .brand-name { font-size: 28px; }
  .brand-tagline { font-size: 13px; }
  /* centrado seguro: con más tarjetas de las que caben, la primera sigue siendo alcanzable */
  .story-card:first-child { margin-left: auto; }
  .story-card:last-child { margin-right: auto; }

  .panel {
    left: auto;
    top: 0;
    height: 100vh;
    width: 35vw;
    min-width: 400px;
    border-radius: 0;
    border-left: 1px solid var(--border);
    box-shadow: none;
    transform: translateX(100%);
  }
  .panel.is-open { transform: translateX(0); }
  .sheet-handle { display: none; }
  .panel-close { right: 16px; }
  .story-figure img { height: 280px; }
  .story-figure figcaption { padding: 8px 32px 0; }
  .story-thumbs { padding: 10px 32px 0; }
  .panel-body { gap: 18px; padding: 12px 32px 40px; }
  .story-title { font-size: 34px; line-height: 38px; }
  .story-short { font-size: 16px; line-height: 24px; }
}

/* ---------- Botones ---------- */
.icon-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); }
.icon-btn:focus-visible, .audio-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.2s, background 0.2s;
}
.btn-gold { height: 56px; background: var(--gold); color: var(--bg); font-size: 16px; }
.btn-gold:hover { filter: brightness(1.08); }
.btn-outline { border: 1px solid var(--gold); color: var(--gold); }
.btn-outline:hover { background: rgba(212, 175, 55, 0.1); }
.btn-dark { width: 100%; background: var(--bg); color: var(--text); }
.btn-dark:hover { background: #000; }
.btn:focus-visible, .go-support:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- Narración ---------- */
.audio { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: var(--surface); }
.audio-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--gold); display: grid; place-items: center; }
.audio-btn .icon-pause { display: none; }
.audio-btn.is-playing .icon-play { display: none; }
.audio-btn.is-playing .icon-pause { display: block; }
.audio-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.audio-label { font-size: 13px; font-weight: 600; }
.audio-track { display: block; height: 4px; border-radius: 2px; background: var(--line); }
.audio-progress { display: block; width: 0; height: 4px; border-radius: 2px; background: var(--gold); }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab-btn {
  height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }
.tab-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
/* Tips siempre resaltada en ladrillo: es lo que el turista busca en la calle */
.tab-tips { color: var(--text); background: rgba(192, 57, 43, 0.18); border-radius: 8px 8px 0 0; }
.tab-tips[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--brick); }

/* ---------- Tips ---------- */
.tips { display: flex; flex-direction: column; gap: 14px; }
.tip-card { display: flex; gap: 14px; padding: 16px; border-radius: 12px; background: var(--surface); }
.tip-icon { flex: none; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; }
.tip-icon-gold { background: rgba(212, 175, 55, 0.14); }
.tip-icon-brick { background: rgba(192, 57, 43, 0.18); }
.tip-body { display: flex; flex-direction: column; gap: 4px; }
.tip-body h3 { font-size: 16px; font-weight: 600; }
.tip-body p { font-size: 15px; line-height: 22px; color: var(--soft); }
.badge {
  align-self: flex-start;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
}
.go-support {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid rgba(212, 175, 55, 0.35);
}
.go-support-text { display: flex; flex-direction: column; gap: 2px; }
.go-support-title { font-family: var(--serif); font-size: 17px; color: var(--gold); }
.go-support-sub { font-size: 13px; color: var(--muted); }

/* ---------- Apoyo ---------- */
.support {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid rgba(212, 175, 55, 0.35);
}
.support-head { display: flex; flex-direction: column; gap: 4px; }
.support-head h3 { font-family: var(--serif); font-size: 20px; font-weight: 500; color: var(--gold); }
.support-head h3:focus { outline: none; }
.support-head p { font-size: 14px; line-height: 20px; color: var(--muted); }
.support-options { display: flex; flex-direction: column; gap: 16px; }
.support-options.is-local-first { flex-direction: column-reverse; }
.support-intl { display: flex; flex-direction: column; gap: 10px; }
.support-alternatives { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.support-alternatives:empty { display: none; }
.note { font-size: 12px; line-height: 17px; color: var(--muted); }
.divider { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.support-local { display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 16px; border-radius: 12px; background: var(--bg); }
.support-local-label { font-weight: 600; text-align: center; }
.support-qr { align-self: center; width: 100%; max-width: 240px; height: auto; border-radius: 12px; background: #fff; }
.pay-key { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.pay-key-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pay-key-label { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.pay-key-value { font-size: 20px; font-weight: 600; letter-spacing: 0.04em; color: var(--gold); font-variant-numeric: tabular-nums; }
.pay-key-holder { font-size: 13px; color: var(--soft); }
.pay-key-copy { flex: none; height: 44px; padding: 0 14px; }

/* Pie legal */
.home-legal { margin: 0 16px; font-size: 11px; color: var(--muted); text-align: center; pointer-events: auto; }
.home-legal a, .panel-legal a { color: var(--soft); text-underline-offset: 2px; }
.home-legal a:hover, .panel-legal a:hover { color: var(--gold); }
.panel-legal { padding-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 16px);
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--bg); }

/* ---------- MapLibre en oscuro ---------- */
.maplibregl-ctrl-top-left { top: 96px; left: 6px; }
@media (max-width: 1023px) { .maplibregl-ctrl-top-left { display: none; } } /* en móvil: gesto de pellizco */
@media (min-width: 1024px) { .maplibregl-ctrl-top-left { top: 232px; left: 14px; } }
.maplibregl-ctrl-group { background: var(--surface) !important; }
.maplibregl-ctrl-group button { width: 44px !important; height: 44px !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { background: rgba(18, 18, 18, 0.7) !important; color: var(--muted); }
.maplibregl-ctrl-attrib a { color: var(--muted) !important; }

@media (prefers-reduced-motion: reduce) {
  .panel, .home-ui, .tab-btn, .toast, .marker-dot { transition: none; }
  .marker-dot::after { animation: none; }
}

/* ---------- Página de aviso legal ---------- */
body.legal-page { overflow: auto; height: auto; }
.legal { max-width: 760px; margin: 0 auto; padding: 32px 20px 64px; line-height: 1.65; }
.legal h1 { font-family: var(--serif); font-size: 32px; line-height: 1.2; color: var(--gold); margin: 24px 0 4px; }
.legal h2 { font-family: var(--serif); font-size: 20px; font-weight: 500; color: var(--gold); margin: 28px 0 8px; }
.legal p { margin: 0 0 12px; color: var(--soft); }
.legal strong { color: var(--text); }
.legal a { color: var(--gold); text-underline-offset: 2px; }
.legal hr { border: 0; border-top: 1px solid var(--line); margin: 40px 0; }
.legal-updated, .legal-foot { font-size: 13px; color: var(--muted) !important; }
.legal-back { font-size: 14px; }

/* ---------- Navegación dentro del panel ---------- */
.panel-back {
  position: absolute;
  top: 16px;
  left: 12px;
  z-index: 10;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px 0 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}
.panel-back:hover { background: rgba(0, 0, 0, 0.8); }
.panel-back:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (min-width: 1024px) { .panel-back { left: 16px; } }

.story-nav { display: flex; flex-direction: column; gap: 12px; padding: 16px 0 4px; border-top: 1px solid var(--line); }
.story-pos { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); text-align: center; }
.story-nav-buttons { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.nav-card {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: left;
  transition: border-color 0.2s;
}
.nav-next { text-align: right; align-items: flex-end; }
.nav-card:hover { border-color: var(--gold); }
.nav-card:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.nav-card[hidden] { display: none !important; }
.nav-card:only-child, .story-nav-buttons:has(> .nav-card[hidden]) .nav-card:not([hidden]) { grid-column: 1 / -1; }
.nav-dir { display: flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.nav-group { font-size: 11px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brick-text); }
.nav-title { font-family: var(--serif); font-size: 15px; line-height: 19px; color: var(--text); }

/* ---------- Portada: el gran relato de Medellín ---------- */
.intro { position: fixed; inset: 0; z-index: 60; background: #000; }
.intro-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(rgba(0, 0, 0, 0.75), transparent);
}
.intro-brand { font-family: var(--serif); font-size: 20px; font-weight: 700; color: var(--gold); }
.intro-bar-actions { display: flex; align-items: center; gap: 8px; }
.intro-lang { display: flex; padding: 4px; border-radius: 999px; background: rgba(18, 18, 18, 0.7); border: 1px solid var(--border); }
.intro-skip {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 14px 0 16px;
  border-radius: 999px;
  background: var(--gold);
  color: var(--bg);
  font-size: 14px;
  font-weight: 600;
}
.intro-skip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.intro-scroll { height: 100%; overflow-y: auto; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.intro-scroll::-webkit-scrollbar { display: none; }

.intro-slide {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: flex-end;
  scroll-snap-align: start;
  overflow: hidden;
}
.intro-slide > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.06);
  transition: transform 6s ease-out;
  filter: saturate(0.9);
}
.intro-slide.is-visible > img { transform: scale(1); }
.intro-slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.15) 0%, rgba(0, 0, 0, 0.35) 40%, rgba(10, 10, 10, 0.92) 78%, #0b0b0b 100%);
}
.intro-content {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 22px 56px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s ease, transform 0.8s var(--ease);
}
.intro-slide.is-visible .intro-content { opacity: 1; transform: none; }
.intro-year { font-family: var(--serif); font-size: clamp(44px, 12vw, 88px); line-height: 1; font-weight: 700; color: var(--gold); }
.intro-title { font-family: var(--serif); font-size: clamp(24px, 6vw, 40px); line-height: 1.15; font-weight: 700; color: #fff; }
.intro-text { font-size: 17px; line-height: 1.6; color: #e6e6e6; max-width: 62ch; }
.intro-credit { font-size: 11px; line-height: 1.4; color: rgba(255, 255, 255, 0.6); }
.intro-credit a { color: rgba(255, 255, 255, 0.75); }
.intro-cta { align-self: flex-start; margin-top: 4px; padding: 0 18px; }
.intro-cover .intro-title { font-size: clamp(34px, 9vw, 64px); }
.intro-kicker { font-size: 12px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--brick-text); }
.intro-hint { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; color: rgba(255, 255, 255, 0.8); }
.intro-hint svg { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(6px); } }
.intro-cover-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.intro-progress { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; height: 3px; background: rgba(255, 255, 255, 0.12); }
.intro-progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width 0.2s linear; }

/* Botón para volver a abrir la portada */
.layer-btn--story { border-color: rgba(212, 175, 55, 0.6); color: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  .intro-slide > img, .intro-content { transition: none; transform: none; opacity: 1; }
  .intro-hint svg { animation: none; }
}

/* Tarjeta discreta que invita a la historia (el mapa sigue siendo lo principal) */
.intro-teaser { display: flex; align-items: center; gap: 4px; margin: 0 16px; border-radius: 14px; padding: 6px; pointer-events: auto; max-width: 360px; align-self: center; width: calc(100% - 32px); }
.teaser-open { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; background: none; border: 0; color: var(--text); text-align: left; cursor: pointer; padding: 0; font: inherit; }
.teaser-open img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; flex-shrink: 0; filter: sepia(.35); }
.teaser-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.teaser-kicker { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.teaser-title { font-family: var(--serif); font-size: 16px; line-height: 1.2; }
.teaser-cta { font-size: 13px; color: var(--gold); }
.teaser-open:hover .teaser-title, .teaser-open:focus-visible .teaser-title { color: var(--gold); }
.teaser-close { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; flex-shrink: 0; }
.teaser-close:hover { color: var(--text); background: rgba(255,255,255,.08); }
@media (min-width: 1024px) { .intro-teaser { position: fixed; top: 92px; right: 24px; margin: 0; width: 340px; } .teaser-kicker { white-space: nowrap; } }

/* ---------- Ajustes de UX: el mapa manda ---------- */
.intro-skip { white-space: nowrap; }
@media (max-width: 1023px) {
  /* Inicio compacto en celular: menos capas de UI sobre el mapa */
  .home-ui { gap: 8px; padding-bottom: calc(40px + env(safe-area-inset-bottom)); }
  body.has-teaser .hint { display: none; }          /* la tarjeta ya invita a explorar */
  .hint { font-size: 13px; padding: 8px 14px; }
  .intro-teaser { padding: 4px 4px 4px 6px; border-radius: 12px; }
  .teaser-open { gap: 10px; }
  .teaser-open img { width: 44px; height: 44px; border-radius: 8px; }
  .teaser-kicker { display: none; }
  .teaser-title { font-size: 15px; }
  .story-card { width: 236px; padding: 8px; gap: 10px; }
  .story-card img { width: 52px; height: 52px; }
  .story-card-title { font-size: 15px; line-height: 19px; }
  .legend { padding: 6px 12px; font-size: 11px; }
  .home-legal { font-size: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: calc(100% - 32px); }
  .legal-rights { display: none; }                   /* los derechos reservados siguen en el panel y en /legal */
  .intro-bar { gap: 8px; }
  .intro-skip { padding-inline: 14px; }
}

/* Botón Centrar */
.recenter-btn { position: fixed; z-index: 20; top: 144px; right: 16px; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--text); cursor: pointer; padding: 0; }
.recenter-btn:hover { color: var(--gold); border-color: var(--gold); }
.recenter-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
@media (max-width: 1023px) { body.panel-open .recenter-btn { top: 16px; right: auto; left: 16px; } }
@media (min-width: 1024px) { .recenter-btn { top: 342px; left: 24px; right: auto; border-radius: 10px; } }
.story-card-commune { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 1023px) { .home-ui { padding-bottom: calc(58px + env(safe-area-inset-bottom)); } }
@media (min-width: 1024px) { .home-legal { align-self: flex-start; margin-left: 24px; } }
