/* Site header: shared by every page. Mobile-first; the full nav appears at 1024px. */

:root {
    /* Every homepage section heading: 28px on phones, about 38px on tablets, 55px from 1440px */
    --section-title: clamp(1.75rem, 1.1875rem + 2.5vw, 3.4375rem);

    /* Shared side spacing, so page sections line up with the header */
    --gutter: 1rem; /* 16px on phones (the minimum), 20px from 768px, 24px from 1024px */

    --header-height: 4rem; /* 64px below 1024px, 72px from 1024px */
    --header-gap: 0.75rem; /* space between the logo, nav and buttons */
    --nav-offset: 1.25rem; /* with --header-gap, puts the first nav link 32px from the logo, the same as the gap between nav links */
    --logo-height: clamp(0.75rem, 0.7rem + 0.15vw, 0.8125rem); /* capitals just above the 15px nav text: 12px on phones, 13px from about 1100px */
    --logo-width: calc(var(--logo-height) * 549.68 / 73.5); /* altigrid-logo-black-2.svg's viewBox is 549.68×73.5 */
    --tap-size: 2.75rem; /* 44px */
    --header-btn-height: 2.5rem; /* 40px visible; the click area is still 44px, see .header-btn::after */
    --tap-spacing: 0.5rem; /* 8px between stacked tap targets */

    --header-text: #0a0a0a;
    --header-text-muted: #737373;
    --header-text-faint: #a3a3a3;
    --header-text-sub: #525252;
    --header-border: #d4d4d4;
    --header-btn-soft-bg-hover: #f4f4f5; /* light grey fill when hovering Log in */
    --header-btn-solid-bg-hover: #2b2b2b; /* softer black fill when hovering Get Started */
    --header-btn-mobile-bg: #e8e8e8;       /* Get Started below 1024px */
    --header-btn-mobile-bg-hover: #dcdcdc;
    --header-menu-bg: #f2f2f2;             /* the menu button below 1024px */
    --menu-bg: #f5f5f5;                    /* the open mobile menu */
    --menu-close-bg: #e8e8e8;              /* the close button while it is open */
    --header-line: rgba(15, 23, 42, 0.12);
    --header-line-soft: rgba(15, 23, 42, 0.08);
    --header-panel-bg: #ffffff;
    --header-radius: 0.25rem; /* 4px: a slight rounding */
    --header-font-size: 0.9375rem; /* 15px */
    --header-dropdown-font-size: 1.125rem; /* 18px */
    --header-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

@media (min-width: 768px) {
    :root {
        --gutter: 1.25rem;
    }
}

@media (min-width: 1024px) {
    :root {
        --gutter: 1.5rem;
        --header-height: 4.5rem;
    }
}

/* Keep in-page anchors (/#services, /#industries…) clear of the sticky header */
[id] {
    scroll-margin-top: var(--header-height);
}

/* Touch screens: no grey flash over tapped links and buttons; each control has its own press state instead
   (the (hover: none) block at the end of this file) */
html {
    -webkit-tap-highlight-color: transparent;
}

/* No default 8px page margin, even for a moment before Tailwind's reset loads (it showed as a layout shift) */
body {
    margin: 0;
}

/* Don't rely on Tailwind's reset being loaded */
.site-header,
.site-header *,
.site-header *::before,
.site-header *::after {
    box-sizing: border-box;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #ffffff;
    border-bottom: 1px solid var(--header-line);
    transition: background-color 0.3s ease, border-color 0.3s ease; /* turns grey with the mobile menu */
    font-family: "Geist", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
    letter-spacing: 0;
}

.site-header__bar {
    display: flex;
    align-items: center;
    gap: var(--header-gap);
    min-height: var(--header-height);
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.site-header__logo {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-size);
    flex-shrink: 0;
}

.site-header__logo img {
    display: block;
    width: auto;
    max-width: none;
    height: var(--logo-height);
}

/* Desktop nav: hidden on small screens, the menu button takes over */
.site-nav {
    display: none;
}

.site-nav__list {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-nav__link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem; /* between "Solutions" and its arrow */
    min-height: var(--tap-size);
    padding: 0;
    border: 0;
    background: none;
    color: var(--header-text);
    font: inherit;
    font-size: var(--header-font-size);
    font-weight: 400;
    line-height: 1.2;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
    .site-nav__link:hover {
        color: var(--header-text-muted);
    }
}

/* While the dropdown is open, the other links fade back, as in the reference */
.site-nav:has([aria-expanded="true"]) .site-nav__link {
    color: var(--header-text-faint);
}

.site-nav:has([aria-expanded="true"]) .site-nav__link[aria-expanded="true"] {
    color: var(--header-text);
}

@media (hover: hover) and (pointer: fine) {
    .site-nav:has([aria-expanded="true"]) .site-nav__link:hover {
        color: var(--header-text);
    }
}

.site-header a:focus-visible,
.site-header button:focus-visible {
    outline: 2px solid var(--header-text);
    outline-offset: 3px;
}

/* The Solutions arrow: a drawn chevron that turns to point up while the dropdown is open */
.site-header__chevron {
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

[aria-expanded="true"] > .site-header__chevron {
    transform: rotate(180deg);
}

/* Industries dropdown: opens on click only, see site-header.js.
   The panel spans the full header width, positioned against .site-header (sticky = containing block).
   Its left padding lines the links up with the panel's own nav link (--dropdown-x, set by site-header.js when
   it opens; before that it falls back to the first nav link). */
.nav-dropdown__panel {
    position: absolute;
    top: 100%; /* straight off the bar: the divider line is hidden while a panel is open */
    left: 0;
    right: 0;
    padding: 2.5rem var(--gutter) 3rem var(--dropdown-x, calc(var(--gutter) + var(--logo-width) + var(--header-gap) + var(--nav-offset)));
    background-color: var(--header-panel-bg); /* solid white */
    border-bottom: 1px solid var(--header-border); /* a thin edge so it stands apart from the white page under it */
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.06);
    clip-path: inset(0 0 -5rem 0); /* the shadow falls only below the panel, never up onto the bar */
    overflow-wrap: anywhere;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.75rem);
    transition:
        opacity 0.3s var(--header-ease),
        transform 0.4s var(--header-ease),
        visibility 0s linear 0.4s;
}

