/* La Mesa AR — estilos compartidos (mobile-first) */

:root {
  --fondo: #111827;
  --fondo-2: #172033;
  --tarjeta: #19223a;
  --linea: rgba(255, 255, 255, 0.09);
  --linea-fuerte: rgba(255, 255, 255, 0.18);
  --texto: #ffffff;
  --suave: #a3acbb;
  --acento: #b62520;
  --acento-claro: #cf322c;
  --radio: 18px;
  --margen: 20px;
  --curva: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Que el atributo hidden siempre oculte, aunque la clase ponga display */
[hidden] { display: none !important; }

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--fondo);
  color: var(--texto);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
main { flex: 1; }

:focus-visible { outline: 2px solid #fff; outline-offset: 3px; border-radius: 6px; }

.contenedor {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 var(--margen);
}

/* Marca */
.marca {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
}
.marca::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--acento);
  box-shadow: 0 0 0 4px rgba(182, 37, 32, 0.22);
}

/* ---------- Carta (index) ---------- */

.cabecera { padding: 36px 0 26px; }

.cabecera__eyebrow {
  margin-top: 28px;
  color: var(--suave);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cabecera__titulo {
  margin-top: 8px;
  font-size: clamp(32px, 9vw, 42px);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.cabecera__texto {
  margin-top: 12px;
  color: var(--suave);
  font-size: 16px;
  max-width: 34ch;
}

.platos {
  list-style: none;
  display: grid;
  gap: 16px;
  padding-bottom: 36px;
}

.plato {
  display: block;
  overflow: hidden;
  background: var(--tarjeta);
  border: 1px solid var(--linea);
  border-radius: var(--radio);
  transition: transform 0.2s var(--curva), border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.plato:hover { border-color: var(--linea-fuerte); }
.plato:active { transform: scale(0.985); }

.plato__foto {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 90% at 50% 62%, #2a3550 0%, #1b2438 48%, #151d2e 100%);
}
.plato__foto img {
  width: 88%;
  height: 92%;
  object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.35));
  transition: transform 0.5s var(--curva);
}
.plato:hover .plato__foto img { transform: scale(1.03); }

.plato__info { display: grid; gap: 4px; padding: 16px 18px 18px; }

.plato__fila {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.plato__nombre { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.3; }
.plato__precio { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.plato__desc { color: var(--suave); font-size: 14px; }

.plato__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 600;
}
.plato__cta .icono {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--acento);
}
.plato__cta svg { width: 15px; height: 15px; }

/* ---------- Pie ---------- */

.pie {
  padding: 26px 0 34px;
  border-top: 1px solid var(--linea);
  color: var(--suave);
  font-size: 13px;
  text-align: center;
}
.pie a { color: var(--texto); font-weight: 500; }

/* ---------- Plato (visor) ---------- */

.barra {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(17, 24, 39, 0.86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--linea);
}
.barra .contenedor {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.barra .marca { font-size: 13px; }

.volver {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -6px;
  padding: 8px 6px;
  font-size: 15px;
  font-weight: 500;
}
.volver svg { width: 20px; height: 20px; }

.visor {
  position: relative;
  width: 100%;
  max-width: 760px;
  height: 66vh;
  height: min(66dvh, 620px);
  min-height: 400px;
  margin: 0 auto;
  background: radial-gradient(110% 80% at 50% 58%, #26324b 0%, #1a2338 45%, #111827 100%);
}

model-viewer {
  display: block;
  width: 100%;
  height: 100%;
  background: transparent;
  --poster-color: transparent;
  --progress-bar-color: var(--acento);
  --progress-bar-height: 3px;
}

.medida {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px 7px 10px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.5s var(--curva), transform 0.5s var(--curva);
  pointer-events: none;
}
.medida.visible { opacity: 1; transform: none; }
.medida strong { font-weight: 700; }
.medida svg { width: 16px; height: 16px; color: var(--acento-claro); }

/* Botón AR (va dentro de model-viewer, slot="ar-button") */
.boton-ar {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 28px;
  border: 0;
  border-radius: 999px;
  background: var(--acento);
  color: #fff;
  font: 600 17px/1 "Inter", system-ui, sans-serif;
  letter-spacing: -0.01em;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(182, 37, 32, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, transform 0.15s var(--curva);
}
.boton-ar:hover { background: var(--acento-claro); }
.boton-ar:active { transform: translateX(-50%) scale(0.96); }
.boton-ar svg { width: 22px; height: 22px; }
.boton-ar::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(182, 37, 32, 0.6);
  pointer-events: none;
}

/* Guías dentro de la cámara (AR web en Android).
   model-viewer pone ar-status = session-started | object-placed | not-presenting
   y ar-tracking = tracking | not-tracking en el propio <model-viewer>. */
.guia-ar {
  display: none;
  position: absolute;
  left: 50%;
  z-index: 1;
  pointer-events: none; /* que los toques lleguen al AR para arrastrar el plato */
  background: rgba(17, 24, 39, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: #fff;
  text-align: center;
  font: 500 15px/1.4 "Inter", system-ui, sans-serif;
}
.guia-ar--buscar {
  top: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border-radius: 20px;
}
.guia-ar--buscar svg { width: 54px; height: 54px; }
.guia-ar--mover {
  bottom: 28px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 999px;
}

/* Buscando la mesa, o si se pierde el seguimiento */
model-viewer[ar-status="session-started"] .guia-ar--buscar,
model-viewer[ar-status="object-placed"][ar-tracking="not-tracking"] .guia-ar--buscar {
  display: flex;
}
/* Ya puesto: recordar que se puede arrastrar (se apaga solo) */
model-viewer[ar-status="object-placed"]:not([ar-tracking="not-tracking"]) .guia-ar--mover {
  display: block;
  animation: guia-temporal 10s ease forwards;
}
@keyframes guia-temporal {
  0% { opacity: 0; }
  5%, 85% { opacity: 1; }
  100% { opacity: 0; }
}

.aviso {
  position: absolute;
  left: 50%;
  bottom: 22px;
  z-index: 2;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border: 1px solid var(--linea-fuerte);
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.82);
  color: var(--texto);
  font-size: 14px;
  text-align: center;
}

.ficha { padding-top: 22px; padding-bottom: 36px; }
.ficha__fila {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}
.ficha__nombre { font-size: 26px; line-height: 1.15; font-weight: 700; letter-spacing: -0.02em; }
.ficha__precio { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ficha__desc { margin-top: 10px; color: var(--suave); }
.ficha__guia {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid var(--linea);
  border-radius: 12px;
  color: var(--suave);
  font-size: 14px;
}
.ficha__guia svg { flex: none; width: 20px; height: 20px; margin-top: 1px; color: var(--acento-claro); }

.vacio { padding: 60px 0; text-align: center; color: var(--suave); }
.vacio a { display: inline-block; margin-top: 14px; color: var(--texto); font-weight: 600; }

@media (min-width: 760px) {
  .visor { margin-top: 20px; border-radius: 24px; overflow: hidden; }
}

/* ---------- Movimiento ---------- */

@media (prefers-reduced-motion: no-preference) {
  .aparece {
    animation: subir 0.7s var(--curva) both;
    animation-delay: calc(var(--i, 0) * 90ms);
  }
  @keyframes subir {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
  }

  .boton-ar::after { animation: latido 2.4s ease-out 1.2s infinite; }
  @keyframes latido {
    0% { box-shadow: 0 0 0 0 rgba(182, 37, 32, 0.55); }
    70%, 100% { box-shadow: 0 0 0 16px rgba(182, 37, 32, 0); }
  }

  .guia-ar svg { animation: barrido 2.2s ease-in-out infinite; }
  @keyframes barrido {
    0%, 100% { transform: translateX(-14px) rotate(-6deg); }
    50% { transform: translateX(14px) rotate(6deg); }
  }
}
