/* ==============================
   HEADER
   Idle: invisible, no bg, just floats over hero.
   Scrolled: dark glass pill slides in with margin from edges.
   ============================== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    pointer-events: none;
    direction: ltr;
    padding: 1.4rem 1.6rem 0;
    transition: padding 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.header[data-scrolled="true"] {
    padding-top: 1rem;
}

/* --- Inner pill --- */

.header__inner {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;

    max-width: 1600px;
    margin: 0 auto;
    padding: 0.9rem 1.6rem;
    pointer-events: auto;
    border-radius: 999px;

    /* IDLE: invisible pill */
    background: transparent;
    border: 1px solid transparent;
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    box-shadow: none;

    transition:
        background 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        border-color 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        backdrop-filter 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        -webkit-backdrop-filter 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
        padding 0.7s cubic-bezier(0.16, 1, 0.3, 1);

    transform: translateY(-8px);
    opacity: 0;
}

/* On load, idle controls fade in (so they're visible even without scrolling) */
.header--ready .header__inner {
    transform: translateY(0);
    opacity: 1;
}

/* SCROLLED: flat dark glass pill */
.header[data-scrolled="true"] .header__inner {
    background: rgba(12, 12, 14, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    padding: 0.7rem 1.8rem;
}

/* ==============================
   COLUMNS
   ============================== */

.header__left   { justify-self: start; }
.header__center {
    justify-self: center;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.header__right  { justify-self: end; display: flex; align-items: center; gap: 1rem; }

/* ==============================
   LANGUAGE TOGGLE
   ============================== */

.header__lang {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 0.4rem 0.6rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.header__lang:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.14);
}

.header__lang-btn {
    position: relative;
    z-index: 2;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.55);
    font-family: 'Bebas Neue', Impact, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
    border-radius: 999px;
    transition: color 0.4s ease;
}

.header__lang-btn--active {
    color: #fff;
}

.header__lang-sep {
    width: 1px;
    height: 12px;
    background: rgba(255, 255, 255, 0.15);
    margin: 0 0.2rem;
}

/* Sliding thumb behind the active language */
.header__lang-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 6px;
    width: calc(50% - 9px);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    z-index: 1;
    transition: transform 0.5s cubic-bezier(0.65, 0, 0.35, 1);
}

.header__lang[data-active="fa"] .header__lang-thumb {
    transform: translateX(calc(100% + 6px));
}

/* ==============================
   LOGO SLOT (destination for ZYRON morph)
   ============================== */

.header__logo-slot {
    width: clamp(90px, 12vw, 150px);
    height: clamp(30px, 3vw, 42px);
    position: relative;
}

/* ==============================
   MENU
   ============================== */

.header__menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0;
    padding: 0;
}

.header__menu-link {
    position: relative;
    display: inline-block;
    padding: 0.55rem 0.95rem;
    font-family: 'Bebas Neue', Impact, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
    text-decoration: none;
    border-radius: 999px;
    transition: color 0.35s ease, background 0.35s ease;
}

.header__menu-link::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.08) 0%,
        transparent 60%);
    opacity: 0;
    transition: opacity 0.35s ease;
    border-radius: 999px;
    pointer-events: none;
}

