/* La Noche de los Museos · Pasaporte virtual
   Paleta: Azul Noche #102A3A (principal) · Marfil #F3EBDD (claros/texto) · Dorado #C9A45C (acento) */
:root {
  --navy: #102A3A;
  --navy-2: #16384C;
  --navy-3: #21506B;
  --ivory: #F3EBDD;
  --ivory-dim: #C9C3B8;
  --gold: #C9A45C;
  --gold-2: #DDBF83;
  --ok: #7FD1A3;
  --warn: #F0B25A;
  --err: #FF9C8F;
  --radius: 14px;
  --serif: 'Playfair Display', 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --nav-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--navy);
  color: var(--ivory);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; letter-spacing: .2px; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .8em; }
a { color: var(--gold-2); }
small, .muted { color: var(--ivory-dim); }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--gold-2); outline-offset: 2px; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(16, 42, 58, .96);
  border-bottom: 1px solid rgba(201, 164, 92, .25);
  backdrop-filter: blur(6px);
}
.topbar img { width: 36px; height: 36px; }
.brand { flex: 1; min-width: 0; }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.05rem; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: .75rem; color: var(--gold); text-transform: uppercase; letter-spacing: 1.6px; font-weight: 600; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(201, 164, 92, .5); background: transparent; color: var(--gold-2); cursor: pointer;
}
.icon-btn svg { width: 24px; height: 24px; }

main#view { padding: 18px 16px calc(var(--nav-h) + var(--safe-b) + 24px); max-width: 640px; margin: 0 auto; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: #0B1F2B; border-top: 1px solid rgba(201, 164, 92, .3);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ivory-dim); text-decoration: none; font-size: .8rem; font-weight: 600;
}
.bottom-nav a svg { width: 26px; height: 26px; }
.bottom-nav a.active { color: var(--gold-2); }
.bottom-nav a.active::before {
  content: ''; position: absolute; top: 0; width: 44px; height: 3px; background: var(--gold); border-radius: 0 0 3px 3px;
}
.bottom-nav a { position: relative; }

/* ---------- Componentes ---------- */
.card {
  background: var(--navy-2); border: 1px solid rgba(201, 164, 92, .18);
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.card.ivory { background: var(--ivory); color: var(--navy); border-color: transparent; }
.card.ivory .muted, .card.ivory small { color: #4A5A64; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 54px; padding: 14px 18px;
  border-radius: 12px; border: 2px solid transparent;
  font: 700 1.05rem var(--sans); letter-spacing: .2px; text-decoration: none; cursor: pointer;
  background: var(--gold); color: var(--navy);
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--gold-2); }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn svg { width: 24px; height: 24px; }
.btn.big { min-height: 68px; font-size: 1.2rem; border-radius: 16px; }
.btn.outline { background: transparent; color: var(--ivory); border-color: rgba(243, 235, 221, .55); }
.btn.outline:hover { background: rgba(243, 235, 221, .08); }
.btn.ghost { background: transparent; color: var(--gold-2); min-height: 44px; text-decoration: underline; border: 0; font-weight: 600; }
.btn.navy { background: var(--navy); color: var(--ivory); }
.btn + .btn { margin-top: 10px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; margin-top: 0 !important; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.chip.done { background: var(--gold); color: var(--navy); }
.chip.pending { border: 1px solid rgba(243, 235, 221, .5); color: var(--ivory-dim); }

/* Formularios */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; min-height: 52px; padding: 12px 14px;
  font: 400 1.05rem var(--sans); color: var(--navy);
  background: var(--ivory); border: 2px solid transparent; border-radius: 10px;
}
.field input:focus { outline: none; border-color: var(--gold); }
.field.invalid input { border-color: var(--err); }
.field .err { color: var(--err); font-size: .88rem; margin-top: 4px; font-weight: 600; }
.check { display: flex; gap: 12px; align-items: flex-start; margin: 8px 0 18px; cursor: pointer; }
.check input { width: 24px; height: 24px; margin-top: 2px; accent-color: var(--gold); flex: none; }
.form-error { background: rgba(255, 156, 143, .14); border: 1px solid var(--err); color: #FFD3CC; padding: 12px; border-radius: 10px; margin-bottom: 14px; font-weight: 600; }

.banner {
  display: flex; gap: 12px; align-items: center;
  background: rgba(201, 164, 92, .14); border: 1px solid rgba(201, 164, 92, .55);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-weight: 600;
}
.banner.info { background: rgba(243, 235, 221, .07); border-color: rgba(243, 235, 221, .35); }

/* ---------- Home / progreso ---------- */
.hello { font-family: var(--serif); font-size: 1.7rem; margin-bottom: 2px; }
.progress-wrap { margin: 14px 0 6px; }
.progress-label { display: flex; justify-content: space-between; align-items: baseline; font-weight: 700; margin-bottom: 8px; }
.progress-label .big { font-family: var(--serif); font-size: 2.1rem; color: var(--gold-2); }
.bar { height: 14px; border-radius: 999px; background: rgba(243, 235, 221, .14); overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-2)); border-radius: 999px; transition: width .6s ease; }
.points { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.points b { font-size: 1.4rem; color: var(--gold-2); }

.stamps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 6px; }
.stamp {
  aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; text-align: center;
  border: 2px dashed rgba(243, 235, 221, .3); color: var(--ivory-dim);
  font-size: .62rem; font-weight: 700; padding: 6px; line-height: 1.1; text-decoration: none; overflow: hidden;
}
.stamp.on { border: 3px double var(--navy); background: var(--gold); color: var(--navy); transform: rotate(-8deg); }

