/* ==========================================================================
   Visor PKPass
   ========================================================================== */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f3;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --border: #d9d9de;
  --accent: #0071e3;
  --accent-text: #ffffff;
  --ok: #1a7f37;
  --bad: #c9271b;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .06);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --border: #38383a;
    --accent: #2997ff;
    --ok: #4ac26b;
    --bad: #ff6b5e;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 24px rgb(0 0 0 / .3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
code { font-family: var(--mono); font-size: .9em; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Botones ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .chip:focus-visible, .dropzone:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-small { font-size: 12px; padding: 4px 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Cabecera y estructura ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.site-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 17px; }
.brand-mark { width: 28px; height: 28px; color: var(--text); }

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  align-items: start;
}
.content { min-width: 0; }

@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Intro ---------- */
.intro h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.12; letter-spacing: -.02em; margin: 8px 0 12px; }
.lead { font-size: 18px; color: var(--text-2); margin: 0 0 24px; max-width: 62ch; }
.lead strong { color: var(--text); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 40px 20px;
  border: 2px dashed var(--border);
  border-radius: 20px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone svg { width: 48px; height: 48px; color: var(--accent); }
.dropzone strong { font-size: 18px; }
.dropzone span { color: var(--text-2); font-size: 14px; }

.samples { margin-top: 20px; }
.samples-title { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 8px; }

.error {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--bad) 12%, var(--surface));
  color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
}

