/* Tipografías: se cargan con <link> en el <head> de cada página (preconnect + una sola petición) */

/* ── Header Nature's Green — Premium Orgánico ──────── */
html, body {
    overflow-x: clip !important;
}

#header-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    /* Reserva la altura del header desktop mientras header.js lo inyecta,
       para que el contenido no salte al aparecer (CLS). En móvil el header
       real es más alto y este mínimo no afecta. */
    min-height: 80px;
}

.main-header {
    position: relative;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 36px;
    height: 80px;
    gap: 0;

    background: linear-gradient(-45deg, #163628, #224c24, #2d6b31, #1b4332);

    border-bottom: 1px solid rgba(168, 230, 163, 0.12);
    box-shadow: 0 1px 0 rgba(168, 230, 163, 0.06), 0 4px 24px rgba(0, 0, 0, 0.25);
    transition: box-shadow .3s ease;
}

/* Animación compuesta (transform) en un pseudo-elemento ancho: antes el
   header animaba background-position y forzaba repintado continuo (H-24).
   El pseudo sobresale a los lados y se mueve dentro de ese margen, por lo
   que nunca deja huecos ni tapa el contenido. */
@keyframes flowGradient {
    0%   { transform: translate3d(-8%, 0, 0); }
    50%  { transform: translate3d(8%, 0, 0); }
    100% { transform: translate3d(-8%, 0, 0); }
}

/* Todos los hijos directos por encima de la capa animada */
.main-header > * {
    position: relative;
    z-index: 1;
}

/* Desktop: logo izq | nav ocupa el espacio | carrito | contacto al final */
@media (min-width: 641px) {
    .header-logo {
        order: 1;
    }

    .header-nav {
        order: 2;
        flex: 1;
        justify-content: flex-end;
    }

    .cart-btn {
        order: 3;
        margin-left: 6px;
    }

    .header-search {
        order: 4;
        margin-left: 12px;
    }

    .header-hamburger {
        order: 5;
    }
}

/* Textura sutil de fondo + capa animada (composited) */
.main-header::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -15%;
    right: -15%;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(61, 139, 64, 0.18) 0%, transparent 70%),
        linear-gradient(-45deg, #163628, #224c24, #2d6b31, #1b4332);
    background-size: 100% 100%, 130% 100%;
    background-position: 0 0, 50% 50%;
    animation: flowGradient 12s ease infinite;
    pointer-events: none;
}

