/* track.css — Página "El taller de Santa" (A4). Usa SOLO variables de tokens.css. */

[hidden] { display: none !important; }

body.page-track {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background:
    radial-gradient(90% 60% at 50% 0%, var(--night-700) 0%, transparent 70%),
    var(--night-950);
}
.noscript { padding: var(--sp-5); text-align: center; color: var(--text); }

/* ---------- Fondo y capas ---------- */
.magic-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}
.topbar, .wrap { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  padding: var(--sp-3) var(--gutter);
  max-width: var(--maxw);
  margin: 0 auto;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
  min-height: 44px;
}
.brand-mark { width: 36px; height: 36px; flex: 0 0 auto; }

.wrap { max-width: 720px; margin: 0 auto; padding: 0 var(--gutter) var(--sp-8); }
.hero { text-align: center; padding: var(--sp-4) 0 var(--sp-5); }
.kicker {
  margin: 0 0 var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--gold-soft);
}
.hero-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-2xl);
  line-height: 1.1;
  color: var(--text);
  text-shadow: 0 0 24px color-mix(in srgb, var(--gold) 40%, transparent);
}
.hero-sub { margin: var(--sp-3) auto 0; max-width: 34ch; color: var(--text-soft); }
.footnote { margin: var(--sp-5) 0 0; text-align: center; font-size: var(--fs-sm); color: var(--text-soft); }
.footnote a { color: var(--gold-soft); font-weight: 700; }

/* ---------- Tarjetas de pergamino ---------- */
.parchment {
  position: relative;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 10% 0%, color-mix(in srgb, var(--snow) 55%, var(--parchment)) 0%, transparent 60%),
    linear-gradient(180deg, var(--parchment), var(--parchment-2));
  border: 2px solid var(--gold-deep);
  outline: 1px solid color-mix(in srgb, var(--gold-deep) 55%, transparent);
  outline-offset: -8px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2), inset 0 0 60px color-mix(in srgb, var(--gold-deep) 22%, transparent);
}
.card-p { padding: var(--sp-5) var(--sp-4); }
@media (min-width: 560px) { .card-p { padding: var(--sp-6) var(--sp-6); } }
.card-title {
  margin: 0 0 var(--sp-2);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-xl);
  line-height: 1.2;
  color: var(--ink);
}
.card-lead { margin: 0 0 var(--sp-4); color: var(--ink-soft); }
.lbl { display: block; margin: 0 0 6px; font-weight: 800; color: var(--ink); }
.field-error { min-height: 1.2em; margin: 6px 0 0; font-size: var(--fs-sm); font-weight: 800; color: var(--santa-red-600); }
.view { margin: 0 0 var(--sp-5); }

/* ---------- Búsqueda ---------- */
.lookup { display: grid; gap: 6px; }
.lookup input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  border: 2px solid var(--parchment-2);
  background: var(--snow);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px; /* evita el zoom en iOS */
  letter-spacing: .08em;
  text-transform: uppercase;
}
.lookup input::placeholder { text-transform: none; letter-spacing: normal; font-family: var(--font-body); font-weight: 400; color: color-mix(in srgb, var(--ink-soft) 70%, transparent); }
.lookup input:focus { outline: 3px solid color-mix(in srgb, var(--gold) 70%, transparent); outline-offset: 2px; border-color: var(--santa-red); }
.lookup .btn { margin-top: var(--sp-3); }

.mine { margin-top: var(--sp-5); }
.mine-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-2); }
.mine-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  min-height: 52px;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--snow);
  border: 2px solid var(--parchment-2);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}
.mine-link:hover { border-color: var(--santa-red); }
.mine-link:focus-visible { outline: 3px solid var(--santa-red); outline-offset: 3px; }
.mine-names { overflow-wrap: anywhere; }
.mine-code { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-sm); letter-spacing: .08em; color: var(--santa-red-600); white-space: nowrap; }

