/* LA HIPOTESIS DEL AMOR — Amazon Prime
   Tokens derivados del arte del cliente: teal #2C7B98, rosa #EC6090.
   Rampa OKLCH manteniendo hue+chroma (premium-ui-system §2). Radios: soft (10/14/20).
   Motion: tabla de premium-ui-system §7, valores literales, sin inventar. */

:root {
  color-scheme: dark;

  /* Tier 1 — primitivos */
  --teal-300: oklch(0.72 0.075 225);
  --teal-500: oklch(0.545 0.075 225);   /* #2C7B98 del arte */
  --teal-700: oklch(0.42 0.062 225);
  --teal-900: oklch(0.27 0.042 225);
  --pink-400: oklch(0.72 0.155 5);
  --pink-500: oklch(0.665 0.165 5);     /* #EC6090 del arte */
  --pink-600: oklch(0.60 0.168 5);
  --paper: oklch(0.985 0.004 225);

  /* Tier 2 — semanticos */
  --surface: var(--teal-500);
  --surface-sunk: var(--teal-900);
  --surface-raised: color-mix(in oklch, var(--paper) 12%, transparent);
  --border: color-mix(in oklch, var(--paper) 26%, transparent);
  --text: var(--paper);
  --text-muted: color-mix(in oklch, var(--paper) 78%, var(--teal-700));
  --accent: var(--pink-500);
  --on-accent: oklch(0.99 0 0);
  --focus-ring: var(--paper);

  /* Elevacion tenida al hue de marca, nunca negro puro */
  --shadow-tint: oklch(0.32 0.05 225);
  --elevation-2: 0 2px 4px color-mix(in oklch, var(--shadow-tint) 18%, transparent),
                 0 8px 16px color-mix(in oklch, var(--shadow-tint) 22%, transparent),
                 0 20px 44px color-mix(in oklch, var(--shadow-tint) 26%, transparent);

  /* Espaciado 4/8 */
  --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 24px;
  --space-6: 32px; --space-7: 48px;

  --radius-sm: 10px; --radius-md: 14px; --radius-lg: 20px;

  /* Motion — tabla de la casa, literal */
  --dur-instant: 120ms;
  --dur-toggle: 240ms;
  --dur-modal: 400ms;
  --dur-page: 500ms;
  --ease-out: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-out-strong: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in: cubic-bezier(0.32, 0, 0.67, 0);

  --font-display: "Outfit", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }   /* dia 1: sin esto, hidden no gana a display:flex */

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
}

/* ---------- Pantallas ---------- */
.screen {
  position: fixed; inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);       /* fila explicita: sin esto el track implicito rompe el centrado */
  background: var(--surface) center / cover no-repeat;
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-4)
           max(var(--space-5), env(safe-area-inset-bottom));
  opacity: 0;
  transition: opacity var(--dur-page) var(--ease-in);
  pointer-events: none;
  z-index: 1;
}
.screen.is-on { opacity: 1; pointer-events: auto; z-index: 2; transition-timing-function: var(--ease-out); }
.screen--flat { background-image: url("/a/fondo.webp"); }

.stack {
  min-height: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-5);
  width: 100%; max-width: 560px; margin-inline: auto;
}
/* En kiosko vertical (1080x1920) 560px deja el visor diminuto: la caja crece con la pantalla. */
@media (min-width: 720px) { .stack { max-width: 780px; gap: var(--space-6); } }
.stack--tight { gap: var(--space-4); justify-content: space-between; }
.stack--end { justify-content: flex-end; padding-bottom: var(--space-6); }

.lockup { width: min(72vw, 300px); height: auto; }
.title { font-size: clamp(26px, 6vw, 40px); font-weight: 800; letter-spacing: -0.015em; text-wrap: balance; text-align: center; }
.paso { font-size: clamp(17px, 4.2vw, 22px); font-weight: 600; color: var(--text-muted); text-align: center; text-wrap: balance; }
.hint { font-size: 13px; color: var(--text-muted); text-align: center; word-break: break-all; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 64px; padding: 0 var(--space-6);
  border: 0; border-radius: var(--radius-md);
  font: inherit; font-size: clamp(17px, 4.3vw, 21px); font-weight: 800; letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform var(--dur-instant) var(--ease-out), background-color var(--dur-instant) var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.btn--primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--elevation-2); }
