/* ============================================
   MagnaTerra Header
   ============================================ */

:root {
    --site-header-height: 80px;
}

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
    background-color: #000;
    transition: transform 0.3s ease;
}

/* Reserve space so content is not hidden under fixed header */
body {
    padding-top: var(--site-header-height);
}

/* Hide header when scrolling down; shown again when scrolling up (see custom-scripts.js) */
.site-header.header-hidden {
    transform: translateY(-100%);
}

.header-container {
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1.5rem;
    padding-left: clamp(1.5rem, 4vw, 3rem);
    padding-right: clamp(1.5rem, 4vw, 3rem);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.site-logo a {
    display: inline-block;
    color: #fff;
}

.site-logo img {
    height: 28px;
    width: auto;
    display: block;
}

.site-name {
    font-size: 1.25rem;
    font-weight: 500;
    color: #fff;
    letter-spacing: 0.02em;
}

/* Desktop nav – visible from 993px up */
.header-nav {
    display: none;
}

/* Nav + button grouped on the right, right next to each other (Figma) */
.header-nav-and-cta {
    display: none;
}

.header-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0;
}

.header-menu li {
    margin: 0;
}

.header-menu li + li {
    margin-left: 2rem;
}

.header-menu a {
    color: #f5f5f5;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.01em;
    transition: color 0.2s ease;
}

.header-menu a:hover {
    color: #fff;
}

/* Top-level nav links: base setup so padding is consistent (no layout shift on hover/active) */
.header-menu > li > a {
    position: relative;
    padding-bottom: 6px;
}

/* Underline pseudo-element – hidden by default */
.header-menu > li > a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #903510 0%, #F65B1B 50%, #903510 100%);
    box-shadow: 0 0 3.1px 0 #F65B1B;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 36%, black 64%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 36%, black 64%, transparent 100%);
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover: same look as active – orange color + underline slides in */
.header-menu > li > a:hover {
    color: #F65B1B;
}

.header-menu > li > a:hover::after {
    transform: scaleX(1);
}

/* Active/current page style – line under link (active item width, 2px height) */
@keyframes nav-underline-in {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

.header-menu .current-menu-item > a,
.header-menu .current-menu-ancestor > a {
    color: #F65B1B;
    position: relative;
    padding-bottom: 6px;
}

.header-menu .current-menu-item > a::after,
.header-menu .current-menu-ancestor > a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #903510 0%, #F65B1B 50%, #903510 100%);
    box-shadow: 0 0 3.1px 0 #F65B1B;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 36%, black 64%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 36%, black 64%, transparent 100%);
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
    animation: nav-underline-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transition: none;
}

.header-menu .current-menu-item > a:hover,
.header-menu .current-menu-ancestor > a:hover {
    color: #F65B1B;
}

/* Desktop submenu dropdown – show on hover with smooth animation */
.header-menu .menu-item-has-children {
    position: relative;
}

/* Parent with submenu: default cursor (not clickable as direct link) */
.header-menu .menu-item-has-children > a {
    cursor: default;
}

.header-menu .sub-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    min-width: 120px;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    background: #000000a1;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s ease;
    z-index: 100;
    text-align: center;
}

.header-menu .menu-item-has-children:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.header-menu .sub-menu li {
    margin: 0;
}

.header-menu .sub-menu a {
    display: block;
    padding: 10px 20px;
    color: #f5f5f5;
    font-size: 15px;
    font-weight: 400;
    transition: color 0.2s ease, background 0.2s ease;
    position: relative;
}

