/* =============================================================
   Vista 3D y realidad aumentada de la carta (plan Pro).
   - Chip "3D" en la tarjeta, botones del detalle del plato.
   - Visor a pantalla completa: modelo 3D (<model-viewer>, cargado
     solo al abrirlo) y vista inmersiva de las fotos (sin IA).
   ============================================================= */

/* ---------- Chip "3D" sobre la foto de la tarjeta */
.cd-card-3d {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  display: inline-flex; align-items: center; gap: 3px;
  padding: 3px 7px 3px 6px; border-radius: 999px;
  background: rgba(17, 17, 20, .78); color: #fff;
  font-size: .68rem; font-weight: 800; letter-spacing: .04em; line-height: 1.1;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  pointer-events: none;
}
.cd-card-3d svg { flex: none; }

/* ---------- Botones en el detalle del plato */
.v3d-acciones { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; margin: 4px 0 2px; }
.v3d-btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 8px 16px 8px 10px; border-radius: 14px;
  text-align: left; line-height: 1.2; -webkit-tap-highlight-color: transparent;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.v3d-btn:active { transform: scale(.98); }
.v3d-btn:focus-visible { outline: 3px solid var(--cd-color, #B03A2E); outline-offset: 2px; }
.v3d-btn-icono {
  flex: none; width: 32px; height: 32px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
}
.v3d-btn strong { display: block; font-size: .98rem; font-weight: 750; }
.v3d-btn small { display: block; font-size: .76rem; opacity: .78; margin-top: 1px; }
.v3d-btn-3d {
  flex: 1 1 220px;
  background: linear-gradient(135deg, #1b1b1f 0%, #2c2b31 100%); color: #fff;
  box-shadow: 0 6px 18px rgba(20, 20, 24, .22), inset 0 1px 0 rgba(255, 255, 255, .08);
}
.v3d-btn-3d .v3d-btn-icono { background: var(--cd-color, #B03A2E); color: var(--cd-sobre, #fff); }
.v3d-btn-inmersiva {
  flex: 1 1 160px;
  background: #f3f0eb; color: #1d1d1f; box-shadow: inset 0 0 0 1px #e4dfd7;
}
.v3d-btn-inmersiva .v3d-btn-icono { background: #fff; color: #1d1d1f; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.v3d-acciones.v3d-solo .v3d-btn-inmersiva { flex-basis: 100%; }

/* ---------- Visor a pantalla completa */
html.v3d-abierto, html.v3d-abierto body { overflow: hidden; }
.v3d {
  position: fixed; inset: 0; z-index: 300;
  display: flex; flex-direction: column;
  color: #f4f2ee;
  background:
    radial-gradient(120% 80% at 50% 0%, color-mix(in srgb, var(--cd-color, #B03A2E) 22%, #18171b) 0%, #0d0d10 62%);
  background-color: #0d0d10;
  animation: v3d-entrar .22s ease;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: contain;
}
@keyframes v3d-entrar { from { opacity: 0; } to { opacity: 1; } }
.v3d-barra {
  position: relative; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 12px 10px 18px;
}
.v3d-titulo { flex: 1; min-width: 0; }
.v3d-titulo strong { display: block; font-size: 1.05rem; font-weight: 750; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v3d-titulo small { display: block; font-size: .78rem; color: rgba(244, 242, 238, .62); margin-top: 1px; }
.v3d-icono-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .12); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: background-color .12s ease;
}
.v3d-icono-btn:hover { background: rgba(255, 255, 255, .2); }
.v3d-icono-btn:focus-visible, .v3d-chip:focus-visible, .v3d-ar:focus-visible, .v3d-flecha:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.v3d-escena { position: relative; flex: 1; min-height: 0; }
.v3d-pie {
  position: relative; z-index: 5;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
}
.v3d-pista-texto { font-size: .8rem; color: rgba(244, 242, 238, .66); text-align: center; max-width: 34em; }
.v3d-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.v3d-chip {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  background: rgba(255, 255, 255, .12); color: #fff; font-size: .86rem; font-weight: 600;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.v3d-chip:hover { background: rgba(255, 255, 255, .2); }
.v3d-chip[aria-pressed="true"] { background: #fff; color: #141416; }

/* ---------- Modelo 3D (<model-viewer>) */
.v3d-modelo { position: absolute; inset: 0; }
.v3d model-viewer {
  width: 100%; height: 100%; display: block;
  --poster-color: transparent;
  --progress-bar-color: transparent;
  background: transparent;
}
.v3d-carga {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  width: min(260px, 70vw); text-align: center; pointer-events: none;
  font-size: .82rem; color: rgba(244, 242, 238, .8);
  transition: opacity .3s ease;
}
.v3d-carga-barra { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .16); overflow: hidden; margin-top: 8px; }
.v3d-carga-barra i { display: block; height: 100%; width: 0; border-radius: 4px; background: #fff; transition: width .2s ease; }
.v3d-carga.listo { opacity: 0; }
.v3d-ar {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 12px 24px; border-radius: 999px;
  background: var(--cd-color, #B03A2E); color: var(--cd-sobre, #fff);
  font-size: 1rem; font-weight: 750; letter-spacing: .01em;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.v3d model-viewer:not(.v3d-listo) .v3d-ar { visibility: hidden; }
.v3d model-viewer .v3d-ar { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); white-space: nowrap; }
.v3d model-viewer .v3d-ar:active { transform: translateX(-50%) scale(.98); }
.v3d-ar[hidden] { display: none !important; }
.v3d-error {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; color: rgba(244, 242, 238, .85);
}
.v3d-error strong { font-size: 1.05rem; color: #fff; }
.v3d-giro {
  position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
  border-radius: 50%; border: 3px solid rgba(255, 255, 255, .18); border-top-color: #fff;
  animation: v3d-girar .9s linear infinite;
}
@keyframes v3d-girar { to { transform: rotate(360deg); } }

/* ---------- Vista inmersiva de las fotos (efecto de profundidad, sin IA) */
/* Ocupa toda la pantalla (detrás de la barra y el pie, que quedan encima con un degradado). */
.v3d-inmersiva { position: fixed; inset: 0; overflow: hidden; touch-action: none; z-index: 1; }
.v3d-inmersiva::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(85% 70% at 50% 48%, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, .55) 100%);
}
.v3d-con-inmersiva .v3d-barra { background: linear-gradient(rgba(10, 10, 12, .55), rgba(10, 10, 12, 0)); }
.v3d-con-inmersiva .v3d-pie { background: linear-gradient(rgba(10, 10, 12, 0), rgba(10, 10, 12, .6)); }
.v3d-fondo {
  position: absolute; inset: -12%;
  background-size: cover; background-position: center;
  filter: blur(42px) saturate(1.3) brightness(.42);
  transform: scale(1.1); opacity: .9;
  transition: background-image .3s ease;
  will-change: transform;
}
.v3d-pista { position: absolute; inset: 0; z-index: 1; display: flex; transition: transform .38s cubic-bezier(.2, .8, .2, 1); will-change: transform; }
.v3d-diapo {
  flex: 0 0 100%; height: 100%; margin: 0;
  display: flex; align-items: center; justify-content: center;
  perspective: 1100px; perspective-origin: 50% 45%;
}
.v3d-tarjeta {
  position: relative; border-radius: 22px; overflow: hidden;
  width: var(--v3d-w, 82vw); height: var(--v3d-h, 60vh);
  transform-style: preserve-3d; will-change: transform;
  box-shadow: 0 2px 0 rgba(255, 255, 255, .06) inset, 0 30px 60px -18px rgba(0, 0, 0, .75), 0 12px 24px -12px rgba(0, 0, 0, .6);
  background: #222;
}
.v3d-tarjeta img {
  position: absolute; inset: -6%; width: 112%; height: 112%; max-width: none;
  object-fit: cover; display: block; will-change: transform;
  -webkit-user-drag: none; pointer-events: none;
}
.v3d-brillo {
  position: absolute; inset: 0; pointer-events: none; mix-blend-mode: soft-light;
  background: radial-gradient(70% 55% at var(--v3d-bx, 30%) var(--v3d-by, 20%), rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 60%);
}
.v3d-borde {
  position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .14);
}
.v3d-sombra {
  position: absolute; left: 50%; top: 50%; width: var(--v3d-w, 82vw); height: 26px;
  margin-left: calc(var(--v3d-w, 82vw) / -2);
  border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, .55), rgba(0, 0, 0, 0));
  filter: blur(6px); pointer-events: none; will-change: transform;
}
.v3d-flecha {
  position: absolute; top: 50%; z-index: 4; margin-top: -24px;
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.v3d-flecha:hover { background: rgba(255, 255, 255, .24); }
.v3d-flecha[disabled] { opacity: 0; pointer-events: none; }
.v3d-flecha-izq { left: 14px; }
.v3d-flecha-der { right: 14px; }
@media (hover: none) { .v3d-flecha { display: none; } }
.v3d-puntos { display: flex; gap: 7px; justify-content: center; min-height: 8px; }
.v3d-puntos span { width: 7px; height: 7px; border-radius: 50%; background: rgba(255, 255, 255, .32); transition: width .2s ease, background-color .2s ease; }
.v3d-puntos span.activo { width: 20px; border-radius: 4px; background: #fff; }

/* Movimiento reducido: sin inclinación ni animaciones (vista estática, mismas fotos). */
@media (prefers-reduced-motion: reduce) {
  .v3d, .v3d-pista, .v3d-carga-barra i, .v3d-puntos span { animation: none !important; transition: none !important; }
  .v3d-giro { animation-duration: 2.4s; }
}
