/* ==========================================================================
   Carta digital — se abre desde el QR de la mesa
   Mobile first. Los colores y la tipografía los elige el dueño en el panel:
   carta.js los aplica como variables CSS. Estos son los valores iniciales.
   ========================================================================== */

:root {
  --fondo: #FAF8F5;
  --texto: #4A3B32;
  --texto-suave: #6B5A4E;
  --linea: #E2DCD4;
  --superficie: #F3EFEA;
  --acento: #C27C5A;
  --acento-texto: #A35E3E;
  --fuente-titulos: 'Fraunces', Georgia, serif;
  --fuente-texto: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --peso-titulos: 400;

  --ancho: 40rem;
  --margen: 1.25rem;
  --radio: 6px;
  --alto-nav: 3.5rem;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente-texto);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }

h1, h2, h3 {
  margin: 0;
  font-family: var(--fuente-titulos);
  font-weight: var(--peso-titulos);
  line-height: 1.15;
}

p { margin: 0; }
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--acento-texto); outline-offset: 2px; }

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

.skip-link {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 50;
  padding: .6rem 1rem;
  border-radius: var(--radio);
  background: var(--texto);
  color: var(--fondo);
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

.contenedor {
  width: 100%;
  max-width: var(--ancho);
  margin-inline: auto;
  padding-inline: var(--margen);
}

/* Íconos de línea */
.icono {
  flex: 0 0 auto;
  width: 1.05rem; height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Estados (cargando, error, vacío) ──────────────────────────────────── */
.estado {
  display: grid;
  place-items: center;
  gap: 1rem;
  min-height: 60vh;
  padding: 2rem var(--margen);
  text-align: center;
  color: var(--texto-suave);
}

.boton {
  min-height: 2.75rem;
  padding: .6rem 1.4rem;
  border: 1px solid var(--linea);
  border-radius: 999px;
  background: none;
  cursor: pointer;
}
.boton:hover { border-color: var(--acento); }

/* ─── Cabecera ──────────────────────────────────────────────────────────── */
.portada {
  width: 100%;
  max-width: var(--ancho);
  height: auto;
  max-height: 15rem;
  margin-inline: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--superficie);
}

.cabecera-texto {
  padding-top: 1.75rem;
  padding-bottom: 1.25rem;
  text-align: center;
}

.logo {
  position: relative;
  width: 4.5rem; height: 4.5rem;
  margin: 0 auto 1rem;
  border: 3px solid var(--fondo);
  border-radius: 50%;
  object-fit: cover;
  background: var(--fondo);
}
/* Con portada, el logo se apoya sobre el borde inferior de la foto */
.con-portada .logo { margin-top: calc(-2.25rem - 1.75rem); }

.nombre {
  font-size: clamp(2rem, 9vw, 2.6rem);
  letter-spacing: -0.01em;
}

.bienvenida {
  max-width: 28rem;
  margin: .5rem auto 0;
  color: var(--texto-suave);
}

.wifi {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  max-width: 100%;
  margin-top: 1.1rem;
  padding: .4rem .9rem;
  border: 1px solid var(--linea);
  border-radius: 999px;
  font-size: .88rem;
  color: var(--texto-suave);
  text-align: left;
}
.wifi strong { font-weight: 600; color: var(--texto); }

/* ─── Navegación de categorías (fija al scrollear) ──────────────────────── */
.nav-categorias {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--fondo);
  border-block: 1px solid var(--linea);
}

.nav-categorias ul {
  position: relative; /* referencia para centrar la categoría activa */
  display: flex;
  gap: .4rem;
  max-width: var(--ancho);
  margin: 0 auto;
  padding: .6rem var(--margen);
  overflow-x: auto;
  list-style: none;
  scrollbar-width: none;
}
.nav-categorias ul::-webkit-scrollbar { display: none; }

.nav-categorias a {
  display: block;
  padding: .45rem 1rem;
  border: 1px solid var(--linea);
  border-radius: 999px;
  font-size: .92rem;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .2s, border-color .2s, color .2s;
}
.nav-categorias a:hover { border-color: var(--acento); }
.nav-categorias a[aria-current='true'] {
  border-color: var(--acento-texto);
  background: var(--acento-texto);
  color: var(--fondo);
}

