/* =========================================================
   AC-v2 Top navigation + dropdown
   Fixed bar, theme-aware, dropdown on hover (desktop) + tap
   (mobile), burger collapse at 767.
   Active + hover states use colour and underline only, never
   font-weight, so nav items do not reflow.
   ========================================================= */

/* 16.05.26 (round 4): register --nav-light as a typed number so it
   can transition. Without @property, CSS custom properties don't
   interpolate; nav.js sets --nav-light = 0 or 1 on section change
   and the colour/glass values snap. With this registered, the
   transition on .nav below lerps --nav-light over time, and every
   color-mix() expression that depends on it (background, --bg,
   --soft-text, --primary-text) smoothly recomputes per frame. */
@property --nav-light {
  syntax: '<number>';
  inherits: true;
  initial-value: 1;
}

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  z-index: 100;

  /* ---------- Untinted glass bar, scroll-linked text colour (15.05.26 PM) ----------
     The nav has no fill, no rim, no hairline, no drop shadow; only
     the backdrop blur reads as glass. Text colour is scroll-linked:
     nav.js writes --nav-light (0 = dark brand-world, 1 = light
     studio) as section tops cross the bar, and --primary-text /
     --soft-text below color-mix off --nav-light so the words shift
     to contrast with whatever content is under the bar. .nav__link
     already has `transition: color`, so the snap reads as a fade
     rather than a hard flip. */
  --nav-light: 1;   /* default light; nav.js drives it from scroll */

  /* themed tokens consumed by nav descendants (links, dropdown, burger).
     16.05.26 (round 2): --soft-text pushed to brand extremes per
     Caoimhín: the prior 20% bump wasn't visibly different. Now:
       dark state (over brand-world)  → #FFFFFF (pure white)
       light state (over studio)      → #0F1419 (brand dark)
     The nav link colour uses --soft-text, so this is what carries the
     contrast lift. Fuchsia accent + hover/aria-current colours are
     unchanged. */
  --bg: color-mix(in srgb, #16181A, #FFFFFF calc(var(--nav-light) * 100%));
  --soft-text: color-mix(in srgb, #FFFFFF, #0F1419 calc(var(--nav-light) * 100%));
  --primary-text: color-mix(in srgb, #FFFFFF, #0F1419 calc(var(--nav-light) * 100%));

  /* 16.05.26 (round 4): saturation pushed from 1.8 → 3.0 per Caoimhín
     for more colour pull through the glass. Keeps the 65%-alpha tint
     + 20px blur + 15deg hue-rotate + 1.1 contrast from round 3; only
     saturate is raised. Dial back if it goes neon.

     21.05.26 r7: Caoimhín reports the dark-state nav now reads as
     solid navy rather than glass. The 20.05.26 ramp to 95% over the
     chamber killed the backdrop-filter effect. Pulling the dark-state
     alpha back to 70% so the blur stays legible while keeping enough
     opacity to soften (not eliminate) the chamber bleed-through. */
  --nav-bg-alpha: calc(60% + (1 - var(--nav-light)) * 10%);
  background: color-mix(in srgb, transparent calc(100% - var(--nav-bg-alpha)), var(--bg) var(--nav-bg-alpha));
  backdrop-filter: blur(20px) saturate(3.0) hue-rotate(15deg) contrast(1.1);
  -webkit-backdrop-filter: blur(20px) saturate(3.0) hue-rotate(15deg) contrast(1.1);
  color: var(--primary-text);   /* propagates to .nav__burger via color: inherit + currentColor on its bars */

  /* The whole bar is hidden while the hero is on screen so it does
     not overlay the hero wordmark. section-observers.js adds
     .nav--logo-visible to the nav once #landing leaves the viewport
     top; the rule below reveals the bar. Class name retained from
     the earlier logo-only reveal pattern; it now drives both. */
  opacity: 0;
  pointer-events: none;
  /* 16.05.26 (round 5): --nav-light transition tightened 500ms → 400ms
     (≈20% quicker, both directions) per Caoimhín. The lerp is still
     ease-curved, just shorter, so the theme change snaps a beat sooner
     while staying smooth. */
  transition: opacity var(--t-standard) var(--ease-standard),
              color var(--t-fast) var(--ease-standard),
              --nav-light 400ms ease;
}

/* 22.05.26 (session 3, step 2): on touch devices lighten the nav glass.
   The base backdrop-filter (blur(20px) plus saturate / hue-rotate /
   contrast) is fixed and always on screen, so it re-blurs whatever moves
   behind it (notably the TEoTE parallax) every scroll frame, a heavy
   per-frame cost on mobile GPUs. Drop to a single small blur on
   coarse-pointer devices, matching the atmosphere + Malus-blend gates.
   The 60 to 70 percent background tint still reads as glass. Desktop
   (fine pointer) keeps the full tinted, saturated glass. */
@media (pointer: coarse) {
  .nav {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }
}

.nav.nav--logo-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Cream nav theme disabled 19.04.26 per user direction.
.nav[data-theme="cream"] {
  background: rgba(239, 231, 216, 0.9);
  border-bottom-color: rgba(255, 63, 209, 0.2);
}
*/

.nav__inner {
  max-width: var(--max-content);
  margin: 0 auto;
  height: 100%;
  padding: 0 var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------- Logo ---------- */
/* Scale history: 60% (initial) > 100% + s-2 padding > 63% (19.04.26) > 50%
   (14.05.26, 20% smaller per Caoimhín). Source: AC's white wordmark
   (ac-wordmark-white-*, regenerated from text-white@4x). nav.css lerps
   it dark via a brightness() filter for the light-studio glass (see
   .nav__logo img below), in step with the scroll-linked --nav-light.
   Reveal: logo is hidden while the hero (#landing) is on screen so the
   nav doesn't double up with the hero wordmark. JS adds .nav--logo-visible
   to the nav once the user scrolls past the hero. See section-observers.js. */
.nav__logo {
  display: inline-flex;
  align-items: center;
  height: 50%;
  flex-shrink: 0;

  /* Hidden by default, faded in once past the hero. */
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: opacity var(--t-standard) var(--ease-standard),
              transform var(--t-standard) var(--ease-standard);
}
.nav.nav--logo-visible .nav__logo {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}
.nav__logo img {
  height: 100%;
  width: auto;
  display: block;
  /* The asset is the white wordmark; brightness() lerps it from white
     (dark nav) to near-black (light nav) in step with --nav-light. */
  filter: brightness(calc(1 - var(--nav-light)));
}
/* 19.05.26: accent X-monogram overlay for the nav logo. Sparks in
   unison with the hero overlay via the same nav.js flash loop
   (querySelectorAll covers both .landing__wordmark-overlay and
   .nav__logo-overlay). Centred over the wordmark's X-monogram glyph;
   shifted ~1.4% right of centre to land on the X (mirrors the
   landing overlay's calibrated proportional offset). */
.nav__logo-stack {
  position: relative;
  display: inline-block;
  height: 100%;
}
.nav__logo-overlay-frame {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(50% + 0.7%);
  transform: translateX(-50%);
  height: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.nav__logo-overlay {
  display: block;
  height: 100%;
  width: auto;
  opacity: 0;
  user-select: none;
  -webkit-user-drag: none;
  /* nav.js overrides opacity + transform per spark; the base values
     above are the resting state (invisible, no offset). */
}

/* ---------- Nav list ---------- */
.nav__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: var(--s-7);
  align-items: center;
}

.nav__item {
  position: relative;
}

/* Links keep a single weight (700) so hover/active never reflow.
   Differentiation is through colour + underline.
   12.05.26: weight bumped 500 to 700, opacity bumped 0.82 to 0.95.
   The previous medium-weight + 18% dim combination read as anaemic;
   bold + near-full-opacity gives the nav the presence it should
   carry, while the subtle 5% dim retains a default-vs-hover signal
   alongside the colour shift cream to copper. */
.nav__link {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: var(--nav);
  color: var(--soft-text);
  opacity: 0.95;
  padding: var(--s-3) 0;
  display: inline-block;
  position: relative;
  transition: color var(--t-fast) var(--ease-standard),
              opacity var(--t-fast) var(--ease-standard);
}

/* .nav[data-theme="cream"] .nav__link { color: var(--cream-text); }; disabled 19.04.26 */

.nav__link:hover,
.nav__link:focus-visible {
  opacity: 1;
  color: var(--accent);
}

.nav__link[aria-current="page"],
.nav__link.is-active-branch {
  opacity: 1;
  color: var(--accent);
}
.nav__link[aria-current="page"]::after,
.nav__link.is-active-branch::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 2px;
  height: 1px;
  background: var(--accent);
}

/* Dropdown chevron rendered inline (inside the label) so it never
   collides with the aria-current underline or changes item width. */
.nav__chevron {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.75em;
  opacity: 0.7;
  transform: translateY(-1px);
}

/* ---------- Dropdown panel ----------
   12.05.26: dropdown surface aligned with .et-card treatment.
   Was solid var(--authority) navy with copper border + radius-md;
   now matches the et-cards (dark translucent fill, backdrop blur,
   no border, larger radius). Per Caoimhín: navy "isn't appropriate,
   anywhere"; the et-card treatment fits the palette. */
.nav__dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 320px;
  /* 12.05.26 v2: opacity bumped 0.70 → 0.92, blur 8px → 16px.
     The et-card values (0.70 + blur 8) read as solid when sitting
     on the chamber backdrop because the chamber is dark and uniform.
     The dropdown sits over varied page content and partly over the
     et-cards themselves; the same values rendered as see-through.
     Bumping opacity + blur makes the dropdown self-contained so it
     reads as solid regardless of what's behind it. Scroll-linked off
     --nav-light, like the bar, but kept more opaque for menu legibility. */
  background: rgba(255, 255, 255, 0.96);   /* fallback */
  /* 20.05.26: dark-side alpha bumped 0.86 -> 0.97 to match the
     light-side and stop the chamber bleeding through the dropdown
     panel after the chamber strip-and-restore (the static chamber
     image was reading as a visible texture through the prior 86%-
     alpha glass; the panel needs to be solid against varied
     backdrops). */
  background: color-mix(in srgb,
              rgba(22, 24, 26, 0.97),
              rgba(255, 255, 255, 0.96) calc(var(--nav-light) * 100%));
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  border-radius: var(--radius-lg);
  padding: var(--s-5) var(--s-6);
  opacity: 0;
  visibility: hidden;
  /* 19.05.26: translateY(-8px) intro animation retired - it caused
     the branch links (Eternal Tales, The Ends of the Earth) to read
     as "drifting" into position on every open. Dropdown now snaps
     in / out via opacity only, anchored at its final position. */
  transition: opacity var(--t-fast) var(--ease-standard),
              visibility 0s linear var(--t-fast);
  box-shadow: var(--shadow-card);
}

.nav__item.has-dropdown:hover .nav__dropdown,
.nav__item.has-dropdown:focus-within .nav__dropdown,
.nav__item.has-dropdown[aria-expanded="true"] .nav__dropdown {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--t-fast) var(--ease-standard),
              visibility 0s linear 0s;
}

