/* ==========================================================================
   BERRYLAND — Design System
   ========================================================================== */

:root {
    /* Colores de marca */
    --berry-red: #E31837;
    --berry-red-dark: #B8122C;
    --berry-pink: #FF85A2;
    --berry-pink-soft: #FFE9EF;
    --whatsapp-green: #1EBE5D;
    --dark-text: #1D1D1F;
    --muted-text: #55555C;
    --light-bg: #FAF8F7;
    --white: #FFFFFF;
    --border: #ECE7E5;

    /* Escala tipográfica (fluida) */
    --fs-sm: 0.875rem;
    --fs-base: 1rem;
    --fs-md: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
    --fs-lg: clamp(1.25rem, 1.1rem + 0.8vw, 1.6rem);
    --fs-xl: clamp(1.6rem, 1.3rem + 1.6vw, 2.4rem);
    --fs-hero: clamp(1.35rem, 1rem + 2vw, 2.1rem);

    /* Escala de espaciado */
    --sp-1: 0.5rem;
    --sp-2: 0.75rem;
    --sp-3: 1rem;
    --sp-4: 1.5rem;
    --sp-5: 2rem;
    --sp-6: 3rem;
    --sp-7: clamp(3rem, 2rem + 4vw, 5rem);

    /* Radios */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 999px;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(29, 29, 31, 0.06);
    --shadow-md: 0 6px 20px rgba(29, 29, 31, 0.08);
    --shadow-lg: 0 16px 40px rgba(29, 29, 31, 0.12);

    /* Animación */
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    --dur-fast: 0.2s;
    --dur: 0.35s;
    --dur-slow: 0.7s;

    /* Layout */
    --container: 1200px;
    --nav-height: 76px;
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--light-bg);
    color: var(--dark-text);
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

section, header[id] {
    scroll-margin-top: calc(var(--nav-height) + 12px);
}

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: var(--sp-7) var(--sp-4);
}

h2 {
    text-align: center;
    font-size: var(--fs-xl);
    font-weight: 900;
    letter-spacing: -0.02em;
    margin-bottom: var(--sp-5);
    color: var(--berry-red);
}

h3 {
    font-size: var(--fs-lg);
    letter-spacing: -0.01em;
    margin-bottom: var(--sp-2);
}

.section-intro {
    text-align: center;
    color: var(--muted-text);
    max-width: 60ch;
    margin: calc(-1 * var(--sp-4)) auto var(--sp-5);
}

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

/* Oculto por completo salvo cuando recibe foco de teclado (Tab) */
.skip-link {
    position: fixed;
    left: var(--sp-3);
    top: var(--sp-2);
    background: var(--dark-text);
    color: var(--white);
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-sm);
    z-index: 2000;
    text-decoration: none;
    clip-path: inset(100%);
    opacity: 0;
    pointer-events: none;
}

.skip-link:focus-visible {
    clip-path: none;
    opacity: 1;
    pointer-events: auto;
}

:focus-visible {
    outline: 3px solid var(--berry-red);
    outline-offset: 2px;
}

/* Honeypot: oculto para humanos, visible para bots */
.hp-field {
    position: absolute !important;
    left: -9999px !important;
    width: 1px; height: 1px;
    opacity: 0;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    vertical-align: -0.25em;
}

/* ==========================================================================
   Navegación
   ========================================================================== */

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--sp-4);
    min-height: var(--nav-height);
    padding: 0 clamp(var(--sp-3), 4vw, var(--sp-6));
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid transparent;
    transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.navbar.scrolled {
    box-shadow: var(--shadow-md);
    border-bottom-color: var(--border);
}

.logo-nav a {
    display: inline-flex;
    align-items: center;
}

/* Logo rectangular: solo se fija la altura (fluida); el ancho escala proporcional */
.logo-nav img {
    height: clamp(38px, 5.5vw, 52px);
    width: auto;
    max-width: min(46vw, 240px);
    object-fit: contain;
    border-radius: 6px;
}

