/**
 * Carta pública — base común a todos los diseños.
 *
 * Aquí vive lo que NO es de ningún diseño concreto: el reinicio, las piezas
 * que pinta `Vista` (clases `c-*`: sellos, alérgenos, precios, formatos…) y
 * lo que pone el marco (hojas, ficha de plato, pregunta de edad, anuncios).
 * Cada diseño lo viste desde su `estilo.css`, normalmente cambiando solo las
 * variables de `:root`.
 *
 * Pensado para 360 px y pulgar: objetivos táctiles ≥ 44 px, zonas seguras
 * (notch) respetadas, sin fuentes ni librerías externas.
 */

:root {
    /* --c1 / --c2 / --sobre-c1 / --sobre-c2 / --c1-tinta / --c2-tinta llegan en línea con los colores del local */
    --fondo: #fff;
    --fondo-2: #f6f4f1;
    --texto: #1c1b19;
    --tenue: #6b6760;
    --linea: #e7e3dd;
    --radio: 14px;
    --ancho: 540px;
    --barra: 56px;
    --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --fuente-titulo: var(--fuente);
    --c1-suave: #f6f4f1;
    --c2-suave: #f6f4f1;
    /* parten de la tinta, no del color: así son oscuros (admiten texto blanco) aunque el local elija un amarillo */
    --c1-oscuro: var(--c1-tinta);
    --c2-oscuro: var(--c2-tinta);
    --sombra: 0 1px 2px rgba(28, 27, 25, .06), 0 6px 20px rgba(28, 27, 25, .07);
}
/* Los derivados finos, solo donde el navegador sabe mezclar colores (una variable no admite la reserva de "dos declaraciones seguidas"). */
@supports (color: color-mix(in srgb, #000, #fff)) {
    :root {
        --c1-suave: color-mix(in srgb, var(--c1) 9%, #fff);
        --c2-suave: color-mix(in srgb, var(--c2) 13%, #fff);
        --c1-oscuro: color-mix(in srgb, var(--c1-tinta) 72%, #000);
        --c2-oscuro: color-mix(in srgb, var(--c2-tinta) 72%, #000);
    }
}

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

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: #eceae6;
    scroll-padding-top: calc(var(--barra) + 12px);
}
html:has(dialog[open]) { overflow: hidden; }

body {
    margin: 0;
    font: 16px/1.45 var(--fuente);
    color: var(--texto);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--c1-tinta); outline-offset: 2px; }

.ic { width: 1.25em; height: 1.25em; flex: none; vertical-align: -.22em; }

.c-oculto {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* ---- lienzo y vistas ------------------------------------------------------ */

.carta {
    max-width: var(--ancho);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    background: var(--fondo);
}
@media (min-width: 600px) {
    .carta { box-shadow: 0 0 0 1px rgba(28, 27, 25, .05), 0 20px 60px rgba(28, 27, 25, .12); }
}

[data-vista][hidden] { display: none !important; }
[data-vista] { min-height: 100vh; min-height: 100dvh; }
[data-vista].entra { animation: c-entra .22s cubic-bezier(.2, .7, .2, 1); }
@keyframes c-entra { from { opacity: 0; transform: translateY(10px); } }

/* Cambio de vista: la pantalla que sale empuja a la que entra (el motor pone data-paso en <html>). */
html[data-paso]::view-transition-old(root),
html[data-paso]::view-transition-new(root) { animation: .3s cubic-bezier(.3, .7, .2, 1) both; }
html[data-paso="adelante"]::view-transition-old(root) { animation-name: c-sale-izq; }
html[data-paso="adelante"]::view-transition-new(root) { animation-name: c-entra-der; }
html[data-paso="atras"]::view-transition-old(root) { animation-name: c-sale-der; }
html[data-paso="atras"]::view-transition-new(root) { animation-name: c-entra-izq; }
@keyframes c-sale-izq { to { transform: translateX(-100%); } }
@keyframes c-entra-der { from { transform: translateX(100%); } }
@keyframes c-sale-der { to { transform: translateX(100%); } }
@keyframes c-entra-izq { from { transform: translateX(-100%); } }

/* ---- barra de una carta: volver · título · idioma ------------------------- */

.c-barra {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 4px;
    min-height: var(--barra);
    padding: env(safe-area-inset-top) 8px 0;
    background: var(--fondo);
    border-bottom: 1px solid var(--linea);
}
.c-barra h1 {
    flex: 1; min-width: 0;
    font: 600 1.0625rem/1.2 var(--fuente-titulo);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.c-barra-atras {
    display: grid; place-items: center;
    width: 44px; height: 44px; flex: none; border-radius: 50%;
}
.c-barra-atras .ic { width: 24px; height: 24px; }
.c-barra-atras:active { background: rgba(127, 127, 127, .16); }

/* variante en el color del local, con el título centrado */
.c-barra--color { background: var(--c1); color: var(--sobre-c1); border-bottom: 0; }
.c-barra--color h1 { text-align: center; font-size: 1.125rem; }
.c-barra--color h1:last-child { padding-right: 44px; }   /* sin botón de idioma: el título sigue centrado */
.c-barra--color .c-idioma { background: rgba(127, 127, 127, .22); background: color-mix(in srgb, currentColor 16%, transparent); }

/* ---- índice de grupos (píldoras deslizables) ------------------------------ */

.c-indice {
    position: sticky; top: calc(var(--barra) + env(safe-area-inset-top)); z-index: 19;
    display: flex; gap: 8px;
    padding: 10px 16px;
    overflow-x: auto; scrollbar-width: none;
    background: var(--fondo);
    border-bottom: 1px solid var(--linea);
}
.c-indice::-webkit-scrollbar { display: none; }
.c-indice a {
    flex: none;
    padding: 7px 14px; min-height: 36px;
    border-radius: 999px;
    background: var(--fondo-2);
    font-size: .875rem; font-weight: 500; white-space: nowrap;
    transition: background-color .15s, color .15s;
}
.c-indice a[aria-current] { background: var(--c1); color: var(--sobre-c1); }
[data-grupo] { scroll-margin-top: calc(var(--barra) + 64px + env(safe-area-inset-top)); }

/* ---- cabecera de una carta: precio, fecha, avisos -------------------------- */

.c-intro { padding: 14px 16px 0; display: grid; gap: 10px; }
.c-intro:empty { display: none; }
.c-intro-linea { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.c-intro-fecha { color: var(--tenue); font-size: .875rem; }
.c-intro-fecha::first-letter { text-transform: uppercase; }
.c-intro-precio { margin-left: auto; font-size: 1.375rem; font-weight: 700; color: var(--c1-tinta); }
.c-nota {
    display: flex; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radio);
    background: var(--fondo-2);
    font-size: .9375rem;
}
.c-nota .ic { margin-top: .1em; color: var(--tenue); }
.c-nota--aviso { background: #fdecea; color: #9b1c13; font-weight: 600; }
.c-nota--aviso .ic { color: inherit; }

.c-vacia { padding: 48px 24px; text-align: center; color: var(--tenue); }

/* ---- portada con la foto del local de fondo -------------------------------- */

.c-hero { position: relative; display: grid; background: var(--c1-oscuro); }
.c-hero-foto { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.c-hero-logo { width: auto; max-width: 70%; max-height: 96px; filter: drop-shadow(0 2px 10px rgba(0, 0, 0, .35)); }
.c-hero h1 { font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -.015em; text-wrap: balance; text-shadow: 0 1px 12px rgba(0, 0, 0, .5); }

/* ---- recomendación con el texto sobre la foto ------------------------------- */

.c-reco {
    position: relative;
    display: flex; flex-direction: column; justify-content: space-between;
    border-radius: var(--radio); overflow: hidden;
    background: var(--c1-oscuro); color: #fff;
}
.c-reco-foto { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.c-reco::after {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(rgba(0, 0, 0, .68), rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, .5));
}
.c-reco:not(:has(img))::after { background: linear-gradient(rgba(0, 0, 0, .3), rgba(0, 0, 0, .08)); }
.c-reco-info, .c-reco-grupo { position: relative; z-index: 1; padding: 12px 14px; }
.c-reco-nombre { display: block; font-weight: 700; line-height: 1.2; text-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.c-reco .c-precio { display: block; margin-top: 2px; font-size: .9375rem; }
.c-reco-grupo { font-size: .8125rem; opacity: .92; }

/* ---- piezas del plato ------------------------------------------------------ */

.c-precio { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bc-money-symbol { font-size: .82em; font-weight: inherit; margin: 0 .08em; }
.bc-money-decimals { font-size: .82em; font-weight: inherit; }

.c-etqs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.c-etq {
    padding: 3px 8px; border-radius: 999px;
    font-size: .6875rem; font-weight: 600; line-height: 1.2; letter-spacing: .01em;
    color: #fff; background: #555;
}
.c-etq--agotado   { background: #c8261b; text-transform: uppercase; }
.c-etq--nuevo     { background: #016fb4; }
.c-etq--casero    { background: #a72500; }
.c-etq--temporada { background: #3c6202; }
.c-etq--local     { background: #6c0a2c; }

.c-num {
    display: inline-block; min-width: 1.6em; padding: 0 .3em;
    border: 1px solid currentColor; border-radius: 5px;
    font-size: .78em; font-weight: 600; line-height: 1.45; text-align: center;
    color: var(--tenue); vertical-align: .08em;
}

.c-dieta { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.c-dieta .ic { width: 1em; height: 1em; }
.c-dieta--vegano, .c-dieta--vegetariano, .c-dieta--singluten { color: #3f7a2f; }
.c-dieta--picante { color: #c8261b; gap: 0; }

.c-algs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.c-algs img { width: 18px; height: 18px; }
.c-trazas { display: block; margin-top: 5px; font-size: .75rem; line-height: 1.35; color: var(--tenue); }

.c-formatos { display: block; margin-top: 8px; }
.c-formato {
    display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
    padding: 5px 0;
    border-top: 1px solid var(--linea);
    font-size: .875rem;
}
.c-formato .c-precio { color: var(--c1-tinta); }

/* Plato sin foto en una carta que tiene fotos: un cuadro del tamaño de la miniatura, en un pastel del color del local. */
span.c-hueco { background: var(--c1-suave); background: color-mix(in srgb, var(--c1) 20%, var(--fondo)); }

/* Plato agotado en un listado: se apaga el plato, no el sello que lo explica. */
a.es-agotado img, a.es-agotado [class*="-nombre"], a.es-agotado [class*="-extra"],
a.es-agotado .c-precio, a.es-agotado .c-algs, a.es-agotado .c-formatos { opacity: .5; }

/* ---- anuncios -------------------------------------------------------------- */

.c-anuncio { min-height: 1px; margin: 0 16px; text-align: center; }
.c-anuncio.cargado { margin: 20px 16px; }

/* ---- acciones, redes, idioma, créditos -------------------------------------- */

.c-redes { display: flex; flex-wrap: wrap; justify-content: center; }
.c-redes a { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.c-redes .ic { width: 22px; height: 22px; }

.c-idioma {
    display: inline-flex; align-items: center; gap: 5px;
    min-height: 36px; padding: 0 10px 0 9px;
    border-radius: 999px;
    font-size: .8125rem; font-weight: 600;
}
.c-idioma .ic { width: 16px; height: 16px; }
.c-idioma .ic:last-child { width: 14px; height: 14px; opacity: .7; }

.c-boton {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 48px; padding: 0 20px;
    border-radius: 12px;
    background: var(--c1); color: var(--sobre-c1);
    font-weight: 600;
}
.c-boton:disabled { opacity: .6; }

.c-creditos { margin-top: 28px; font-size: .8125rem; color: var(--tenue); text-align: center; }
.c-creditos-marca { display: inline-flex; align-items: center; gap: 8px; padding: 8px; color: var(--texto); }
.c-creditos-marca img { height: 20px; width: auto; }
.c-creditos-enlaces { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 18px; }
.c-creditos-enlaces > * { padding: 12px 4px; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: rgba(127, 127, 127, .5); }

/* ---- hojas (suben desde abajo; en escritorio, ventana centrada) ------------- */

dialog.c-hoja {
    position: fixed; inset: auto 0 0;
    width: 100%; max-width: var(--ancho); max-height: 92vh; max-height: 92dvh;
    margin: 0 auto; padding: 0; border: 0;
    border-radius: 22px 22px 0 0;
    background: var(--fondo); color: var(--texto);
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .22);
    overflow: hidden;
    transition: transform .2s;
}
dialog.c-hoja[open] { display: flex; flex-direction: column; animation: c-sube .3s cubic-bezier(.2, .8, .2, 1); }
dialog.c-hoja::backdrop { background: rgba(20, 18, 15, .5); animation: c-aparece .25s; }
dialog.c-hoja.sale { animation: c-baja .18s ease-in forwards; }
dialog.c-hoja.sale::backdrop { animation: c-desaparece .18s forwards; }
@keyframes c-sube { from { transform: translateY(100%); } }
@keyframes c-baja { to { transform: translateY(100%); } }
@keyframes c-aparece { from { opacity: 0; } }
@keyframes c-desaparece { to { opacity: 0; } }

.c-hoja-cab {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 10px 10px 20px;
}
.c-hoja-cab h2 { font: 600 1.125rem/1.25 var(--fuente-titulo); }
.c-hoja-cerrar {
    display: grid; place-items: center;
    width: 40px; height: 40px; flex: none; border-radius: 50%;
    background: var(--fondo-2);
}
.c-hoja-cuerpo {
    overflow-y: auto; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom);
}

.c-hoja-cuerpo:focus { outline: 0; }

.c-hoja--ficha > .c-hoja-cerrar {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    background: rgba(255, 255, 255, .92);
    color: #1c1b19;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}

@media (min-width: 600px) {
    dialog.c-hoja { inset: 0; margin: auto; height: fit-content; max-width: 460px; max-height: 86vh; border-radius: 22px; }
    dialog.c-hoja[open] { animation: c-emerge .22s cubic-bezier(.2, .8, .2, 1); }
    dialog.c-hoja.sale { animation: c-desaparece .18s forwards; }
    @keyframes c-emerge { from { opacity: 0; transform: translateY(16px) scale(.98); } }
}

/* listas dentro de una hoja: compartir, idiomas */
.c-lista { padding: 0 8px 12px; }
.c-lista > a, .c-lista > button {
    display: flex; align-items: center; gap: 14px;
    width: 100%; min-height: 52px; padding: 0 12px;
    border-radius: 12px;
    font-size: 1rem; text-align: left;
}
.c-lista > :active { background: var(--fondo-2); }
.c-lista > [aria-current] { font-weight: 600; }
.c-lista .ic { width: 22px; height: 22px; color: var(--tenue); }
.c-lista-cod { width: 30px; font-size: .75rem; font-weight: 700; color: var(--tenue); letter-spacing: .04em; }
.c-lista .c-lista-check { margin-left: auto; color: var(--c1-tinta); }

/* formulario de denuncia */
.c-form { display: grid; gap: 8px; padding: 4px 20px 20px; }
.c-form label { font-size: .875rem; font-weight: 600; margin-top: 6px; }
.c-form select, .c-form textarea {
    width: 100%; padding: 12px;
    border: 1px solid var(--linea); border-radius: 12px;
    background: var(--fondo); color: var(--texto);
    font: inherit; font-size: 16px;   /* 16 px: iOS no hace zoom al enfocar */
}
.c-form textarea { resize: vertical; min-height: 96px; }
.c-form .c-boton { margin-top: 8px; }
.c-form-msg { min-height: 1.3em; font-size: .875rem; }
.c-form-msg.es-error { color: #c8261b; }

/* ---- ficha de plato --------------------------------------------------------- */

.c-ficha-foto { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--fondo-2); }
.c-ficha-cuerpo { padding: 20px 20px 28px; }
.c-ficha:not(:has(.c-ficha-foto)) .c-ficha-cuerpo { padding-top: 26px; padding-right: 64px; }
.c-ficha-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.c-ficha-nombre { font: 700 1.4375rem/1.2 var(--fuente-titulo); text-wrap: balance; }
.c-ficha-precio { font-size: 1.3125rem; font-weight: 700; color: var(--c1-tinta); }
.c-ficha-extra { margin-top: 4px; font-size: 1.0625rem; color: var(--tenue); }
.c-ficha-dieta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: .9375rem; font-weight: 500; }
.c-ficha .c-formatos { margin-top: 16px; }
.c-ficha .c-formato { padding: 10px 0; font-size: 1rem; font-weight: 500; }
.c-ficha-desc { margin-top: 16px; color: #45423d; line-height: 1.55; }
.c-ficha .c-etqs { margin-bottom: 10px; }
.c-ficha .c-etq { font-size: .75rem; padding: 4px 10px; }

.c-alergenos { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--linea); }
.c-alergenos h3 { font-size: .8125rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tenue); margin-bottom: 10px; }
.c-alergenos ul { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.c-alergenos li { display: flex; align-items: center; gap: 9px; font-size: .9375rem; }
.c-alergenos img { width: 24px; height: 24px; flex: none; }
.c-alergenos .c-trazas { margin-top: 12px; font-size: .875rem; }

/* ---- pregunta de edad ------------------------------------------------------- */

.c-edad { display: flex; flex-direction: column; gap: 14px; padding: calc(40px + env(safe-area-inset-top)) 20px 28px; text-align: center; }
.c-edad-cab { display: grid; justify-items: center; gap: 14px; margin-bottom: 8px; }
.c-edad-cab h1 { font: 700 1.75rem/1.15 var(--fuente-titulo); text-wrap: balance; }
.c-edad-logo { max-height: 96px; max-width: 70%; width: auto; }
.c-edad-pregunta { font-size: 1.25rem; margin-bottom: 4px; }
.c-edad-op {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 20px 16px;
    border-radius: 18px;
    background: var(--fondo-2);
}
.c-edad-op strong { font-size: 1.625rem; line-height: 1.1; }
.c-edad-op span { color: var(--tenue); }
.c-edad-op--si { background: var(--c1); color: var(--sobre-c1); }
.c-edad-op--si span { color: inherit; opacity: .85; }
.c-edad-pie { margin-top: auto; padding-top: 16px; color: var(--tenue); font-size: .875rem; display: grid; justify-items: center; gap: 8px; }

/* ---- aviso de la demo y toast ----------------------------------------------- */

.c-demo {
    position: fixed; z-index: 30; left: 0; right: 0; bottom: 0;
    width: calc(100% - 16px); max-width: calc(var(--ancho) - 16px);
    margin: 0 auto 8px; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    border-radius: 18px;
    background: #fff; color: #1c1b19;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .1), 0 12px 40px rgba(0, 0, 0, .2);
    text-align: center; font-size: .9375rem; line-height: 1.35;
    view-transition-name: c-demo;   /* se queda quieto mientras las vistas se deslizan */
}
.c-demo strong { display: block; margin-top: 2px; color: #1f8a00; }
.c-demo .c-boton { margin-top: 10px; background: #1fa200; color: #fff; }
.con-demo .carta { padding-bottom: 170px; }

.c-toast {
    position: fixed; z-index: 100; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    padding: 10px 16px; border-radius: 999px;
    background: #1c1b19; color: #fff;
    font-size: .875rem; font-weight: 500; white-space: nowrap;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
    animation: c-aparece .2s;
}
.c-toast[hidden] { display: none; }

/* ---- modo oscuro (cuando lo pide el sistema del lector) ---------------------- */

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --fondo: #1e1c1a;
        --fondo-2: #2a2825;
        --texto: #f2efea;
        --tenue: #a9a39a;
        --linea: #38352f;
        --c1-suave: #141312;
        --c2-suave: #141312;
        --sombra: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .35);
    }
    /* La tinta llega pensada para fondo claro: aquí se aclara. Va en body para
       que --c1-oscuro / --c2-oscuro (calculados en :root) sigan siendo oscuros. */
    body { --c1-tinta: #e2ded7; --c2-tinta: #e2ded7; }
    @supports (color: color-mix(in srgb, #000, #fff)) {
        :root {
            --c1-suave: color-mix(in srgb, var(--c1) 14%, #141312);
            --c2-suave: color-mix(in srgb, var(--c2) 12%, #141312);
        }
        body {
            --c1-tinta: color-mix(in srgb, var(--c1) 45%, #fff);
            --c2-tinta: color-mix(in srgb, var(--c2) 45%, #fff);
        }
    }

    html { background: #0c0b0a; }
    .c-nota--aviso { background: #3b1613; color: #ffb4ab; }
    .c-dieta--vegano, .c-dieta--vegetariano, .c-dieta--singluten { color: #84c770; }
    .c-dieta--picante, .c-form-msg.es-error { color: #ff7a6e; }
    .c-ficha-desc { color: #d2cdc5; }
    .c-toast { background: #f2efea; color: #1c1b19; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after, dialog.c-hoja, dialog.c-hoja::backdrop { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
