/* Cabecera pública: una sola definición para geometría, menú y breakpoints. */
.site-header {
    --header-nav-height: 88px;
    --header-brand-width: max(300px, 20vw);
    --header-cut: 40px;
    position: fixed;
    inset: 0 0 auto;
    z-index: 100;
    height: var(--header-height);
    color: var(--white);
    pointer-events: none;
}

.header-backdrop {
    position: absolute;
    z-index: 1;
    inset: 0;
    filter: drop-shadow(0 2px 0 var(--cyan-500));
}

/* El borde sigue el recorte del fondo; no afecta a menús ni a las migas. */
.header-backdrop::before {
    position: absolute;
    inset: 0;
    content: "";
    background: rgb(24 49 88);
    clip-path: polygon(0 0, 100% 0, 100% var(--header-nav-height), calc(var(--header-brand-width) + var(--header-cut)) var(--header-nav-height), var(--header-brand-width) 100%, 0 100%);
}

.main-content:has(> .hero-carousel, > .product-banner) { padding-top: 0; }

.header-inner {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(270px, 1fr) auto auto;
    align-items: start;
    gap: 42px;
    width: 95%;
    height: 100%;
    padding-left: max(24px, calc((19vw - 250px) / 2));
}

.header-breadcrumb-slot {
    position: absolute;
    z-index: 0;
    top: var(--header-nav-height);
    right: 0;
    left: var(--header-brand-width);
    display: flex;
    height: calc(var(--header-height) - var(--header-nav-height));
    align-items: center;
    padding: 0 24px 0 calc(var(--header-cut) + 16px);
    color: var(--muted);
    background: var(--surface);
    clip-path: polygon(var(--header-cut) 0, 100% 0, 100% 100%, 0 100%);
    pointer-events: auto;
}

.header-breadcrumb-slot .breadcrumb {
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 5px 0;
    font-size: .85rem;
}

.header-breadcrumb-slot .breadcrumb a { color: var(--blue-800); text-decoration: none; }

.brand {
    display: flex;
    width: 250px;
    height: var(--header-height);
    align-items: center;
    pointer-events: auto;
}
.brand img { width: 100%; height: auto; }
.brand-mobile, .menu-toggle, .mobile-language-switches { display: none; }

.primary-navigation {
    display: flex;
    align-items: center;
    gap: 26px;
    height: var(--header-nav-height);
    pointer-events: auto;
}
.primary-navigation > a,
.products-navigation > a,
.products-navigation > button {
    display: flex;
    align-items: center;
    min-height: 54px;
    padding: 12px 0;
    gap: 7px;
    border: 0;
    color: var(--surface);
    /* El fondo explicito permite que los analizadores de contraste no tengan
       que inferir el color situado detras del recorte de la cabecera. */
    background: rgb(24 49 88);
    font-size: 20px;
    font-weight: 600;
    text-decoration: none;
    text-transform: uppercase;
    white-space: nowrap;
    cursor: pointer;
    transition: color var(--motion-normal) ease;
}
.primary-navigation > a.active,
.products-navigation > a.active { color: var(--cyan-100); }
.primary-navigation > a:hover,
.products-navigation > a:hover,
.products-navigation > button:hover { color: var(--cyan-200); }
.products-navigation { position: relative; z-index: 3; display: flex; align-items: center; }
.products-link { flex: 0 0 auto; }
.products-toggle { min-width: 32px; justify-content: center; }
/* Chevrón de 9 px con trazo de 2 px (antes, triángulo de 6 × 4 px casi invisible); gira al abrir. */
.products-caret { display: inline-block; width: 9px; height: 9px; margin: -5px 0 0 4px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform var(--motion-fast) ease; }
.products-toggle[aria-expanded="true"] .products-caret { margin-top: 5px; transform: rotate(-135deg); }
.products-submenu {
    position: absolute;
    top: 100%;
    left: -20px;
    display: grid;
    width: 310px;
    max-width: calc(100vw - 28px);
    padding: 4px 0;
    border-radius: var(--radius-media);
    color: var(--blue-900);
    background: var(--white);
    box-shadow: var(--shadow-raised);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: opacity var(--motion-fast) ease, transform var(--motion-fast) ease;
}
.products-navigation[data-open] .products-submenu {
    opacity: 1;
    visibility: visible;
    transform: none;
}
.products-submenu a {
    padding: 12px 20px;
    font-size: 18px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color var(--motion-fast) ease;
}
.products-submenu a:hover, .products-submenu a:focus-visible { background: rgb(32 55 97 / 10%); }
/* Selector de idioma copiado de piero.lindis.net: bandera de 24 × 16 con código; el actual, sin enlace. */
.language-navigation {
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--header-nav-height);
    color: var(--surface);
    font-size: 14px;
    pointer-events: auto;
}
.language-navigation a,
.language-navigation .language-current { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; color: inherit; text-decoration: none; }
/* Fondo explícito, como en el menú: los analizadores de contraste no deben inferir el recorte de la cabecera. */
.language-navigation a,
.language-navigation .language-current,
.language-navigation .language-separator { background: rgb(24 49 88); }
.language-navigation a:is(:hover, :focus-visible) { opacity: .8; }
.language-navigation img,
.mobile-language-switch img { flex: 0 0 auto; width: 24px; height: 16px; border: 1px solid rgb(255 255 255 / 45%); }

