/* Carta pública (/r/): estructura y diseño base, mobile first.
   Las plantillas (css/plantillas/*.css) cambian el aspecto pisando estas variables y reglas;
   una plantilla sin CSS propio se ve con este diseño. */

:root {
  --color-primary-dark: #9c1b12;
  --color-divider: color-mix(in srgb, var(--color-border) 45%, transparent);
  --color-on-primary: #ffffff;
  --color-on-ok: #ffffff;
  --color-estrella: #8a5d00;
  /* js/tema.js calcula --color-primary-text (el principal como letra, AA sobre el fondo) */
  --color-focus: var(--color-primary-text, var(--color-primary));
  --font-hand: var(--font-body);
  --pestanas-alto: 60px;  /* lo actualiza js/carta.js con el alto real */
  --ancho: 40rem;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }  /* lugar para el resumen */

[hidden] { display: none !important; }

.saltar {
  position: absolute; left: 16px; top: -100px; z-index: 100;
  background: var(--color-text); color: var(--color-bg); padding: 12px 16px; font-weight: 700;
}
.saltar:focus { top: 16px; }

/* ---------- Encabezado del local ---------- */
.local {
  max-width: var(--ancho); margin: 0 auto; padding: 32px 16px 20px; text-align: center;
}
.local-logo {
  width: 72px; height: 72px; object-fit: cover; border-radius: 50%; margin: 0 auto 12px;
}
.local-nombre { font-size: clamp(1.75rem, 8vw, 2.5rem); margin-bottom: .25em; overflow-wrap: anywhere; }
.local-mesa { font-size: 1.125rem; margin-bottom: .75rem; }
.estado {
  display: inline-flex; align-items: center; gap: .5em; margin: 0;
  padding: .35em .9em; border: 2px solid currentColor; border-radius: 999px; font-weight: 700;
}
.estado::before { content: ""; width: .6em; height: .6em; border-radius: 50%; background: currentColor; }
.estado[data-estado="abierto"] { color: var(--color-ok); }
.estado[data-estado="cerrado"] { color: var(--color-error); }

.aviso {
  max-width: calc(var(--ancho) - 32px); margin: 0 auto 16px; padding: 12px 16px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-left: 6px solid var(--color-warn); border-radius: var(--radius); font-weight: 600;
}
@media (max-width: 40rem) { .aviso { margin-inline: 16px; } }

/* ---------- Pestañas de categorías (fijas arriba) ---------- */
.pestanas {
  position: sticky; top: 0; z-index: 20;
  background: var(--color-bg); border-bottom: 1px solid var(--color-divider);
}
.pestanas ul {
  display: flex; gap: 8px; max-width: var(--ancho); margin: 0 auto; padding: 8px 16px;
  list-style: none; overflow-x: auto; scrollbar-width: none;
}
.pestanas ul::-webkit-scrollbar { display: none; }
.pestanas a {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface);
  color: var(--color-text); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.pestanas a[aria-current="true"] {
  background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary);
}

/* ---------- Carta ---------- */
.carta { max-width: var(--ancho); margin: 0 auto; padding: 8px 16px 32px; }
.cargando, .error-carta { text-align: center; padding: 48px 0 16px; font-size: 1.125rem; }
.error-carta + .boton { display: flex; margin: 0 auto; }

.categoria { padding-top: 16px; scroll-margin-top: calc(var(--pestanas-alto) + 8px); }
.categoria h2 { font-size: 1.5rem; margin: 8px 0 4px; }

.items { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 1fr; gap: 8px 12px; padding: 16px 0;
  border-bottom: 1px solid var(--color-divider);
}
.item.con-foto { grid-template-columns: 88px 1fr; }
.item-foto {
  width: 88px; height: 88px; object-fit: cover; border-radius: var(--radius);
  background: var(--color-border); grid-row: span 2;
}
.item-nombre { font-size: 1.125rem; margin: 0; }
.item-desc { color: var(--color-muted); font-size: .95rem; margin: .25rem 0 0; }
.etiqueta-sin-stock {
  display: inline-block; margin: .5rem 0 0; padding: .15em .6em;
  border: 2px solid currentColor; border-radius: 999px; font-size: .875rem; font-weight: 700;
}
.item.sin-stock .item-nombre,
.item.sin-stock .precio { color: var(--color-muted); }
.item.sin-stock .item-foto { filter: grayscale(1); opacity: .6; }

