@font-face {
  font-family: "Overpass";
  src: url("fonts/Overpass.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  /* Medidos en los iconos reales de Renfe, Cercanías y Rodalies */
  --morado: #8c065f;
  --morado-hondo: #5f084e;
  --violeta: #51286e;
  --magenta: #d83353;
  --cercanias: #dc1b1f;
  --rodalies: #ee7f00;

  --fondo: #f6f1f5;
  --papel: #ffffff;
  --tinta: #1f1420;
  --tinta-2: #5f5063;
  --linea: #e7dce5;
  --suave: #f1e7ef;
  --bien: #0a7448;
  --bien-claro: #9be8c2;

  --r-s: 10px;
  --r-m: 16px;
  --r-l: 24px;
  --sale: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; }

html { height: 100%; }

body {
  min-height: 100%;
  background: #eae1e8;
  color: var(--tinta);
  font: 400 16px/1.4 "Overpass", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--morado); color: #fff; }

button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }

:focus-visible { outline: 3px solid var(--violeta); outline-offset: 2px; border-radius: 6px; }
.billete :focus-visible, .capa-billete .boton-morado:focus-visible { outline-color: #fff; }

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.estado svg { fill: currentColor; stroke: none; }

/* ---------- Escena de escritorio ---------- */

.escena {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 340px) auto;
  gap: 72px;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ficha h1 { font-size: 2.5rem; line-height: 1.05; font-weight: 800; letter-spacing: -.02em; text-wrap: balance; }
.ficha p { margin-top: 16px; color: var(--tinta-2); font-size: 1.0625rem; max-width: 34ch; }
.ficha .aviso { margin-top: 28px; font-size: .875rem; }

.interruptor { display: inline-flex; align-items: center; gap: 12px; margin-top: 28px; min-height: 44px; font-weight: 600; cursor: pointer; }
.interruptor input { position: absolute; opacity: 0; pointer-events: none; }
.carril { width: 50px; height: 30px; border-radius: 15px; background: #c9bac6; position: relative; transition: background .2s; }
.carril::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(31 20 32 / .3); transition: translate .25s var(--sale); }
.interruptor input:checked + .carril { background: var(--morado); }
.interruptor input:checked + .carril::after { translate: 20px 0; }
.interruptor input:focus-visible + .carril { outline: 3px solid var(--violeta); outline-offset: 2px; }

.movil {
  width: 390px;
  height: 844px;
  zoom: var(--escala, 1);
  border-radius: 54px;
  padding: 10px;
  background: #17101a;
  box-shadow: 0 2px 4px rgb(31 20 32 / .2), 0 30px 60px -20px rgb(81 40 110 / .45);
}

.pantalla {
  position: relative;
  height: 100%;
  border-radius: 44px;
  overflow: hidden;
  background: var(--fondo);
  display: flex;
  flex-direction: column;
}

/* ---------- Barra de estado ---------- */

.estado { flex: none; height: 50px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 28px 0; font-weight: 700; font-size: .9375rem; position: relative; z-index: 6; }
.isla { width: 104px; height: 30px; border-radius: 15px; background: #17101a; }
.iconos { justify-self: end; display: flex; align-items: center; gap: 6px; }
.avion { display: none; }
.sin-red .senal { display: none; }
.sin-red .avion { display: block; }

/* ---------- Vistas ---------- */

.vista { flex: 1; overflow-y: auto; padding: 4px 16px 24px; scrollbar-width: none; }
.vista::-webkit-scrollbar { display: none; }
.vista[hidden] { display: none; }

.cabecera { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 8px 4px 14px; }
.cabecera h2 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.015em; }
.fecha { color: var(--tinta-2); font-size: .9375rem; }

h3 { font-size: 1.0625rem; font-weight: 700; margin: 28px 4px 10px; }

.reloj, .panel dd, .proximos, .precio, .horas { font-variant-numeric: tabular-nums; }

.nota-red { display: none; align-items: center; gap: 8px; margin: 0 0 12px; padding: 10px 14px; border-radius: var(--r-s); background: var(--tinta); color: #fff; font-size: .9375rem; font-weight: 600; }
.sin-red .nota-red { display: flex; }

/* ---------- Billete ---------- */

.billete {
  background: var(--morado);
  background-image: linear-gradient(165deg, #9a0a66 0%, var(--morado) 45%, var(--morado-hondo) 100%);
  color: #fff;
  border-radius: var(--r-l);
  padding: 18px 18px 16px;
  box-shadow: 0 1px 2px rgb(95 8 78 / .3), 0 14px 28px -14px rgb(95 8 78 / .6);
  view-transition-name: billete;
}

.b-arriba { display: flex; align-items: center; gap: 8px; font-size: .875rem; }
.tren { font-weight: 600; color: #f3d3e8; font-variant-numeric: tabular-nums; }
.b-estado { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.b-estado i { width: 8px; height: 8px; border-radius: 50%; background: var(--bien-claro); }

.servicio { display: inline-grid; place-items: center; min-width: 40px; height: 22px; padding: 0 7px; border-radius: 6px; font-size: .75rem; font-weight: 800; letter-spacing: .04em; }
.servicio-ave { background: #fff; color: var(--morado); }
.servicio-ave.sobre-claro { background: var(--morado); color: #fff; }

.trayecto { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 10px; margin-top: 16px; }
.trayecto .reloj { display: block; font-size: 2.625rem; line-height: 1; font-weight: 800; letter-spacing: -.02em; }
.trayecto span { display: block; margin-top: 6px; font-size: .875rem; color: #f3d3e8; max-width: 12ch; line-height: 1.25; }
.trayecto .llega { text-align: right; }
.trayecto .llega span { margin-left: auto; }
.dura { display: flex; align-items: center; gap: 6px; padding-top: 14px; }
.dura i { flex: 1; height: 2px; border-radius: 1px; background: rgb(255 255 255 / .35); }
.trayecto .dura span { margin: 0; max-width: none; font-size: .75rem; font-weight: 600; white-space: nowrap; color: #fff; }

.panel { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 18px; padding: 12px 0; border-block: 1px dashed rgb(255 255 255 / .4); }
.panel div + div { border-left: 1px solid rgb(255 255 255 / .22); padding-left: 14px; }
.panel dt { font-size: .75rem; color: #f3d3e8; }
.panel dd { font-size: 1.5rem; font-weight: 800; line-height: 1.15; }

.b-abajo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.guardado { display: inline-flex; align-items: center; gap: 6px; font-size: .8125rem; color: #f3d3e8; line-height: 1.2; }

.boton { min-height: 48px; padding: 0 20px; border-radius: 24px; font-weight: 700; font-size: 1rem; display: inline-grid; place-items: center; transition: scale .15s var(--sale), background .15s; }
.boton { white-space: nowrap; }
.boton:active { scale: .97; }
.corto { display: none; }
.boton-claro { background: #fff; color: var(--morado); }
.boton-claro:hover { background: #fbeaf5; }
.boton-morado { background: var(--morado); color: #fff; width: 100%; }
.boton-morado:hover { background: #7a0553; }
.boton-linea { width: 100%; box-shadow: inset 0 0 0 1.5px var(--linea); color: var(--tinta); }
.boton-linea:hover { background: var(--suave); }
.boton-texto { width: 100%; color: var(--tinta-2); }

/* ---------- Buscador de inicio ---------- */

.campo-buscar { width: 100%; margin-top: 14px; min-height: 56px; padding: 0 18px; display: flex; align-items: center; gap: 12px; border-radius: var(--r-m); background: var(--papel); box-shadow: inset 0 0 0 1px var(--linea); color: var(--tinta-2); font-size: 1.0625rem; text-align: left; }
.campo-buscar svg { color: var(--morado); }
.campo-buscar:hover { box-shadow: inset 0 0 0 1.5px var(--morado); }

/* ---------- Salidas de cada día ---------- */

.salidas { list-style: none; padding: 0; background: var(--papel); border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--linea); }
.salidas li { display: grid; grid-template-columns: 28px auto 1fr auto; align-items: center; gap: 10px; padding: 12px 14px; }
.salidas li + li { border-top: 1px solid var(--linea); }
.salidas img, .marca { border-radius: 7px; display: block; }
.linea { display: inline-grid; place-items: center; min-width: 38px; height: 24px; padding: 0 6px; border-radius: 6px; background: var(--l); color: #fff; font-size: .8125rem; font-weight: 800; }
.ruta b, .proximos b { display: block; font-weight: 700; font-size: .9375rem; line-height: 1.25; }
.ruta small, .proximos small { color: var(--tinta-2); font-size: .8125rem; }
.proximos { text-align: right; }
.proximos b { color: var(--bien); }

/* ---------- Buscar ---------- */

.ruta-caja { position: relative; background: var(--papel); border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--linea); }
.ruta-caja label { display: block; padding: 10px 64px 10px 16px; }
.ruta-caja label + label { border-top: 1px solid var(--linea); }
.ruta-caja span { display: block; font-size: .75rem; color: var(--tinta-2); }
.ruta-caja input { width: 100%; border: 0; background: none; font-size: 1.125rem; font-weight: 700; padding: 0; outline: none; caret-color: var(--morado); }
.ruta-caja label:focus-within { box-shadow: inset 0 0 0 2px var(--morado); border-radius: var(--r-m); }
.cambiar { position: absolute; right: 12px; top: 50%; translate: 0 -50%; width: 44px; height: 44px; border-radius: 50%; background: var(--suave); color: var(--morado); display: grid; place-items: center; transition: rotate .35s var(--sale); }
.cambiar:active { rotate: 180deg; }

.fichas { display: flex; gap: 8px; margin: 12px -16px 0; padding: 0 16px 4px; overflow-x: auto; scrollbar-width: none; }
.fichas::-webkit-scrollbar { display: none; }
.fichas button { flex: none; min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--papel); box-shadow: inset 0 0 0 1px var(--linea); font-size: .875rem; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.fichas button[aria-pressed="true"] { background: var(--tinta); color: #fff; box-shadow: none; }
.fichas img { border-radius: 5px; }
.fichas .servicio { min-width: 0; height: 20px; }

.cab-resultados { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 4px 10px; }
.cab-resultados h3 { margin: 0; }
.cab-resultados small { color: var(--tinta-2); font-size: .8125rem; }

.trenes { list-style: none; padding: 0; background: var(--papel); border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--linea); overflow: hidden; }
.trenes li + li { border-top: 1px solid var(--linea); }
.trenes button { width: 100%; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px; padding: 13px 16px; text-align: left; min-height: 64px; }
.trenes button:hover { background: #fbf7fa; }
.trenes button[aria-pressed="true"] { background: var(--suave); box-shadow: inset 0 0 0 2px var(--morado); }
.trenes li:first-child button { border-radius: var(--r-m) var(--r-m) 0 0; }
.trenes li:last-child button { border-radius: 0 0 var(--r-m) var(--r-m); }
.horas { font-size: 1.25rem; font-weight: 800; letter-spacing: -.01em; }
.horas i { font-style: normal; color: var(--tinta-2); font-weight: 400; margin: 0 4px; }
.precio { font-size: 1.125rem; font-weight: 800; text-align: right; }
.detalle { display: flex; align-items: center; gap: 8px; font-size: .8125rem; color: var(--tinta-2); }
.etiqueta { justify-self: end; font-size: .75rem; font-weight: 700; color: var(--bien); }
.via { justify-self: end; font-size: .8125rem; color: var(--tinta-2); }

.tarifa { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 10px; border-radius: var(--r-m); background: var(--papel); box-shadow: inset 0 0 0 1px var(--linea); }
.tarifa div { flex: 1; line-height: 1.3; }
.tarifa b { display: block; font-size: .9375rem; }
.tarifa small { color: var(--tinta-2); font-size: .8125rem; }
.tarifa .precio { font-size: 1.375rem; }

.comprar { position: sticky; bottom: -24px; margin: 16px -16px -24px; padding: 12px 16px 16px; background: linear-gradient(to top, var(--fondo) 70%, transparent); }

.vacio { margin-top: 36px; text-align: center; padding: 0 20px; }
.vacio svg { color: var(--tinta-2); }
.vacio b { display: block; font-size: 1.125rem; margin-top: 10px; }
.vacio p { color: var(--tinta-2); margin: 6px 0 18px; }

/* ---------- Billetes y cuenta ---------- */

.lista-billetes, .ajustes { list-style: none; padding: 0; display: grid; gap: 10px; }
.lista-billetes button { width: 100%; text-align: left; background: var(--papel); border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--linea); padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; min-height: 72px; }
.lista-billetes button:hover { box-shadow: inset 0 0 0 1.5px var(--morado); }
.lista-billetes .cuando { font-size: .8125rem; color: var(--tinta-2); grid-column: 1 / -1; }
.lista-billetes .nuevo { color: var(--bien); font-weight: 700; }
.lista-billetes svg { color: var(--tinta-2); grid-row: 2 / span 2; grid-column: 2; }
.pie-lista { display: flex; gap: 8px; align-items: flex-start; margin: 18px 4px 0; color: var(--tinta-2); font-size: .875rem; }

.perfil { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--papel); border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--linea); margin-bottom: 14px; }
.iniciales { width: 48px; height: 48px; border-radius: 50%; background: var(--violeta); color: #fff; display: grid; place-items: center; font-weight: 800; }
.perfil b, .perfil small { display: block; }
.perfil small { color: var(--tinta-2); font-size: .875rem; }
.ajustes { gap: 0; background: var(--papel); border-radius: var(--r-m); box-shadow: inset 0 0 0 1px var(--linea); }
.ajustes li + li { border-top: 1px solid var(--linea); }
.ajustes button { width: 100%; min-height: 54px; padding: 0 16px; display: flex; align-items: center; justify-content: space-between; font-weight: 600; text-align: left; }
.ajustes svg { color: var(--tinta-2); }

/* ---------- Pestañas ---------- */

.pestanas { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 8px 22px; background: var(--papel); border-top: 1px solid var(--linea); position: relative; z-index: 2; }
.pestanas button { min-height: 52px; display: grid; justify-items: center; align-content: center; gap: 2px; font-size: .75rem; font-weight: 600; color: var(--tinta-2); border-radius: 12px; }
.pestanas svg { box-sizing: border-box; width: 60px; height: 30px; padding: 3px 18px; border-radius: 15px; transition: background .2s; }
.pestanas button[aria-current="page"] { color: #c01f4b; font-weight: 800; }
.pestanas button[aria-current="page"] svg { stroke-width: 2.3; color: var(--magenta); background: #fde4ea; }

/* ---------- Billete a pantalla completa ---------- */

.capa-billete { position: absolute; inset: 0; z-index: 5; background: var(--papel); padding: 54px 20px 24px; display: flex; flex-direction: column; align-items: center; overflow-y: auto; view-transition-name: billete; }
.capa-billete[hidden] { display: none; }
.capa-billete header { width: 100%; display: flex; align-items: center; justify-content: space-between; }
.capa-billete h2 { font-size: 1.375rem; font-weight: 800; }
.redondo { width: 44px; height: 44px; border-radius: 50%; background: var(--suave); display: grid; place-items: center; }
.red-billete { margin-top: 10px; align-self: stretch; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 12px; border-radius: var(--r-s); font-size: .875rem; font-weight: 600; background: #e4f5ec; color: #075c39; }
.sin-red .red-billete { background: var(--tinta); color: #fff; }
.qr { margin-top: 18px; padding: 16px; border-radius: var(--r-l); box-shadow: inset 0 0 0 1.5px var(--linea); line-height: 0; }
.viajero { margin-top: 14px; text-align: center; }
.viajero b { display: block; font-size: 1.125rem; }
.viajero span { color: var(--tinta-2); font-size: .875rem; font-variant-numeric: tabular-nums; }
.resumen { margin-top: 14px; display: flex; align-items: center; gap: 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.resumen i { font-style: normal; color: var(--tinta-2); font-weight: 400; }
.panel-claro { align-self: stretch; border-block-color: var(--linea); border-block-style: solid; margin-top: 14px; }
.panel-claro div + div { border-left-color: var(--linea); }
.panel-claro dt { color: var(--tinta-2); }
.capa-billete .boton-linea { margin-top: auto; }

/* ---------- Hoja de compra ---------- */

.velo { position: absolute; inset: 0; z-index: 7; background: rgb(31 20 32 / .45); animation: aparece .2s both; }
.hoja { position: absolute; left: 0; right: 0; bottom: 0; z-index: 8; background: var(--papel); border-radius: 28px 28px 0 0; padding: 22px 20px 26px; display: grid; gap: 10px; animation: sube .4s var(--sale) both; }
.velo[hidden], .hoja[hidden] { display: none; }
.hoja h2 { font-size: 1.375rem; font-weight: 800; }
.hoja-fila { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--linea); }
.hoja-fila span { color: var(--tinta-2); }
.hoja-fila b { text-align: right; font-variant-numeric: tabular-nums; }
.hoja .boton-morado { margin-top: 8px; }
.hoja .hecho { display: flex; align-items: center; gap: 10px; color: var(--bien); font-weight: 700; padding: 6px 0 2px; }

@keyframes sube { from { translate: 0 100%; } }
@keyframes aparece { from { opacity: 0; } }

::view-transition-group(billete) { animation-duration: .45s; animation-timing-function: var(--sale); }
::view-transition-old(billete), ::view-transition-new(billete) { height: 100%; object-fit: cover; object-position: top; }

@media (prefers-reduced-motion: reduce) {
  *, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: .01s !important; transition-duration: .01s !important; }
}

/* ---------- En el móvil: la app ocupa la pantalla ---------- */

@media (max-width: 760px) {
  body { background: var(--fondo); }
  .escena { display: flex; flex-direction: column; gap: 0; padding: 0; min-height: 100dvh; align-items: stretch; }
  .ficha { order: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 12px; padding: 4px 16px 8px; background: var(--tinta); color: #fff; }
  .largo { display: none; }
  .corto { display: inline; }
  .interruptor { font-weight: 500; }
  .carril { width: 40px; height: 24px; }
  .carril::after { width: 18px; height: 18px; }
  .interruptor input:checked + .carril::after { translate: 16px 0; }
  .ficha h1 { font-size: .9375rem; letter-spacing: 0; }
  .ficha p { display: none; }
  .ficha .aviso { display: block; order: 3; flex-basis: 100%; margin: 0; font-size: .75rem; line-height: 1.3; color: #cdbfd0; max-width: none; }
  .interruptor { margin: 0; font-size: .8125rem; gap: 8px; flex-direction: row-reverse; }
  .carril { background: #6b5d6e; }
  .interruptor input:checked + .carril { background: var(--magenta); }
  .movil { width: 100%; height: auto; flex: 1; min-height: 0; zoom: 1; border-radius: 0; padding: 0; background: none; box-shadow: none; display: flex; }
  .pantalla { border-radius: 0; flex: 1; height: auto; }
  .estado { display: none; }
  .vista { padding-top: 12px; }
  .capa-billete { padding-top: 16px; }
  .pestanas { padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .escena { height: 100dvh; }
}

/* ---------- Modo captura para el vídeo: ?embed ---------- */

.embed body, body.embed { background: var(--fondo); }
body.embed .escena { display: block; padding: 0; }
body.embed .ficha { display: none; }
body.embed .movil { zoom: 1; border-radius: 0; padding: 0; box-shadow: none; background: none; }
body.embed .pantalla { border-radius: 0; }

/* Botones con importe: acción a la izquierda, precio a la derecha */
#continuar, #pagar[data-paso="pagar"] { display: flex; justify-content: space-between; align-items: center; padding: 0 22px; }
#continuar span + span, #pagar span + span { font-variant-numeric: tabular-nums; }