/* ---------- Cargando ---------- */
.loading { display: grid; justify-items: center; gap: var(--sp-3); padding: var(--sp-7) 0; text-align: center; color: var(--text-soft); }
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--gold) 25%, transparent);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Botones ---------- */
.btn, .btn-main {
  min-height: 52px;
  padding: 12px 22px;
  border-radius: var(--r-pill);
  border: 0;
  background: linear-gradient(180deg, var(--santa-red), var(--santa-red-600));
  color: var(--snow);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: var(--fs-md);
  box-shadow: var(--shadow-1);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
}
.btn-main { width: 100%; }
.btn:focus-visible, .btn-main:focus-visible, .btn-ghost:focus-visible, .play:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}
.btn-ghost {
  min-height: 44px;
  padding: 10px 16px;
  border-radius: var(--r-pill);
  border: 2px solid var(--glass-border);
  background: var(--glass);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Cabecera de la carta ---------- */
.order-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--sp-2); margin: 0 0 var(--sp-3); }
.order-number { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: var(--fs-lg); color: var(--text); overflow-wrap: anywhere; }
.sync { margin: 0; font-size: var(--fs-xs); color: var(--text-faint); }

/* ---------- Etapa actual ---------- */
.stage-box { text-align: center; margin-bottom: var(--sp-5); }
.stage-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-xl);
  line-height: 1.2;
  color: var(--ink);
}
.stage-text { margin: 0 auto; max-width: 40ch; color: var(--ink-soft); }

/* ---------- Recorrido de 5 estaciones ---------- */
.track { position: relative; padding-top: 40px; }
.track-line {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 40px;
  transform: translateY(26px);
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--parchment-2);
  overflow: hidden;
  z-index: 0;
}
.track-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold));
  transition: width var(--t-slow) var(--ease-out);
}

.sled {
  position: absolute;
  top: 0;
  left: calc(10% + var(--cur, 0) * 20% - 28px);
  width: 56px;
  height: 36px;
  z-index: 2;
  transition: left var(--t-slow) var(--ease-out);
  animation: sled-bob 2.4s ease-in-out infinite;
}
.sled svg { width: 56px; height: 36px; display: block; overflow: visible; }
.sled-body { fill: var(--santa-red); }
.sled-gift { fill: var(--gold); }
.sled-runner { fill: none; stroke: var(--gold-deep); stroke-width: 3; stroke-linecap: round; }
@keyframes sled-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.stations {
  position: relative;
  z-index: 1;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
}
.station { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; min-width: 0; }
.station-art {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--snow) 65%, var(--parchment-2));
  border: 2px solid var(--parchment-2);
  transition: border-color var(--t-med), box-shadow var(--t-med), opacity var(--t-med);
}
.station-name {
  font-size: .72rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
  overflow-wrap: anywhere;
  hyphens: auto;
}
.art { width: 46px; height: 46px; display: block; overflow: visible; }
.art-glow { fill: var(--aurora-teal); opacity: .14; }
.art-body, .art-hat, .art-box, .art-lid { fill: var(--santa-red); }
.art-lid { fill: var(--santa-red-600); }
.art-skin { fill: var(--gold-soft); }
.art-lens { fill: color-mix(in srgb, var(--aurora-blue) 35%, var(--snow)); stroke: var(--ink); stroke-width: 2.5; }
.art-handle { stroke: var(--gold-deep); stroke-width: 3.5; stroke-linecap: round; }
.art-lupa { transform-box: view-box; transform-origin: 46px 42px; }
.art-post { fill: var(--pine); }
.art-slot { fill: var(--ink); opacity: .6; }
.art-flag { fill: var(--gold); }
.art-feather { fill: var(--gold-soft); stroke: var(--gold-deep); stroke-width: 1.5; transform-box: view-box; transform-origin: 30px 50px; }
.art-nib { fill: var(--ink); }
.art-ink { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 44; stroke-dashoffset: 44; opacity: .8; }
.art-stand { fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; }
.art-mic .art-body { fill: var(--ink); }
.art-wave { fill: none; stroke: var(--aurora-teal); stroke-width: 3; stroke-linecap: round; opacity: .25; }
.art-ribbon { fill: var(--gold); }
.art-star { fill: var(--gold-soft); stroke: var(--gold-deep); stroke-width: 1; transform-box: view-box; transform-origin: 32px 8px; }

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: linear-gradient(135deg, var(--gold-soft), var(--gold));
  border: 2px solid var(--parchment);
  box-shadow: var(--glow-gold);
}
.badge svg { width: 14px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* Estados de estación */
.station.is-done .station-art { border-color: var(--gold-deep); }
.station.is-done .badge { display: grid; }
.station:not(.is-done):not(.is-current) { opacity: .5; }
.station.is-current .station-art {
  border-color: var(--santa-red);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 45%, transparent);
}
.station.is-current .station-name { color: var(--santa-red-600); }

