/* ==================================================================
   Machala GPS — Header
   Barra "isla" flotante (despegada de los bordes, esquinas píldora)
   con dropdown de Productos y menú móvil flotante (drawer + overlay).
   ================================================================== */

/* Envoltorio transparente: aporta la separación del borde superior */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-header);
    padding-block: var(--header-gap);
    padding-inline: var(--header-gap);
}

/* La isla: píldora clay con desenfoque, siempre flotante */
.site-header__inner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: var(--header-height-mobile);
    padding-inline: clamp(0.9rem, 2vw, 1.5rem);
    border-radius: var(--radius-pill);
    background-color: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(12px) saturate(160%);
    backdrop-filter: blur(12px) saturate(160%);
    box-shadow:
        0 2px 6px rgba(16, 42, 102, 0.07),
        0 14px 34px -10px rgba(16, 42, 102, 0.2),
        inset 0 1.5px 0 rgba(255, 255, 255, 0.95);
    transition: box-shadow var(--dur-base) var(--ease-out);
}

/* Con scroll la isla se asienta con una sombra más profunda */
.site-header.is-scrolled .site-header__inner {
    box-shadow:
        0 3px 8px rgba(16, 42, 102, 0.09),
        0 20px 44px -12px rgba(16, 42, 102, 0.3),
        inset 0 1.5px 0 rgba(255, 255, 255, 0.95);
}

@media (min-width: 1024px) {
    .site-header__inner {
        height: var(--header-height);
    }
}

/* ---------- Logo ---------- */

.site-header__brand {
    display: inline-flex;
    flex-shrink: 0;
}

.site-header__logo {
    height: 2.125rem;
    width: auto;
}

@media (min-width: 1024px) {
    .site-header__logo {
        height: 2.5rem;
    }
}

/* Doble logo: por defecto se ve la versión azul */
.site-header__logo--light {
    display: none;
}

/* La isla es blanca en todas las páginas: el logo azul se usa siempre
   (la variante clara del markup queda oculta por defecto). */

/* ---------- Navegación de escritorio ---------- */

.site-nav {
    display: none;
}

@media (min-width: 1024px) {
    .site-nav {
        display: block;
        margin-inline: auto;
    }
}

.site-nav__list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.site-nav__item {
    position: relative;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.9rem;
    border: 0;
    border-radius: var(--radius-pill);
    background-color: transparent;
    color: var(--c-text);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition:
        color var(--dur-fast) ease,
        background-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
    .site-nav__link:hover {
        color: var(--c-navy);
        background-color: rgba(30, 79, 204, 0.07);
    }
}

.site-nav__link[aria-current="page"] {
    color: var(--c-blue-600);
    font-weight: 700;
    background-color: rgba(30, 79, 204, 0.08);
}

.site-nav__chevron {
    transition: transform 200ms var(--ease-out);
}

.site-nav__trigger[aria-expanded="true"] .site-nav__chevron {
    transform: rotate(180deg);
}

/* ---------- Dropdown de Productos ---------- */

.dropdown {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    min-width: 19rem;
    padding: 0.5rem;
    border-radius: var(--radius-lg);
    background-color: var(--c-surface);
    box-shadow: var(--shadow-clay);
    transform: translateX(-50%) translateY(6px) scale(0.97);
    transform-origin: top center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
        opacity 180ms var(--ease-out),
        transform 180ms var(--ease-out),
        visibility 0s linear 180ms;
}

/* Puente invisible para no perder el hover entre trigger y panel */
.dropdown::before {
    content: "";
    position: absolute;
    top: -12px;
    left: 0;
    right: 0;
    height: 12px;
}

.dropdown.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
    transition:
        opacity 180ms var(--ease-out),
        transform 180ms var(--ease-out);
}

.dropdown__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown__link {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
    .dropdown__link:hover {
        background-color: var(--c-bg);
    }
}

.dropdown__title {
    color: var(--c-navy);
    font-size: 0.9375rem;
    font-weight: 700;
}

.dropdown__desc {
    color: var(--c-text-soft);
    font-size: 0.8125rem;
}

/* ---------- Acciones (CTA + hamburguesa) ---------- */

.site-header__actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    margin-left: auto;
}

@media (max-width: 599px) {
    /* En móviles pequeños el CTA vive dentro del drawer.
       Doble clase para ganar especificidad sobre .btn (components.css). */
    .site-header__actions .site-header__cta {
        display: none;
    }
}

.site-header__toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    background-color: var(--c-surface);
    box-shadow: var(--shadow-clay-sm);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-out);
}

.site-header__toggle:active {
    transform: scale(0.94);
}