.btn--primary:hover { background: var(--pink-600); }
.btn--ghost { background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.btn--breath { min-width: min(80vw, 340px); min-height: 84px; animation: breath 4s ease-in-out infinite; }
@keyframes breath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

.btn--ancho { min-width: min(80vw, 340px); }

/* ---------- Galería ---------- */
.galeria {
  flex: 1 1 0; min-height: 0; width: 100%; overflow-y: auto; overscroll-behavior: contain;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(96px, 26vw, 150px), 1fr));
  gap: var(--space-3); align-content: start; padding: 2px;
}
.celda {
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-sunk); cursor: pointer; position: relative;
  transition: transform var(--dur-instant) var(--ease-out);
}
.celda:active { transform: scale(0.97); }
.celda:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.celda img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; }
.celda__tipo {
  position: absolute; top: 6px; right: 6px; padding: 2px 7px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 11px; font-weight: 800; letter-spacing: .04em;
}
.galeria__vacia { grid-column: 1 / -1; padding: var(--space-7) var(--space-4); text-align: center; color: var(--text-muted); }

/* Visor: cubre la pantalla de galería sin desmontarla, para volver al grid tal cual estaba. */
.visor-modal {
  position: absolute; inset: 0; z-index: 3;
  background: color-mix(in oklch, var(--teal-900) 88%, transparent);
  backdrop-filter: blur(10px);
  display: grid; grid-template-rows: minmax(0, 1fr);
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-4)
           max(var(--space-5), env(safe-area-inset-bottom));
  animation: aparece var(--dur-modal) var(--ease-out);
}
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }
.visor-modal__caja {
  min-height: 0; display: flex; flex-direction: column; justify-content: space-between;
  gap: var(--space-4); width: 100%; max-width: min(96vw, 1040px); margin-inline: auto;
}

.link {
  background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 16px; font-weight: 600;
  text-decoration: underline; text-underline-offset: 4px; padding: var(--space-3); cursor: pointer;
}
.link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

.acciones { display: flex; gap: var(--space-3); width: 100%; justify-content: center; flex-wrap: wrap; }
.acciones .btn { flex: 1 1 auto; min-width: 150px; }
@media (max-width: 640px) {
  /* Tres acciones con icono no caben a 390px: la fila se apila y el visor cede alto. */
  .acciones { flex-direction: column; }
  .acciones .btn { flex: none; width: 100%; min-width: 0; }
}

/* ---------- Modo ---------- */
.modos { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); width: 100%; }
.modo {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-2);
  padding: var(--space-6) var(--space-3);
  background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-lg);
  color: var(--text); font: inherit; cursor: pointer;
  transition: transform var(--dur-instant) var(--ease-out), background-color var(--dur-instant) var(--ease-out);
}
.modo:active { transform: scale(0.97); }
.modo:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }
.modo__ico { color: var(--pink-400); display: block; }
.modo__n { font-size: clamp(20px, 5vw, 26px); font-weight: 800; }
.modo__d { font-size: 13.5px; font-weight: 400; color: var(--text-muted); text-align: center; text-wrap: balance; }

/* ---------- Visor ---------- */
.visor {
  position: relative; flex: 1 1 0; min-height: 0; width: 100%;
  display: grid; grid-template-rows: minmax(0, 1fr);
  border-radius: var(--radius-lg); overflow: hidden;
  background: var(--surface-sunk); box-shadow: var(--elevation-2);
}
.visor video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
.visor video.no-espejo { transform: none; }
.visor__flash {
  position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none;
}
.visor__flash.is-on { animation: flash var(--dur-modal) var(--ease-out); }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }

