/* =========================================================
   AC-v2 Top navigation + dropdown
   Fixed bar, theme-aware, dropdown on hover (desktop) + tap
   (mobile), burger collapse at 900 (was 767 until 27.05.26 EOD).
   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, #0F1419, #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. */
  background: color-mix(in srgb, transparent 35%, var(--bg) 65%);
  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;
}

.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, 107, 74, 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 */
  background: color-mix(in srgb,
              rgba(15, 20, 25, 0.86),
              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, 107, 74, 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, 107, 74, 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;
  /* 27.05.26 EOD: rounded bar ends mirror the lightbox close X's
     stroke-linecap: round so the burger-as-X (when menu is open)
     visually matches the modal close X. Apple-sheet consistency. */
  border-radius: 1px;
  transition: transform var(--t-fast) var(--ease-standard),
              background-color 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); }

/* 27.05.26 EOD: hover/focus shifts the burger bars to the accent
   coral, matching the lightbox close button's hover behaviour. The
   inline override in index.html forces the bars white at rest; this
   rule has equal class-count specificity (0,2,1 with :hover/:focus)
   AND comes later in the cascade, so the accent wins on interaction. */
.nav__burger:hover .nav__burger-bar,
.nav__burger:focus-visible .nav__burger-bar {
  background: var(--accent);
}
.nav__burger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 999px;
}

/* ---------- Mobile collapse (<=899.98) ----------
   27.05.26 EOD: bumped from 767 to 900 per user. At ~770-900 the
   full nav items row was crowding the wordmark logo on the left;
   the burger menu kicks in earlier so the top bar stays uncluttered. */
@media (max-width: 899.98px) {
  .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;
  }

  /* 23.05.26: the chevron was a tap-to-toggle affordance; on mobile
     "About" now navigates to the intro card (no toggle), so hide it. */
  .nav__chevron { display: none; }

  .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;
    /* 23.05.26: the mobile dropdown is ALWAYS open now (was collapsed
       until "About" was tapped). "About" navigates to the intro card on
       mobile, so the three stories sit as a permanent sub-list beneath
       it - one tap away, no toggle needed. */
    max-height: none;
    overflow: visible;
  }

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