/* ─── Categorías y platos ───────────────────────────────────────────────── */
.platos { padding-bottom: 1rem; }
.platos:focus { outline: none; }

.seccion {
  padding-top: 2.25rem;
  scroll-margin-top: var(--alto-nav);
}

.seccion h2 { font-size: 1.65rem; }

.seccion-descripcion {
  margin-top: .3rem;
  font-size: .9rem;
  color: var(--texto-suave);
}

.lista-platos {
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
}

.plato {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .9rem;
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--linea);
}
.plato:last-child { border-bottom: 0; }
.plato.con-foto { grid-template-columns: 4.75rem minmax(0, 1fr); }

.plato-foto {
  width: 4.75rem; height: 4.75rem;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--radio);
  background: var(--superficie);
  cursor: zoom-in;
}
.plato-foto img { width: 100%; height: 100%; object-fit: cover; }

.plato-cabecera {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.plato h3 { font-size: 1.15rem; }

.plato-precio {
  flex: 0 0 auto;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--acento-texto);
}

.plato-descripcion {
  margin-top: .3rem;
  font-size: .93rem;
  color: var(--texto-suave);
}

.etiquetas {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin: .6rem 0 0;
  padding: 0;
  list-style: none;
}
.etiqueta {
  padding: .12rem .55rem;
  border: 1px solid var(--linea);
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--texto-suave);
}
.etiqueta-agotado { border-color: currentColor; color: var(--texto); }

/* Plato agotado (si el dueño eligió mostrarlos) */
.plato.agotado h3,
.plato.agotado .plato-precio { color: var(--texto-suave); }
.plato.agotado .plato-precio { text-decoration: line-through; }
.plato.agotado .plato-foto img { filter: grayscale(1); opacity: .7; }

.vacio {
  padding: 3rem 0;
  text-align: center;
  color: var(--texto-suave);
}

/* ─── Pie ───────────────────────────────────────────────────────────────── */
.pie {
  margin-top: 1.5rem;
  padding-block: 2rem calc(2.5rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--linea);
  font-size: .9rem;
  text-align: center;
  color: var(--texto-suave);
}

.pie-nota { max-width: 30rem; margin: 0 auto 1.5rem; }

.pie-datos {
  display: grid;
  justify-items: center;
  gap: .6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.pie-datos li { display: flex; align-items: flex-start; gap: .5rem; text-align: left; }
.pie-datos .icono { margin-top: .2rem; }

.pie-sitio { display: inline-block; margin-top: 1.75rem; color: var(--texto); }

/* ─── Visor de fotos ────────────────────────────────────────────────────── */
.visor {
  position: relative;
  width: min(30rem, calc(100% - 2rem));
  max-height: calc(100% - 2rem);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: var(--radio);
  background: var(--fondo);
  color: var(--texto);
}
.visor[open] { animation: aparecer .25s var(--ease); }
.visor::backdrop { background: rgba(0, 0, 0, .6); }

.visor-media img {
  width: 100%;
  max-height: 60vh;
  aspect-ratio: 1;
  object-fit: cover;
}

.visor-texto { padding: 1.1rem 1.25rem 1.4rem; }
.visor-texto h2 { font-size: 1.4rem; }
.visor-texto p { margin-top: .35rem; color: var(--texto-suave); }
.visor-texto .visor-precio { color: var(--acento-texto); font-weight: 600; }

.visor-cerrar {
  position: absolute;
  top: .6rem; right: .6rem;
  display: grid;
  place-items: center;
  width: 2.5rem; height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #FFFFFF;
  cursor: pointer;
}
.visor-cerrar svg {
  width: 1.1rem; height: 1.1rem;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
}

@keyframes aparecer {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

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

/* ─── Pantallas más anchas ──────────────────────────────────────────────── */
@media (min-width: 42em) {
  .portada { margin-top: 1.5rem; border-radius: var(--radio); }
  .seccion h2 { font-size: 1.85rem; }
}