.nav-links {
    list-style: none;
    display: flex;
    align-items: center;
    gap: clamp(var(--sp-2), 2vw, var(--sp-5));
}

.nav-links a {
    text-decoration: none;
    color: var(--dark-text);
    font-weight: 500;
    font-size: var(--fs-sm);
    letter-spacing: 0.01em;
    padding: var(--sp-1) 0;
    position: relative;
    transition: color var(--dur-fast) var(--ease);
}

.nav-links a::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -2px;
    height: 2px;
    background: var(--berry-red);
    border-radius: 2px;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--dur) var(--ease);
}

.nav-links a:hover {
    color: var(--berry-red);
}

.nav-links a:hover::after {
    transform: scaleX(1);
}

/* Botón hamburguesa */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.menu-bar {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--dark-text);
    border-radius: 2px;
    transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}

.menu-toggle[aria-expanded="true"] .menu-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .menu-bar:nth-child(2) {
    opacity: 0;
}
.menu-toggle[aria-expanded="true"] .menu-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Overlay del menú móvil */
.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(29, 29, 31, 0.45);
    z-index: 900;
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
}

.nav-overlay.visible {
    opacity: 1;
}

/* ==========================================================================
   Toast de formularios
   ========================================================================== */

.toast {
    position: fixed;
    left: 50%;
    bottom: var(--sp-5);
    transform: translateX(-50%);
    max-width: min(90vw, 480px);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-weight: 500;
    z-index: 1500;
    animation: toast-in var(--dur-slow) var(--ease);
}

.toast-ok { background: var(--dark-text); color: var(--white); }
.toast-error { background: var(--berry-red); color: var(--white); }

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 16px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero-section {
    background: linear-gradient(140deg, var(--berry-red) 0%, #F04E6C 55%, var(--berry-pink) 100%);
    color: var(--white);
    text-align: center;
    padding: var(--sp-7) var(--sp-4);
}

.hero-logo {
    max-width: min(686px, 92vw);
    width: auto;
    max-height: 528px;
    height: auto;
    object-fit: contain;
    margin-bottom: var(--sp-4);
    filter: drop-shadow(0 10px 15px rgba(0, 0, 0, 0.2));
}

.hero-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.28em;
    font-size: var(--fs-sm);
    font-weight: 700;
    opacity: 0.9;
    margin-bottom: var(--sp-2);
}

.exito-frase {
    font-size: var(--fs-hero);
    font-weight: 700;
    line-height: 1.35;
    max-width: 780px;
    margin: 0 auto var(--sp-5);
    letter-spacing: -0.01em;
    text-wrap: balance;
}

.hero-actions {
    display: flex;
    gap: var(--sp-3);
    justify-content: center;
    flex-wrap: wrap;
}

/* ==========================================================================
   Botones
   ========================================================================== */

.btn-primary, .btn-whatsapp, .btn-submit, .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 0.9rem 1.9rem;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--fs-base);
    text-align: center;
    border: none;
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}

.btn-primary {
    background-color: var(--berry-red);
    color: var(--white);
    margin: var(--sp-4) auto 0;
    display: flex;
    width: fit-content;
}

.btn-hero {
    background: var(--white);
    color: var(--berry-red);
    margin: 0;
}

.btn-outline {
    background: transparent;
    color: var(--white);
    border: 2px solid rgba(255, 255, 255, 0.7);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--white);
}

.btn-dark {
    background-color: var(--dark-text);
}

.btn-whatsapp {
    background-color: var(--whatsapp-green);
    color: var(--white);
    width: 100%;
    margin-top: var(--sp-3);
    font-size: var(--fs-sm);
}

.btn-submit {
    background-color: var(--berry-red);
    color: var(--white);
}

.btn-submit.dark-btn {
    background-color: var(--dark-text);
}

