/* ───────── Tokens ───────── */
:root {
  --red: #E3170D;
  --red-deep: #B80F07;
  --paper: #ECEBE6;
  --paper-shade: #D6D5CF;
  --ink: #232323;
  --ink-soft: #5E5D59;
  --ink-faint: #9B9A94;

  --receipt-w: 440px;
  --gutter: 16px;
  --pad: clamp(20px, 6vw, 40px);

  --f-receipt: "VT323", ui-monospace, Menlo, monospace;
  --f-input: "Space Mono", ui-monospace, Menlo, monospace;

  --t-body: 22px;     /* VT323 corre pequeño: 22px ≈ 16px de una mono normal */
  --t-small: 19px;
  --t-big: clamp(96px, 30vw, 132px);
  --t-name: clamp(38px, 11vw, 48px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--red);
  color: var(--ink);
  font-family: var(--f-receipt);
  font-size: var(--t-body);
  line-height: 1.15;
  overflow-x: hidden;
}

/* Grano del fondo rojo, como el flyer */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .32; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 -.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.test-mode {
  position: relative; z-index: 3; margin: 0; padding: 8px var(--gutter);
  background: #FFD84D; color: #222; text-align: center;
  font: 13px/1.4 var(--f-input);
}

/* ───────── Escenario + ranura de impresora ───────── */
.stage {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  padding: 28px var(--gutter) 72px;
}
.slot {
  width: min(calc(var(--receipt-w) + 28px), 100%);
  height: 12px; border-radius: 6px;
  background: linear-gradient(#3a0603, #6d0a04 60%, #8f0e06);
  box-shadow: inset 0 2px 3px rgba(0,0,0,.6), 0 1px 0 rgba(255,255,255,.18);
  position: relative; z-index: 2;
}
.receipt {
  width: min(var(--receipt-w), 100%);
  margin-top: -6px;
  overflow: hidden;              /* el papel sale "desde" la ranura */
  padding: 0 0 24px;             /* espacio para la sombra */
  position: relative; z-index: 1;
}

/* ───────── Papel ───────── */
.paper {
  position: relative;
  padding: 34px var(--pad) 40px;
  background:
    radial-gradient(120% 40% at 85% 8%, rgba(0,0,0,.06), transparent 60%),
    radial-gradient(90% 30% at 10% 48%, rgba(0,0,0,.05), transparent 70%),
    linear-gradient(176deg, transparent 47.6%, rgba(0,0,0,.07) 48%, rgba(255,255,255,.5) 48.6%, transparent 49.4%),
    linear-gradient(183deg, transparent 71%, rgba(0,0,0,.05) 71.4%, rgba(255,255,255,.4) 71.9%, transparent 72.6%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E"),
    var(--paper);
  filter: drop-shadow(0 14px 18px rgba(80, 0, 0, .35)) drop-shadow(0 2px 2px rgba(60,0,0,.25));
  animation: print-out 1.5s steps(18, end) both;
}
/* borde inferior rasgado */
.paper::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -8px; height: 8px;
  background: conic-gradient(from -45deg at 50% 0, var(--paper) 90deg, transparent 0) 0 0 / 14px 8px repeat-x;
}
@keyframes print-out { from { transform: translateY(-101%); } to { transform: none; } }

p { margin: 0; }
.center { text-align: center; }
.small { font-size: var(--t-small); color: var(--ink-soft); }
.faded { color: var(--ink-faint); }
.row { display: flex; justify-content: space-between; gap: 16px; }

.stars {
  margin: 26px 0;
  overflow: hidden; white-space: nowrap;
  letter-spacing: .5px; color: var(--ink);
}
.stars::before { content: "******************************************************"; }

/* ───────── Encabezado ───────── */
.r-venue { text-align: center; letter-spacing: 1px; }
.barcode { display: block; width: 100%; height: 34px; margin: 14px 0 22px; }
.barcode.big { height: 64px; margin: 6px 0 4px; }
.r-title { margin: 0; text-align: center; font-weight: 400; line-height: .85; }
.r-num {
  display: block; font-size: var(--t-big); letter-spacing: .04em;
  -webkit-text-stroke: 2.5px var(--ink);
}
.r-name { display: block; font-size: var(--t-name); letter-spacing: .06em; margin-top: 6px; }

/* ───────── Lineup ───────── */
.lineup ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; }
.lineup li { display: flex; justify-content: space-between; gap: 16px; }
.lineup li span:first-child { white-space: pre-line; }
.lineup li span:last-child { white-space: nowrap; }
.lineup .date { margin-top: 30px; }
.addr { margin-top: 4px; color: var(--ink-soft); font-size: var(--t-small); }