.nav__dropdown-label {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-soft);
  margin: 0 0 var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid rgba(255, 63, 209, 0.25);
}

/* Tree: two peer branches (Eternal Tales, The Ends of the Earth) */
.nav__tree {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.nav__tree-branch {
  display: block;
}

.nav__branch-link {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 17px;
  color: var(--primary-text);
  line-height: 1.3;
  display: inline-block;
  padding: 2px 0;
  position: relative;
  transition: color var(--t-fast) var(--ease-standard);
}
.nav__branch-link:hover,
.nav__branch-link:focus-visible {
  color: var(--accent);
}
.nav__branch-link[aria-current="page"],
.nav__branch-link.is-active-branch {
  color: var(--accent);
}
.nav__branch-link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--accent);
}

.nav__tree-children {
  list-style: none;
  margin: var(--s-3) 0 0;
  padding: 0 0 0 var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  border-left: 1px solid rgba(255, 63, 209, 0.35);
}

.nav__child-link {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--body-small);
  color: var(--soft-text);
  opacity: 0.88;
  padding: 2px 0;
  display: block;
  transition: color var(--t-fast) var(--ease-standard),
              opacity var(--t-fast) var(--ease-standard);
}
.nav__child-link:hover,
.nav__child-link:focus-visible {
  color: var(--accent);
  opacity: 1;
}
.nav__child-link[aria-current="page"] {
  color: var(--accent);
  opacity: 1;
}

