/* Elsa Bakery & Lunch · base común del inicio y la carta (versión 11).
   Especificación: estrategia/diseno-y-motion.md §4. Sistema: papel y tinta; el rojo solo para actuar.
   Young Serif para títulos, Figtree para texto. Cinco tamaños. Una sola forma de botón (radio 12 px).
   Sin degradados, sin sombras en reposo, sin filetes: las superficies se separan por tono. */

/* Letras propias (latín: tildes, ñ, ¿ y ¡). Sin servidores externos. Figtree es variable: un archivo cubre 400 y 600. */
@font-face {
  font-family: "Young Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fuentes/young-serif.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url("fuentes/figtree-variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Figtree";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fuentes/figtree-cursiva.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Respaldos con las medidas de cada letra: al llegar la fuente real (swap) el texto no salta de línea ni mueve nada (CLS 0). */
@font-face {
  font-family: "Young Serif Respaldo";
  src: local("Georgia");
  size-adjust: 112.7%;
  ascent-override: 93.2%;
  descent-override: 32.8%;
  line-gap-override: 0%;
}
@font-face {
  font-family: "Figtree Respaldo";
  src: local("Arial"), local("Helvetica");
  size-adjust: 98.25%;
  ascent-override: 96.7%;
  descent-override: 25.4%;
  line-gap-override: 0%;
}

:root {
  --rojo: #B3171F;
  --rojo-hondo: #7E0F14;
  --rosa: #F6D5D2;
  --papel: #FBF3E6;
  --papel-2: #F1E2CC;
  --tinta: #2B1313;
  --tinta-2: #6B4F4B;
  --error: #9B1B1B;

  --fuente-titulo: "Young Serif", "Young Serif Respaldo", Georgia, "Times New Roman", serif;
  --fuente: "Figtree", "Figtree Respaldo", system-ui, -apple-system, sans-serif;

  /* 390 px → 1440 px */
  --t-nota: 0.9375rem;                                      /* 15 */
  --t-texto: clamp(1.0625rem, 1.039rem + 0.095vw, 1.125rem); /* 17 → 18 */
  --t-entrada: clamp(1.3125rem, 1.196rem + 0.476vw, 1.625rem); /* 21 → 26 */
  --t-titulo: clamp(2rem, 1.521rem + 2.476vw, 3.75rem);      /* 34 → 60 */
  --t-tapa: clamp(3rem, 2.071rem + 3.81vw, 5.5rem);          /* 48 → 88 */

  --margen: clamp(1rem, 4.1vw, 3rem);
  --seccion: clamp(4.5rem, 2.457rem + 8.38vw, 10rem);
  --radio: 12px;
  --barra: calc(72px + env(safe-area-inset-bottom));

  --ease-salida: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-suave: cubic-bezier(0.33, 1, 0.68, 1);
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--papel);
  color: var(--tinta);
  font-family: var(--fuente);
  font-size: var(--t-texto);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img, svg, picture { display: block; max-width: 100%; }
h1, h2, h3, p, ul, ol, figure, blockquote, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }

h1, h2, h3,
.titulo {
  font-family: var(--fuente-titulo);
  font-weight: 400;
  font-synthesis: none;
  text-wrap: balance;
}

.titulo {
  font-size: var(--t-titulo);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.entrada {
  font-family: var(--fuente-titulo);
  font-weight: 400;
  font-synthesis: none;
  font-size: var(--t-entrada);
  line-height: 1.2;
}

.secundario { color: var(--tinta-2); font-size: var(--t-nota); line-height: 1.4; }
.precio { font-weight: 600; color: var(--rojo-hondo); font-variant-numeric: tabular-nums; white-space: nowrap; }

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

.saltar {
  position: absolute;
  left: -9999px;
  top: max(8px, env(safe-area-inset-top));
  z-index: 100;
  padding: 12px 16px;
  border-radius: var(--radio);
  background: var(--papel);
  color: var(--rojo-hondo);
  font-weight: 600;
}
.saltar:focus { left: 16px; }

:focus-visible {
  outline: 3px solid var(--tinta);
  outline-offset: 3px;
}
.sobre-oscuro :focus-visible { outline-color: var(--papel); }

/* ---------- Botones: una forma, radio 12 ---------- */

.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 22px;
  border: 0;
  border-radius: var(--radio);
  background: var(--rojo);
  color: var(--papel);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s var(--ease-suave), color 0.2s var(--ease-suave), transform 0.12s var(--ease-suave);
}
.boton:active { background: var(--rojo-hondo); transform: scale(0.97); }
@media (hover: hover) { .boton:hover { background: var(--rojo-hondo); } }
.boton:disabled { background: var(--papel-2); color: var(--tinta-2); cursor: not-allowed; transform: none; }