/* While a dropdown is open the header's divider line fades out, so the bar and the panel read as one white surface */
.site-header:has(.nav-dropdown__panel.is-open) {
    border-bottom-color: transparent;
}

.nav-dropdown__panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition:
        opacity 0.3s var(--header-ease),
        transform 0.4s var(--header-ease),
        visibility 0s;
}

.nav-dropdown__label {
    margin: 0 0 1rem;
    color: var(--header-text-muted);
    font-size: 0.8125rem; /* 13px */
    letter-spacing: 0.02em;
}

.nav-dropdown__list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--tap-spacing);
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-dropdown__list a {
    display: inline-flex;
    align-items: center;
    min-height: var(--tap-size);
    color: var(--header-text);
    font-size: var(--header-dropdown-font-size);
    letter-spacing: -0.01em;
    text-decoration: none;
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 0.35s ease, transform 0.45s var(--header-ease), color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .nav-dropdown__list a:hover {
        color: var(--header-text-muted);
    }
}

/* With a mouse the links sit closer: each is 36px tall with no extra gap, so about 18px of space shows
   between lines of text. Touch screens keep 44px tap targets 8px apart. */
@media (hover: hover) and (pointer: fine) {
    .nav-dropdown__list {
        gap: 0;
    }

    .nav-dropdown__list a {
        min-height: 2.25rem;
    }
}

/* Links rise in one after another once the panel opens */
/* Each industry starts with a slash, like the "/ About" labels; it isn't read out */
.nav-dropdown__list a::before {
    content: "/" / "";
    margin-right: 0.3em;
}

.is-open .nav-dropdown__list a {
    opacity: 1;
    transform: translateY(0);
}

.is-open .nav-dropdown__list li:nth-child(1) a { transition-delay: 0.05s; }
.is-open .nav-dropdown__list li:nth-child(2) a { transition-delay: 0.09s; }
.is-open .nav-dropdown__list li:nth-child(3) a { transition-delay: 0.13s; }
.is-open .nav-dropdown__list li:nth-child(4) a { transition-delay: 0.17s; }
.is-open .nav-dropdown__list li:nth-child(5) a { transition-delay: 0.21s; }