.main-header.header-scrolled {
    background: rgba(30, 68, 32, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 32px rgba(0, 0, 0, 0.35);
}

.main-header.header-scrolled::before {
    animation: none; /* sin animación al hacer scroll (ahorra batería) */
    background: transparent;
}

/* ── Logo ─────────────────────────────────────────── */
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.header-logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #3d8b40 0%, #5aad5e 100%);
    box-shadow: 0 2px 10px rgba(61, 139, 64, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    transition: transform .2s ease, box-shadow .2s ease;
}

.header-logo:hover .header-logo-icon {
    transform: rotate(-5deg) scale(1.05);
    box-shadow: 0 4px 16px rgba(61, 139, 64, 0.55);
}

.header-logo-icon svg {
    color: #ffffff;
}

.header-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.header-logo-name {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 600;
    color: #e5e5e5;
    letter-spacing: 0.02em;
}

.header-logo-tagline {
    font-family: 'Outfit', sans-serif;
    font-size: 0.6rem;
    font-weight: 500;
    color: rgba(168, 230, 163, 0.7);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── Nav ──────────────────────────────────────────── */
.header-nav {
    display: flex;
    align-items: center;
    gap: 1px;
    overflow-x: auto;
    scrollbar-width: none;
    position: relative;
    z-index: 1;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-size: .82rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
    transition: background .2s ease, color .2s ease, transform .15s ease;
    position: relative;
}

.nav-link i {
    font-size: .72rem;
    opacity: .8;
    transition: opacity .2s ease, transform .2s ease;
}

.nav-link:hover,
.nav-link--active {
    background: rgba(255, 255, 255, 0.09);
    color: #c8f0c4;
    transform: translateY(-1px);
}

.nav-link:hover i,
.nav-link--active i {
    opacity: 1;
    transform: scale(1.15);
}

/* Pill de promociones */
.nav-link--promo {
    background: linear-gradient(135deg, rgba(255, 183, 0, 0.18) 0%, rgba(255, 140, 0, 0.12) 100%);
    border: 1px solid rgba(255, 183, 0, 0.3);
    color: #ffd166;
    margin-right: 4px;
}

.nav-link--promo i {
    color: #ffd166;
    opacity: 1;
}

.nav-link--promo:hover,
.nav-link--promo.nav-link--active {
    background: linear-gradient(135deg, rgba(255, 183, 0, 0.28) 0%, rgba(255, 140, 0, 0.2) 100%);
    color: #ffe08a;
    border-color: rgba(255, 183, 0, 0.5);
}

/* Separador vertical */
.nav-separator {
    width: 1px;
    height: 18px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 6px;
    flex-shrink: 0;
}

/* ── Buscador ─────────────────────────────────────── */
.header-search {
    display: flex;
    align-items: center;
    background: #f4f7f4;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 0;
    overflow: hidden;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    height: 38px;
    z-index: 1;
}

.header-search:focus-within {
    background: #ffffff;
    border-color: #a8e6a3;
    box-shadow: 0 0 0 3px rgba(168, 230, 163, 0.3);
}

.header-search input {
    background: transparent;
    border: none;
    color: #1a3d1c;
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    padding: 0 12px;
    width: 140px;
    outline: none;
    transition: width 0.3s ease;
}

.header-search input::placeholder {
    color: rgba(26, 61, 28, 0.5);
}

.header-search input:focus {
    width: 180px;
}

.header-search button {
    background: transparent;
    border: none;
    color: #224c24;
    padding: 0 12px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.header-search button:hover {
    color: #3d8b40;
}

/* ── Botón Flotante WhatsApp ────────────────────────── */
.floating-wa {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    text-decoration: none;
    z-index: 9999;
}

.floating-wa-msg {
    background: #ffffff;
    color: #1a3d1c;
    padding: 10px 16px;
    border-radius: 18px 18px 4px 18px; /* Burbuja de chat */
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(37, 211, 102, 0.2);
    transition: transform 0.2s ease, opacity 0.2s ease;
    margin-bottom: 6px;
}

.floating-wa:hover .floating-wa-msg {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.floating-wa-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #25d366 0%, #1da851 100%);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 4px 18px rgba(37, 211, 102, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.floating-wa:hover .floating-wa-icon {
    transform: scale(1.08);
    box-shadow: 0 6px 22px rgba(37, 211, 102, 0.55);
}

@media (max-width: 640px) {
    .floating-wa {
        bottom: 16px;
        right: 16px;
    }
    .floating-wa-msg {
        display: none; /* Ocultar texto en móviles para no estorbar */
    }
    .floating-wa-icon {
        width: 50px;
        height: 50px;
        font-size: 1.6rem;
    }
}

/* ── Botón Carrito ────────────────────────────────── */
.cart-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    flex-shrink: 0;
    transition: background .2s ease, color .2s ease, transform .15s ease;
    z-index: 1;
}

.cart-btn:hover {
    background: rgba(255, 255, 255, 0.09);
    color: #c8f0c4;
    transform: translateY(-1px);
}

.cart-btn svg {
    flex-shrink: 0;
}

/* Badge rojo con el número de items */
.cart-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 99px;
    background: #e53e3e;
    color: #ffffff;
    font-family: 'Outfit', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 17px;
    text-align: center;
    display: none;
    /* oculto cuando está en 0 */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.cart-badge.visible {
    display: block;
}

/* ── Hamburguesa ──────────────────────────────────── */
.header-hamburger {
    display: none !important;
}

/* ════════════════════════════════════════════════════
   MOBILE  ≤ 640px  —  Layout 2 filas
   Fila 1: Logo | Carrito | Contacto
   Fila 2: Nav chips scrollable
════════════════════════════════════════════════════ */
@media (max-width: 640px) {

    .main-header {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 14px 0;
        gap: 0;
        align-items: center;
    }

    /* ── Fila 1 ── */
    .header-logo {
        order: 1;
        flex: 0 1 auto;
    }

    /* Buscador en el medio (entre logo y carrito) */
    .header-search {
        order: 2;
        flex: 1;
        margin: 0 8px;
        height: 34px;
        width: auto;
    }

    .header-search input {
        width: 100%;
        padding: 0 8px;
        font-size: 0.8rem;
    }

    .header-search input:focus {
        width: 100%; /* No se expande en mobile para no desbordar */
    }

    .header-search button {
        padding: 0 8px;
    }

    /* Carrito a la derecha del buscador */
    .cart-btn {
        order: 3;
        margin-left: 0;
        width: 34px;
        height: 34px;
    }

    /* ── Fila 2: chips nav ── */
    .header-nav {
        order: 4;
        width: 100%;
        margin: 8px 0 0;
        padding: 0 0 10px;
        gap: 5px;
        flex-wrap: wrap;
        justify-content: flex-start; /* Alineado a los bordes */
    }

    .header-nav::-webkit-scrollbar {
        display: none;
    }

    .header-nav .nav-link {
        padding: 4px 9px;
        font-size: .68rem;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.07);
        border: 1px solid rgba(168, 230, 163, 0.18);
        color: rgba(255, 255, 255, 0.8);
        gap: 4px;
        transform: none;
        flex: 1 0 auto;
        justify-content: center;
    }

    .header-nav .nav-link:hover,
    .header-nav .nav-link:active,
    .header-nav .nav-link--active {
        background: rgba(255, 255, 255, 0.14);
        color: #c8f0c4;
        border-color: rgba(168, 230, 163, 0.4);
        transform: none;
    }

    .header-nav .nav-link--promo {
        background: linear-gradient(135deg, rgba(255, 183, 0, 0.2) 0%, rgba(255, 140, 0, 0.14) 100%);
        border-color: rgba(255, 183, 0, 0.35);
        color: #ffd166;
        margin-right: 0;
    }

    .header-nav .nav-link--promo:hover,
    .header-nav .nav-link--promo.nav-link--active {
        background: linear-gradient(135deg, rgba(255, 183, 0, 0.3) 0%, rgba(255, 140, 0, 0.2) 100%);
        color: #ffe08a;
        border-color: rgba(255, 183, 0, 0.5);
    }

    .header-nav .nav-separator {
        display: none;
    }

    .header-nav .nav-link i {
        font-size: .7rem;
        opacity: .9;
    }
}

/* ── Entre 641px y 900px: layout PC pero más compacto ── */
@media (min-width: 641px) and (max-width: 900px) {
    .main-header {
        padding: 0 16px;
    }

    .header-nav {
        flex: 1;
        justify-content: flex-end;
        padding-right: 4px;
    }

    .header-logo-name {
        font-size: 1rem;
    }

    .header-logo-icon {
        width: 28px;
        height: 28px;
    }

    .nav-link {
        padding: 6px 10px;
        font-size: .8rem;
    }
}

/* ── Accesibilidad: sin animaciones si el usuario lo pide ── */
@media (prefers-reduced-motion: reduce) {
    .main-header::before,
    .nav-link,
    .nav-link i,
    .cart-btn,
    .header-logo-icon,
    .header-search,
    .header-search input,
    .floating-wa-msg,
    .floating-wa-icon {
        animation: none !important;
        transition: none !important;
    }
}