.header__menu-link:hover { color: #fff; }
.header__menu-link:hover::before { opacity: 1; }

/* Letter reveal: the inner span is the clip window. The visible text
   sits at top:0; an ::after duplicate sits at top:100% (below the clip).
   On hover both shift up by 100% so the duplicate becomes visible. */
.header__menu-link-text {
    position: relative;
    display: inline-block;
    overflow: hidden;
    line-height: 1.2;
    vertical-align: top;
}

.header__menu-link-text::after {
    content: attr(data-text);
    position: absolute;
    inset: 100% 0 auto 0;
    color: #fff;
    transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}

.header__menu-link-text {
    transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}

.header__menu-link:hover .header__menu-link-text {
    transform: translateY(-100%);
}

/* ==============================
   BURGER (mobile)
   ============================== */

.header__burger {
    display: none;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    cursor: pointer;
    position: relative;
    padding: 0;
}

.header__burger span {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 1.5px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.4s cubic-bezier(0.65, 0, 0.35, 1),
                opacity 0.3s ease,
                top 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.header__burger span:nth-child(1) { top: 13px; }
.header__burger span:nth-child(2) { top: 18px; }
.header__burger span:nth-child(3) { top: 23px; }

.header__burger--open span:nth-child(1) {
    top: 18px;
    transform: translateX(-50%) rotate(45deg);
}
.header__burger--open span:nth-child(2) { opacity: 0; }
.header__burger--open span:nth-child(3) {
    top: 18px;
    transform: translateX(-50%) rotate(-45deg);
}

/* ==============================
   FULLSCREEN MOBILE NAV
   ============================== */

.header__nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    pointer-events: none;
    visibility: hidden;
    opacity: 0;
    transition:
        opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0s linear 0.48s;
}

.header__nav-overlay.header__nav-overlay--open {
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
    transition-delay: 0s, 0s;
}

.header__nav-overlay-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(120% 80% at 50% 0%, rgba(40, 40, 55, 0.45) 0%, transparent 55%),
        radial-gradient(80% 60% at 100% 100%, rgba(80, 30, 90, 0.12) 0%, transparent 50%),
        rgba(3, 3, 5, 0.88);
    opacity: 0;
    transform: scale(1.04);
    transition:
        opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-backdrop-filter: blur(0);
    backdrop-filter: blur(0);
}

.header__nav-overlay--open .header__nav-overlay-bg {
    opacity: 1;
    transform: scale(1);
    -webkit-backdrop-filter: blur(32px);
    backdrop-filter: blur(32px);
    transition-delay: 0.05s, 0.05s;
}

.header__nav-overlay-inner {
    position: relative;
    z-index: 2;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding:
        max(1.25rem, env(safe-area-inset-top, 0px))
        max(1.25rem, env(safe-area-inset-right, 0px))
        max(1.25rem, env(safe-area-inset-bottom, 0px))
        max(1.25rem, env(safe-area-inset-left, 0px));
    transform: translate3d(0, 1.25rem, 0);
    opacity: 0;
    filter: blur(10px);
    transition:
        transform 0.6s cubic-bezier(0.16, 1, 0.35, 1),
        opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
        filter 0.55s ease;
    transition-delay: 0s;
}

.header__nav-overlay--open .header__nav-overlay-inner {
    transform: translate3d(0, 0, 0);
    opacity: 1;
    filter: blur(0);
    transition-delay: 0.12s;
}

.header__nav-overlay-frame {
    position: absolute;
    inset: max(0.85rem, env(safe-area-inset-top, 0px)) max(0.85rem, env(safe-area-inset-right, 0px))
        max(0.85rem, env(safe-area-inset-bottom, 0px)) max(0.85rem, env(safe-area-inset-left, 0px));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.25rem;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.985);
    transition:
        opacity 0.5s ease 0.1s,
        transform 0.65s cubic-bezier(0.16, 1, 0.35, 1) 0.08s;
}

.header__nav-overlay--open .header__nav-overlay-frame {
    opacity: 1;
    transform: scale(1);
}

.header__nav-close {
    position: absolute;
    top: max(1rem, calc(env(safe-area-inset-top, 0px) + 0.5rem));
    right: max(1rem, calc(env(safe-area-inset-right, 0px) + 0.5rem));
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.35s ease, border-color 0.35s ease, transform 0.35s ease;
}

.header__nav-close:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
}

.header__nav-close-line {
    position: absolute;
    width: 20px;
    height: 1.5px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.45s cubic-bezier(0.65, 0, 0.35, 1);
}

.header__nav-close-line:nth-child(1) {
    transform: rotate(45deg);
}
.header__nav-close-line:nth-child(2) {
    transform: rotate(-45deg);
}

.header__nav-close:active {
    transform: scale(0.94);
}

.header__nav-mobile {
    width: 100%;
    max-width: 22rem;
}

.header__nav-mobile-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.header__nav-mobile-item {
    opacity: 0;
    transform: translate3d(0, 1.5rem, 0) skewX(-3deg);
    transition:
        opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.55s cubic-bezier(0.16, 1, 0.35, 1);
    transition-delay: 0s;
}

