/*
 * Fixed, scroll-linked shrinking site header.
 *
 * Markup: <header class="cultina-site-header"> (fixed) wraps the [Global] Header
 * Elementor template, whose first container has class "cultina-header-row"
 * (rests at min-height 159px) and holds the cultina_nav widget. The page content
 * lives in <main class="cultina-site-main"> right after it.
 *
 * Why position:fixed (not sticky): the shrink is SCROLL-LINKED — nav.js writes a
 * progress value --cn-shrink (0 at the top → 1 after ~120px of scroll) to the
 * header on every scroll frame, and the bar height, logo→icon morph (nav.css)
 * and shadow interpolate off it. A *sticky* header is in document flow, so
 * changing its height every frame would reflow the whole page below it. A
 * *fixed* header is out of flow, so its height changes never reflow the
 * document — only the header's own (small) subtree. The content keeps a constant
 * padding-top equal to the RESTING header height, so the layout is pixel-identical
 * to before at the top and the content simply scrolls under the shrinking bar.
 * No CSS transitions here — the scroll position is the timeline.
 *
 * Contact flaps inside the header are position:fixed (flap.css) and float
 * independently. Colours come from the design tokens.
 */

/* Header heights kept in one place so the bar and the content offset stay in
   sync. --cultina-header-h is the resting height (and the constant content
   offset); --cultina-header-h-min is the shrunk height once scrolled, sized to
   sit snugly around the logo's compact icon form. */
:root {
    --cultina-header-h: 159px;
    --cultina-header-h-min: 96px;
}

/* Anchor / skip-link targets must clear the fixed bar instead of landing behind
   it (it is at most ~96px tall once scrolled). */
html {
    scroll-padding-top: 96px;
}

.cultina-site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* Above page content; below the contact flaps (z 9000+) so they stay on top. */
    z-index: 100;
    background: var(--cultina-color-surface, #fff);
    /* Shadow fades in with scroll progress so the bar reads as floating. */
    box-shadow: 0 2px 16px rgba(49, 49, 49, calc(0.08 * var(--cn-shrink, 0)));
}

/* Reserve the resting header height so the first content sits exactly where it
   did before (pixel-perfect). This offset stays CONSTANT while the bar shrinks —
   that is what keeps the shrink reflow-free; the content scrolls under the bar. */
.cultina-site-main {
    padding-top: var(--cultina-header-h, 159px);
}

/* Header row height is SCROLL-LINKED: it interpolates from the resting height
   down to --cultina-header-h-min as --cn-shrink goes 0 → 1 (written by nav.js),
   so the bar tightens around the logo's icon form on scroll. The logo SLOT keeps
   its WIDTH (nav.css) so the nav links never move horizontally — only the bar
   HEIGHT, the slot height and the logo→icon morph shrink. The content offset
   below stays CONSTANT at the resting height (reflow-free; the content scrolls
   under the shrinking bar). !important + the doubled class beat Elementor's
   per-element min-height rule. */
.cultina-header-row.cultina-header-row {
    min-height: calc(
        var(--cultina-header-h, 159px) -
        (var(--cultina-header-h, 159px) - var(--cultina-header-h-min, 96px)) * var(--cn-shrink, 0)
    ) !important;
}

/* QA preview (?headershrunk=1): force the fully-scrolled state so the bar shows
   at its shrunk height with the logo as its icon. The content offset is dropped
   to the shrunk height too, so the preview reads like the real scrolled bar
   rather than leaving a gap above the content. */
body.cultina-header-shrunk {
    --cn-shrink: 1;
}
body.cultina-header-shrunk .cultina-site-main {
    padding-top: var(--cultina-header-h-min, 96px);
}

/* WordPress admin bar (logged-in users): it is fixed at the very top, so push
   the fixed header below it. The admin bar already adds html{margin-top} for the
   in-flow content, so only the fixed header needs the offset. */
body.admin-bar .cultina-site-header {
    top: 32px;
}
@media screen and (max-width: 782px) {
    body.admin-bar .cultina-site-header {
        top: 46px;
    }
}

/* Elementor-Canvas pages have no theme header — drop the reserved offset. */
.cultina-elementor-canvas .cultina-site-main {
    padding-top: 0;
}