/* ───────── Botones ───────── */
button, .btn-line { font: inherit; color: inherit; cursor: pointer; }
.btn-print {
  display: block; width: 100%; margin: 22px 0 12px; padding: 16px 12px 14px;
  background: var(--ink); color: var(--paper); border: 0; border-radius: 2px;
  font-size: 28px; letter-spacing: .08em;
  box-shadow: 0 3px 0 #000;
  transition: transform .08s, box-shadow .08s;
}
.btn-print:hover { background: #000; }
.btn-print:active { transform: translateY(3px); box-shadow: 0 0 0 #000; }
.btn-print[disabled] { opacity: .55; cursor: progress; }
.btn-print.loading span::after { content: ""; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.btn-ghost {
  background: none; border: 0; padding: 10px 2px; color: var(--ink-soft);
  font-size: var(--t-body); text-decoration: underline; text-underline-offset: 4px;
}
.btn-line {
  display: block; width: 100%; padding: 12px; text-align: center; text-decoration: none;
  background: none; border: 1.5px dashed var(--ink); border-radius: 2px; font-size: var(--t-body);
}
.btn-line:hover { background: rgba(0,0,0,.05); }
.link {
  display: block; margin: 22px auto 0; background: none; border: 0;
  color: var(--ink-soft); font-size: var(--t-small); text-decoration: underline; text-underline-offset: 4px;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.btn-print:focus-visible { outline-color: var(--red); }


/* ───────── Pedido (ítems impresos) ───────── */
.order-head { color: var(--ink-soft); font-size: var(--t-small); margin-bottom: 8px; }
.items { list-style: none; margin: 0; padding: 0; }
.item { padding: 3px 0; }
.items li { animation: print-line .32s steps(4, end) both; }
@keyframes print-line { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0); } }
.items button {
  display: flex; width: 100%; gap: 8px; align-items: baseline;
  padding: 4px 0; background: none; border: 0; text-align: left;
}
.items button:hover .val { text-decoration: underline; text-underline-offset: 3px; }
.items .lbl { flex: none; }
.items .dots { flex: 1; border-bottom: 2px dotted var(--ink-faint); transform: translateY(-5px); min-width: 12px; }
.items .val { flex: none; max-width: 62%; text-align: right; overflow-wrap: anywhere; }

/* ───────── Kiosco ───────── */
.kiosk { margin-top: 26px; padding-top: 22px; border-top: 2px dashed var(--ink-faint); }
.k-step { font-size: var(--t-small); color: var(--ink-soft); }
.k-q { font-size: 34px; line-height: 1; margin: 6px 0 6px; letter-spacing: .02em; font-weight: 400; }
.k-hint { font: 13px/1.5 var(--f-input); color: var(--ink-soft); margin: 0 0 14px; }

.field {
  display: flex; align-items: center; margin-top: 12px;
  border-bottom: 2px solid var(--ink); background: rgba(255,255,255,.35);
}
.field .pre { padding: 0 2px 0 10px; font: 700 16px var(--f-input); color: var(--ink-soft); }
.field input {
  flex: 1; min-width: 0; padding: 14px 10px 12px;
  background: transparent; border: 0; outline: 0; color: var(--ink);
  font: 16px var(--f-input);   /* 16px evita el zoom en iOS */
}
.field input::placeholder { color: var(--ink-faint); }
.field:focus-within { background: rgba(255,255,255,.7); box-shadow: 0 2px 0 var(--ink); }
.field-label { display: block; margin-top: 16px; font-size: var(--t-small); color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  padding: 9px 13px 7px; background: transparent;
  border: 1.5px solid var(--ink); border-radius: 2px; font-size: var(--t-body); line-height: 1;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.chip[aria-pressed="true"]::before { content: "✓ "; }
.chip:hover { background: rgba(0,0,0,.07); }
.chip[aria-pressed="true"]:hover { background: #000; }

.check { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; font: 13px/1.5 var(--f-input); cursor: pointer; }
.check input { appearance: none; flex: none; width: 22px; height: 22px; margin: 0; border: 2px solid var(--ink); border-radius: 2px; background: rgba(255,255,255,.4); display: grid; place-content: center; cursor: pointer; }
.check input:checked { background: var(--ink); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: solid var(--paper); border-width: 0 0 2.5px 2.5px; transform: translateY(-2px) rotate(-45deg); }
.check a { color: inherit; }

.k-error { min-height: 1.2em; margin-top: 10px; color: var(--red-deep); font-size: var(--t-small); }
.k-actions { display: flex; align-items: center; gap: 16px; }
.k-actions .btn-print { flex: 1; margin: 10px 0 0; }
.k-actions .btn-ghost { margin-top: 10px; }
.k-actions .btn-ghost[hidden] { display: none; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ───────── Ticket ───────── */
.ticket { margin-top: 20px; }
.total { font-size: 30px; }
.t-status { letter-spacing: .06em; }
.t-status.wait { color: var(--red-deep); }
.t-label { margin-top: 8px; font-size: var(--t-small); color: var(--ink-soft); }
.t-number { text-align: center; font-size: clamp(84px, 26vw, 112px); line-height: .9; -webkit-text-stroke: 2px var(--ink); }
.t-code { letter-spacing: .3em; font-size: var(--t-small); }
.t-who { margin: 18px 0 8px; font-size: 26px; }
.t-actions { display: grid; gap: 10px; margin-top: 20px; }
.t-actions .btn-print { margin: 0 0 4px; }
.ticket.stamp .t-number { animation: stamp .45s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes stamp { from { transform: scale(1.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* ───────── Pie ───────── */
.r-foot { display: grid; gap: 14px; justify-items: center; }
.logo { width: 64px; height: auto; opacity: .92; margin: 6px 0 2px; }
.r-foot a { color: inherit; }

/* ───────── Movimiento reducido ───────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 380px) {
  :root { --t-body: 20px; --t-small: 18px; }
  .k-q { font-size: 30px; }
}
.chips + .k-hint { margin-top: 18px; }
