/* Header-critical layout and interaction surfaces */

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--v4-line);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 20px rgba(10, 26, 46, 0.08);
}

.main-header.scrolled {
    box-shadow: 0 12px 28px rgba(10, 26, 46, 0.14);
    background: rgba(255, 255, 255, 0.95);
}

html[data-theme="dark"] .main-header {
    background: rgba(18, 22, 28, 0.92);
    border-bottom-color: var(--v4-line);
    box-shadow: 0 10px 22px rgba(1, 5, 11, 0.4);
}

html[data-theme="dark"] .main-header.scrolled {
    background: rgba(18, 22, 28, 0.96);
    box-shadow: 0 14px 30px rgba(1, 5, 11, 0.5);
}

body.page-home .main-header {
    border-bottom: 1px solid rgba(13, 60, 113, 0.15);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 20px rgba(10, 41, 73, 0.08);
}

body.page-home .main-header.scrolled {
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 10px 24px rgba(10, 41, 73, 0.12);
}

html[data-theme="dark"] body.page-home .main-header {
    background: rgba(18, 22, 28, 0.92);
    border-bottom-color: rgba(188, 201, 216, 0.24);
    box-shadow: 0 8px 22px rgba(2, 8, 16, 0.36);
}

html[data-theme="dark"] body.page-home .main-header.scrolled {
    background: rgba(18, 22, 28, 0.96);
    box-shadow: 0 12px 26px rgba(2, 8, 16, 0.42);
}

.navbar,
.navbar .container {
    height: var(--v4-header-height);
}

.navbar {
    padding: 0;
    background: transparent;
}

.navbar .container {
    width: var(--v4-container);
    padding: 0;
}

.nav-wrapper {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.logo-image {
    width: clamp(160px, 14vw, 220px);
    height: auto;
    filter: brightness(0) saturate(100%);
    transition: transform var(--v4-ease), filter var(--v4-ease);
}

.logo:hover .logo-image {
    transform: scale(1.03);
}

html[data-theme="dark"] .logo-image {
    filter: none;
}

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

.nav-list {
    order: 1;
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-item {
    position: relative;
}

.nav-item.dropdown::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 14px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 42px;
    padding: 0.45rem 0.72rem;
    border-radius: 10px;
    color: #1d2e43;
    text-decoration: none;
    font-size: 0.96rem;
    font-weight: 700;
    font-family: var(--font-sans);
    transition: background var(--v4-ease), color var(--v4-ease), border-color var(--v4-ease);
}

.nav-toggle {
    border: 0;
    background: none;
    cursor: pointer;
    text-align: left;
    appearance: none;
}

.nav-link:hover,
.nav-link.active,
.nav-link:focus-visible {
    background: rgba(39, 94, 156, 0.1);
    color: #123d6d;
}

html[data-theme="dark"] .nav-link {
    color: #e4eaf2;
}

html[data-theme="dark"] .nav-link:hover,
html[data-theme="dark"] .nav-link.active,
html[data-theme="dark"] .nav-link:focus-visible {
    background: rgba(207, 218, 232, 0.12);
    color: #ffffff;
}

body.page-home .nav-link {
    color: #173f6a;
}

body.page-home .nav-link:hover,
body.page-home .nav-link.active,
body.page-home .nav-link:focus-visible {
    color: #0d3c71;
}

html[data-theme="dark"] body.page-home .nav-link {
    color: #e8edf4;
}

html[data-theme="dark"] body.page-home .nav-link:hover,
html[data-theme="dark"] body.page-home .nav-link.active,
html[data-theme="dark"] body.page-home .nav-link:focus-visible {
    color: #ffffff;
}

.dropdown-toggle {
    white-space: nowrap;
}

.dropdown-arrow {
    margin-left: auto;
    font-size: 0.86rem;
    line-height: 1;
    transition: transform var(--v4-ease), opacity var(--v4-ease);
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    left: 0;
    min-width: 240px;
    padding: 0.4rem;
    border-radius: var(--v4-radius-md);
    border: 1px solid var(--v4-line-strong);
    background: var(--v4-surface);
    box-shadow: var(--v4-shadow-md);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity var(--v4-ease), transform var(--v4-ease), visibility var(--v4-ease);
    z-index: 1200;
}

.mega-menu {
    display: flex;
    width: auto;
    min-width: auto;
    max-width: min(1120px, calc(100vw - 2rem));
    padding: 0.9rem;
    gap: 0.8rem;
}

.mega-menu-section {
    min-width: 220px;
    padding: 0.15rem;
}

.mega-menu-3col {
    min-width: 720px;
}

.mega-menu-3col .mega-menu-section {
    flex: 1;
    min-width: 200px;
}

.mega-menu-heading {
    display: inline-flex;
    margin-bottom: 0.5rem;
    text-decoration: none;
}

.mega-menu-heading span,
.mega-menu-heading-text {
    margin: 0;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    line-height: 1.2;
    font-weight: 700;
    color: var(--v4-text);
}

.mega-menu-heading-text {
    display: inline-flex;
    margin-bottom: 0.5rem;
}

.dropdown-menu-simple {
    left: 50%;
    min-width: 280px;
    transform: translate(-50%, 8px);
}

.dropdown-item {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem;
    border-radius: 10px;
    text-decoration: none;
    color: var(--v4-text-soft);
    transition: background var(--v4-ease), color var(--v4-ease);
}

.dropdown-item strong {
    display: block;
    color: var(--v4-text);
    font-size: 0.9rem;
    line-height: 1.25;
}

.dropdown-item small {
    display: block;
    color: var(--v4-text-muted);
    font-size: 0.78rem;
    line-height: 1.35;
    margin-top: 0.14rem;
}

.dropdown-item:hover,
.dropdown-item:focus-visible {
    background: rgba(39, 94, 156, 0.08);
}

.menu-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

html[data-theme="dark"] .dropdown-menu {
    background: var(--v4-surface);
    border-color: var(--v4-line-strong);
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus-visible {
    background: rgba(202, 214, 229, 0.12);
}

.language-switcher-dropdown {
    order: 2;
    position: relative;
    flex-shrink: 0;
}

.lang-dropdown-toggle {
    min-height: 38px;
    min-width: 44px;
    border-radius: 10px;
    border: 1px solid var(--v4-line-strong);
    background: rgba(255, 255, 255, 0.8);
    color: var(--v4-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.26rem;
    padding: 0.45rem 0.7rem;
    cursor: pointer;
}

html[data-theme="dark"] .lang-dropdown-toggle {
    background: rgba(22, 28, 36, 0.9);
    color: var(--v4-text);
}

.lang-chevron {
    transition: transform var(--v4-ease);
}

.language-switcher-dropdown.open .lang-chevron {
    transform: rotate(180deg);
}

.lang-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    min-width: 210px;
    border-radius: var(--v4-radius-md);
    border: 1px solid var(--v4-line-strong);
    background: var(--v4-surface);
    box-shadow: var(--v4-shadow-md);
    padding: 0.3rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--v4-ease), transform var(--v4-ease), visibility var(--v4-ease);
    z-index: 1400;
}

.language-switcher-dropdown.open .lang-dropdown-menu,
.language-switcher-dropdown:hover .lang-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.46rem 0.55rem;
    border-radius: 8px;
    text-decoration: none;
    color: #30465f !important;
    font-size: 0.9rem;
}

