/* ==========================================================================
   ThunderWolf · Menú público
   Theming por restaurante + modo claro/oscuro + refinamiento de UI
   Principios: easings con carácter, solo transform/opacity, <300ms,
   hover detrás de media query, stagger sutil, detalles que se acumulan.
   ========================================================================== */

:root {
    /* Marca (se sobre-escribe por restaurante vía style inline en .menu-shell) */
    --brand-primary: #c82127;
    --brand-secondary: #287343;
    --brand-accent: #f2b544;

    /* Derivados de marca — se adaptan a claro/oscuro porque mezclan con --surface */
    --brand-primary-strong: color-mix(in srgb, var(--brand-primary) 82%, #000);
    --brand-primary-soft: color-mix(in srgb, var(--brand-primary) 12%, var(--surface));
    --brand-accent-soft: color-mix(in srgb, var(--brand-accent) 22%, var(--surface));
    --brand-on-primary: #ffffff;
    --brand-ring: color-mix(in srgb, var(--brand-primary) 38%, transparent);

    /* Superficies y tinta — tema claro */
    --ink: #15171c;
    --ink-soft: #3c424d;
    --muted: #6b7280;
    --line: #e6e8ee;
    --line-soft: #eef0f4;
    --surface: #ffffff;
    --surface-2: #fbfbfd;
    --soft: #f5f6f9;

    --shadow-sm: 0 1px 2px rgba(20, 24, 31, 0.05), 0 1px 1px rgba(20, 24, 31, 0.04);
    --shadow-md: 0 10px 24px rgba(20, 24, 31, 0.08);
    --shadow-lg: 0 22px 48px rgba(20, 24, 31, 0.12);

    /* Halos de marca del fondo (se atenúan en oscuro) */
    --halo-1: color-mix(in srgb, var(--brand-secondary) 9%, transparent);
    --halo-2: color-mix(in srgb, var(--brand-primary) 8%, transparent);

    /* Tipografía: par editorial no genérico (display serif + sans limpia).
       Si el restaurante define una fuente, --brand-font la sobre-escribe. */
    --font-display: "Fraunces", Georgia, "Times New Roman", serif;
    --font-body: "Manrope", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* Radios y ritmo (escala de 4px) */
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 20px;
    --r-pill: 999px;

    /* Movimiento */
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

    color-scheme: light;
    font-family: var(--brand-font, var(--font-body));
}

:root[data-theme="dark"] {
    --ink: #f3f5f8;
    --ink-soft: #c9ced8;
    --muted: #98a1b2;
    --line: #272d38;
    --line-soft: #1d222b;
    --surface: #161a21;
    --surface-2: #1c212a;
    --soft: #0e1116;

    --brand-primary-strong: color-mix(in srgb, var(--brand-primary) 78%, #fff 6%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 26px 56px rgba(0, 0, 0, 0.55);

    --halo-1: color-mix(in srgb, var(--brand-secondary) 16%, transparent);
    --halo-2: color-mix(in srgb, var(--brand-primary) 15%, transparent);

    color-scheme: dark;
}

/* Fallback sin JS: respeta el sistema cuando no hay preferencia explícita */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --ink: #f3f5f8;
        --ink-soft: #c9ced8;
        --muted: #98a1b2;
        --line: #272d38;
        --line-soft: #1d222b;
        --surface: #161a21;
        --surface-2: #1c212a;
        --soft: #0e1116;
        --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 26px 56px rgba(0, 0, 0, 0.55);
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

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

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(120% 60% at 6% -4%, var(--halo-1), transparent 42%),
        radial-gradient(90% 50% at 96% 0%, var(--halo-2), transparent 38%),
        var(--soft);
    color: var(--ink);
    font-family: var(--brand-font, var(--font-body));
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background-color 240ms var(--ease-out), color 240ms var(--ease-out);
}

button,
input {
    font: inherit;
    color: inherit;
}

a {
    color: inherit;
}

h1, h2, h3, h4 {
    font-family: var(--brand-font, var(--font-display));
    font-weight: 600;
    letter-spacing: -0.01em;
}

:where(button, a, input):focus-visible {
    outline: 2px solid var(--brand-ring);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

h1:focus, h2:focus, h3:focus {
    outline: none;
}

/* ---------- Layout ---------- */
.menu-shell {
    width: min(1180px, calc(100% - 36px));
    margin: 0 auto;
    padding: 28px 0 48px;
}

/* ---------- Header ---------- */
.menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 0 26px;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.brand-logo,
.brand-fallback {
    width: 76px;
    height: 76px;
    flex: 0 0 auto;
    border-radius: var(--r-lg);
    background: var(--surface);
    border: 1px solid var(--line-soft);
    box-shadow: var(--shadow-md);
}

.brand-logo {
    object-fit: contain;
    padding: 10px;
}

.brand-fallback {
    display: grid;
    place-items: center;
    color: var(--brand-primary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.6rem;
}

.brand-lockup h1 {
    margin: 0;
    font-size: clamp(2rem, 4.6vw, 3.4rem);
    line-height: 1;
    letter-spacing: -0.02em;
}

.brand-lockup p {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 0.98rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.restaurant-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    font-size: 0.92rem;
    text-align: right;
    color: var(--muted);
}

.restaurant-meta a {
    text-decoration: none;
    transition: color 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .restaurant-meta a:hover {
        color: var(--brand-primary);
    }
}

/* ---------- Theme toggle ---------- */
.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 160ms var(--ease-out), border-color 160ms var(--ease-out),
        color 160ms var(--ease-out);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (hover: hover) and (pointer: fine) {
    .theme-toggle:hover {
        border-color: var(--brand-ring);
        color: var(--brand-primary);
    }
}

.theme-toggle:active {
    transform: scale(0.94);
}

/* ---------- Search ---------- */
.search-band {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px 0 10px;
    background: linear-gradient(180deg, var(--soft) 70%, transparent);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 18px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color 180ms var(--ease-out), box-shadow 180ms var(--ease-out);
}

.search-box:focus-within {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px var(--brand-ring);
}

.search-box svg {
    width: 21px;
    height: 21px;
    flex: 0 0 auto;
    fill: none;
    stroke: var(--muted);
    stroke-width: 2;
    stroke-linecap: round;
}

.search-box input {
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--ink);
    font-size: 1rem;
}

.search-box input::placeholder {
    color: var(--muted);
}

/* ---------- Category rail (sticky bajo el buscador) ---------- */
.category-rail {
    position: sticky;
    top: 78px;
    z-index: 15;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 0 16px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, var(--soft) 78%, transparent);
}

.category-button {
    min-height: 42px;
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 0 18px;
    background: var(--surface);
    color: var(--ink-soft);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 160ms var(--ease-out), color 160ms var(--ease-out),
        background-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .category-button:hover {
        transform: translateY(-1px);
        border-color: var(--brand-ring);
        color: var(--ink);
    }
}

.category-button:active {
    transform: scale(0.97);
}

.category-button.is-active {
    border-color: transparent;
    background: var(--brand-primary);
    color: var(--brand-on-primary);
    box-shadow: var(--shadow-sm);
}

/* ---------- Secciones ---------- */
.menu-section {
    margin-top: 44px;
}

.section-heading,
.category-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.section-heading h2,
.category-heading h3 {
    margin: 0;
    font-size: clamp(1.5rem, 2.8vw, 2.1rem);
    line-height: 1.05;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--brand-secondary);
    font-family: var(--font-body);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.item-count {
    color: var(--muted);
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.category-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    max-width: 60ch;
    line-height: 1.5;
}

/* ---------- Combos ---------- */
.combo-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(280px, 1fr);
    gap: 18px;
    overflow-x: auto;
    padding: 2px 2px 14px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.combo-card,
.item-card {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out),
        border-color 200ms var(--ease-out);
}