/* Animaciones de la estación actual */
.station.is-current .art-glow { animation: glow-pulse 2.4s ease-in-out infinite; }
.station.is-current .art-lupa { animation: lupa-wiggle 1.6s ease-in-out infinite; }
.station.is-current .art-feather { animation: pen-write 1.4s ease-in-out infinite; }
.station.is-current .art-ink { animation: ink-draw 2.2s linear infinite; }
.station.is-current .art-wave { animation: wave-pulse 1.2s ease-in-out infinite; }
.station.is-current .art-wave.w2 { animation-delay: .35s; }
.station.is-current .art-star { animation: star-spin 3s ease-in-out infinite; }
.station.is-current .art-flag { animation: flag-wave 1.4s ease-in-out infinite; transform-box: view-box; transform-origin: 50px 22px; }
.station.is-current .art-slot { animation: slot-light 1.8s ease-in-out infinite; }
.station.is-current .art-mail .art-body { animation: mail-glow 2.4s ease-in-out infinite; }

@keyframes glow-pulse { 0%, 100% { opacity: .14; } 50% { opacity: .38; } }
@keyframes lupa-wiggle { 0%, 100% { transform: rotate(-10deg); } 50% { transform: rotate(12deg); } }
@keyframes pen-write {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  50% { transform: translate(-4px, 3px) rotate(-6deg); }
}
@keyframes ink-draw { to { stroke-dashoffset: -88; } }
@keyframes wave-pulse { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
@keyframes star-spin { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.18) rotate(8deg); } }
@keyframes flag-wave { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }
@keyframes slot-light { 0%, 100% { opacity: .3; } 50% { opacity: 1; } }
@keyframes mail-glow {
  0%, 100% { filter: none; }
  50% { filter: drop-shadow(0 0 6px var(--gold)); }
}

/* ---------- Rechazado ---------- */
.reason-label { margin: 0 0 4px; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft); }
.reason { margin: 0 0 var(--sp-5); padding: var(--sp-3); border-radius: var(--r-md); background: var(--snow); border: 2px solid var(--parchment-2); color: var(--ink); overflow-wrap: anywhere; }

/* ---------- Entregado ---------- */
.delivered {
  position: relative;
  overflow: hidden;
  margin-top: var(--sp-5);
  padding: var(--sp-6) var(--sp-4);
  border-radius: var(--r-xl);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-2), var(--glow-gold);
  backdrop-filter: blur(8px);
  text-align: center;
  animation: reveal .9s var(--ease-out) both;
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.delivered .kicker { color: var(--gold-soft); }
.delivered-title {
  margin: 0 0 var(--sp-4);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: var(--fs-xl);
  line-height: 1.25;
  color: var(--text);
  overflow-wrap: anywhere;
}
.delivered-title span { color: var(--gold-soft); }

.burst { position: absolute; left: 50%; top: 34%; width: 0; height: 0; pointer-events: none; z-index: 0; }
.spark {
  position: absolute;
  left: 0;
  top: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-soft);
  box-shadow: var(--glow-gold);
  opacity: 0;
  animation: spark 1.6s var(--ease-out) var(--d, 0s) both;
}
@keyframes spark {
  0% { transform: translate(-50%, -50%) scale(.2); opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1); opacity: 0; }
}

.player {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: var(--sp-4) 0 var(--sp-3);
  text-align: left;
}
.play {
  width: 76px;
  height: 76px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--gold-soft), var(--gold) 50%, var(--gold-deep));
  color: var(--ink);
  box-shadow: var(--glow-gold);
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease-bounce);
}
.play:hover { transform: scale(1.05); }
.play svg { width: 34px; height: 34px; fill: currentColor; }
.play .i-pause { display: none; }
.play.is-playing .i-play { display: none; }
.play.is-playing .i-pause { display: block; }

.player-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 4px; }
.viz { width: 100%; height: 56px; display: block; }
.seek-row { display: flex; align-items: center; gap: var(--sp-2); }
.seek-row input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  accent-color: var(--gold);
  cursor: pointer;
}
.time { flex: 0 0 auto; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); color: var(--text-soft); }
.player-error { position: relative; z-index: 1; margin: 0 0 var(--sp-3); color: var(--st-rejected); font-weight: 800; }

.actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: var(--sp-2); justify-content: center; }
.actions .btn, .actions .btn-ghost { flex: 1 1 150px; }
.share-status { position: relative; z-index: 1; min-height: 1.2em; margin: var(--sp-3) 0 0; font-size: var(--fs-sm); color: var(--aurora-green); font-weight: 700; }