/* ---------- Burger ---------- */
.nav__burger {
  display: none;
  background: transparent;
  border: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  color: inherit;
  margin-left: auto;
}

.nav__burger-bar {
  display: block;
  width: 24px;
  height: 2px;
  margin: 5px auto;
  background: currentColor;
  transition: transform var(--t-fast) var(--ease-standard),
              opacity var(--t-fast);
}

.nav.is-open .nav__burger-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav.is-open .nav__burger-bar:nth-child(2) { opacity: 0; }
.nav.is-open .nav__burger-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- Support heart icon (28.05.26) ----------
   Heart icon button after Get in Touch. Opens the Support modal
   inside the existing lightbox shell via data-lightbox-open (see
   the figure + template alongside the lightbox shell, plus
   support.css for the modal panel itself). The button is a real
   <button> not an <a>, so it does not register with the nav scroll-
   spy or get the aria-current underline. Accent fuchsia so it reads
   as a CTA distinct from the text links. Icon-only at desktop; on
   mobile sits at the centre of the nav bar (top-level CTA, always
   visible regardless of burger state).
   Heartbeat: a slow "lub-dub" double-pulse every 2.4s (~25 BPM),
   well below resting heart rate so the icon reads as a quiet living
   mark rather than an attention-grabber. Runs on the .nav__icon SVG
   (not the button) so hover scale stays independent. Suppressed
   under prefers-reduced-motion. Ported from ET (25.05.26 + 27.05.26
   EOD refinements). */
