/* Depends on: base.css (uses var(--header-h), var(--burgundy), etc.) */

/* ============================================================
   HEADER
   ============================================================ */
header.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-h);
  background: none;
  z-index: 500;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3vw, 40px);
  opacity: 1;
  /* 0.9s on the transform to match .s1-panel's own height transition
     (section-1.css), so the row travelling out of the subsection and
     the subsection collapsing behind it move as one gesture. */
  transition:
    opacity 0.5s ease,
    transform 0.9s var(--ease);

  /* Adaptive foreground colors for the burger bars vs. the logo/links,
     flipped to white by the dark-slide rules further down once the
     header is riding over a dark section background. */
  --header-icon: var(--ink);
  --header-accent: var(--burgundy);
  --header-sep: var(--line);

  /* How far the row drops to sit inside Section 1's subsection, and how
     much bigger the logo reads while it's down there — see the block
     below the hidden/dark rules. One drop, for the fullscreen subsection
     at step 2: the row is hidden for steps 0 and 1, so the part-height
     drawer never has a header in it to place. This is the knob for
     placing the row above the type. */
  --header-drop-full: 22vh;
  --header-logo-grow: 2;
}
header.site-header > * {
  pointer-events: auto;
}
/* Hidden entirely through Section 1's hero look AND the first scroll
   into it — step 0 is the pure hero (fullscreen clouds video, centered
   logo, bazar_praga image, roof art, see section-1.css) and step 1 is
   the subsection opening as a part-height drawer. The row only fades in
   at step 2, once that subsection has grown to cover the section and
   there is actually a panel for it to be sitting inside; appearing at
   step 1 put it on screen over a half-open drawer, well before the
   subsection it belongs to had arrived.

   Scoped to data-slide="0" same as the dark-theme rule below, so it
   stops matching the instant the user has scrolled past Section 1 (its
   data-step then stays at its final value forever — see enterFreeMode
   in scroll-engine.js — but data-slide moves on, so this never
   re-hides the header later). */