/* Buttons */
.site-header__actions {
    /* Below 1024px the bar's buttons are a size down, to sit in proportion with the small logo:
       36px tall, 14px text (the tap areas stay 44px). From 1024px they're back to 40px and 15px. */
    --header-btn-height: 2.25rem;
    --header-font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem; /* 8px below 1024px, var(--header-gap) from 1024px */
    margin-left: auto;
}

.header-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--header-btn-height);
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: var(--header-radius);
    font: inherit;
    font-size: var(--header-font-size);
    font-weight: 400;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    /* Hover fill rises from the bottom: a solid gradient in --btn-fill grows from 0 to full height */
    background-image: linear-gradient(var(--btn-fill), var(--btn-fill));
    background-repeat: no-repeat;
    background-origin: border-box; /* fill covers the border area too, so no ring shows around it */
    background-position: bottom;
    background-size: 100% 0;
    transition:
        background-size 0.35s var(--header-ease),
        color 0.2s ease;
}

/* Hover only with a mouse, so the fill doesn't stick after a tap; keyboard focus shows it everywhere */
.header-btn:focus-visible {
    background-size: 100% 100%;
}

@media (hover: hover) and (pointer: fine) {
    .header-btn:hover {
        background-size: 100% 100%;
    }
}

/* Invisible extension so the click/tap area stays 44px tall around the smaller visible button */
.header-btn::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: calc((var(--header-btn-height) - var(--tap-size)) / 2);
    bottom: calc((var(--header-btn-height) - var(--tap-size)) / 2);
}

.header-btn--outline {
    --btn-fill: var(--header-btn-soft-bg-hover);
    display: none;
    background-color: transparent;
    border-color: var(--header-border);
    color: var(--header-text-muted);
}

.header-btn--outline:focus-visible {
    color: var(--header-text);
}

@media (hover: hover) and (pointer: fine) {
    .header-btn--outline:hover {
        color: var(--header-text);
    }
}

/* Below 1024px Get Started is a wider light-grey button (design-refs/scale_mob_header.png); black from 1024px */
.header-btn--solid {
    --btn-fill: var(--header-btn-mobile-bg-hover);
    min-width: clamp(7rem, 30vw, 9.5rem); /* 112px on a 360px phone, up to 152px on tablets */
    padding: 0 1rem;
    background-color: var(--header-btn-mobile-bg);
    color: var(--header-text);
}

/* Menu button (below 1024px): a light-grey square the height of Get Started, two-line icon */
.menu-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--header-btn-height);
    height: var(--header-btn-height);
    padding: 0;
    border: 0;
    border-radius: var(--header-radius);
    background: var(--header-menu-bg);
    color: var(--header-text);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* The two-line icon a touch smaller, to match the smaller square */
.menu-toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* Invisible extension so the tap area stays 44×44px */
.menu-toggle::after {
    content: "";
    position: absolute;
    inset: calc((var(--header-btn-height) - var(--tap-size)) / 2);
}

@media (hover: hover) and (pointer: fine) {
    .menu-toggle:hover {
        background-color: var(--header-btn-mobile-bg);
    }
}

.menu-toggle:focus-visible {
    outline: 2px solid var(--header-text);
    outline-offset: 2px;
}

.menu-toggle__close,
.menu-toggle[aria-expanded="true"] .menu-toggle__open {
    display: none;
}

.menu-toggle[aria-expanded="true"] .menu-toggle__close {
    display: block;
}

/* Mobile menu (below 1024px), after design-refs/scale-menu.png: a light-grey screen under the bar with
   large links, an arrow only on Industries, and Log in + Get Started in a white panel at the bottom.
   While it's open the bar turns the same grey, loses its divider line and shows only the logo and close button. */
.mobile-menu {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding:
        0.5rem max(var(--gutter), env(safe-area-inset-right))
        max(1rem, env(safe-area-inset-bottom))
        max(var(--gutter), env(safe-area-inset-left));
    background-color: var(--menu-bg);
    overflow-wrap: anywhere;
}

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

/* Opening: the panel drops down from under the bar and the links follow, one after another.
   Closing (.is-closing, set by site-header.js) rolls it back up before it's hidden. */
.mobile-menu:not([hidden]) {
    animation: mobile-menu-drop 0.45s var(--header-ease) both;
}

.mobile-menu.is-closing {
    animation: mobile-menu-lift 0.3s var(--header-ease) both;
}

