html {
    scrollbar-gutter: stable;
}

[hidden] {
    display: none !important;
}

:root {
    --color-primary: #0a3d62;
    --color-border: #eceff1;
    --bg-white: #ffffff;
    --navbar-background: #102D3A;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
}

body {
    padding: 0;
}

/* Posicionar el header externo conserva el espacio en las páginas internas. */
.navbar-shell {
    position: sticky;
    top: 0;
    z-index: 100;
}

.home-page .navbar-shell {
    position: fixed;
    inset: 0 0 auto;
}

#navbar-container {
    margin: 0;
}

.main-header {
    position: relative;
    display: flex;
    align-items: center;
    min-height: 70px;
    padding: 6px clamp(20px, 5vw, 70px);
    color: #ffffff;
    background-color: var(--navbar-background);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
        'Open Sans', 'Helvetica Neue', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.home-page .main-header:not(.nav-scrolled) {
    background-color: transparent;
    box-shadow: none;
}

.logo-container {
    --logo-height: 54px;
    flex-shrink: 0;
}

.logo-container a {
    position: relative;
    display: block;
    width: calc(var(--logo-height) * 900 / 427);
    height: var(--logo-height);
    overflow: hidden;
    border-radius: 6px;
}

.logo {
    /* Área visible del WebP: x=80, y=76, ancho=900, alto=427 (1046x656). */
    position: absolute;
    left: calc(var(--logo-height) * -80 / 427);
    top: calc(var(--logo-height) * -76 / 427);
    display: block;
    width: auto;
    max-width: none;
    height: calc(var(--logo-height) * 656 / 427);
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    color: inherit;
    background: transparent;
    border: 2px solid currentColor;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.burger-icon {
    width: 22px;
    height: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
}

.bar {
    width: 100%;
    height: 2px;
    background-color: currentColor;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.menu-toggle.active .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.active .bar:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.nav-menu {
    margin-left: auto;
}

.nav-menu ul {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-menu ul li a {
    display: block;
    padding: 10px 13px;
    color: inherit;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-menu a:hover,
.menu-toggle:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

.main-header a:focus-visible,
.menu-toggle:focus-visible {
    outline: 3px solid #5ee0f2;
    outline-offset: 3px;
}

@media (min-width: 901px) {
    .nav-menu {
        display: flex;
        align-self: stretch;
    }

    .nav-menu ul {
        align-items: stretch;
    }

    .nav-menu ul li {
        display: flex;
    }

    .nav-menu ul li a {
        position: relative;
        display: flex;
        align-items: center;
    }

    .nav-menu a[aria-current]::after {
        content: "";
        position: absolute;
        left: 13px;
        right: 13px;
        bottom: -6px;
        height: 2px;
        background-color: #ffffff;
        pointer-events: none;
    }
}

@media (max-width: 900px) {
    .main-header {
        justify-content: space-between;
        min-height: 62px;
        padding: 5px 15px;
    }

    .logo-container {
        --logo-height: 48px;
    }

    .menu-toggle {
        display: flex;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        max-height: 0;
        overflow: hidden;
        visibility: hidden;
        margin-left: 0;
        background-color: var(--navbar-background);
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
        transition: max-height 0.3s ease-in-out, visibility 0.3s,
            background-color 0.3s ease;
    }

    /* Sin soporte de blur se conserva el fondo sólido para asegurar contraste. */
    @supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
        .home-page .main-header:not(.nav-scrolled) .nav-menu {
            background-color: rgba(16, 45, 58, 0.78);
            -webkit-backdrop-filter: blur(8px);
            backdrop-filter: blur(8px);
        }
    }

    .nav-menu.active {
        max-height: min(400px, calc(100dvh - 100%));
        overflow-y: auto;
        visibility: visible;
    }

    .nav-menu ul {
        display: block;
        padding: 4px;
    }

    .nav-menu ul li + li {
        border-top: 1px solid rgba(255, 255, 255, 0.2);
    }

    .nav-menu ul li a {
        padding: 18px 21px;
        border-radius: 0;
        white-space: normal;
    }

    .nav-menu a[aria-current] {
        font-weight: 700;
    }
}

@media (prefers-reduced-motion: reduce) {
    .main-header,
    .menu-toggle,
    .bar,
    .nav-menu,
    .nav-menu ul li a {
        transition: none;
    }
}