.cuenta {
  position: absolute; top: 50%; left: 50%; translate: -50% -50%;
  font-size: clamp(90px, 30vw, 190px); font-weight: 800; line-height: 1;
  color: var(--paper); text-shadow: 0 10px 40px color-mix(in oklch, var(--teal-900) 70%, transparent);
  animation: tic 1s var(--ease-out-strong);
}
@keyframes tic { from { opacity: 0; transform: scale(1.45); } 35% { opacity: 1; transform: scale(1); } to { opacity: 0.85; } }

.tomas { position: absolute; left: 50%; bottom: 14px; translate: -50% 0; display: flex; gap: 8px; }
.tomas i { width: 10px; height: 10px; border-radius: 999px; background: color-mix(in oklch, var(--paper) 35%, transparent); }
.tomas i.on { background: var(--pink-400); }

/* ---------- Previo / marcos ---------- */
.previo, .final { flex: 1 1 0; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; gap: var(--space-4); overflow: hidden; }
.previo img, .final img { min-height: 0; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: var(--radius-sm); box-shadow: var(--elevation-2); }

.marcos { display: flex; gap: var(--space-3); justify-content: center; width: 100%; }
.marco {
  flex: 0 1 108px; padding: 6px 6px 8px; cursor: pointer;
  background: var(--surface-raised); border: 2px solid transparent; border-radius: var(--radius-md);
  color: var(--text-muted); font: inherit; font-size: 13px; font-weight: 600;
  transition: border-color var(--dur-toggle) var(--ease-out), color var(--dur-toggle) var(--ease-out);
}
/* El marco 2 es un degradado de alfa: sin fondo teal la miniatura se lee casi negra. */
.marco img { display: block; width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 6px; background: var(--teal-500); }
.marco span { display: block; margin-top: 6px; }
.marco.is-sel { border-color: var(--accent); color: var(--text); }
@media (min-width: 720px) { .marco { flex-basis: 150px; font-size: 15px; } }
.marco:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 3px; }

/* ---------- Entrega (QR al costado, la foto manda) ----------
   En vertical la foto toma todo el alto disponible y el QR vive en una columna angosta
   a su derecha, alineado al pie: asi el recuerdo es la pieza grande y el codigo acompana. */
.final { align-items: stretch; }
.final img { flex: 1 1 auto; min-width: 0; align-self: center; }
.entrega { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
           justify-content: flex-end; gap: var(--space-2); }
.entrega__txt { font-size: clamp(12px, 3vw, 15px); font-weight: 400; line-height: 1.35; color: var(--text-muted); text-align: center; }
/* La pantalla final no se topa en 780px como el resto: ahi el ancho es tamano de foto. */
#s-listo .stack { max-width: min(96vw, 1040px); }

/* Celular angosto: al costado la foto perderia un tercio de su tamano, asi que el QR
   baja a una fila compacta y la foto se queda con todo el alto. */
@media (max-width: 560px) {
  .final { flex-direction: column; }
  .final img { flex: 1 1 0; min-height: 0; }
  .entrega { flex-direction: row; justify-content: center; gap: var(--space-4); }
  .entrega__txt { text-align: left; }
}
.entrega__txt b { font-weight: 800; color: var(--text); }
.qr { background: var(--paper); padding: 8px; border-radius: var(--radius-sm); box-shadow: var(--elevation-2); flex: 0 0 auto; }
/* Pequeno pero escaneable: nunca por debajo de ~112px de lado. */
/* El canvas se genera grande y CSS lo reduce: sin 'pixelated' el reescalado no entero
   suaviza los modulos en vez de dentarlos, que es lo que agradece la camara. */
.qr canvas { display: block; width: clamp(92px, 19vw, 150px); height: auto; }

/* ---------- Barra ---------- */
.barra { width: min(78vw, 360px); height: 10px; border-radius: 999px; background: var(--surface-raised); overflow: hidden; }
.barra i { display: block; height: 100%; width: 0%; border-radius: 999px; background: var(--accent); transition: width var(--dur-modal) var(--ease-out); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); translate: -50% 0; z-index: 10;
  max-width: min(92vw, 460px); padding: var(--space-3) var(--space-5);
  background: var(--surface-sunk); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text); font-size: 15px; font-weight: 600; text-align: center; box-shadow: var(--elevation-2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 120ms !important; }
}