/* ---------- Ajustes para 360 px ---------- */
@media (max-width: 380px) {
  .station-name { font-size: .66rem; }
  .station-art { width: 50px; height: 50px; }
  .art { width: 42px; height: 42px; }
  .play { width: 66px; height: 66px; }
  .play svg { width: 30px; height: 30px; }
  .sled { left: calc(10% + var(--cur, 0) * 20% - 24px); }
  .sled svg { width: 48px; height: 31px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner, .sled { animation: none; }
}

/* Arquitecto: subtítulo legible sobre la aurora */
.hero-sub { color: var(--snow-200); text-shadow: 0 1px 12px rgba(5, 10, 26, .95), 0 0 2px rgba(5, 10, 26, .9); }

/* Arquitecto: pedido múltiple (varios mensajes, un solo pago) */
.family { margin-top: var(--sp-5); }
.family[hidden] { display: none; }
.family-list { list-style: none; margin: var(--sp-4) 0 0; padding: 0; display: grid; gap: 8px; }
.family-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md);
  background: rgba(127, 18, 34, .05); border: 1.5px solid rgba(185, 160, 122, .45);
}
.family-item.is-self { border-color: var(--santa-red); box-shadow: 0 0 0 3px rgba(215, 38, 61, .14); }
.family-num {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: #e9dcc0; color: var(--ink); font-weight: 800;
}
.family-item.is-ready .family-num { background: #1f6b4a; color: #fff; }
.family-body { display: grid; min-width: 0; flex: 1; }
/* El título del audio se lee completo (antes se cortaba en el teléfono y no se sabía cuál era cada uno). */
.family-name { font-weight: 800; color: var(--ink); line-height: 1.3; overflow-wrap: anywhere; }
.family-stage { font-size: var(--fs-sm); color: var(--ink-soft); }
.family-item.is-ready .family-stage { color: #155238; font-weight: 700; }
.family-tag { font-size: var(--fs-xs); font-weight: 800; color: var(--santa-red-600); text-transform: uppercase; letter-spacing: .06em; }
.family-go { min-height: 40px; padding: 6px 16px; flex: 0 0 auto; color: #fff; background: linear-gradient(180deg, #e5394d, var(--santa-red-600)); border-color: transparent; }
.family-item.is-ready .family-go { background: linear-gradient(180deg, #2f9466, #1f6b4a); }

/* Arquitecto: el cielo no se estira cuando la barra del navegador móvil aparece o desaparece */
.magic-bg { height: 100vh; height: 100lvh; bottom: auto; }

/* Paquetes: rótulo de cuándo poner el audio (Nochebuena / mañana del 25) */
.delivered-when {
  margin: 4px auto 14px;
  max-width: 34rem;
  padding: 8px 14px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--gold) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, transparent);
  color: var(--gold-soft);
  font-weight: 700;
  text-align: center;
}

/* Diploma listo para imprimir */
.diploma-card {
  display: grid; grid-template-columns: auto 1fr; gap: var(--sp-4); align-items: start;
  margin: var(--sp-5) 0; padding: var(--sp-5); border-radius: var(--r-lg);
  background: linear-gradient(160deg, #fff8e6, var(--parchment) 60%, var(--parchment-2));
  border: 2px solid var(--gold); box-shadow: var(--shadow-2), 0 0 32px rgba(246, 196, 83, .35); color: var(--ink);
}
.diploma-card[hidden] { display: none; }
.diploma-card__art { font-size: 3rem; line-height: 1; filter: drop-shadow(0 4px 10px rgba(200, 146, 42, .45)); }
.diploma-card .kicker { color: var(--santa-red-600); }
.diploma-card__title { margin: 2px 0 6px; font-family: var(--font-display); font-size: clamp(1.25rem, 1rem + 1vw, 1.6rem); color: var(--ink); }
.diploma-card__title span { color: var(--santa-red-600); }
.diploma-card__text { margin: 0 0 8px; color: var(--ink-soft); }
.diploma-card__tips { margin: 0 0 var(--sp-4); padding: 0; list-style: none; display: grid; gap: 4px; color: var(--ink); font-size: var(--fs-sm); }
.diploma-card__btn { display: inline-flex; }
@media (max-width: 560px) { .diploma-card { grid-template-columns: 1fr; text-align: center; } .diploma-card__art { margin: 0 auto; } }