.milestone { display: flex; gap: 14px; align-items: center; padding: 14px 0; border-top: 1px solid rgba(243, 235, 221, .12); }
.milestone:first-of-type { border-top: 0; }
.milestone .ico {
  flex: none; width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(243, 235, 221, .35); color: var(--ivory-dim);
}
.milestone .ico svg { width: 24px; height: 24px; }
.milestone.on .ico { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.milestone .txt { flex: 1; min-width: 0; }
.milestone .txt b { display: block; }
.milestone a.btn { width: auto; min-height: 44px; padding: 8px 14px; font-size: .92rem; }

/* ---------- Museos ---------- */
.museum-item {
  display: flex; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--navy-2); border: 1px solid rgba(201, 164, 92, .16); border-radius: var(--radius);
  padding: 10px; margin-bottom: 10px;
}
.museum-item.done { border-color: rgba(201, 164, 92, .6); }
.thumb {
  flex: none; width: 78px; height: 78px; border-radius: 10px; object-fit: cover;
  background: linear-gradient(135deg, var(--navy-3), #0B1F2B);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 1.6rem; color: var(--gold); font-weight: 700;
}
.museum-item .info { flex: 1; min-width: 0; }
.museum-item .info b { display: block; font-family: var(--serif); font-size: 1.08rem; line-height: 1.2; margin-bottom: 2px; }
.museum-item .info small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.museum-item .chip { margin-top: 6px; }

.hero-photo { width: calc(100% + 32px); margin: -18px -16px 16px; height: 220px; object-fit: cover; display: block; }
.hero-photo.ph { display: flex; align-items: center; justify-content: center; font-size: 4rem; }
.detail-meta { list-style: none; padding: 0; margin: 0 0 16px; }
.detail-meta li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid rgba(243, 235, 221, .1); }
.detail-meta svg { width: 20px; height: 20px; flex: none; color: var(--gold); margin-top: 2px; }

/* ---------- Mapa ---------- */
#map { height: calc(100dvh - 64px - var(--nav-h) - var(--safe-b) - 70px); min-height: 320px; border-radius: var(--radius); border: 1px solid rgba(201, 164, 92, .3); background: #0B1F2B; }
.map-legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: .9rem; }
.map-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 6px; }
.pin {
  width: 34px; height: 34px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--navy); box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
}
.pin span { transform: rotate(45deg); font: 800 13px var(--sans); }
.pin.done { background: var(--gold); color: var(--navy); }
.pin.pending { background: var(--ivory); color: var(--navy); }
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { font-family: var(--sans); color: var(--navy); margin: 12px 14px; }
.leaflet-popup-content b { font-family: var(--serif); font-size: 1.05rem; }
.leaflet-popup-content a.pop-link { display: inline-block; margin-top: 8px; font-weight: 700; color: var(--navy); }