.boton--secundario { background: var(--papel); color: var(--rojo-hondo); }
.boton--secundario:active { background: var(--rosa); }
@media (hover: hover) { .boton--secundario:hover { background: var(--rosa); } }

.boton--chico { min-height: 44px; padding: 0 16px; font-size: var(--t-nota); }

/* Icono funcional dentro de un botón (timbre, teléfono): pequeño, de trazo y del color del texto. */
.boton__icono {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.boton--texto {
  min-height: 44px;
  padding: 0 4px;
  background: transparent;
  color: var(--rojo);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 4px;
}
.boton--texto:active { background: transparent; color: var(--rojo-hondo); }
@media (hover: hover) { .boton--texto:hover { background: transparent; color: var(--rojo-hondo); } }

/* ---------- Barra de acciones fija (abajo en teléfono, arriba a la derecha en escritorio) ---------- */

.acciones {
  position: fixed;
  inset: auto 0 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  padding: 8px var(--margen) max(8px, env(safe-area-inset-bottom));
  background: var(--papel-2);
  box-shadow: 0 -10px 24px -16px rgb(43 19 19 / 0.28); /* taste-skill-ignore: la barra flota sobre el contenido */
}
.acciones .boton { min-height: 48px; }
.acciones__corta { display: none; }
@media (max-width: 359px) {
  .acciones__larga { display: none; }
  .acciones__corta { display: inline; }
}
.con-acciones { padding-bottom: var(--barra); }

@media (min-width: 900px) {
  .acciones {
    inset: max(16px, env(safe-area-inset-top)) var(--margen) auto auto;
    padding: 0;
    background: transparent;
    grid-template-columns: auto auto;
  }
  .con-acciones { padding-bottom: 0; }
}

/* ---------- Formularios ---------- */

.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radio);
  background: var(--papel-2);
  color: var(--tinta);
  font-size: var(--t-nota);
  cursor: pointer;
  transition: background-color 0.2s var(--ease-suave), color 0.2s var(--ease-suave);
}
.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.chip:has(input:checked) { background: var(--rosa); color: var(--rojo-hondo); font-weight: 600; }
.chip:has(input:checked)::before { content: "✓"; font-weight: 600; } /* taste-skill-ignore: marca funcional de opción elegida */
.chip:has(input:focus-visible) { outline: 3px solid var(--tinta); outline-offset: 2px; }

.campo label { display: block; margin-bottom: 6px; font-weight: 600; }
.campo input {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1.5px solid #B99A8A; /* campo de formulario: el borde es su convención */
  border-radius: var(--radio);
  background: #fff;
  color: var(--tinta);
  font: inherit;
  font-size: max(16px, var(--t-texto)); /* 16 px o más: iOS no hace zoom al enfocar */
}
.campo input[aria-invalid="true"] { border-color: var(--error); }
.ayuda { margin-top: 6px; color: var(--tinta-2); font-size: var(--t-nota); }
.error { margin-top: 6px; color: var(--error); font-weight: 600; font-size: var(--t-nota); }