/* ---------- Visor ---------- */
.viewer { scroll-margin-top: 70px; }
.viewer.is-loading { opacity: .5; pointer-events: none; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.select select {
  appearance: none;
  font: inherit;
  font-size: 14px;
  padding: 7px 32px 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center / 10px;
}

.viewer-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
@media (max-width: 760px) {
  .viewer-grid { grid-template-columns: minmax(0, 1fr); }
}

.stage { display: flex; justify-content: center; padding: 4px 0 12px; }

.details { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.tabs { display: flex; gap: 4px; padding: 8px; border-bottom: 1px solid var(--border); }
.tabs [role="tab"] {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.tabs [role="tab"][aria-selected="true"] { background: var(--surface-2); color: var(--text); }
.tab-panel { padding: 8px 16px 16px; position: relative; }

.kv-list { margin: 0; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.kv:last-child { border-bottom: 0; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }

#tab-json pre {
  margin: 8px 0 0;
  max-height: 560px;
  overflow: auto;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
  font-size: 12.5px;
  line-height: 1.45;
}
#tab-json code { overflow-wrap: normal; }
#copy-json { position: absolute; right: 26px; top: 18px; }

.files { width: 100%; border-collapse: collapse; font-size: 14px; }
.files th { text-align: left; color: var(--text-2); font-weight: 500; padding: 8px 0; border-bottom: 1px solid var(--border); }
.files td { padding: 6px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.files td:first-child { display: flex; align-items: center; gap: 10px; overflow-wrap: anywhere; }
.files td:last-child { text-align: right; white-space: nowrap; color: var(--text-2); padding-left: 12px; }
.files img, .file-ico {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex: none;
  border-radius: 6px;
  background: repeating-conic-gradient(#ccc 0 25%, #fff 0 50%) 0 0 / 10px 10px;
}
.file-ico { background: var(--surface-2); }

/* ---------- FAQ ---------- */
.info { margin-top: 56px; }
.info h2 { font-size: 22px; margin: 0 0 12px; }
.info details { background: var(--surface); border-radius: 12px; padding: 0 16px; margin-bottom: 8px; box-shadow: var(--shadow); }
.info summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.info details p { margin: 0 0 14px; color: var(--text-2); }

/* ---------- Publicidad ---------- */
.ad-rail { position: sticky; top: 76px; }
.ad-slot { width: 300px; max-width: 100%; margin: 0 auto; }
.ad-label { display: block; font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; text-align: center; }
.ad-slot ins.adsbygoogle { min-height: 250px; }
.ad-slot:not(.ad-live) ins.adsbygoogle { display: none !important; }
.ad-slot.ad-live .ad-placeholder { display: none; }
.ad-placeholder {
  height: 600px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-2);
  font-size: 14px;
}
@media (max-width: 1023px) {
  .ad-rail { position: static; }
  .ad-placeholder { height: 250px; }
}

/* ---------- Pie ---------- */
.site-footer { max-width: 1280px; margin: 0 auto; padding: 24px 16px 48px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 14px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0; }
.site-footer p { margin: 4px 0; }

/* ---------- Arrastrar ---------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-overlay div { background: var(--surface); padding: 20px 28px; border-radius: 16px; font-size: 18px; font-weight: 600; box-shadow: var(--shadow); }

/* ---------- Banner de cookies ---------- */
.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  max-width: 960px;
  margin: 0 auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgb(0 0 0 / .22);
}
.cookie-inner { display: flex; gap: 20px; align-items: flex-end; padding: 18px 20px; }
.cookie-text { flex: 1; min-width: 0; }
.cookie-text h2 { font-size: 16px; margin: 0 0 4px; }
.cookie-text p { margin: 0; font-size: 14px; color: var(--text-2); }
.cookie-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.cookie-prefs { margin-top: 12px; display: grid; gap: 10px; justify-items: start; }
.pref { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.pref input { margin-top: 4px; accent-color: var(--accent); }
@media (max-width: 680px) {
  .cookie-inner { flex-direction: column; align-items: stretch; }
  .cookie-actions .btn { flex: 1; }
}

/* ==========================================================================
   Pase (aproximación a Apple Wallet)
   ========================================================================== */

.pass {
  --pass-w: 340px;
  --pad: 14px;
  width: var(--pass-w);
  max-width: 100%;
  perspective: 1600px;
  filter: drop-shadow(0 2px 3px rgb(0 0 0 / .12)) drop-shadow(0 12px 22px rgb(0 0 0 / .14));
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.pass-inner {
  position: relative;
  display: grid;
  transform-style: preserve-3d;
  transition: transform .7s cubic-bezier(.3, .1, .2, 1);
}
.pass.is-flipped .pass-inner { transform: rotateY(180deg); }

.pass-face {
  grid-area: 1 / 1;
  position: relative;
  min-height: 430px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--pass-bg);
  color: var(--pass-fg);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.pass-front { display: flex; flex-direction: column; }
.pass-back { transform: rotateY(180deg); display: flex; flex-direction: column; }

/* Muesca superior de las entradas */
.pass--eventTicket .pass-face {
  -webkit-mask: radial-gradient(circle 21px at 50% -4px, transparent 20.5px, #000 21px);
  mask: radial-gradient(circle 21px at 50% -4px, transparent 20.5px, #000 21px);
}

/* Borde perforado de los cupones */
.pass--coupon .pass-face {
  border-radius: 4px;
  -webkit-mask:
    radial-gradient(circle 4px at 50% 0, transparent 3.6px, #000 4px) top / 11px 51% repeat-x,
    radial-gradient(circle 4px at 50% 100%, transparent 3.6px, #000 4px) bottom / 11px 51% repeat-x;
  mask:
    radial-gradient(circle 4px at 50% 0, transparent 3.6px, #000 4px) top / 11px 51% repeat-x,
    radial-gradient(circle 4px at 50% 100%, transparent 3.6px, #000 4px) bottom / 11px 51% repeat-x;
}

/* Fondo desenfocado (entradas con background.png) */
.pass-bg { position: absolute; inset: 0; overflow: hidden; z-index: 0; }
.pass-bg img { width: 100%; height: 100%; object-fit: cover; filter: blur(9px) saturate(1.1); transform: scale(1.15); }
.pass-bg::after { content: ""; position: absolute; inset: 0; background: rgb(0 0 0 / .08); }
.pass-front > :not(.pass-bg) { position: relative; z-index: 1; }

/* Cabecera */
.pass-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px var(--pad) 6px;
}
.pass--eventTicket .pass-header { padding-top: 14px; }
.pass-logo { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }
.pass-logo img { max-height: 38px; max-width: 150px; object-fit: contain; object-position: left center; flex: none; }
.logo-text { font-size: 17px; font-weight: 600; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.01em; }
.header-fields { display: flex; gap: 14px; flex: none; max-width: 62%; }
.header-field .field-value { font-size: 17px; }

/* Campos */
.field { min-width: 0; }
.field-label {
  color: var(--pass-label);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-value {
  font-size: 16px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px var(--pad) 0;
}
.field-row > .field { flex: 0 1 auto; }
.field-row > .field:only-child { flex: 1; }

.pass-body { display: flex; flex-direction: column; }

/* Primarios genéricos / entrada sin banda */
.with-thumb { display: flex; gap: 12px; align-items: flex-start; padding: 4px var(--pad) 0; }
.with-thumb-col { flex: 1; min-width: 0; }
.with-thumb-col .field-row { padding-left: 0; padding-right: 0; }
.thumbnail { max-width: 84px; max-height: 84px; object-fit: contain; flex: none; border-radius: 2px; margin-top: 4px; }
.primary-plain .field-value { font-size: 26px; line-height: 1.15; overflow: hidden; text-overflow: clip; }
.pass--generic .primary-plain .field-value { font-size: 28px; }
.pass--generic .primary-plain .field-label { font-size: 12px; text-transform: none; font-weight: 500; letter-spacing: 0; margin-top: 1px; }
.pass--generic .pass-body > .field-row:first-of-type { padding-top: 14px; }
.pass--generic .with-thumb { min-height: 92px; }

/* Banda (strip) */
.strip { position: relative; min-height: 89px; display: flex; align-items: flex-start; }
.pass--coupon .strip, .pass--storeCard .strip { min-height: 128px; }
.strip-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.strip-primary { position: relative; padding: 8px var(--pad); min-width: 0; width: 100%; }
.strip-primary .field-value { font-size: 44px; font-weight: 300; line-height: 1.05; letter-spacing: -.01em; text-overflow: clip; }
.strip-primary .field-label { font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; margin-top: 2px; }
.pass--eventTicket .strip-primary .field-value { font-size: 34px; }
.has-strip .pass-body > .field-row:first-of-type { padding-top: 12px; }
.plain-primary { padding: 6px var(--pad) 0; }
.plain-primary .field-value { font-size: 40px; font-weight: 300; line-height: 1.1; text-overflow: clip; }
.plain-primary .field-label { font-size: 13px; text-transform: none; font-weight: 500; letter-spacing: 0; }

/* Tarjeta de embarque */
.boarding-primary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 8px;
  padding: 6px var(--pad) 4px;
}
.boarding-primary .field-value { font-size: 42px; font-weight: 300; line-height: 1.05; letter-spacing: -.01em; text-overflow: clip; }
.boarding-primary .field-label { font-size: 11px; }
.transit-icon { width: 30px; height: 30px; color: var(--pass-label); margin-bottom: 8px; }
.transit-icon svg { width: 100%; height: 100%; display: block; }
.footer-img { display: block; max-width: calc(100% - 2 * var(--pad)); max-height: 15px; margin: 14px auto 0; object-fit: contain; }

/* Código de barras */
.barcode-area {
  margin-top: auto;
  padding: 16px var(--pad) 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.barcode-box {
  background: #fff;
  color: #000;
  border-radius: 6px;
  padding: 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.barcode-box.square .barcode-svg { width: 132px; height: 132px; }
.barcode-box.wide { padding: 10px 12px 8px; }
.barcode-box.wide .barcode-svg { width: 262px; height: 74px; }
.pass--boardingPass .barcode-box.wide .barcode-svg { height: 82px; }
.barcode-svg svg { width: 100%; height: 100%; display: block; }
.barcode-alt { font-size: 11.5px; line-height: 1.2; margin-top: 6px; max-width: 262px; text-align: center; overflow-wrap: anywhere; }
.barcode-loading { width: 100%; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #eee, #f8f8f8, #eee); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; }
.barcode-error { font-size: 12px; color: #b00; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; }
.barcode-box.dimmed { opacity: .35; }
@keyframes shimmer { to { background-position: -200% 0; } }

.pass-status {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--pass-fg) 16%, transparent);
}
.nfc-badge { font-size: 12px; font-weight: 600; opacity: .75; }

.info-btn {
  position: absolute !important;
  right: 10px;
  bottom: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background: transparent;
  color: var(--pass-fg);
  font: italic 600 13px/1 Georgia, "Times New Roman", serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  opacity: .8;
}
.info-btn:hover { opacity: 1; }

/* Reverso */
.pass-back { padding: 0 0 12px; }
.back-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px var(--pad) 10px;
}
.pass--eventTicket .back-top { padding-top: 20px; }
.back-title { flex: 1; min-width: 0; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-done {
  border: 0;
  background: color-mix(in srgb, var(--pass-fg) 18%, transparent);
  color: var(--pass-fg);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.back-status { margin: 0 var(--pad) 10px; font-weight: 600; font-size: 13px; }
.back-list {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  margin: 0 10px;
  background: #fff;
  color: #000;
  border-radius: 10px;
  overscroll-behavior: contain;
}
.back-row { padding: 10px 14px; border-bottom: 1px solid #e5e5ea; font-size: 14px; }
.back-row:last-child { border-bottom: 0; }
.back-label { color: #6e6e73; font-size: 12.5px; margin-bottom: 2px; }
.back-value { overflow-wrap: anywhere; line-height: 1.4; }
.back-value a { color: #0066cc; }
.back-empty { color: #6e6e73; text-align: center; padding: 24px; }

@media (prefers-reduced-motion: reduce) {
  .pass-inner { transition: none; }
}

@media (max-width: 380px) {
  .pass { --pass-w: 100%; }
}