@media (min-width: 901px) and (max-width: 1200px) {
    .site-header { --header-brand-width: 300px; }
    .header-inner { grid-template-columns: minmax(250px, 1fr) auto auto; gap: 20px; width: 97%; padding-left: 20px; }
    .primary-navigation { gap: 17px; }
    .primary-navigation > a, .products-navigation > a, .products-navigation > button { font-size: 17px; }
}
/* Entre 901 y 1100 no caben los códigos: solo banderas, como en móvil no cabría la lista entera. */
@media (min-width: 901px) and (max-width: 1100px) {
    .primary-navigation { gap: 12px; }
    .language-navigation { gap: 8px; }
    .language-navigation .language-separator { display: none; }
    .language-navigation a > span:not(.visually-hidden),
    .language-navigation .language-current > span:not(.visually-hidden) { display: none; }
}


@media (max-width: 900px) {
    :root { --header-height: 65px; }
    .site-header { background: var(--surface); color: var(--blue-900); box-shadow: 0 1px 4px rgb(0 0 0 / 18%); }
    .header-backdrop { display: none; }
    .main-content:has(> .hero-carousel, > .product-banner) { padding-top: var(--header-height); }
    .site-header-with-breadcrumb { height: calc(var(--header-height) + 34px); }
    .site-header-with-breadcrumb + .main-content { padding-top: calc(var(--header-height) + 34px); }
    .header-inner { grid-template-columns: 1fr auto 1fr; width: 100%; height: var(--header-height); gap: 0; align-items: center; padding-inline: 12px; }
    .header-breadcrumb-slot {
        top: var(--header-height);
        right: 0;
        left: 0;
        height: 34px;
        padding-inline: 16px;
        border-top: 1px solid var(--line);
        border-bottom: 2px solid var(--cyan-500);
        clip-path: none;
    }
    .header-breadcrumb-slot .breadcrumb { font-size: .78rem; }
    .brand { grid-column: 2; grid-row: 1; justify-self: center; width: 90px; height: 65px; }
    .brand-desktop { display: none; }
    .brand-mobile { display: block; }
    .menu-toggle {
        display: grid;
        width: 44px;
        height: 44px;
        padding: 0;
        place-items: center;
        color: var(--blue-950);
        border: 0;
        background: transparent;
        pointer-events: auto;
        cursor: pointer;
        grid-column: 1;
        grid-row: 1;
        justify-self: start;
    }
    .mobile-language-switches { grid-column: 3; grid-row: 1; justify-self: end; display: flex; gap: 4px; pointer-events: auto; }
    .mobile-language-switch { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 52px; min-height: 44px; color: var(--blue-950); font-size: .85rem; font-weight: 600; text-decoration: none; }
    .mobile-language-switch img { border-color: rgb(0 0 0 / 20%); }
    @media (max-width: 360px) { .mobile-language-switch { min-width: 44px; gap: 3px; } }
    .menu-toggle-lines, .menu-toggle-lines::before, .menu-toggle-lines::after { display: block; width: 20px; height: 2px; background: currentColor; content: ""; transition: transform var(--motion-fast) ease; }
    .menu-toggle-lines { position: relative; }
    .menu-toggle-lines::before, .menu-toggle-lines::after { position: absolute; left: 0; }
    .menu-toggle-lines::before { transform: translateY(-6px); }
    .menu-toggle-lines::after { transform: translateY(6px); }
    .menu-toggle[aria-expanded="true"] .menu-toggle-lines { background: transparent; }
    .menu-toggle[aria-expanded="true"] .menu-toggle-lines::before { transform: rotate(45deg); }
    .menu-toggle[aria-expanded="true"] .menu-toggle-lines::after { transform: rotate(-45deg); }
    .primary-navigation {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        display: none;
        height: auto;
        max-height: calc(100dvh - var(--header-height));
        overflow-y: auto;
        overscroll-behavior: contain;
        align-items: stretch;
        flex-direction: column;
        gap: 0;
        padding: 8px 24px 18px;
        background: var(--blue-900);
        box-shadow: var(--shadow);
        z-index: 3;
    }
    .primary-navigation[data-open] { display: flex; }
    .primary-navigation > a, .products-navigation > a, .products-navigation > button { width: 100%; padding: 13px 8px; min-height: 48px; border-bottom: 1px solid rgb(255 255 255 / 18%); text-align: left; font-size: 18px; }
    .products-navigation { display: grid; grid-template-columns: minmax(0, 1fr) 48px; align-items: stretch; }
    .products-toggle { padding-inline: 0; }
    .products-submenu { grid-column: 1 / -1; position: static; display: none; width: 100%; max-width: none; box-shadow: none; background: var(--blue-950); color: var(--white); border-radius: var(--radius-control); }
    .products-navigation[data-open] .products-submenu { display: grid; }
    .products-submenu a:hover { background: var(--blue-800); }
    .language-navigation { display: none; }
}

/* Sin JavaScript, navegación y submenú siguen disponibles por foco/hover.
   data-js lo pone early.js en <head>, antes del primer pintado (evita el salto del menú móvil). */
html:not([data-js]) .products-navigation:is(:hover, :focus-within) .products-submenu { opacity: 1; visibility: visible; transform: none; display: grid; }
@media (max-width: 900px) {
    html:not([data-js]) .site-header { position: relative; height: auto; }
    html:not([data-js]) .header-inner { height: auto; min-height: 65px; }
    html:not([data-js]) .primary-navigation { position: static; display: flex; grid-column: 1 / -1; max-height: none; }
    html:not([data-js]) .products-navigation { grid-template-columns: 1fr; }
    html:not([data-js]) .products-toggle { display: none; }
    html:not([data-js]) .products-submenu { display: grid; opacity: 1; visibility: visible; transform: none; }
    html:not([data-js]) .menu-toggle { display: none; }
    html:not([data-js]) .main-content { padding-top: 0; }
    html:not([data-js]) .header-breadcrumb-slot { position: static; }
}

@media print {
    .site-header { position: relative; }
    .main-content { padding-top: 0; }
}