.mobile-menu:not([hidden]):not(.is-closing) .mobile-menu__list > li,
.mobile-menu:not([hidden]):not(.is-closing) .mobile-menu__actions {
    animation: mobile-menu-item 0.4s var(--header-ease) both;
}

.mobile-menu__list > li:nth-child(1) { animation-delay: 0.08s; }
.mobile-menu__list > li:nth-child(2) { animation-delay: 0.12s; }
.mobile-menu__list > li:nth-child(3) { animation-delay: 0.16s; }
.mobile-menu__list > li:nth-child(4) { animation-delay: 0.2s; }
.mobile-menu__actions { animation-delay: 0.24s; }

@keyframes mobile-menu-drop {
    from { clip-path: inset(0 0 100% 0); }
    to { clip-path: inset(0 0 0 0); }
}

@keyframes mobile-menu-lift {
    from { clip-path: inset(0 0 0 0); }
    to { clip-path: inset(0 0 100% 0); }
}

@keyframes mobile-menu-item {
    from { opacity: 0; transform: translateY(-0.75rem); }
    to { opacity: 1; transform: none; }
}

.mobile-menu > nav {
    display: flex;
    flex: 1;
    flex-direction: column;
}

.mobile-menu__list,
.mobile-menu__sublist {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

.mobile-menu__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 4rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--header-text);
    font: inherit;
    font-size: 1.75rem; /* 28px */
    line-height: 1.15;
    letter-spacing: -0.02em;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.mobile-menu__chevron {
    flex-shrink: 0;
    color: var(--header-text-sub);
    transition: transform 0.25s ease;
}

[aria-expanded="true"] > .mobile-menu__chevron {
    transform: rotate(90deg);
}

/* An opened item shows its links the way the desktop dropdown does: the small grey label, then 18px black
   links, each with a slash before it */
/* Opening and closing feel like the desktop dropdown: the space grows open (rows 0fr → 1fr), the content
   fades in, and the label and links rise in one after another. Closed, it's hidden from screen readers too
   (visibility). */
.mobile-menu__sub {
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    transition:
        grid-template-rows 0.4s var(--header-ease),
        opacity 0.3s var(--header-ease),
        visibility 0s linear 0.4s;
}

.mobile-menu__sub.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
    transition:
        grid-template-rows 0.4s var(--header-ease),
        opacity 0.3s var(--header-ease),
        visibility 0s;
}

.mobile-menu__sub-inner {
    min-height: 0;
    overflow: hidden; /* no padding here, so it shrinks all the way to 0 when closed */
}

.mobile-menu__label,
.mobile-menu__sublist a {
    opacity: 0;
    transform: translateY(0.5rem);
    transition: opacity 0.35s ease, transform 0.45s var(--header-ease);
}

.is-open .mobile-menu__label,
.is-open .mobile-menu__sublist a {
    opacity: 1;
    transform: translateY(0);
}

.is-open .mobile-menu__label { transition-delay: 0.05s; }
.is-open .mobile-menu__sublist li:nth-child(1) a { transition-delay: 0.09s; }
.is-open .mobile-menu__sublist li:nth-child(2) a { transition-delay: 0.13s; }
.is-open .mobile-menu__sublist li:nth-child(3) a { transition-delay: 0.17s; }
.is-open .mobile-menu__sublist li:nth-child(4) a { transition-delay: 0.21s; }
.is-open .mobile-menu__sublist li:nth-child(5) a { transition-delay: 0.25s; }

.mobile-menu__label {
    margin: 0.25rem 0 0.5rem;
    color: var(--header-text-muted);
    font-size: 0.8125rem; /* 13px */
    letter-spacing: 0.02em;
}

.mobile-menu__sublist {
    gap: var(--tap-spacing);
    padding-bottom: 1rem;
}

.mobile-menu__sublist a {
    display: flex;
    align-items: center;
    min-height: var(--tap-size);
    color: var(--header-text);
    font-size: var(--header-dropdown-font-size); /* 18px */
    letter-spacing: -0.01em;
    text-decoration: none;
}

.mobile-menu__sublist a::before {
    content: "/" / "";
    margin-right: 0.3em;
}

.mobile-menu__link:focus-visible,
.mobile-menu__sublist a:focus-visible {
    outline: 2px solid var(--header-text);
    outline-offset: 2px;
}