.language-switcher-dropdown .lang-option .lang-name,
.language-switcher-dropdown .lang-option .lang-check {
    color: inherit !important;
}

.lang-option:hover,
.lang-option:focus-visible {
    background: rgba(39, 94, 156, 0.08);
    color: #173f6a !important;
}

.lang-option-active {
    background: rgba(39, 94, 156, 0.12);
    color: #173f6a !important;
    font-weight: 700;
}

.lang-name {
    flex: 1;
}

.lang-check {
    color: var(--v4-accent-blue);
}

html[data-theme="dark"] .language-switcher-dropdown .lang-option {
    color: #d8e3ef !important;
}

html[data-theme="dark"] .language-switcher-dropdown .lang-option:hover,
html[data-theme="dark"] .language-switcher-dropdown .lang-option:focus-visible,
html[data-theme="dark"] .language-switcher-dropdown .lang-option-active {
    color: #f5f9ff !important;
}

.theme-toggle {
    order: 3;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--v4-line-strong);
    background: rgba(255, 255, 255, 0.8);
    color: var(--v4-text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--v4-ease), border-color var(--v4-ease);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
    background: rgba(39, 94, 156, 0.12);
}

html[data-theme="dark"] .theme-toggle {
    background: rgba(22, 28, 36, 0.9);
    border-color: var(--v4-line-strong);
    color: var(--v4-text);
}

.theme-icon-sun,
.theme-icon-moon {
    width: 18px;
    height: 18px;
}

.theme-icon-sun {
    display: none;
}

.theme-icon-moon {
    display: inline-block;
}

html[data-theme="dark"] .theme-icon-sun {
    display: inline-block;
}

html[data-theme="dark"] .theme-icon-moon {
    display: none;
}

.nav-cta {
    order: 4;
    display: inline-flex;
    align-items: center;
    gap: 0.48rem;
}