.combo-card {
    min-width: 280px;
    scroll-snap-align: start;
}

@media (hover: hover) and (pointer: fine) {
    .combo-card:hover,
    .item-card:hover {
        transform: translateY(-3px);
        box-shadow: var(--shadow-lg);
        border-color: var(--line-soft);
    }

    .combo-card:hover .menu-image img,
    .item-card:hover .menu-image img {
        transform: scale(1.05);
    }
}

.combo-card__body,
.item-card__body {
    padding: 18px;
}

.combo-card h3,
.item-card h4 {
    margin: 0;
    font-size: 1.12rem;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.combo-card p,
.item-card p {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.5;
    font-size: 0.94rem;
}

.price-row,
.item-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
}

.price-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.price-row strong,
.price-stack strong {
    color: var(--brand-primary);
    font-size: 1.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.price-row span,
.price-stack .price-was {
    color: var(--muted);
    font-size: 0.86rem;
    text-decoration: line-through;
    font-variant-numeric: tabular-nums;
}

/* Badge de descuento */
.discount-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 5px 10px;
    border-radius: var(--r-pill);
    background: var(--brand-primary);
    color: var(--brand-on-primary);
    font-family: var(--font-body);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    box-shadow: var(--shadow-sm);
    font-variant-numeric: tabular-nums;
}

/* ---------- Grid de platillos ---------- */
.category-block {
    margin-top: 36px;
}