@media (min-width: 1024px) {
    .site-header__toggle {
        display: none;
    }
}

.site-header__toggle-line {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background-color: var(--c-navy);
    transition: transform 220ms var(--ease-out);
}

.site-header__toggle[aria-expanded="true"] .site-header__toggle-line:nth-child(1) {
    transform: translateY(3.5px) rotate(45deg);
}

.site-header__toggle[aria-expanded="true"] .site-header__toggle-line:nth-child(2) {
    transform: translateY(-3.5px) rotate(-45deg);
}

/* ---------- Overlay del menú móvil ---------- */

.drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background-color: rgba(8, 20, 51, 0.45);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 280ms ease,
        visibility 0s linear 280ms;
}

.drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 280ms ease;
}

/* ---------- Drawer lateral (menú móvil) ---------- */

/* Panel flotante: despegado de los bordes, esquinas generosas */
.drawer {
    position: fixed;
    top: var(--header-gap);
    right: var(--header-gap);
    bottom: var(--header-gap);
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    width: min(21.5rem, calc(100vw - var(--header-gap) * 2));
    padding: 1.25rem 1.5rem 1.5rem;
    border-radius: var(--radius-lg);
    background-color: #ffffff;
    box-shadow:
        0 30px 70px rgba(8, 20, 51, 0.4),
        inset 0 1.5px 0 rgba(255, 255, 255, 0.95);
    transform: translateX(calc(100% + var(--header-gap) * 2));
    visibility: hidden;
    transition:
        transform var(--dur-slow) var(--ease-drawer),
        visibility 0s linear var(--dur-slow);
}

.drawer.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform var(--dur-slow) var(--ease-drawer);
}

/* Bloqueo de scroll del documento con el drawer abierto */
html.has-drawer,
html.has-drawer body {
    overflow: hidden;
}

.drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
}

.drawer__logo {
    height: 1.875rem;
    width: auto;
}

.drawer__close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 13px;
    background-color: var(--c-surface);
    color: var(--c-navy);
    box-shadow: var(--shadow-clay-sm);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease-out);
}

.drawer__close:active {
    transform: scale(0.94);
}

.drawer__nav {
    flex: 1;
    overflow-y: auto;
    padding-block: 0.5rem;
}

.drawer__list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Entrada escalonada de los ítems al abrir el drawer */
.drawer.is-open .drawer__item {
    animation: drawer-item-in 320ms var(--ease-out) both;
    animation-delay: calc(60ms + var(--stagger, 0) * 40ms);
}

@keyframes drawer-item-in {
    from {
        opacity: 0;
        transform: translateX(16px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.drawer__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.8rem 1rem;
    border: 0;
    border-radius: 14px;
    background-color: transparent;
    color: var(--c-navy);
    font-size: 1.0625rem;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background-color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
    .drawer__link:hover {
        background-color: rgba(30, 79, 204, 0.06);
    }
}

.drawer__link[aria-current="page"] {
    color: var(--c-blue-600);
    background-color: rgba(30, 79, 204, 0.07);
}

.drawer__chevron {
    transition: transform 200ms var(--ease-out);
}

.drawer__accordion-trigger[aria-expanded="true"] .drawer__chevron {
    transform: rotate(180deg);
}

/* Acordeón animable sin tocar height (grid-template-rows 0fr → 1fr) */
.drawer__accordion {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 280ms var(--ease-out);
}

.drawer__accordion.is-open {
    grid-template-rows: 1fr;
}

.drawer__sublist {
    overflow: hidden;
    list-style: none;
    min-height: 0;
    padding-left: 0.75rem;
}

.drawer__sublink {
    display: block;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--c-text);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--dur-fast) ease, color var(--dur-fast) ease;
}

@media (hover: hover) and (pointer: fine) {
    .drawer__sublink:hover {
        color: var(--c-navy);
        background-color: rgba(30, 79, 204, 0.06);
    }
}

.drawer__footer {
    padding-top: 1.15rem;
    border-top: 1px solid rgba(16, 42, 102, 0.08);
}

/* Contactos rápidos sobre el CTA */
.drawer__contact {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.drawer__contact-link {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    background-color: #f2f6fd;
    text-decoration: none;
    transition:
        background-color var(--dur-fast) ease,
        transform var(--dur-fast) var(--ease-out);
}

.drawer__contact-link:active {
    transform: scale(0.97);
}

.drawer__contact-label {
    color: var(--c-text-soft);
    font-size: 0.71875rem;
    font-weight: 600;
}

.drawer__contact-value {
    color: var(--c-navy);
    font-size: 0.875rem;
    font-weight: 800;
    white-space: nowrap;
}

.drawer__cta {
    width: 100%;
}
