/* =================================== */
/* Header experiment — NEW rules only.                                     */
/*                                                                          */
/* Everything visual for the header itself (.header__wrap, .header__link,  */
/* .btn, .acc-btn, .burger-icon, header{}, the mobile menu, the on-light   */
/* theme colors...) already exists in css/main.css and applies to this     */
/* markup automatically since it reuses the exact same class names — DO    */
/* NOT redeclare any of that here. This file used to duplicate it "for     */
/* clarity", but at equal specificity the LATER stylesheet in <head> wins  */
/* the cascade regardless of which selector it came from — since this file */
/* loads after main.css, redeclaring .btn/.acc-btn here silently overrode  */
/* every color-modifier class across the whole site that depends on        */
/* beating .btn's own default (tasks__footer-btn, construct__btn-accent,   */
/* how__btn, etc.) back to plain white. That's the bug that broke buttons  */
/* everywhere. Lesson: only put NEW classes/selectors in this file.        */
/* =================================== */

[data-header-v2] .header__link{
    white-space: nowrap;
}

[data-header-v2]{
    transition: padding-top .3s ease;
}

[data-header-v2] .header__wrap{
    transition: border-color .4s ease, box-shadow .4s ease, backdrop-filter .4s ease, padding .3s ease;
}


/* =================================== */
/* NEW — hover dropdowns                                                   */
/* Each .header__link that has a following .header__dropdown becomes a    */
/* trigger. Wrap trigger+panel in .header__item so hover/focus can target  */
/* both without JS having to do the show/hide (pure CSS, JS only adds a    */
/* small "open" delay/touch fallback — see header.js).                    */
/* =================================== */

.header__item{
    position: relative;
    display: flex;
    align-items: center;
}

/* .header__item sets its own `display`, which — at equal specificity — beats
   the browser's default `[hidden]{display:none}` rule. Force it explicitly
   so toggling the `hidden` attribute from header.js always works, on any
   element regardless of what else sets its display. */
[hidden]{
    display: none !important;
}

.header__link-caret{
    display: inline-block;
    margin-left: 6px;
    translate: 0 1px;
    transition: rotate .25s ease;
}

/* .header__item-toggle is the touch/keyboard-only trigger button (see
   header.js) — on desktop the caret baked into .header__link already
   shows and hover/focus already opens the panel, so the button itself
   stays invisible there. Only the @media block further down turns it
   back on for mobile, where hover doesn't exist. */
.header__item-toggle{
    display: none;
}

.header__item.is-open .header__link-caret,
.header__item:hover .header__link-caret{
    rotate: 180deg;
}

.header__dropdown{
    position: absolute;
    top: calc(100% + 18px);
    left: 50%;
    translate: -50% 0;
    width: 340px;
    padding: 14px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--color-white);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgb(var(--color-black-rgb) / 0.16);
    opacity: 0;
    visibility: hidden;
    translate: -50% 6px;
    transition: opacity .2s ease, visibility 0s linear .2s, translate .2s ease;
    z-index: 5;
}

.header__item:hover .header__dropdown,
.header__item.is-open .header__dropdown,
.header__dropdown:hover{
    opacity: 1;
    visibility: visible;
    translate: -50% 0;
    transition: opacity .2s ease, visibility 0s linear 0s, translate .2s ease;
}

/* small invisible bridge so the mouse can travel from the link down to the
   panel without the gap (top: 100% + 18px above) closing the dropdown */
.header__item::after{
    content: "";
    position: absolute;
    left: 50%;
    translate: -50% 0;
    top: 100%;
    width: 340px;
    height: 18px;
}

.header__dropdown-item{
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    transition: background-color .2s ease;
}

.header__dropdown-item:hover,
.header__dropdown-item:focus-visible{
    background: var(--color-surface-cool, #f5f5f7);
}

.header__dropdown-item-title{
    color: var(--color-black);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.header__dropdown-item-sub{
    color: var(--color-text-secondary, #666);
    font-size: 12.5px;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.4;
}

@media (max-width: 1024px) {
    /* Dropdowns fall back to plain in-flow lists inside the mobile sheet —
       no floating panel, no hover, just tap-to-expand (handled in JS). */
    .header__dropdown{
        position: static;
        translate: none;
        width: 100%;
        opacity: 1;
        visibility: visible;
        box-shadow: none;
        padding: 6px 0 0;
        display: none;
    }

    .header__item.is-open .header__dropdown{
        display: flex;
    }

    .header__item::after{
        display: none;
    }

    .header__link-caret{
        display: none;
    }

    .header__item-toggle{
        display: inline-flex;
        margin-left: 8px;
    }
}


/* =================================== */
/* NEW — active section highlight (scroll-spy)                             */
/* header.js's IntersectionObserver adds is-active to whichever            */
/* .header__link's href matches the section currently under the header.    */
/* =================================== */

.header__link.is-active{
    color: var(--color-orange);
}

header.header--on-light .header__link.is-active{
    color: var(--color-orange);
}

.header__link.is-active::after{
    width: 100%;
}


/* =================================== */
/* NEW — shrink on scroll                                                  */
/* Small, tasteful: once the user scrolls past the hero, the header pill   */
/* trims its own padding a bit so it takes up slightly less vertical       */
/* space while browsing — expands back at the top of the page.             */
/* =================================== */

header.header--scrolled {
    padding-top: 12px;
}

header.header--scrolled .header__wrap {
    padding: 8px 20px;
}