@keyframes nav-heart-beat {
  0%, 100% { transform: scale(1); }
  14%      { transform: scale(1.18); }
  28%      { transform: scale(1); }
  42%      { transform: scale(1.18); }
  56%      { transform: scale(1); }
}
.nav .nav__link--icon .nav__icon {
  animation: nav-heart-beat 2.4s ease-in-out infinite;
  transform-origin: center;
}
@media (prefers-reduced-motion: reduce) {
  .nav .nav__link--icon .nav__icon { animation: none; }
}
.nav .nav__link--icon {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: 0;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-2) var(--s-3);
  color: var(--accent);
  transition: color 160ms ease, transform 160ms ease;
}
.nav .nav__link--icon:hover {
  color: var(--accent-soft, var(--accent));
  transform: scale(1.08);
}
.nav .nav__icon {
  width: 22px;
  height: 22px;
  display: block;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}
.nav .nav__link--icon:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 999px;
}

/* ---------- Mobile collapse (<=767) ---------- */
@media (max-width: 767px) {
  .nav__burger { display: block; }

  .nav__items {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    /* 11.05.26: copper border-bottom removed per Caoimhín. Was
       `border-bottom: 1px solid rgba(181, 106, 59, 0.2)`. When the
       mobile menu was CLOSED, max-height:0 collapsed the items but
       the 1px copper border still rendered as a visible line right
       under the nav band, looking like a nav-bottom rule. */
    max-height: 0;
    overflow: hidden;
    padding: 0;
    transition: max-height var(--t-standard) var(--ease-standard),
                padding var(--t-standard) var(--ease-standard);
  }

  /* .nav[data-theme="cream"] .nav__items { background: var(--cream); }; disabled 19.04.26 */

  .nav.is-open .nav__items {
    max-height: 80vh;
    overflow-y: auto;
    padding: var(--s-4) 0;
  }

  .nav__item {
    padding: 0 var(--s-5);
    /* 11.05.26: copper inter-item separators removed per Caoimhín. */
  }

  .nav__link {
    display: block;
    padding: var(--s-4) 0;
  }

  .nav__dropdown {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: 0 0 var(--s-3) var(--s-4);
    min-width: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--t-standard) var(--ease-standard);
  }
  .nav__item.has-dropdown[aria-expanded="true"] .nav__dropdown {
    max-height: 800px;
  }

  .nav__dropdown-label {
    margin-top: var(--s-3);
  }

  /* 28.05.26: heart icon moves OUT of the burger dropdown and into
     the centre of the nav bar so it reads as a top-level CTA, always
     visible regardless of menu state. position: fixed anchors to the
     viewport, matching .nav's own position: fixed top:0 left:0 right:
     0 - the <li> centres horizontally in the nav bar, and its full
     nav-height lets the flex inside vertically centre the heart
     button. z-index sits one above .nav (z:100) so it stays on top
     of the burger dropdown when it opens. */
  .nav .nav__item--support {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    height: var(--nav-height);
    padding: 0;
    z-index: 101;
    display: flex;
    align-items: center;
  }
}