body[data-slide="0"]:has(#slide-s1[data-step="0"]) header.site-header,
body[data-slide="0"]:has(#slide-s1[data-step="1"]) header.site-header {
  opacity: 0;
  pointer-events: none;
}

/* ---- Section 1: the header starts out inside the subsection ----
   Nothing here rebuilds the header. The row is already burger-left /
   logo-centre / links-right, which is exactly the arrangement wanted
   inside the subsection, so all this does is hold the whole row down
   in the panel, grown, for as long as the panel is open (steps 0-2 —
   step 0 included so it is already in place and already at size before
   it is ever visible, see the rule above), then let it ease back up to
   its real place at step 3 as the panel collapses into the SZCZEGÓŁY
   pill. The row never travels INTO the subsection: it is simply
   already there, and the only move it makes is following the panel
   from its 46vh drawer height up to fullscreen, and finally home.

   Step 2 is excluded when #slide-s1 carries `s1-reopened` — that class
   marks a step 2 arrived at by CLICKING the pill rather than by
   scrolling (see section-1.js). On that path the header stays put at
   the top and only the subsection opens, exactly as it did before any
   of this existed.

   The header is a sibling of the slide deck, not a descendant, so the
   step has to be read with :has() — the same way the two rules above
   and below this one already do it. */
/* One drop, not two: the row is invisible for steps 0 and 1, so it is
   parked at its step-2 resting place from the start and simply fades in
   there. Giving steps 0/1 the taller drawer drop instead meant the row
   animated up 35vh at the same moment it faded in, which read as the
   header flying in from the middle of the screen. */
body[data-slide="0"]:has(#slide-s1[data-step="0"]) header.site-header,
body[data-slide="0"]:has(#slide-s1[data-step="1"]) header.site-header,
body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
  header.site-header {
  transform: translateY(var(--header-drop-full));
}
/* .logo-btn is absolutely centred with a translate of its own, so the
   growth has to be appended to that rather than replacing it. Step 0 is
   in the list for the same reason the row is pre-placed above: the logo
   has to be at full size before it becomes visible, or step 1 would
   fade it in mid-grow. */
body[data-slide="0"]:has(#slide-s1[data-step="0"]) .logo-btn,
body[data-slide="0"]:has(#slide-s1[data-step="1"]) .logo-btn,
body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
  .logo-btn {
  /* The trailing translateX runs AFTER the scale, so it is measured in
     the scaled-up coordinate system — which is what's wanted: the
     lockup's re-centring has to grow with the lockup. */
  transform: translate(-50%, -50%) scale(var(--header-logo-grow))
    translateX(calc(var(--logo-lockup-shift) * -1));
}
/* The type joins the mark for exactly as long as the row is down in the
   subsection. Step 0 is in the list for the same reason as everywhere
   else here — in place before it is ever visible, so step 1 has nothing
   to animate and it simply appears alongside the mark. */
body[data-slide="0"]:has(#slide-s1[data-step="0"]) .logo-type,
body[data-slide="0"]:has(#slide-s1[data-step="1"]) .logo-type,
body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
  .logo-type {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
/* The liquid glass is a bar pinned across the header's own box, so it
   would travel down with the row and read as a glass strip floating
   mid-screen. It belongs to the header's resting place: hidden while
   the row is in the subsection, faded back in as it arrives home. Off
   at step 0 too — otherwise it sits there at full strength under the
   invisible row and visibly fades out as step 1 fades the row in. */
body[data-slide="0"]:has(#slide-s1[data-step="0"]) header.site-header::before,
body[data-slide="0"]:has(#slide-s1[data-step="1"]) header.site-header::before,
body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
  header.site-header::before {
  opacity: 0;
}

/* The burger now sits inside the subsection, so the menu can be opened
   while the row is down there — and opening it doesn't touch data-step
   (nav.js only adds .menu-open), which would leave burger/logo/links
   stranded in the middle of a fullscreen menu panel. Send the row home
   for as long as the menu is open.

   !important rather than out-specifying the rules above: those carry a
   :not() nested inside their :has(), which makes them awkwardly hard
   to beat, and matching them would mean padding these selectors with
   attributes picked for weight rather than meaning — the kind of thing
   the next edit up there silently breaks. "Menu open always wins" is
   the actual intent, so say it outright. */
body.menu-open header.site-header {
  transform: none !important;
}
body.menu-open .logo-btn {
  transform: translate(-50%, -50%) !important;
}
body.menu-open .logo-type {
  opacity: 0 !important;
}
body.menu-open header.site-header::before {
  opacity: 1 !important;
}

/* "Liquid glass" — test build, no blur: only the SVG turbulence-warp
   + chromatic-aberration filter (see index.html) runs on the sharp
   backdrop, so it's clear to see on its own instead of being washed
   out by a blur. Split into its own ::before (rather than living on
   the header itself) so a mask-image can fade it out towards the
   bottom, and so it can be reliably painted BEHIND the header's real
   content (burger/logo/links, all given z-index: 1 below) instead of
   risking it visually overlapping that content.
   `backdrop-filter: blur(0px)` is a deliberate no-op: SOME
   backdrop-filter value has to be present for the browser to capture
   what's behind the header as this element's own pixels at all — that
   captured image is then what `filter: url(#header-liquid-glass)`
   warps/aberrates. `filter` and `backdrop-filter` are kept as two
   separate properties rather than one `backdrop-filter: <fn> url(#...)`
   list because browser support for referencing an SVG filter *inside*
   backdrop-filter is still shaky (it silently did nothing in testing),
   whereas `filter: url(#...)` is old, well-supported syntax that runs
   on the element's already-composited output. */
header.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: rgba(255, 255, 255, 0);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  filter: url(#header-liquid-glass);
  /* Fades with the row's return from the subsection — see the block
     above. Shorter than the 0.9s move so the glass is fully back by
     the time the row settles, rather than still resolving under it. */
  transition: opacity 0.5s ease;
  -webkit-mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) 75%,
    rgba(0, 0, 0, 0) 100%
  );
  mask-image: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 1) 0%,
    rgba(0, 0, 0, 1) 75%,
    rgba(0, 0, 0, 0) 100%
  );
}

/* Dark section backgrounds the fixed header can ride over — burgundy
   (S4), ink (S6), the ink-colored footer — where the burgundy/ink
   foreground would disappear, so the icons/logo/links swap to
   paper-2 instead. `[data-slide]` is kept live the whole time:
   render.js updates it while scrolling is still "hijacked", and
   updateFreeScrollHeaderTheme() (scroll-engine.js) takes over once the
   user reaches the end and scrolling becomes native.
   (Indices shifted +1 from the section numbers in the comment above —
   the new Section Guest was inserted at index 1 — burgundy is index
   3, ink index 5. S3, index 2, used to be here too when its
   background was --pitch, but it's a light pink now — see the
   dedicated burgundy rule just below instead.) */
body[data-slide="3"] header.site-header,
body[data-slide="5"] header.site-header,
body[data-slide="footer"] header.site-header,
/* Section 1: once past its very first step (the header is hidden
   there anyway — see the opacity rule above — so this is really about
   what happens once it fades in: the burgundy panel drawer/fullscreen),
   treat it the same as a dark section. Scoped to `data-slide = "0"` as
   well as the :has() check — #slide-s1's data-step, once reached, stays
   at its final value forever (see enterFreeMode in scroll-engine.js),
   so without that extra check this would keep matching long after the
   user has scrolled past Section 1 entirely. */
body[data-slide="0"]:has(#slide-s1:not([data-step="0"])) header.site-header {
  --header-icon: var(--paper-2);
  --header-accent: var(--paper-2);
  --header-sep: rgba(233, 223, 201, 0.35); /* var(--paper-2) at low opacity */
}
/* Section 6 (index 5): overrides the paper-2 above with the section's
   own orange accent instead — matching the color of its "NASZE
   WSPOMNIENIA 2025" label, since the header floats over the same ink
   background the whole time this section is in view. `:not(.menu-open)`
   so this doesn't fight the "menu open always wins" paper-2 rule further
   down (same specificity, and this rule would otherwise sit later in
   several of that rule's properties by source order). */
body[data-slide="5"]:not(.menu-open) header.site-header {
  --header-icon: var(--orange);
  --header-accent: var(--orange);
  --header-sep: rgba(255, 106, 31, 0.35); /* var(--orange) at low opacity */
}
/* S3 (index 2): pink background, so every header element goes
   burgundy instead of the light paper-2 used on the actual dark
   sections above. --header-accent and .logo-mask's own default are
   already burgundy without any override (see their base rules), so
   this only needs to state what's NOT already burgundy by default:
   --header-icon (the burger bars, normally --ink) and --header-sep
   (normally --line, a neutral light gray). */
body[data-slide="2"] header.site-header {
  --header-icon: var(--burgundy);
  --header-sep: rgba(124, 17, 40, 0.35); /* var(--burgundy) at low opacity */
}
/* S5 (index 4, WYSTAWCY): same fix as S3 above and for the same
   reason — --header-accent already defaults to burgundy, so only the
   burger icon (--header-icon, normally --ink) and the separator
   needed the explicit push. */
body[data-slide="1"] header.site-header,
body[data-slide="4"] header.site-header,
body[data-slide="6"] header.site-header {
  --header-icon: var(--burgundy);
  --header-sep: rgba(124, 17, 40, 0.35);
}
body[data-slide="3"] .fb-bazar-link:hover,
body[data-slide="5"] .fb-bazar-link:hover,
body[data-slide="footer"] .fb-bazar-link:hover,
body[data-slide="0"]:has(#slide-s1:not([data-step="0"])) .fb-bazar-link:hover {
  color: rgba(233, 223, 201, 0.7); /* var(--paper-2) at lower opacity */
}
body[data-slide="5"]:not(.menu-open) .fb-bazar-link:hover {
  color: rgba(255, 106, 31, 0.7); /* var(--orange) at lower opacity — see Section 6's header override above */
}

/* The nav menu panel (nav-menu.css) is an ink-dark background sitting
   right underneath the still-visible header (header is z-index 500,
   above the menu's 400) — burgundy/ink header elements would have poor
   contrast against it, so force paper-2 the whole time the menu is
   open, regardless of which section/slide is behind it. Higher
   specificity than the plain `header.site-header` defaults above, so
   it wins regardless of slide. */
body.menu-open header.site-header {
  --header-icon: var(--paper-2);
  --header-accent: var(--paper-2);
  --header-sep: rgba(233, 223, 201, 0.35);
}
body.menu-open .fb-bazar-link:hover {
  color: rgba(233, 223, 201, 0.7);
}
body.menu-open .logo-ellipse img {
  filter: brightness(0) invert(1) sepia(0.3) saturate(1.6) brightness(0.95);
}

/* hamburger */
.burger {
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  z-index: 20;
  /* So it can fade rather than blink when Section 1's subsection hides
     it on mobile (see the block at the end of this file). */
  transition: opacity 0.4s ease;
}
.burger span {
  display: block;
  width: 26px;
  height: 2px;
  background: var(--header-icon);
  transition:
    transform 0.35s var(--ease),
    opacity 0.25s ease,
    background 0.4s ease;
}
.burger[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}
.burger[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}
.burger[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* logo — centered against the header itself (not as the middle flex item)
   so it stays dead-center regardless of how wide the burger/right-links
   groups on either side are; with plain space-between, the logo would
   only land at true center if those two groups happened to match width. */
.logo-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  transform: translate(-50%, -50%);
  border: none;
  background: none;
  padding: 0;
  height: calc(var(--header-h) * 0.8);
  width: calc(var(--header-h) * 0.8 * 2);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Same 0.9s as the row's own move, so the logo shrinks back to size
     over exactly the travel up to the header rather than finishing
     early and riding the last of the way already small. */
  transition: transform 0.9s var(--ease);

  /* ---- lockup geometry, for .logo-type below ----
     The painted mark is smaller than this button box: .logo-ellipse
     insets it by its own 0.5rem padding, and mask-size:contain then
     fits what's left by HEIGHT, so the artwork ends up this tall and —
     at the SVG's own 331.8:226.52 — this wide, sitting centred with
     empty space either side. The type has to be placed off that
     artwork, not off the box, or it lands visibly too far out. */
  --logo-art-h: calc(var(--header-h) * 0.8 - 1rem);
  --logo-art-w: calc(var(--logo-art-h) * 331.8 / 226.52);
  /* Proportions taken from brand_logo-logotype.svg, the combined
     lockup: against a 352-wide mark the type is 376.45 wide and stands
     42 clear of it. Kept as ratios so the pair holds together at any
     header height and at any scale the subsection grows it to. */
  --logo-type-w: calc(var(--logo-art-w) * 376.45 / 352);
  --logo-type-gap: calc(var(--logo-art-w) * 42 / 352);
  /* Hanging the type off the right pushes the pair's centre of mass
     right by half of everything added, so the lockup is shifted back
     by exactly that to sit centred as one unit. */
  --logo-lockup-shift: calc((var(--logo-type-gap) + var(--logo-type-w)) / 2);
}

/* The brand type that joins the mark inside the subsection. Same
   stencil trick as .logo-mask below — the asset is flat #0bbbef, so it
   is used as a mask over a paper-2 background rather than recoloured.
   Absolutely positioned, so .logo-btn's flex centring of the mark is
   untouched; being a CHILD of .logo-btn means it inherits the
   subsection's scale-up for free. */
.logo-type {
  position: absolute;
  top: 50%;
  /* Measured from the ARTWORK's right edge: 50% is the box's centre,
     plus half the artwork, plus the lockup gap. */
  left: calc(50% + var(--logo-art-w) / 2 + var(--logo-type-gap));
  width: var(--logo-type-w);
  aspect-ratio: 376.45 / 178.4;
  background-color: var(--paper-2);
  -webkit-mask-image: url("../assets/images/logo/brand_logo-type.svg");
  mask-image: url("../assets/images/logo/brand_logo-type.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  pointer-events: none;
  /* Resting state is ABSENT: parked off to the right and invisible, so
     the header's normal look is the bare mark exactly as before, and
     leaving the subsection reads as a slide out to the right. */
  opacity: 0;
  transform: translateY(-50%) translateX(50%);
  transition:
    opacity 0.45s ease,
    transform 0.9s var(--ease);
}
.logo-ellipse {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  /* background: var(--burgundy); */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  transition:
    transform 0.25s var(--ease),
    background 0.25s ease;
}
.logo-btn:hover .logo-ellipse {
  transform: scaleX(1.05);
  /* background: var(--burgundy-dark); */
}

/* The logo is a flat-color SVG asset (not inlined), so it can't pick
   up var(--header-accent) via `color`/currentColor directly. Rather
   than an <img> recolored with a `filter` (which can only ever
   approximate a target hex — filters can't hit one precisely), this
   uses the SVG purely as a `mask-image` stencil on a plain element
   whose own `background-color` does the actual painting — that gives
   an exact color match, burgundy normally and paper-2 on dark slides. */
.logo-mask {
  display: block;
  width: 100%;
  height: 100%;
  background-color: var(--burgundy);
  -webkit-mask-image: url("../assets/images/logo/pbp_logo_burgundy.svg");
  mask-image: url("../assets/images/logo/pbp_logo_burgundy.svg");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  transition: background-color 0.4s ease;
}
/* S3 (index 2) isn't here — .logo-mask's own base rule above already
   defaults to var(--burgundy), which is exactly what's wanted there
   now, so it needs no override at all rather than a redundant one
   restating the default. */
body[data-slide="3"] .logo-mask,
body[data-slide="5"] .logo-mask,
body[data-slide="footer"] .logo-mask,
body[data-slide="0"]:has(#slide-s1:not([data-step="0"])) .logo-mask {
  background-color: var(--paper-2);
}
body[data-slide="5"]:not(.menu-open) .logo-mask {
  background-color: var(--orange); /* overrides the paper-2 above — see Section 6's header override further up. `:not(.menu-open)` so the logo still goes paper-2 (not orange) against the dark nav-menu panel, matching every other slide. */
}
/* .logo-mark {
  font-family: var(--display); font-weight:800;
  color: var(--paper);
  font-size: 1rem;
  letter-spacing: 0.05em;
  transform: scale(1, 0.9);
} */

/* right side */
.header-right {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  /* Same reason as .burger above. */
  transition: opacity 0.4s ease;
}

.fb-bazar-link {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--display); font-weight:800;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--header-accent);
  white-space: nowrap;
  transition: color 0.4s ease;
}
.fb-bazar-link svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.fb-bazar-link:hover {
  color: var(--burgundy-dark);
}

.header-sep {
  color: var(--header-sep);
  font-size: 1rem;
  transition: color 0.4s ease;
}

.help-link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--display); font-weight:800;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  color: var(--header-accent);
  white-space: nowrap;
  transition: color 0.4s ease;
}
.help-link .txt {
  display: flex;
  flex-direction: row;
  gap: 0.35em;
}
.help-link .arrow {
  width: 18px;
  height: 18px;
  flex: none;
  margin-top: 2px;
}
.help-link .arrow path {
  stroke: var(--header-accent);
  transition: stroke 0.4s ease;
}

@media (max-width: 900px) {
  .help-link .txt {
    flex-direction: column;
    gap: 0;
    line-height: 1.05;
  }
  .help-link .arrow {
    width: 20px;
    height: 38px;
    margin-top: 0;
  }
  .fb-bazar-link span {
    display: none;
  } /* keep the header from getting crowded on narrow screens */
}

/* ---- Section 1's subsection, on mobile only ----
   Two adjustments while the header row is riding down inside the
   subsection (steps 0-2; step 2 only when it was reached by scrolling,
   not by re-opening the panel with the pill — same condition the
   desktop rules above use).

   1. The logo lockup — the mark and the brand type it is joined by —
      reads 25% smaller down there. At the shared --header-logo-grow of
      2 the pair was simply too wide for a phone, crowding both edges;
      the grow is the one knob that sizes it, so the mobile value is
      just that same knob turned down. Everything hung off the lockup
      (the type's placement, the re-centring shift) is expressed in
      ratios of it, so they all follow on their own.

   2. The burger and the right-hand links stay hidden. They belong to
      the header proper, and inside the subsection they read as loose
      controls floating over the panel rather than as a header row. They
      fade in at step 3, when the row actually arrives at the top — the
      same moment the panel collapses into the SZCZEGÓŁY pill.

   Deliberately NOT touching the row on desktop, where there is room
   for all three. */
@media (max-width: 760px) {
  body[data-slide="0"]:has(#slide-s1[data-step="0"]) header.site-header,
  body[data-slide="0"]:has(#slide-s1[data-step="1"]) header.site-header,
  body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
    header.site-header {
    --header-logo-grow: 1.5; /* 2 × 0.75 */
  }
  body[data-slide="0"]:has(#slide-s1[data-step="0"]) .burger,
  body[data-slide="0"]:has(#slide-s1[data-step="1"]) .burger,
  body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
    .burger,
  body[data-slide="0"]:has(#slide-s1[data-step="0"]) .header-right,
  body[data-slide="0"]:has(#slide-s1[data-step="1"]) .header-right,
  body[data-slide="0"]:has(#slide-s1[data-step="2"]:not(.s1-reopened))
    .header-right {
    opacity: 0;
    pointer-events: none;
  }
  /* Opening the menu sends the row home (see the .menu-open rule
     further up), so the burger has to come back with it — otherwise
     the close button for the menu you just opened is invisible. */
  body.menu-open .burger,
  body.menu-open .header-right {
    opacity: 1;
    pointer-events: auto;
  }
}