.btn-primary:hover, .btn-whatsapp:hover, .btn-submit:hover, .btn-hero:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active, .btn-whatsapp:active, .btn-submit:active {
    transform: translateY(0);
}

/* ==========================================================================
   Delivery
   ========================================================================== */

.delivery-grid {
    display: flex;
    justify-content: center;
    gap: var(--sp-4);
    flex-wrap: wrap;
}

.delivery-card {
    background: var(--white);
    padding: var(--sp-5);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    text-align: center;
    text-decoration: none;
    color: var(--dark-text);
    box-shadow: var(--shadow-sm);
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
    flex: 1 1 220px;
    max-width: 280px;
}

.delivery-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.delivery-card img {
    width: 100%;
    max-width: 150px;
    height: auto;
    border-radius: var(--radius-sm);
    margin-bottom: var(--sp-3);
}

.delivery-fallback {
    display: block;
    font-size: var(--fs-lg);
    color: var(--berry-red);
    margin-bottom: var(--sp-3);
}

.delivery-card span {
    display: block;
    font-weight: 500;
    color: var(--muted-text);
    font-size: var(--fs-sm);
}

/* ==========================================================================
   Promociones y Menú
   ========================================================================== */

.promo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}

.promo-box img {
    width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: block;
}

/* ==========================================================================
   Cards (Ubicaciones, Historia, Formularios)
   ========================================================================== */

.ubicaciones-grid, .contacto-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
    gap: var(--sp-4);
}

/* Tarjetas de filosofía: siempre centradas, incluso en filas incompletas */
.historia-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--sp-4);
}

.historia-grid .historia-card {
    flex: 1 1 280px;
    max-width: 360px;
}

/* Texto de Nuestra Historia */
.historia-texto {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: clamp(var(--sp-4), 3vw, var(--sp-5));
    max-width: 860px;
    margin: 0 auto;
    text-align: left;
}

.historia-texto p + p {
    margin-top: var(--sp-3);
}

/* Formato del documento de Nuestra Historia */
.historia-lema {
    text-align: center !important;
    font-size: var(--fs-md);
    margin-bottom: var(--sp-3);
}

.historia-subtitulo {
    color: var(--berry-red) !important;
    font-size: var(--fs-md);
    font-weight: 700;
    margin: var(--sp-6) 0 var(--sp-3);
}

/* Textos dentro de cajas visuales: justificados al ancho de su contenedor */
.historia-texto p,
.info-franquicia p,
.historia-card p {
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
}

/* Facturación */
.facturacion-section {
    text-align: center;
}

.sucursal-card, .historia-card, .form-container {
    background: var(--white);
    padding: clamp(var(--sp-4), 3vw, var(--sp-5));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: box-shadow var(--dur) var(--ease);
}

.sucursal-card:hover, .historia-card:hover {
    box-shadow: var(--shadow-md);
}

.historia-card h3 {
    color: var(--berry-red);
}

.map-link {
    display: inline-block;
    color: var(--berry-red);
    font-weight: 500;
    text-decoration: none;
    margin: var(--sp-2) 0;
    border-bottom: 1px solid currentColor;
}

/* ==========================================================================
   Formularios
   ========================================================================== */

form {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    margin-top: var(--sp-4);
    text-align: left;
}

.field-label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--muted-text);
    margin-bottom: calc(-1 * var(--sp-2));
}

input, select, textarea {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    font-family: inherit;
    background: var(--white);
    color: var(--dark-text);
    transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--berry-red);
    box-shadow: 0 0 0 3px rgba(227, 24, 55, 0.12);
}

textarea {
    resize: vertical;
    min-height: 110px;
}

.contacto-logo {
    width: auto;
    max-width: clamp(90px, 15vw, 150px);
    max-height: 110px;
    height: auto;
    object-fit: contain;
    margin: 0 auto var(--sp-3);
    display: block;
}

/* ==========================================================================
   Franquicias
   ========================================================================== */