.opciones { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.item.con-foto .opciones { grid-column: 2; }
.opcion { display: flex; align-items: center; gap: 12px; min-height: var(--tap); }
.opcion-nombre { font-weight: 600; }
.precio { margin-left: auto; font-weight: 800; white-space: nowrap; }
.precio.a-confirmar { font-weight: 600; font-style: italic; color: var(--color-muted); }

.stepper { display: inline-flex; align-items: center; gap: 4px; }
.stepper button {
  width: var(--tap); height: var(--tap); padding: 0; border-radius: 50%;
  font-size: 1.5rem; font-weight: 800; line-height: 1;
}
.stepper .mas { border: 0; background: var(--color-primary); color: var(--color-on-primary); }
.stepper .menos { border: 2px solid var(--color-border); background: var(--color-surface); color: var(--color-text); }
.stepper button:disabled { opacity: .5; cursor: not-allowed; }
.stepper .cantidad { min-width: 2ch; text-align: center; font-weight: 800; font-size: 1.125rem; }

/* ---------- Lo que dicen de nosotros ---------- */
.opiniones { max-width: var(--ancho); margin: 0 auto; padding: 8px 16px 32px; }
.opiniones h2 { font-size: 1.5rem; margin: 8px 0 4px; }
.opiniones-resumen { font-weight: 800; margin-bottom: 12px; }
.lista-opiniones { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.opinion {
  background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: var(--radius); padding: 14px;
}
.opinion p { margin: 0 0 6px; }
.opinion-estrellas { color: var(--color-estrella); font-size: 1.25rem; letter-spacing: 2px; }
.opinion-foto { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--radius); margin-bottom: 8px; }
.opinion-autor { color: var(--color-muted); font-size: .9rem; margin: 0; }

/* ---------- Pie ---------- */
.pie {
  max-width: var(--ancho); margin: 0 auto; padding: 24px 16px 32px;
  border-top: 1px solid var(--color-divider);
}
.pie p { margin-bottom: .5em; }
.pie a { color: inherit; font-weight: 700; }
.pie summary {
  display: inline-flex; align-items: center; min-height: var(--tap); cursor: pointer; font-weight: 700;
}
.pie table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.pie th, .pie td { padding: 8px 0; text-align: left; font-weight: 400; border-bottom: 1px dashed var(--color-divider); }
.pie td { text-align: right; }
.pie tr.hoy th, .pie tr.hoy td { font-weight: 800; }

/* ---------- Avisos del pedido ---------- */
.aviso-enlace { display: block; color: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Resumen del pedido (botón fijo abajo) ---------- */
.resumen {
  position: fixed; z-index: 30; left: 16px; right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: auto; max-width: calc(var(--ancho) - 32px); min-height: 56px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; border: 0; border-radius: var(--radius); text-align: left;
  background: var(--color-text); color: var(--color-bg); font-weight: 700;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
}
.resumen-accion { margin-left: auto; text-decoration: underline; text-underline-offset: 3px; }
.resumen-total { font-size: 1.25rem; font-weight: 800; }

/* ---------- Hoja de confirmación ---------- */
.hoja {
  width: 100%; max-width: var(--ancho); max-height: 100%; height: 100%; margin: 0 auto;
  padding: 0 16px 24px; border: 0; background: var(--color-bg); color: var(--color-text);
}
@media (min-width: 42rem) { .hoja { height: auto; max-height: calc(100% - 48px); margin-top: 24px; border-radius: var(--radius); } }
.hoja::backdrop { background: rgba(0, 0, 0, .55); }
.hoja-cabecera {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 0; background: var(--color-bg); border-bottom: 1px solid var(--color-divider);
}
.hoja-cabecera h2 { margin: 0; font-size: 1.5rem; }
.cerrar {
  width: var(--tap); height: var(--tap); padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--color-text); font-size: 2rem; line-height: 1;
}
.renglones { list-style: none; margin: 0; padding: 0; }
.renglon {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--color-divider);
}
.renglon-cabeza { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-weight: 700; }
.renglon-precio { white-space: nowrap; }
.renglon-nota { grid-column: 1 / -1; }
.renglon-nota label { font-size: .875rem; font-weight: 600; }
.total-pedido {
  display: flex; justify-content: space-between; margin: 16px 0; font-size: 1.25rem; font-weight: 800;
}

.form-pedido fieldset { border: 0; margin: 0 0 12px; padding: 0; }
.form-pedido legend { font-weight: 700; margin-bottom: 8px; }
.opciones-modo { display: grid; gap: 8px; }
.opcion-modo {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-surface); font-weight: 600;
}
.opcion-modo input { width: 22px; height: 22px; accent-color: var(--color-primary); }
.pedido-mesa { font-weight: 700; }
.nota-chica { font-size: .875rem; color: var(--color-muted); text-align: center; margin-top: 12px; }