.header__nav-overlay--open .header__nav-mobile-item {
    opacity: 1;
    transform: translate3d(0, 0, 0) skewX(0deg);
    transition-delay: calc(0.18s + var(--i) * 0.065s);
}

.header__nav-overlay:not(.header__nav-overlay--open) .header__nav-mobile-item {
    transition-delay: 0s;
    transition-duration: 0.28s;
}

.header__nav-mobile-link {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.85rem 0;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: color 0.35s ease, padding-left 0.45s cubic-bezier(0.16, 1, 0.35, 1);
}

.header__nav-mobile-link:hover,
.header__nav-mobile-link:focus-visible {
    color: #fff;
    padding-left: 0.35rem;
    outline: none;
}

.header__nav-mobile-link:focus-visible {
    box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.65);
}

.header__nav-mobile-link-index {
    font-family: 'Bebas Neue', Impact, sans-serif;
    font-size: 0.65rem;
    letter-spacing: 0.2em;
    color: rgba(255, 255, 255, 0.28);
    min-width: 1.5rem;
    transition: color 0.35s ease;
}

.header__nav-mobile-link:hover .header__nav-mobile-link-index,
.header__nav-mobile-link:focus-visible .header__nav-mobile-link-index {
    color: rgba(255, 255, 255, 0.55);
}

.header__nav-mobile-link-label {
    font-family: 'Bebas Neue', Impact, sans-serif;
    font-size: clamp(1.85rem, 9vw, 2.6rem);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    line-height: 1.05;
}

@media (min-width: 901px) {
    .header__nav-overlay {
        display: none !important;
    }
}

/* ==============================
   HERO NAME - MORPH (clone-based)
   The original .hero__name stays put; a clone is appended to <body>,
   pinned via position:fixed, and animated into the header slot.
   Below are the rules that style the clone in its "in-header" state.
   ============================== */

.hero__name {
    will-change: transform;
}

/* The clone is identical to .hero__name but gets these overrides while sitting
   inside the header slot. Animation is driven by inline transforms from JS. */
.hero__name--clone {
    z-index: 1100 !important;
    /* Sub-pixel rendering hints to keep edges crisp while scaled down */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: geometricPrecision;
    backface-visibility: hidden;
}

/* When the clone is sitting in the header (scaled small), the SVG turbulence
   texture that fills each letter looks blurry/pixelated. Replace the textured
   fill with a clean flat white so the small logo stays sharp. */
.hero__name--clone.hero__name--in-header .hero__name-letter {
    animation: none !important;
    background-image: none !important;
    background-color: transparent !important;
    -webkit-text-fill-color: #fff !important;
    color: #fff !important;
    filter: none !important;
    text-shadow: none;
}

/* ==============================
   RESPONSIVE
   ============================== */

@media (max-width: 900px) {
    .header__menu { display: none; }
    .header__burger { display: inline-block; }
    .header__right { gap: 0.6rem; }
    .header__logo-slot {
        width: clamp(70px, 18vw, 110px);
        height: clamp(20px, 4vw, 28px);
    }
}

@media (max-width: 600px) {
    .header { padding: 1rem 0.9rem 0; }
    .header__inner { padding: 0.6rem 0.9rem; gap: 0.5rem; }
    .header[data-scrolled="true"] .header__inner { padding: 0.55rem 1rem; }
    .header__lang-btn { font-size: 0.7rem; padding: 0.3rem 0.5rem; letter-spacing: 0.14em; }
    .header__lang { padding: 0.3rem 0.4rem; }
}

body.header-nav-open {
    overflow: hidden;
    touch-action: none;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .header__inner,
    .header__lang-thumb,
    .header__menu-link-text,
    .header__menu-link-text::after,
    .header__burger span,
    .header__nav-overlay,
    .header__nav-overlay-bg,
    .header__nav-overlay-inner,
    .header__nav-overlay-frame,
    .header__nav-mobile-item,
    .header__nav-close-line { transition: none !important; }
}
