/* CAFFEINE — shrinking centred logo header
   Header floats over the hero, reserving no space (keeps page
   height constant, which is what stops the shrink flickering).
   --p (0->1) is written by caffeine-header.js; everything below
   derives from it. Hero section must have margin-top: 0. */

:root {
  --logo-width-start: 90vw;                 /* logo at top of page */
  --logo-width-end:   220px;                /* logo once shrunk */
  --logo-colour-start:#FFEFD4;
  --logo-colour-end:  #1C1C3C;

  --hdr-pad:          10px;                 /* above/below logo */
  --hdr-side-pad:     24px;                 /* left/right inset */
  --hdr-btn-gap:      12px;
  --hdr-nav-offset:   180px;                /* logo centre -> nav btn; must exceed 110px */

  --btn-fade-start:   0.7;                  /* how late buttons appear */
  --btn-fade-span:    0.3;                  /* keep = 1 - fade-start */

  --hdr-bg:           rgba(255,239,212,.55);/* lower alpha = more see-through */
  --hdr-blur:         16px;
  --hdr-saturate:     1.25;
  --hdr-border:       rgba(28,28,60,.10);
  --hdr-shadow:       0 2px 18px rgba(28,28,60,.08);
}

html, body { overflow-x: clip; overflow-anchor: none; }

header.elementor-location-header { position: relative; height: 0; }

.caffeine-header {
  --p: 0;
  --logo-w: calc(var(--logo-width-start) - (var(--logo-width-start) - var(--logo-width-end)) * var(--p));

  position: fixed !important;
  top: 0; left: 0; right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  height: auto !important;
  min-height: 0 !important;
  padding: var(--hdr-pad) var(--hdr-side-pad) !important;
  background: transparent !important;
  pointer-events: none;                     /* let clicks reach the hero */
}

.caffeine-header.is-shrunk,
.caffeine-header .caffeine-logo { pointer-events: auto; }

body.admin-bar .caffeine-header { top: 32px; }

/* Glass bar. Opacity is driven by --p, so the blur fades in too. */
.caffeine-header::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--hdr-bg);
  -webkit-backdrop-filter: blur(var(--hdr-blur)) saturate(var(--hdr-saturate));
  backdrop-filter: blur(var(--hdr-blur)) saturate(var(--hdr-saturate));
  border-bottom: 1px solid var(--hdr-border);
  box-shadow: var(--hdr-shadow);
  opacity: var(--p);
  pointer-events: none;
}

/* Logo. The .caffeine-header prefix + !important is needed to beat
   Elementor's widget CSS. SVG logos render inline, hence `svg`. */
.caffeine-header .caffeine-logo {
  width: var(--logo-w) !important;
  max-width: none !important;
  display: flex;
  justify-content: center;
}

/* Colour must carry !important on BOTH declarations — Elementor's
   own logo colour rule otherwise wins the cascade and the logo
   stays cream. Applied to the svg too, not just the wrapper. */
.caffeine-header .caffeine-logo,
.caffeine-header .caffeine-logo svg {
  color: var(--logo-colour-start) !important;   /* fallback */
  color: color-mix(in srgb, var(--logo-colour-end) calc(var(--p) * 100%), var(--logo-colour-start)) !important;
}

.caffeine-header .caffeine-logo svg,
.caffeine-header .caffeine-logo img {
  width: 100% !important;
  height: auto !important;
  display: block;
  max-height: 46vh;
}

/* Buttons: nav pair positioned from the centre so they stay
   balanced either side of the logo.
   Opacity clamps out of range, so the calc holds them at 0
   until --p passes --btn-fade-start. */
.caffeine-header [class*="caffeine-btn-"] {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: var(--hdr-btn-gap);
  width: auto !important;
  max-width: none !important;
  padding: 0 !important;
  flex-direction: row !important;
  opacity: calc((var(--p) - var(--btn-fade-start)) / var(--btn-fade-span));
  pointer-events: none;
}

.caffeine-header .caffeine-btn-left  { left: 50%; transform: translate(calc(-100% - var(--hdr-nav-offset)), -50%); }
.caffeine-header .caffeine-btn-right { left: 50%; transform: translate(var(--hdr-nav-offset), -50%); }

.caffeine-header.is-shrunk [class*="caffeine-btn-"] { pointer-events: auto; }

/* Tablet: logo shrinks but the offset is fixed, so pull the nav
   pair in closer rather than letting them drift wide. */
@media (max-width: 1024px) {
  :root { --hdr-nav-offset: 140px; }
}

/* Mobile: not enough width for symmetric nav — push the pair
   out to the edges instead. */
@media (max-width: 767px) {
  :root { --logo-width-end: 150px; --hdr-side-pad: 14px; }

  .caffeine-header .caffeine-btn-left  { left: var(--hdr-side-pad); transform: translateY(-50%); }
  .caffeine-header .caffeine-btn-right { left: auto; right: var(--hdr-side-pad); transform: translateY(-50%); }

  .caffeine-header .caffeine-logo svg,
  .caffeine-header .caffeine-logo img { max-height: 32vh; }
}

@media (max-width: 782px) {
  body.admin-bar .caffeine-header { top: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .caffeine-header { --p: 1 !important; }
}