/* ---------- Escáner ---------- */
.scanner-box { position: relative; border-radius: var(--radius); overflow: hidden; background: #000; min-height: 300px; }
#qr-reader { width: 100%; }
#qr-reader video { object-fit: cover; }

/* ---------- Voucher ---------- */
.voucher {
  background: var(--ivory); color: var(--navy); border-radius: 18px; padding: 22px 20px; text-align: center;
  position: relative; border: 3px double var(--gold);
}
.voucher .v-app { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.voucher .v-sub { font-size: .72rem; letter-spacing: 2px; text-transform: uppercase; color: #6A5326; font-weight: 700; }
.voucher hr { border: 0; border-top: 2px dashed rgba(16, 42, 58, .3); margin: 16px -20px; }
.voucher .v-benefit { font-family: var(--serif); font-size: 1.35rem; margin: 6px 0 4px; }
.voucher .v-code { font: 800 2.2rem/1 ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; letter-spacing: 3px; margin: 10px 0; }
.voucher .v-qr svg { width: 180px; height: 180px; }
.voucher .v-user { font-weight: 600; }
.voucher .redeemed { margin-top: 12px; background: var(--navy); color: var(--ivory); border-radius: 10px; padding: 10px; font-weight: 700; }

/* ---------- Pantalla de éxito ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  background: radial-gradient(circle at 50% 30%, #1B4560 0%, var(--navy) 60%, #081822 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 22px calc(30px + var(--safe-b)); text-align: center;
  animation: fadein .25s ease;
}
.overlay h2 { font-size: 1.8rem; margin-top: 18px; }
.overlay .result-msg { font-size: 1.1rem; max-width: 420px; }
.overlay .actions { width: 100%; max-width: 420px; margin-top: 18px; }
.seal {
  width: 150px; height: 150px; border-radius: 50%;
  background: var(--gold); color: var(--navy);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 6px double var(--navy); box-shadow: 0 0 0 6px var(--gold), 0 10px 40px rgba(201, 164, 92, .35);
  animation: stamp .6s cubic-bezier(.2, 1.6, .4, 1) both;
}
.seal b { font-family: var(--serif); font-size: 2.6rem; line-height: 1; }
.seal small { color: var(--navy); font-weight: 800; letter-spacing: 1px; text-transform: uppercase; font-size: .72rem; }
.seal.neutral { background: var(--ivory); box-shadow: 0 0 0 6px var(--ivory); }
.seal.bad { background: #F6D7CF; box-shadow: 0 0 0 6px #F6D7CF; }
.seal svg { width: 64px; height: 64px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 101; }
.confetti i {
  position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; opacity: .95;
  animation: fall linear forwards;
}
.unlock {
  margin-top: 18px; width: 100%; max-width: 420px;
  background: var(--ivory); color: var(--navy); border-radius: 14px; padding: 16px; border: 3px double var(--gold);
  animation: pop .5s .5s ease both;
}
.unlock b { font-family: var(--serif); font-size: 1.2rem; display: block; }

@keyframes stamp { 0% { transform: scale(2.4) rotate(-25deg); opacity: 0; } 100% { transform: scale(1) rotate(-8deg); opacity: 1; } }
@keyframes pop { 0% { transform: translateY(16px); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 54px; height: 54px; border-radius: 50%; border: 5px solid rgba(243, 235, 221, .2); border-top-color: var(--gold); animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); transform: translateX(-50%);
  z-index: 200; width: calc(100% - 32px); max-width: 480px;
  background: var(--ivory); color: var(--navy); border-radius: 12px; padding: 14px 16px;
  font-weight: 600; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: pop .25s ease;
}

/* ---------- Bienvenida ---------- */
.welcome { text-align: center; padding-top: 10px; }
.welcome img.logo { width: 96px; height: 96px; margin-bottom: 10px; }
.welcome .kicker { color: var(--gold); text-transform: uppercase; letter-spacing: 3px; font-weight: 700; font-size: .8rem; }
.steps { text-align: left; list-style: none; padding: 0; margin: 18px 0; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.steps li::before {
  content: counter(s); flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: var(--gold); color: var(--navy); font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.footer-note { text-align: center; font-size: .8rem; color: var(--ivory-dim); margin-top: 22px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--gold-2); text-decoration: none; font-weight: 600; margin-bottom: 12px; min-height: 40px; }

/* ---------- Movimiento: presentación y transiciones ---------- */
#splash {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 40%, #1B4560 0%, var(--navy) 55%, #07151E 100%);
  transition: opacity .55s ease, transform .55s ease;
}
#splash.out { opacity: 0; transform: scale(1.06); pointer-events: none; }
#splash img { width: 110px; height: 110px; animation: splash-logo 1.1s cubic-bezier(.2, 1.4, .4, 1) both; filter: drop-shadow(0 0 24px rgba(201, 164, 92, .45)); }
#splash .s-title { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; animation: rise .7s .35s ease both; text-align: center; padding: 0 20px; }
#splash .s-sub { color: var(--gold); letter-spacing: 4px; text-transform: uppercase; font-size: .78rem; font-weight: 700; animation: rise .7s .55s ease both; }
#splash .s-line { width: 0; height: 2px; background: linear-gradient(90deg, transparent, var(--gold), transparent); animation: line 1s .6s ease forwards; }
@keyframes splash-logo { 0% { transform: scale(.4) rotate(-30deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes line { to { width: 160px; } }

/* Entrada de cada pantalla: fundido + desplazamiento, con hijos escalonados */
.view-enter > * { animation: rise .45s cubic-bezier(.2, .8, .2, 1) both; }
.view-enter > *:nth-child(1) { animation-delay: .02s; }
.view-enter > *:nth-child(2) { animation-delay: .07s; }
.view-enter > *:nth-child(3) { animation-delay: .12s; }
.view-enter > *:nth-child(4) { animation-delay: .17s; }
.view-enter > *:nth-child(5) { animation-delay: .22s; }
.view-enter > *:nth-child(6) { animation-delay: .27s; }
.view-enter > *:nth-child(n+7) { animation-delay: .32s; }
.view-enter .museum-item { animation: slide-in .45s cubic-bezier(.2, .8, .2, 1) both; }
.view-enter .museum-item:nth-of-type(2) { animation-delay: .05s; } .view-enter .museum-item:nth-of-type(3) { animation-delay: .1s; }
.view-enter .museum-item:nth-of-type(4) { animation-delay: .15s; } .view-enter .museum-item:nth-of-type(5) { animation-delay: .2s; }
.view-enter .museum-item:nth-of-type(n+6) { animation-delay: .25s; }
@keyframes slide-in { from { transform: translateX(-18px); opacity: 0; } to { transform: none; opacity: 1; } }

.view-enter .stamp { animation: stamp-in .5s cubic-bezier(.2, 1.5, .4, 1) both; }
.view-enter .stamp:nth-child(4n+1) { animation-delay: .25s; } .view-enter .stamp:nth-child(4n+2) { animation-delay: .32s; }
.view-enter .stamp:nth-child(4n+3) { animation-delay: .39s; } .view-enter .stamp:nth-child(4n) { animation-delay: .46s; }
@keyframes stamp-in { from { transform: scale(.3); opacity: 0; } }
.stamp.on { animation-name: stamp-on !important; }
@keyframes stamp-on { 0% { transform: scale(1.8) rotate(-30deg); opacity: 0; } 100% { transform: rotate(-8deg); opacity: 1; } }

.view-enter .bar > span { animation: grow 1s .3s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes grow { from { width: 0; } }

/* Brillo sutil en el botón principal */
.btn.big { position: relative; overflow: hidden; box-shadow: 0 8px 24px rgba(201, 164, 92, .25); }
.btn.big::after {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: skewX(-20deg); animation: shine 3.8s 1.2s ease-in-out infinite;
}
.btn.big.outline::after, .btn.big.navy::after { display: none; }
@keyframes shine { 0%, 70% { left: -60%; } 100% { left: 130%; } }

.card, .museum-item { transition: transform .2s ease, border-color .2s ease; }
.museum-item:active, .stamp:active { transform: scale(.97); }
.milestone.on .ico { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(201, 164, 92, .55); } 50% { box-shadow: 0 0 0 8px rgba(201, 164, 92, 0); } }
.bottom-nav a svg { transition: transform .25s cubic-bezier(.2, 1.5, .4, 1); }
.bottom-nav a.active svg { transform: translateY(-2px) scale(1.12); }
.voucher { animation: voucher-in .6s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes voucher-in { from { transform: perspective(800px) rotateX(25deg) translateY(30px); opacity: 0; } }
.welcome img.logo { animation: splash-logo 1s cubic-bezier(.2, 1.4, .4, 1) both, float 5s 1s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-6px); } }
