/* =========================================================================
   Motor Carta · Base
   Colores y tipografías de respaldo: tema.js los reemplaza con identidad.json
   ========================================================================= */

:root {
  --c-fondo: #f6f0e8;        --c-fondo-rgb: 246 240 232;
  --c-superficie: #fffcf8;   --c-superficie-rgb: 255 252 248;
  --c-arena: #ede3d6;        --c-arena-rgb: 237 227 214;
  --c-texto: #2b211b;        --c-texto-rgb: 43 33 27;
  --c-texto-2: #74675d;      --c-texto-2-rgb: 116 103 93;
  --c-marca: #6b4a35;        --c-marca-rgb: 107 74 53;
  --c-acento: #b97946;       --c-acento-rgb: 185 121 70;
  --c-acento-texto: #93582e; --c-acento-texto-rgb: 147 88 46;

  --f-titulos: Georgia, serif;
  --f-ui: system-ui, sans-serif;

  --linea: rgb(var(--c-texto-rgb) / 0.08);
  --sombra-suave: 0 1px 2px rgb(var(--c-texto-rgb) / 0.04), 0 8px 24px -14px rgb(var(--c-texto-rgb) / 0.22);
  --radio: 20px;
  --radio-chico: 14px;
  --gutter: 20px;
  --ancho: 1080px;

  --cab-fila: 68px;
  --cab-fila-compacta: 52px;
  --cab-chips: 56px;
  --barra-alto: 76px;
  --seguro-arriba: env(safe-area-inset-top, 0px);
  --seguro-abajo: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t: 220ms;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--c-fondo);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--c-fondo);
  color: var(--c-texto);
  font-family: var(--f-ui);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
}
html.con-ficha body { overflow: hidden; }

img, video, picture, svg { display: block; max-width: 100%; }
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--c-marca);
  outline-offset: 3px;
  border-radius: 10px;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.ico {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Estructura ---------- */
.contenido {
  width: 100%;
  max-width: var(--ancho);
  margin: 0 auto;
  padding: calc(var(--cab-fila) + var(--cab-chips) + var(--seguro-arriba) + 4px) 0
           calc(var(--barra-alto) + var(--seguro-abajo) + 36px);
}
html[data-vista="buscar"] .contenido,
html[data-vista="favoritos"] .contenido {
  padding-top: calc(var(--cab-fila) + var(--seguro-arriba) + 4px);
}

.vista.is-entrando { animation: entrar 260ms var(--ease) both; }
@keyframes entrar {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Piezas comunes ---------- */
.etiqueta {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-acento-texto);
}

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  background: var(--c-marca);
  color: var(--c-superficie);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--t) var(--ease), transform var(--t) var(--ease);
}
.boton .ico { width: 18px; height: 18px; transition: transform var(--t) var(--ease); }
.boton:active { transform: scale(0.97); }
@media (hover: hover) {
  .boton:hover { background: rgb(var(--c-marca-rgb) / 0.9); }
  .boton:hover .ico { transform: translateX(2px); }
}
.boton--suave { background: var(--c-arena); color: var(--c-texto); }

.enlace {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--c-texto-2);
}
.enlace .ico { width: 16px; height: 16px; }

/* Contenedor de foto: recorte prolijo, fondo mientras carga */
.media {
  position: relative;
  overflow: hidden;
  background: var(--c-arena);
  isolation: isolate;
}
.media picture,
.media img,
.media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media picture { position: absolute; inset: 0; }
.media img { opacity: 0; transition: opacity 400ms var(--ease); }
.media img.is-cargada { opacity: 1; }

.media--video .media__video {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 400ms var(--ease);
}
.media--video.is-reproduciendo .media__video { opacity: 1; }
.media__pausa {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgb(var(--c-superficie-rgb) / 0.86);
  color: var(--c-texto);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.media__pausa .ico { width: 16px; height: 16px; fill: currentColor; stroke-width: 2; }

/* Favorito */
.fav {
  position: relative;
  display: grid;
  place-items: center;
  color: var(--c-texto);
  transition: color var(--t) var(--ease), background-color var(--t) var(--ease);
}
.fav[aria-pressed="true"] { color: var(--c-acento-texto); }
.fav[aria-pressed="true"] .fav__ico { fill: currentColor; }
.fav.is-latido .fav__ico { animation: latido 360ms var(--ease); }
@keyframes latido { 40% { transform: scale(1.22); } }

.fav--icono {
  width: 44px;
  height: 44px;
}
.fav--icono::before {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgb(var(--c-superficie-rgb) / 0.92);
  box-shadow: 0 2px 8px -4px rgb(var(--c-texto-rgb) / 0.4);
}
.fav--icono .fav__ico { position: relative; width: 18px; height: 18px; }

.fav--linea { width: 44px; height: 44px; color: var(--c-texto-2); }
.fav--linea .fav__ico { width: 20px; height: 20px; }

.fav--texto {
  display: inline-flex;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--linea);
  border-radius: 999px;
  background: var(--c-superficie);
  font-size: 0.9rem;
  font-weight: 600;
}
.fav--texto .fav__ico { width: 18px; height: 18px; }

.aviso-error {
  padding: 40vh var(--gutter) 0;
  text-align: center;
  color: var(--c-texto-2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Producto agotado ----------
   Sigue en la carta: en lugar del precio dice "Agotado" (mismo lugar y tamaño,
   tono secundario) y la foto baja apenas su intensidad. Nada más cambia. */
.es-agotado {
  color: var(--c-texto-2);
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: normal;
}
.is-agotado .media img,
.is-agotado .mdd__foto img {
  opacity: 0.78;
  filter: saturate(0.9);
}