.item-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.item-card {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
}

.item-card__body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    min-height: 188px;
}

.prep-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--r-pill);
    background: color-mix(in srgb, var(--brand-secondary) 14%, var(--surface));
    color: var(--brand-secondary);
    padding: 6px 11px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* ---------- Imágenes ---------- */
.menu-image {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    background:
        linear-gradient(135deg,
            color-mix(in srgb, var(--brand-secondary) 10%, var(--surface-2)),
            color-mix(in srgb, var(--brand-primary) 8%, var(--surface-2)));
    overflow: hidden;
}

.menu-image img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    transition: transform 320ms var(--ease-out);
}

.menu-image__fallback {
    width: 78px;
    color: var(--brand-secondary);
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.55;
}

/* ---------- Estados ---------- */
.state-panel {
    display: grid;
    place-items: center;
    min-height: 60vh;
    padding: 36px;
    text-align: center;
    border-radius: var(--r-lg);
}

.state-panel--inline {
    min-height: 220px;
    border: 1px dashed var(--line);
    background: var(--surface-2);
}

.state-panel h1,
.state-panel h3 {
    margin: 12px 0 6px;
    font-size: clamp(1.7rem, 4.4vw, 2.6rem);
    line-height: 1.08;
}

.state-panel p {
    margin: 0;
    color: var(--muted);
    max-width: 44ch;
}

.primary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    margin-top: 18px;
    border: 0;
    border-radius: var(--r-md);
    padding: 0 22px;
    background: var(--brand-primary);
    color: var(--brand-on-primary);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .primary-button:hover {
        background: var(--brand-primary-strong);
    }
}

.primary-button:active {
    transform: scale(0.97);
}

.loading-mark {
    width: 40px;
    height: 40px;
    border-radius: var(--r-pill);
    border: 3px solid color-mix(in srgb, var(--brand-primary) 22%, transparent);
    border-top-color: var(--brand-primary);
    animation: spin 700ms linear infinite;
}

/* ---------- Skeleton de carga ---------- */
.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin-top: 8px;
}

.skeleton-card {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface);
    overflow: hidden;
}

.skeleton-card__media {
    aspect-ratio: 4 / 3;
}

.skeleton-card__body {
    display: grid;
    gap: 10px;
    padding: 18px;
}

.skeleton-line {
    height: 12px;
    border-radius: var(--r-pill);
}

.skeleton-line.is-title { width: 70%; height: 16px; }
.skeleton-line.is-short { width: 40%; }

.skeleton,
.skeleton-card__media,
.skeleton-line {
    background: linear-gradient(
        100deg,
        var(--line-soft) 30%,
        color-mix(in srgb, var(--line) 60%, var(--surface)) 50%,
        var(--line-soft) 70%
    );
    background-size: 200% 100%;
    animation: shimmer 1.3s var(--ease-in-out) infinite;
}

/* ---------- Footer ---------- */
.menu-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-top: 52px;
    padding: 24px 0 4px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

.menu-footer a {
    text-decoration: none;
    transition: color 160ms var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
    .menu-footer a:hover {
        color: var(--brand-primary);
    }
}

/* ---------- Entrada con stagger ---------- */
.fade-up {
    animation: fadeUp 420ms var(--ease-out) both;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    to { background-position: -200% 0; }
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

    .menu-image img { transition: none !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .item-grid,
    .skeleton-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .menu-header,
    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .restaurant-meta {
        align-items: flex-start;
        text-align: left;
    }

    .category-rail {
        top: 74px;
    }
}

@media (max-width: 620px) {
    .menu-shell {
        width: min(100% - 24px, 1180px);
        padding-top: 14px;
    }

    .brand-logo,
    .brand-fallback {
        width: 60px;
        height: 60px;
        border-radius: var(--r-md);
    }

    .brand-lockup {
        align-items: center;
        gap: 14px;
    }

    .brand-lockup h1 {
        font-size: 2rem;
    }

    .search-box {
        min-height: 52px;
        padding: 0 14px;
    }

    .combo-strip {
        grid-auto-columns: minmax(248px, 84vw);
    }

    .item-grid,
    .skeleton-grid {
        grid-template-columns: 1fr;
    }

    .item-card {
        grid-template-columns: 124px 1fr;
        grid-template-rows: auto;
    }

    .item-card .menu-image {
        height: 100%;
        min-height: 160px;
        aspect-ratio: auto;
    }

    .item-card__body {
        min-height: 160px;
        padding: 14px;
    }

    .discount-badge {
        top: 8px;
        left: 8px;
    }

    .menu-footer {
        flex-direction: column;
        align-items: flex-start;
    }
}
