/* =========================================================
   BAHÍA ESTUDIO — REALIDAD AUMENTADA
   ========================================================= */
:root {
  --brand: #374c8b;
  --brand-dark: #1e3a8a;
  --brand-deep: #0f1a3d;
  --accent: #3b82f6;
  --chip: #e3eafc;
  --wa: #1faa53;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: "Poppins", var(--font);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--brand-deep); }
body { font-family: var(--font); color: #fff; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
h1, h2 { font-family: var(--font-head); margin: 0; line-height: 1.15; letter-spacing: -.01em; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

/* Contenedor de MindAR: ocupa toda la pantalla */
#ar { position: fixed; inset: 0; touch-action: none; }
#ar video { object-fit: cover; }

/* ---------- Pantallas (inicio, cargando, error) ---------- */
.pantalla {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 24px 20px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(59, 130, 246, .35), transparent 60%),
    radial-gradient(90% 60% at 100% 100%, rgba(55, 76, 139, .55), transparent 60%),
    var(--brand-deep);
  text-align: center;
}
.intro-caja { width: 100%; max-width: 400px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.intro-logo { width: 150px; height: auto; margin-bottom: 4px; }
.intro-caja h1 { font-size: clamp(24px, 6.5vw, 30px); }
.intro-caja h2 { font-size: 22px; }
.intro-caja p { margin: 0; color: #c9d4f2; line-height: 1.5; }
.etiqueta {
  display: inline-block; padding: 5px 12px; border-radius: 999px;
  background: rgba(59, 130, 246, .2); color: #bcd3ff;
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.pasos { list-style: none; margin: 4px 0; padding: 0; width: 100%; display: grid; gap: 10px; text-align: left; }
.pasos li {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px;
  color: #dbe3f7; font-size: 15px;
}
.pasos b {
  flex: none; width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 50%; background: var(--accent); color: #fff; font-size: 14px;
}
.pasos em { font-style: normal; font-weight: 600; color: #fff; }
.enlace { color: #9fbcff; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 14px;
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: transform .15s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn-primario { width: 100%; background: var(--accent); color: #fff; box-shadow: 0 10px 30px rgba(59, 130, 246, .4); font-size: 16px; }
.btn-claro { background: var(--chip); color: var(--brand-dark); }
.btn-wa { background: var(--wa); color: #fff; }

.spinner {
  width: 54px; height: 54px; border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, .15); border-top-color: var(--accent);
  animation: girar 0.9s linear infinite;
}
#cargando { align-content: center; gap: 18px; }
#cargando p { margin: 0; color: #c9d4f2; }
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Barra superior ---------- */
#barra {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: linear-gradient(rgba(15, 26, 61, .7), transparent);
  pointer-events: none;
}
#barra img { height: 34px; width: auto; }
#barra .cerrar {
  pointer-events: auto; width: 40px; height: 40px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(15, 26, 61, .6); color: #fff; text-decoration: none; font-size: 16px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* ---------- Indicación de escaneo ---------- */
#escaneo {
  position: fixed; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  pointer-events: none;
}
#escaneo p {
  margin: 0 20px; padding: 10px 16px; border-radius: 12px;
  background: rgba(15, 26, 61, .75); font-weight: 500; text-align: center;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.visor { position: relative; width: min(62vw, 270px); aspect-ratio: 1; }
.visor img { width: 100%; height: 100%; border-radius: 10px; opacity: .45; }
.esq { position: absolute; width: 30px; height: 30px; border: 4px solid #fff; }
.e1 { top: -10px; left: -10px; border-right: 0; border-bottom: 0; border-top-left-radius: 12px; }
.e2 { top: -10px; right: -10px; border-left: 0; border-bottom: 0; border-top-right-radius: 12px; }
.e3 { bottom: -10px; left: -10px; border-right: 0; border-top: 0; border-bottom-left-radius: 12px; }
.e4 { bottom: -10px; right: -10px; border-left: 0; border-top: 0; border-bottom-right-radius: 12px; }
.linea {
  position: absolute; left: 4%; right: 4%; height: 3px; top: 0; border-radius: 3px;
  background: var(--accent); box-shadow: 0 0 14px 3px rgba(59, 130, 246, .8);
  animation: barrer 2.2s ease-in-out infinite alternate;
}
@keyframes barrer { to { top: calc(100% - 3px); } }

/* ---------- Ficha del producto ---------- */
#ficha {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 10;
  max-width: 480px; margin: 0 auto; padding: 14px 14px 14px;
  background: rgba(15, 26, 61, .82); border: 1px solid rgba(255, 255, 255, .12); border-radius: 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  animation: subir .35s ease-out;
}
@keyframes subir { from { transform: translateY(30px); opacity: 0; } }
.ficha-fila { display: flex; align-items: center; gap: 8px; }
.ficha-info { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ficha-info .etiqueta { font-size: 11px; padding: 4px 10px; }
.ficha-info h2 { font-size: 18px; max-width: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ficha-precio { margin: 0; font-size: 15px; color: #c9d4f2; }
.ficha-precio b { color: #fff; font-size: 18px; font-family: var(--font-head); }
.ficha-precio s { color: #8d9bc4; margin-left: 2px; }
.ficha-precio small { display: block; color: #9fb0dc; font-size: 12px; margin-top: 2px; }
.flecha {
  flex: none; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .1); font-size: 28px; line-height: 1; padding-bottom: 4px;
}
.flecha:active { background: rgba(255, 255, 255, .2); }
.puntos { display: flex; justify-content: center; gap: 6px; margin: 10px 0 12px; }
.puntos button { width: 8px; height: 8px; padding: 0; border-radius: 4px; background: rgba(255, 255, 255, .3); transition: width .25s, background .25s; }
.puntos button[aria-current="true"] { width: 22px; background: var(--accent); }
.ficha-acciones { display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px; }
.ficha-acciones .btn { min-height: 44px; padding: 0 12px; font-size: 14px; }

/* Aviso breve (marcador perdido) */
.aviso {
  position: fixed; top: calc(70px + env(safe-area-inset-top)); left: 50%; z-index: 11;
  transform: translateX(-50%); padding: 8px 14px; border-radius: 999px;
  background: rgba(15, 26, 61, .8); font-size: 13px; white-space: nowrap;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

@media (prefers-reduced-motion: reduce) {
  .linea, .spinner, #ficha { animation: none; }
}

.cargando-modelo { display: inline-flex; align-items: center; gap: 6px; color: #9fbcff; font-size: 12px; }
.cargando-modelo::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); animation: girar .8s linear infinite; }
.cargando-modelo[hidden] { display: none; }

/* ---------- Juego «Imprime tu producto» ---------- */
.juego {
  position: fixed; top: calc(68px + env(safe-area-inset-top)); left: 50%; z-index: 9;
  transform: translateX(-50%); width: min(88vw, 360px);
  display: grid; gap: 8px; padding: 10px 14px 12px; border-radius: 16px;
  background: rgba(15, 26, 61, .78); border: 1px solid rgba(255, 255, 255, .12);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  pointer-events: none; text-align: center;
}
.juego p { margin: 0; font-size: 14px; font-weight: 600; }
.juego-barra { position: relative; height: 22px; border-radius: 11px; background: rgba(255, 255, 255, .12); overflow: hidden; border: 2px solid #4ade80; }
.juego-barra i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #22c55e, #4ade80); transition: width .35s ease-out; }
.juego-barra span { position: relative; font-size: 12px; font-weight: 700; line-height: 18px; }

.premio { z-index: 30; background: rgba(8, 13, 33, .82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.premio-insignia {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #22c55e, #3b82f6); font-size: 38px; font-weight: 800;
  box-shadow: 0 0 0 10px rgba(59, 130, 246, .18); animation: aparecer .5s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes aparecer { from { transform: scale(.3); opacity: 0; } }
.premio h2 { font-size: 26px; }
.cupon { width: 100%; display: grid; gap: 6px; padding: 14px; border-radius: 16px; border: 2px dashed rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .06); }
.cupon[hidden] { display: none; }
.cupon small { color: #c9d4f2; font-size: 12px; }
.cupon-codigo { font-family: var(--font-head); font-size: 30px; font-weight: 800; letter-spacing: .08em; color: #fff; }
.btn-ancho { width: 100%; }
.btn-wa[hidden] { display: none; }

.nota-camara { font-size: 12.5px !important; color: #9fb0dc !important; }
.nota-camara a { color: #bcd3ff; text-decoration: underline; }