/* The two header buttons, side by side in a white panel at the bottom */
.mobile-menu__actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    margin-top: auto;
    padding: 0.5rem;
    border-radius: 0.625rem;
    background-color: #ffffff;
}

.mobile-menu__list {
    margin-bottom: 2rem; /* keeps the panel clear of the links when Industries is open */
}

.mobile-menu__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: 0 1rem;
    border: 1px solid transparent;
    border-radius: var(--header-radius);
    font: inherit;
    font-size: var(--header-font-size);
    line-height: 1;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.mobile-menu__btn--outline {
    border-color: var(--header-border);
    background-color: #ffffff;
    color: var(--header-text-muted);
}

.mobile-menu__btn--solid {
    background-color: #000000;
    color: #ffffff;
}

@media (hover: hover) and (pointer: fine) {
    .mobile-menu__btn--outline:hover {
        background-color: var(--header-btn-soft-bg-hover);
        color: var(--header-text);
    }

    .mobile-menu__btn--solid:hover {
        background-color: var(--header-btn-solid-bg-hover);
    }
}

.mobile-menu__btn:focus-visible {
    outline: 2px solid var(--header-text);
    outline-offset: 2px;
}

/* The bar while the menu is open */
body.menu-open .site-header {
    border-bottom-color: transparent;
    background-color: var(--menu-bg);
}

body.menu-open .site-header__actions .header-btn--solid {
    display: none;
}

body.menu-open .menu-toggle {
    background-color: var(--menu-close-bg);
}

body.menu-open {
    overflow: hidden;
}

@media (min-width: 1024px) {
    .site-nav {
        display: block;
        margin-left: var(--nav-offset);
    }

    .header-btn--outline {
        display: inline-flex;
    }

    .site-header__actions {
        --header-btn-height: 2.5rem;
        --header-font-size: 0.9375rem;
        gap: var(--header-gap);
    }

    .header-btn--solid {
        --btn-fill: var(--header-btn-solid-bg-hover);
        min-width: 0;
        padding: 0 1rem;
        background-color: #000000;
        color: #ffffff;
    }

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

/* ---------- Touch screens: press feedback ----------
   Without a mouse there's no hover, so controls answer the moment a finger lands: buttons dip slightly and
   darken, links fade. Mouse and trackpad users never see these. */
@media (hover: none) {
    .header-btn,
    .menu-toggle,
    .mobile-menu__btn {
        transition:
            background-size 0.35s var(--header-ease),
            background-color 0.2s ease,
            color 0.2s ease,
            transform 0.1s ease-out;
    }

    .header-btn:active,
    .menu-toggle:active,
    .mobile-menu__btn:active {
        transform: scale(0.97);
    }

    .header-btn--solid:active,
    .menu-toggle:active {
        background-color: var(--header-btn-mobile-bg-hover);
    }

    .header-btn--outline:active,
    .mobile-menu__btn--outline:active {
        background-color: var(--header-btn-soft-bg-hover);
    }

    .mobile-menu__btn--solid:active {
        background-color: var(--header-btn-solid-bg-hover);
    }
}

/* From 1024px Get Started is black again, so its press fill is the softer black */
@media (hover: none) and (min-width: 1024px) {
    .header-btn--solid:active {
        background-color: var(--header-btn-solid-bg-hover);
    }

    .mobile-menu__link {
        transition: opacity 0.1s ease-out;
    }

    .mobile-menu__link:active {
        opacity: 0.6;
    }

    /* The sublist links keep their rise-in transition; only the press itself is quick */
    .is-open .mobile-menu__sublist li a:active {
        opacity: 0.6;
        transition: opacity 0.1s ease-out;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mobile-menu:not([hidden]),
    .mobile-menu.is-closing,
    .mobile-menu .mobile-menu__list > li,
    .mobile-menu .mobile-menu__actions {
        animation: none !important;
    }

    .site-header,
    .site-nav__link,
    .menu-toggle,
    .site-header__chevron,
    .mobile-menu__chevron,
    .mobile-menu__btn,
    .header-btn,
    .nav-dropdown__panel,
    .nav-dropdown__panel.is-open,
    .nav-dropdown__list a,
    .mobile-menu__sub,
    .mobile-menu__sub.is-open,
    .mobile-menu__label,
    .mobile-menu__sublist a {
        transition: none;
        transition-delay: 0s;
        transform: none;
    }
}
