:root {
  /* DOXA: negro, azul de cabecera y azul de enlaces · Papal: oro vaticano y blanco marfil */
  --black: #0d0d0d;
  --navy: #27506c;
  --navy-2: #1e3f55;
  --blue: #2270b0;
  --gold: #e9b824;
  --gold-deep: #8f6b0c;
  --gold-soft: #fbf3d9;
  --bg: #faf8f2;
  --card: #ffffff;
  --ink: #1c1c1c;
  --muted: #494d50;
  --line: #e3e2e2;
  --live: #d0312d;
  --ok: #2e7d4f;
  --warn: #b26a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(13, 13, 13, .05), 0 4px 16px rgba(39, 80, 108, .07);
  --serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
  --sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 108px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--sans); }
a { color: var(--blue); }
button { font: inherit; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Barra superior */
.topbar { background: linear-gradient(90deg, var(--black) 0%, #173246 55%, var(--navy) 100%); color: #fff; border-bottom: 3px solid var(--gold); }
.topbar-in { display: flex; align-items: center; gap: 14px; height: 52px; }
.brand { font-family: var(--serif); font-weight: 600; letter-spacing: .32em; color: #fff; text-decoration: none; font-size: 20px; }
.topbar-title { min-width: 0; font-size: 14px; color: #d6dde3; border-left: 1px solid rgba(255, 255, 255, .22); padding-left: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.live-pill { flex: none; white-space: nowrap; margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; background: var(--live); color: #fff; padding: 3px 9px; border-radius: 99px; }
.live-pill i { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.sections { position: sticky; top: 0; z-index: 20; background: rgba(250, 248, 242, .95); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.sections-in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-top: 8px; padding-bottom: 8px; }
.sections-in::-webkit-scrollbar { display: none; }
.sections a { flex: none; text-decoration: none; color: var(--navy); font-size: 14px; font-weight: 600; padding: 6px 12px; border-radius: 99px; }
.sections a:hover, .sections a:focus-visible { background: var(--gold-soft); }

main { padding-top: 16px; padding-bottom: 40px; display: grid; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.h2 { font-family: var(--serif); font-size: 22px; line-height: 1.2; margin: 0 0 12px; color: var(--navy); }
.h3 { font-size: 15px; margin: 0 0 6px; color: var(--navy); }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--blue); }
.fine { font-size: 13px; color: var(--muted); margin: 10px 0 0; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--navy); color: #fff; width: 100%; padding: 14px; font-size: 16px; }
.btn-primary:hover { background: var(--navy-2); }
.btn-primary[disabled] { opacity: .6; cursor: wait; }
.btn-ghost { background: var(--gold-soft); color: var(--navy); }
.btn-ghost:hover { background: #f6e6ae; }
.btn-small { background: var(--navy); color: #fff; padding: 8px 12px; font-size: 14px; }

/* Portada con la foto del Papa */
.hero { position: relative; overflow: hidden; border-radius: var(--radius); min-height: 190px; display: flex; align-items: flex-end; color: #fff;
  background: linear-gradient(100deg, var(--black) 0%, #173246 45%, var(--navy) 100%); box-shadow: var(--shadow); }
.hero img { position: absolute; top: 0; right: 0; width: 50%; height: 100%; object-fit: cover; object-position: 50% 10%;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 40%); mask-image: linear-gradient(90deg, transparent 0%, #000 40%); }
.hero-text { position: relative; padding: 20px; max-width: 64%; }
.hero-eyebrow { color: var(--gold); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { font-family: var(--serif); font-size: clamp(27px, 6.4vw, 44px); line-height: 1.05; margin: 6px 0 8px; }
.hero p { margin: 0; color: #dbe4eb; font-size: 14px; }
.hero .dates { display: inline-block; margin-top: 12px; background: var(--gold); color: var(--black); font-weight: 700; font-size: 13px; padding: 4px 11px; border-radius: 99px; }
.hero-credit { position: absolute; right: 6px; top: 6px; font-size: 10px; color: rgba(255, 255, 255, .9); background: rgba(13, 13, 13, .55); padding: 1px 6px; border-radius: 6px; }
.hero-credit a { color: inherit; }

/* Ahora */
.now { border-top: 5px solid var(--gold); }
.now-head { display: flex; justify-content: space-between; align-items: center; }
.clock { font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.now-title { font-family: var(--serif); font-size: clamp(24px, 5vw, 34px); line-height: 1.15; margin: 6px 0 4px; color: var(--navy); }
.now-place { margin: 0; color: var(--muted); font-size: 16px; }
.now-next { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: var(--bg); display: grid; gap: 2px; }
.now-next:empty { display: none; }
.now-next .lbl { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.now-next .what { font-weight: 600; }
.now-next .late { font-weight: 700; color: var(--warn); }
.countdown { font-family: var(--serif); font-size: 28px; font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; }
.now-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.progress { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 12px; }
.progress span { display: block; height: 100%; background: var(--gold); width: 0; transition: width .6s; }

/* Novedades */
.updates-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.updates-list li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.updates-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.updates-list time { font-weight: 700; color: var(--blue); font-variant-numeric: tabular-nums; font-size: 14px; padding-top: 1px; }
.updates-list .pin { background: var(--gold-soft); border-radius: 8px; padding: 8px; border-bottom: 0; }

/* Mapa */
.map-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.map-head .h2 { margin: 0; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 99px; padding: 6px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.map { height: min(62vh, 520px); min-height: 340px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #e9e6df; }
.legend { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 4px; border-radius: 2px; display: inline-block; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; }

.pin-place { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px; background: #fff; border: 2px solid var(--navy); color: var(--navy); font: 700 12px/22px var(--sans); text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,.25); cursor: pointer; font-variant-numeric: tabular-nums; }
.pin-place.is-past { border-color: #9aa4ad; color: #9aa4ad; }
.pin-place.is-live { background: var(--gold); border-color: var(--navy); }
.pope { position: relative; width: 22px; height: 22px; }
.pope b { position: absolute; inset: 0; border-radius: 50%; background: var(--gold); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--black), 0 2px 6px rgba(0,0,0,.35); }
.pope::before { content: ""; position: absolute; inset: -12px; border-radius: 50%; background: rgba(233, 184, 36, .45); animation: pulse 2s infinite; }
.pope span { position: absolute; left: 50%; top: -30px; transform: translateX(-50%); background: var(--black); color: #fff; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
@keyframes pulse { 0% { transform: scale(.4); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } }
.maplibregl-popup-content { font: 14px/1.4 var(--sans); border-radius: 10px; padding: 10px 12px; max-width: 260px; }
.maplibregl-popup-content b { color: var(--navy); }

/* Agenda */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.section-head .h2 { margin: 0; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #eeebe3; padding: 4px; border-radius: 12px; }
.tab { border: 0; background: transparent; padding: 10px 6px; border-radius: 9px; font-weight: 700; color: var(--navy); cursor: pointer; }
.tab[aria-selected="true"] { background: #fff; box-shadow: var(--shadow), inset 0 -3px 0 var(--gold); }
.tab small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.day-route { margin: 12px 2px 8px; font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ev { display: grid; grid-template-columns: 64px 1fr; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; position: relative; }
.ev-time { font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--navy); font-variant-numeric: tabular-nums; line-height: 1.1; }
.ev-time small { display: block; font-family: var(--sans); font-size: 11px; font-weight: 500; color: var(--muted); margin-top: 4px; }
.ev h3 { margin: 0; font-size: 16px; line-height: 1.3; }
.ev .where { margin: 3px 0 0; font-size: 14px; color: var(--muted); }
.ev .desc { margin: 6px 0 0; font-size: 14px; }
.ev .tip { margin: 8px 0 0; font-size: 14px; background: var(--gold-soft); border-radius: 8px; padding: 8px 10px; }
.ev .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: #eaf1f7; color: var(--navy); }
.tag.t-ticket { background: #fdecec; color: #a12622; }
.tag.t-public { background: #e7f4ec; color: var(--ok); }
.tag.t-live { background: var(--live); color: #fff; }
.tag.t-done { background: #eceef0; color: #6c7680; }
.tag.t-late { background: #fff1db; color: var(--warn); }
.ev .links { display: flex; gap: 14px; margin-top: 8px; font-size: 14px; }
.ev .links a, .ev .links button { color: var(--blue); background: none; border: 0; padding: 0; cursor: pointer; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.ev.is-past { opacity: .62; }
.ev.is-live { border: 2px solid var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); opacity: 1; }
.ev.is-rest { background: transparent; border-style: dashed; }
.ev.is-rest h3 { font-weight: 600; color: var(--muted); }
.ev .note { margin: 8px 0 0; font-size: 14px; font-weight: 600; color: var(--warn); }

.spots { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.spots p { margin: 4px 0 0; font-size: 15px; }
.spots .eta { color: var(--muted); font-size: 14px; }
.spots .eta:empty { display: none; }
details { border-top: 1px solid var(--line); padding: 10px 0; }
details:first-of-type { border-top: 0; padding-top: 0; }
summary { cursor: pointer; font-weight: 700; color: var(--navy); padding: 4px 0; }
details ul { margin: 8px 0 0; padding-left: 20px; font-size: 15px; }
details li { margin-bottom: 6px; }
.grid3 { display: grid; gap: 18px; }
.grid3 p { margin: 0 0 8px; font-size: 15px; }

/* App instalable */
.offline { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: #fff1db; color: var(--warn); font-size: 14px; font-weight: 600; }
.install-lead { margin: 0 0 12px; }
.install-done { margin: 0 0 12px; padding: 10px 12px; border-radius: 10px; background: #e7f4ec; color: var(--ok); font-weight: 600; }
.install-btn { margin-bottom: 14px; }
.install-steps { display: flex; flex-direction: column; gap: 12px; }
.step-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.step-card ol { margin: 6px 0 0; padding-left: 20px; font-size: 15px; }
.step-card li { margin-bottom: 6px; }
.step-card .mine { display: none; margin-left: 6px; font-size: 11px; font-weight: 700; vertical-align: middle; background: var(--gold); color: var(--black); padding: 2px 8px; border-radius: 99px; }
.step-card.is-mine { order: -1; border: 2px solid var(--gold); }
.step-card.is-mine .mine { display: inline-block; }
.ico { width: 18px; height: 18px; vertical-align: -3px; color: var(--blue); }

.foot { font-size: 13px; color: var(--muted); padding: 8px 2px 24px; }
.foot p { margin: 0 0 6px; }

/* Puerta de correo */
.gate { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(13, 13, 13, .6); }
body.gated .gate { display: flex; }
body.gated main, body.gated .sections { filter: blur(6px); pointer-events: none; user-select: none; }
body.gated { overflow: hidden; }
.gate-card { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow: auto; background: #fff; border-radius: 18px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.gate-photo { position: relative; border-bottom: 4px solid var(--gold); }
.gate-photo img { display: block; width: 100%; height: 170px; object-fit: cover; object-position: 50% 18%; }
.gate-photo small { position: absolute; right: 6px; top: 6px; font-size: 10px; color: rgba(255, 255, 255, .9); background: rgba(13, 13, 13, .55); padding: 1px 6px; border-radius: 6px; }
.gate-body { padding: 18px 24px 22px; }
.gate-title { font-family: var(--serif); font-size: 26px; line-height: 1.15; margin: 6px 0 8px; color: var(--navy); }
.gate-sub { margin: 0 0 16px; color: var(--muted); }
.field { display: grid; gap: 6px; font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.field input { font: 16px var(--sans); padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; }
.field input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(39, 80, 108, .15); }
.check { display: grid; grid-template-columns: 20px 1fr; gap: 10px; font-size: 13px; color: var(--muted); margin-bottom: 12px; align-items: start; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--navy); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.gate-error { color: var(--live); font-size: 14px; min-height: 0; margin: 0 0 8px; }
.gate-error:empty { display: none; }

/* En celular la parte superior se "disuelve" para poner el mapa entre las novedades y la agenda */
.top, .col-main { display: contents; }
.hero { order: -1; } #ahora { order: 0; } .updates { order: 1; } .map-section { order: 2; } #agenda { order: 3; }
#instalar { order: 4; } #verlo { order: 5; } #transito { order: 6; } #info { order: 7; } .foot { order: 8; }

@media (min-width: 900px) {
  /* El mapa queda fijo solo mientras se recorre el bloque superior (Ahora, novedades y agenda) */
  .top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
  .col-main { display: grid; gap: 16px; }
  .map-section { position: sticky; top: 64px; }
  .map { height: calc(100vh - 170px); max-height: none; }
  .grid3 { grid-template-columns: repeat(3, 1fr); }
  .hero { min-height: 230px; }
  .hero img { width: 42%; }
  .hero-text { padding: 28px 32px; }
  .install-steps { flex-direction: row; }
  .step-card { flex: 1; }
  .step-card.is-mine { order: -1; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .pope::before, .live-pill i { animation: none; }
}