.nav-cta .btn {
    min-height: 40px;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0;
    font-family: var(--font-sans);
}

.mobile-header-actions {
    display: none;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.mobile-menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid var(--v4-line-strong);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--v4-text);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
}

.mobile-menu-toggle span {
    width: 18px;
    height: 2px;
    background: currentColor;
    border-radius: 999px;
    transition: transform var(--v4-ease), opacity var(--v4-ease);
}

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

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

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

.mobile-menu-panel-header {
    display: none;
}

.mobile-menu-panel-copy {
    min-width: 0;
}

.mobile-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.46);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--v4-ease), visibility var(--v4-ease);
    z-index: 980;
}

body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body.menu-open .mobile-menu-overlay {
    opacity: 1;
    visibility: visible;
}

@media (min-width: 1231px) {
    .dropdown:hover > .dropdown-menu,
    .dropdown:hover > .mega-menu,
    .dropdown:hover > .dropdown-menu-simple {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
    }

    .dropdown:hover > .dropdown-menu-simple {
        transform: translate(-50%, 0);
    }
}

@media (max-width: 1230px) {
    .mobile-header-actions {
        display: flex;
    }

    .mobile-header-actions .theme-toggle {
        width: 32px;
        height: 32px;
        padding: 5px;
    }

    .mobile-header-actions .theme-toggle svg {
        width: 16px;
        height: 16px;
    }

    .mobile-menu-toggle {
        display: inline-flex;
    }

    .logo-image {
        max-width: 140px;
    }

    .nav-menu {
        position: fixed;
        top: 0;
        right: 0;
        width: min(400px, 94vw);
        height: 100dvh;
        background: var(--v4-surface);
        border-left: 1px solid var(--v4-line);
        box-shadow: var(--v4-shadow-md);
        padding: 0.9rem 0.9rem calc(1rem + env(safe-area-inset-bottom, 0px));
        flex-direction: column;
        align-items: stretch;
        gap: 0.72rem;
        transform: translateX(100%);
        transition: transform var(--v4-ease);
        z-index: 1100;
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    html[data-theme="dark"] .nav-menu {
        background: linear-gradient(180deg, #171d25 0%, #121820 100%);
        border-left-color: rgba(198, 210, 223, 0.26);
    }

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

    .mobile-menu-panel-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 0.8rem;
        position: sticky;
        top: calc(-1 * env(safe-area-inset-top, 0px));
        margin: calc(-0.9rem - env(safe-area-inset-top, 0px)) -0.9rem 0.9rem;
        padding: calc(1rem + env(safe-area-inset-top, 0px)) 0.9rem 0.9rem;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.97) 0%, rgba(255, 255, 255, 0.92) 100%);
        border-bottom: 1px solid var(--v4-line);
        backdrop-filter: blur(18px);
        z-index: 2;
    }

    html[data-theme="dark"] .mobile-menu-panel-header {
        background: linear-gradient(180deg, rgba(23, 29, 37, 0.98) 0%, rgba(18, 24, 32, 0.94) 100%);
        border-bottom-color: rgba(198, 210, 223, 0.18);
    }

    .mobile-menu-panel-copy {
        display: grid;
        gap: 0.18rem;
    }

    .mobile-menu-eyebrow {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--v4-text-muted);
    }

    .mobile-menu-title {
        font-family: var(--font-heading);
        font-size: 1.1rem;
        line-height: 1.05;
        color: var(--v4-text);
    }

    .mobile-menu-subtitle {
        max-width: 26ch;
        font-size: 0.82rem;
        line-height: 1.4;
        color: var(--v4-text-muted);
    }

    .mobile-menu-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        margin: 0;
        border: 1px solid var(--v4-line-strong);
        border-radius: 12px;
        background: rgba(255, 255, 255, 0.82);
        color: var(--v4-text);
        flex-shrink: 0;
    }

    .mobile-menu-close:hover,
    .mobile-menu-close:focus-visible {
        background: rgba(39, 94, 156, 0.12);
        border-color: rgba(39, 94, 156, 0.28);
    }

    html[data-theme="dark"] .mobile-menu-close {
        background: rgba(20, 27, 36, 0.9);
        color: #e6edf7;
        border-color: rgba(198, 210, 223, 0.32);
    }

    html[data-theme="dark"] .mobile-menu-close:hover,
    html[data-theme="dark"] .mobile-menu-close:focus-visible {
        background: rgba(39, 94, 156, 0.18);
        border-color: rgba(108, 153, 214, 0.32);
    }

    .nav-menu > .nav-list {
        order: 2;
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0.55rem;
    }

    .nav-item {
        width: 100%;
        border: 1px solid rgba(18, 32, 52, 0.08);
        border-radius: 18px;
        background: rgba(255, 255, 255, 0.72);
        box-shadow: 0 10px 24px rgba(8, 24, 44, 0.08);
        overflow: hidden;
    }

    html[data-theme="dark"] .nav-item {
        background: rgba(16, 21, 28, 0.78);
        border-color: rgba(198, 210, 223, 0.12);
        box-shadow: none;
    }

    .nav-item.dropdown.active {
        border-color: rgba(39, 94, 156, 0.28);
        background: rgba(39, 94, 156, 0.08);
    }

    html[data-theme="dark"] .nav-item.dropdown.active {
        background: rgba(39, 94, 156, 0.14);
        border-color: rgba(108, 153, 214, 0.28);
    }

    .nav-link {
        width: 100%;
        min-height: 56px;
        padding: 0.92rem 1rem;
        border-radius: 16px;
        font-size: 1rem;
        justify-content: space-between;
    }

    .nav-menu .dropdown-menu,
    .nav-menu .mega-menu,
    .nav-menu .dropdown-menu-simple {
        all: unset;
        display: none;
        flex-direction: column;
        width: 100%;
        box-sizing: border-box;
    }

    .nav-item.dropdown.active > .dropdown-menu,
    .nav-item.dropdown.active > .mega-menu,
    .nav-item.dropdown.active > .dropdown-menu-simple {
        display: flex;
        padding: 0 0.85rem 0.85rem;
        gap: 0.6rem;
    }

    .mega-menu-section {
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
    }

    .mega-menu-heading,
    .mega-menu-heading-text {
        display: flex;
        align-items: center;
        min-height: 40px;
        padding: 0.68rem 0.85rem;
        border-radius: 14px;
        border: 1px solid rgba(39, 94, 156, 0.16);
        background: rgba(39, 94, 156, 0.08);
        font-size: 0.76rem;
        font-weight: 700;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--v4-accent-blue-dark);
        text-decoration: none;
        margin-bottom: 0;
    }

    html[data-theme="dark"] .mega-menu-heading,
    html[data-theme="dark"] .mega-menu-heading-text {
        border-color: rgba(108, 153, 214, 0.22);
        background: rgba(39, 94, 156, 0.18);
        color: #dbeafe;
    }

    .mega-menu-heading span {
        color: inherit;
    }

    .nav-menu .dropdown-item {
        gap: 0.78rem;
        padding: 0.78rem 0.85rem;
        border-radius: 14px;
    }

    .nav-menu .menu-icon {
        display: block;
        width: 18px;
        height: 18px;
        margin-top: 0.18rem;
        color: var(--v4-accent-blue);
    }

    html[data-theme="dark"] .nav-menu .menu-icon {
        color: #9ec4ef;
    }

    .nav-menu .dropdown-item div {
        display: block;
        min-width: 0;
    }

    .nav-menu .dropdown-item strong {
        font-size: 0.92rem;
        font-weight: 700;
        line-height: 1.25;
    }

    .nav-menu .dropdown-item small {
        margin-top: 0.16rem;
        font-size: 0.76rem;
        line-height: 1.4;
    }

    .nav-menu > .language-switcher-dropdown {
        order: 1;
        position: static;
        width: auto;
        align-self: stretch;
        margin: 0 0.85rem 0.75rem;
    }

    .nav-menu > .language-switcher-dropdown .lang-dropdown-toggle {
        width: 100%;
        min-height: 50px;
        justify-content: space-between;
        padding: 0.82rem 1rem;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.82);
        border-color: rgba(18, 32, 52, 0.12);
    }

    html[data-theme="dark"] .nav-menu > .language-switcher-dropdown .lang-dropdown-toggle {
        background: rgba(20, 27, 36, 0.88);
        border-color: rgba(198, 210, 223, 0.2);
    }

    .nav-menu > .language-switcher-dropdown .lang-dropdown-menu {
        position: static;
        top: auto;
        right: auto;
        left: auto;
        width: 100%;
        min-width: 0;
        margin-top: 0.55rem;
        display: none;
        opacity: 1;
        visibility: visible;
        transform: none;
        box-shadow: none;
        border-radius: 16px;
    }

    .nav-menu > .language-switcher-dropdown.open .lang-dropdown-menu {
        display: block;
    }

    .nav-menu > .language-switcher-dropdown .lang-option {
        padding: 0.72rem 0.85rem;
    }

    .nav-menu > .theme-toggle {
        display: none;
    }

    .nav-cta {
        width: 100%;
        display: grid;
        gap: 0.5rem;
    }

    .nav-cta .btn {
        width: 100%;
    }
}