/* Underline pseudo-element – hidden by default for sub-menu */
.header-menu .sub-menu li > a::after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 10px;
    height: 2px;
    background: linear-gradient(90deg, #903510 0%, #F65B1B 50%, #903510 100%);
    box-shadow: 0 0 3.1px 0 #F65B1B;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
    transform: scaleX(0);
    transform-origin: center;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover: same look as active – orange + underline slides in */
.header-menu .sub-menu li > a:hover {
    color: #F65B1B;
}

.header-menu .sub-menu li > a:hover::after {
    transform: scaleX(1);
}

.header-menu .sub-menu .current-menu-item > a {
    color: #F65B1B;
    padding-bottom: 10px;
}

.header-menu .sub-menu .current-menu-item > a::after {
    left: 20px;
    right: 20px;
    bottom: 10px;
    width: auto;
    animation: nav-underline-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    transition: none;
}

/* Figma: Contact button – orange from design */
.header-button {
    display: inline-block;
    padding: 12px 32px;
    background-color: #F65B1B;
    border-radius: 9999px;
    color: #fff;
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.01em;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    border: 1px solid transparent;
    cursor: pointer;
    margin-left: 2rem;
}

.header-button:hover {
    border: 1px solid #F65B1B;
    background: var(--Primary-100, #0B0B0B);
    box-shadow: 0 0 8px 4px rgba(246, 91, 27, 0.25);
    color: var(--Secondary-100, #F65B1B);
    transform: none;
}

/* Mobile toggle – plus (+) when closed, one line when open */
.mobile-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.mobile-menu-toggle:hover {
    opacity: 0.85;
}

.hamburger-lines {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hamburger-lines .line {
    position: absolute;
    background-color: #fff;
    border-radius: 1px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease;
}

/* Horizontal line */
.hamburger-lines .line-1 {
    width: 24px;
    height: 2px;
    left: 0;
    top: 50%;
    margin-top: -1px;
}

/* Vertical line – forms + with line-1 */
.hamburger-lines .line-2 {
    width: 2px;
    height: 24px;
    left: 50%;
    top: 0;
    margin-left: -1px;
}

/* Open state: vertical line collapses to form single horizontal line */
.mobile-menu-toggle.is-open .hamburger-lines .line-2 {
    opacity: 0;
    transform: scaleY(0);
}

.mobile-menu-close .hamburger-lines {
    width: 24px;
    height: 24px;
}

.mobile-menu-close .hamburger-lines .line {
    position: absolute;
}

.mobile-menu-close .hamburger-lines .line-1 {
    width: 24px;
    height: 2px;
    left: 0;
    top: 50%;
    margin-top: -1px;
}

.mobile-menu-close .hamburger-lines .line-2 {
    width: 2px;
    height: 24px;
    left: 50%;
    top: 0;
    margin-left: -1px;
    opacity: 0;
    transform: scaleY(0);
}

/* Desktop: nav + button on right, right next to each other */
@media (min-width: 993px) {
    .header-container {
        padding-top: 18px;
        padding-bottom: 18px;
    }

    .site-logo img {
        height: 32px;
    }

    .header-nav-and-cta {
        display: flex;
        align-items: center;
        gap: 0;
        margin-left: auto;
    }

    .header-nav {
        display: block;
    }

    .mobile-menu-toggle {
        display: none;
    }
}

/* Large monitors – more padding, no max-width */
@media (min-width: 1400px) {
    .header-container {
        padding-left: clamp(3rem, 5vw, 5rem);
        padding-right: clamp(3rem, 5vw, 5rem);
    }
}

/* ========== Mobile menu overlay ========== */
.mobile-menu {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    z-index: 1001;
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s ease, opacity 0.3s ease;
}

.mobile-menu[hidden] {
    display: block;
    pointer-events: none;
}

.mobile-menu.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.mobile-menu.is-open[hidden] {
    display: block;
}

.mobile-menu-inner {
    min-height: 100%;
    padding: 24px 24px 32px;
    padding-left: clamp(24px, 6vw, 40px);
    padding-right: clamp(24px, 6vw, 40px);
    display: flex;
    flex-direction: column;
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.mobile-menu-header .site-logo img {
    height: 28px;
}

.mobile-menu-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.mobile-menu-close:hover {
    opacity: 0.85;
}

.mobile-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mobile-menu-list {
    list-style: none;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 320px;
    text-align: left;
}

.mobile-menu-list > li {
    margin: 0 0 42px 0;
}

.mobile-menu-list > li:last-child {
    margin-bottom: 30px;
}

/* Active page style – mobile: only the current item, not parent when a submenu item is active */
.mobile-menu-list .current-menu-item > a {
    color: #F65B1B;
    position: relative;
    padding-bottom: 5px;
}

.mobile-menu-list .current-menu-item > a::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, #903510 0%, #F65B1B 50%, #903510 100%);
    box-shadow: 0 0 3.1px 0 #F65B1B;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 30%, black 70%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 30%, black 70%, transparent 100%);
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
}

.mobile-menu-list .current-menu-item > a:hover {
    color: #F65B1B;
}

/* Parent with submenu on mobile: not clickable */
.mobile-menu-list .menu-item-has-children > a {
    pointer-events: none;
    cursor: default;
}

/* Submenu in mobile – always open, button style */
.mobile-menu-list .sub-menu {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0 0 0 16px;
    display: block;
}

.mobile-menu-list .sub-menu li {
    margin: 0 0 14px 0;
}

.mobile-menu-list .sub-menu li:last-child {
    margin-bottom: 0;
}

.mobile-menu-list .sub-menu a {
    display: block;
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 16px;
    font-weight: 400;
    letter-spacing: 0.01em;
    line-height: 1.4;
    transition: color 0.2s ease, background 0.2s ease;
}

.mobile-menu-list .sub-menu a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-list .sub-menu .current-menu-item > a {
    color: #F65B1B;
    position: relative;
    display: inline-block;
}

.mobile-menu-list .sub-menu .current-menu-item > a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 10px;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, #903510 0%, #F65B1B 50%, #903510 100%);
    box-shadow: 0 0 3.1px 0 #F65B1B;
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    mask-image: linear-gradient(to right, transparent 0%, black 10%, black 90%, transparent 100%);
    mask-size: 100% 100%;
    -webkit-mask-size: 100% 100%;
}

/* CTA right after nav items – centered */
.mobile-menu-cta {
    margin-top: 28px;
    display: flex;
    justify-content: center;
}

/* Mobile CTA – orange button */
.header-button-mobile {
    display: block;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    text-align: center;
    padding: 16px 24px;
    font-size: 18px;
    font-weight: 400;
    background-color: #F65B1B;
    border-radius: 9999px;
    color: #fff;
    border: 1px solid transparent;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.header-button-mobile:hover {
    border: 1px solid #F65B1B;
    background: var(--Primary-100, #0B0B0B);
    box-shadow: 0 0 8px 4px rgba(246, 91, 27, 0.25);
    color: var(--Secondary-100, #F65B1B);
    transform: translateY(-1px);
}

/* Body scroll lock when menu open */
body.mobile-menu-open {
    overflow: hidden;
}