.motivos { margin: 20px 0 0; padding: 0; border: 0; }
.motivos legend { margin-bottom: 8px; font-weight: 600; }
.motivos__lista { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Diálogos (flotan: pueden llevar sombra) ---------- */

.dialogo {
  width: min(480px, 100vw);
  max-width: 100vw; /* el navegador deja márgenes a los lados de un <dialog>; la hoja va de borde a borde */
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tinta);
  overflow: visible;
}
.dialogo::backdrop { background: rgb(30 14 14 / 0.55); }

.dialogo__caja {
  max-height: 92dvh;
  overflow-y: auto;
  padding: 24px var(--margen) max(24px, env(safe-area-inset-bottom));
  border-radius: 28px 28px 0 0;
  background: var(--papel);
  box-shadow: 0 -20px 60px -30px rgb(43 19 19 / 0.6); /* taste-skill-ignore: el diálogo flota */
}

@media (prefers-reduced-motion: no-preference) {
  .dialogo[open] .dialogo__caja { animation: hoja-sube 0.32s var(--ease-salida) both; }
}
@keyframes hoja-sube { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (min-width: 600px) {
  .dialogo { margin: auto; }
  .dialogo__caja { border-radius: 24px; padding-bottom: 24px; }
}

.dialogo__cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.titulo-dialogo { font-size: var(--t-entrada); line-height: 1.15; }

.cerrar {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radio);
  background: var(--papel-2);
  color: var(--tinta);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.cerrar:active { background: var(--rosa); }

.dialogo__estado {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radio);
  background: var(--rosa);
  font-size: var(--t-nota);
}
.dialogo__nota { margin-top: 12px; color: var(--tinta-2); font-size: var(--t-nota); }

.dialogo__acciones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
}
.dialogo__acciones .boton:not(.boton--texto) { flex: 1; min-width: 180px; }

.mesa-nota { margin-top: -6px; color: var(--rojo-hondo); font-weight: 600; }

.linea {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 12px;
  padding: 14px 0;
}
.linea__texto { grid-column: 1; grid-row: 1; }
.linea__nombre { font-family: var(--fuente-titulo); font-size: var(--t-texto); line-height: 1.25; }
.linea__op { color: var(--tinta-2); font-size: var(--t-nota); }
.linea__control { grid-column: 2; grid-row: 1; display: flex; align-items: center; gap: 6px; }
.ajuste {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radio);
  background: var(--papel-2);
  color: var(--rojo-hondo);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
}
.ajuste:active { background: var(--rosa); }
.linea__cantidad { min-width: 24px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.linea__quitar {
  grid-column: 1;
  grid-row: 2;
  justify-self: start;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--rojo);
  font: inherit;
  font-size: var(--t-nota);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.linea__precio { grid-column: 2; grid-row: 2; justify-self: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.vacio { padding: 18px 0; color: var(--tinta-2); }

.pedido-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radio);
  background: var(--papel-2);
  font-weight: 600;
}
.pedido-total strong {
  font-family: var(--fuente-titulo);
  font-size: var(--t-entrada);
  font-weight: 400;
  color: var(--rojo-hondo);
  font-variant-numeric: tabular-nums;
}

.aviso {
  position: fixed;
  left: 50%;
  bottom: calc(var(--barra) + 12px);
  z-index: 90;
  max-width: calc(100vw - 32px);
  padding: 12px 18px;
  border-radius: var(--radio);
  background: var(--tinta);
  color: var(--papel);
  font-size: var(--t-nota);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s var(--ease-suave), transform 0.2s var(--ease-suave);
}
.aviso--visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Entradas al aparecer (IntersectionObserver en movimiento.js) ----------
   El estado oculto solo existe con JavaScript y sin preferencia de movimiento reducido:
   sin script, o con movimiento reducido, todo está visible desde el principio. */
@media (prefers-reduced-motion: no-preference) {
  .js .aparece {
    opacity: 0;
    transform: translate3d(0, var(--dy, 24px), 0);
    transition: opacity 0.45s var(--ease-suave), transform 0.6s var(--ease-salida);
    transition-delay: calc(min(var(--d, 0), 3) * 70ms);
  }
  .js .aparece.visto { opacity: 1; transform: none; }
}

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