.franquicias-section {
    background: linear-gradient(160deg, var(--berry-pink) 0%, #FF9DB4 100%);
    color: var(--white);
    padding: var(--sp-7) var(--sp-4);
}

.franquicias-section .container {
    padding-top: 0;
    padding-bottom: 0;
}

.franquicias-section h2 {
    color: var(--white);
}

.franquicia-highlight {
    font-size: var(--fs-md);
    text-align: center;
    font-weight: 700;
    font-style: italic;
    max-width: 720px;
    margin: 0 auto var(--sp-5);
    text-wrap: balance;
}

.info-franquicia {
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    border-radius: var(--radius-lg);
    padding: clamp(var(--sp-4), 3vw, var(--sp-5));
    max-width: 860px;
    margin: 0 auto var(--sp-4);
}

.form-franquicia {
    color: var(--dark-text);
    margin: var(--sp-5) auto 0;
    max-width: 640px;
}

/* ==========================================================================
   Carrusel de Galería
   ========================================================================== */

.carousel-container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    background: var(--white);
}

.carousel-track {
    display: flex;
    transition: transform 0.6s var(--ease);
}

.carousel-slide {
    min-width: 100%;
    aspect-ratio: 8 / 5;
    height: auto;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--dur-slow) var(--ease);
}

.carousel-slide.loaded {
    opacity: 1;
}

.carousel-empty {
    width: 100%;
    text-align: center;
    padding: var(--sp-6) var(--sp-4);
    color: var(--muted-text);
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    background: var(--white);
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
    border-top: 1px solid var(--border);
}

.footer-logo {
    height: 64px;
    width: auto;
    object-fit: contain;
    margin-bottom: var(--sp-3);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    font-size: var(--fs-sm);
}

.footer-links a {
    color: var(--dark-text);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--berry-red);
}

.social-icons {
    margin: var(--sp-4) 0;
    display: flex;
    justify-content: center;
    gap: var(--sp-3);
}

.social-icons a {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 45px;
    height: 45px;
    background-color: var(--berry-pink);
    color: var(--white);
    border-radius: 50%;
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.social-icons a:hover {
    background-color: var(--berry-red);
    transform: translateY(-2px);
}

.footer-copy {
    font-size: var(--fs-sm);
    color: var(--muted-text);
}

/* ==========================================================================
   Animaciones de entrada (Intersection Observer)
   ========================================================================== */

.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}

.reveal.in-view {
    opacity: 1;
    transform: none;
}

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

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet: el nav completo ya no cabe cómodo */
@media (max-width: 1024px) {
    .nav-links {
        gap: var(--sp-3);
    }
}

/* Móvil / tablet vertical */
@media (max-width: 860px) {
    .menu-toggle {
        display: flex;
    }

    .nav-links {
        position: fixed;
        top: 0;
        right: 0;
        height: 100dvh;
        width: min(320px, 85vw);
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 0;
        padding: calc(var(--nav-height) + var(--sp-4)) var(--sp-4) var(--sp-5);
        background-color: var(--white);
        box-shadow: var(--shadow-lg);
        transform: translateX(100%);
        transition: transform var(--dur) var(--ease);
        z-index: 950;
        overflow-y: auto;
    }

    .nav-links.active {
        transform: translateX(0);
    }

    .nav-links li {
        border-bottom: 1px solid var(--border);
    }

    .nav-links a {
        display: block;
        padding: var(--sp-3) var(--sp-1);
        font-size: var(--fs-md);
    }

    .nav-links a::after {
        display: none;
    }

    /* El botón hamburguesa queda por encima del panel */
    .menu-toggle {
        position: relative;
        z-index: 960;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: var(--sp-3);
        padding-right: var(--sp-3);
    }

    .hero-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary, .btn-outline {
        width: 100%;
    }

    .sucursal-card, .historia-card, .form-container {
        padding: var(--sp-4);
    }
}
