/* =============================================================================
   COMPONENT: HEADER (nav + news ticker)
   Sticky; hides on scroll down, returns on scroll up. Behaviour: js/components/nav.js
   ============================================================================= */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--c-mint);
  border-bottom: var(--b) solid var(--c-ink);
  transition: transform var(--d-mid) var(--e-out);
}

.nav.is-hidden { transform: translateY(-100%); }

.nav__inner {
  max-width: 1280px;
  min-height: 74px;
  margin: auto;
  padding: 8px clamp(16px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  min-height: 44px;
  flex-shrink: 0;
  transition: transform var(--d-fast) var(--e-back);
}

.logo:hover { transform: rotate(-3deg) scale(1.04); }
.logo img { width: clamp(96px, 9vw, 132px); height: auto; }

/* ---- Links ------------------------------------------------------------- */
.nav__menu {
  display: flex;
  align-items: center;
  gap: clamp(4px, 1vw, 12px);
}

/* Plain links with an ink underline that draws in: no pills. */
.nav__link {
  position: relative;
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  padding: 0 10px;
  font: 700 0.92rem/1 var(--f-body);
  white-space: nowrap;
}

.nav__link::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 6px;
  height: 3px;
  background: var(--c-ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--d-mid) var(--e-out);
}

.nav__link:hover::after { transform: scaleX(1); }

/* Scrollspy sets aria-current on the link for the section in view. */
.nav__link[aria-current="true"]::after {
  background: var(--c-red);
  transform: scaleX(1);
}


/* ---- Simple view toggle -------------------------------------------------
   A switch (off = colourful) that opens simple.html, where it shows "on".
   The knob slides over as it's pressed. Remove this block with the toggle. */
.view-toggle {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font: 700 0.85rem/1 var(--f-body);
  white-space: nowrap;
}

.view-toggle__track {
  position: relative;
  flex: none;
  width: 44px;
  height: 24px;
  background: var(--c-paper);
  border: var(--b-thin) solid var(--c-ink);
  border-radius: 99px;
  box-shadow: 2px 2px 0 var(--c-ink);
  transition: background-color var(--d-mid);
}

.view-toggle__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--c-ink);
  transition: translate var(--d-mid) var(--e-back);
}

@media (hover: hover) {
  .view-toggle:hover .view-toggle__track::after { translate: 5px 0; }
}

.view-toggle:active .view-toggle__track { background: var(--c-mint); }
.view-toggle:active .view-toggle__track::after { translate: 20px 0; }

/* ---- Burger ------------------------------------------------------------ */
.nav__burger {
  display: none;
  width: 48px;
  height: 44px;
  padding: 10px 11px;
  background: var(--c-salmon);
  border: var(--b) solid var(--c-ink);
  border-radius: var(--r-sm);
  box-shadow: var(--sh-sm);
}

.nav__burger span {
  display: block;
  height: 3px;
  background: var(--c-ink);
  border-radius: 2px;
  transition: transform var(--d-mid) var(--e-back), opacity var(--d-fast);
}

.nav__burger span + span { margin-top: 4px; }
.nav__burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav__burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav__burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- Ticker ------------------------------------------------------------ */
.press-strip {
  display: flex;
  border-top: var(--b-thin) solid var(--c-ink);
  background: #26221e;
  color: #fff2d4;
  font: 600 0.9rem/1.5 var(--f-body);
}

.ticker { flex: 1; min-width: 0; overflow: hidden; }
.ticker__track { display: flex; width: max-content; }
.ticker__track[data-ready] { animation: news-scroll var(--ticker-duration, 50s) linear infinite; }
.ticker:hover .ticker__track { animation-play-state: paused; }
.ticker__track span { display: inline-flex; align-items: center; white-space: nowrap; }

/* A mustard star between headlines instead of a plain rule */
.ticker__track span::after {
  content: "✦";
  margin-inline: clamp(16px, 2.6vw, 40px);
  color: var(--c-mustard);
  font-size: 0.8em;
}

@keyframes news-scroll { to { transform: translateX(-50%); } }

/* Menu-only items: on desktop, Résumé is the floating button and the
   Simple view switch sits in the header */
.nav__note,
.nav__resume,
.nav__menu .view-toggle { display: none; }

/* ---- Tablet & phone: full-screen menu ----------------------------------
   The sheet grows out of the burger as a circle (clip-path; the origin is
   set by nav.js), then the links rise in one after another. Logo and
   burger stay on top so the burger doubles as the close button. */
@media (max-width: 980px) {
  .nav__burger { display: block; }
  /* Phones & tablets: the switch moves into the menu, the header keeps just logo + burger */
  .nav__inner > .view-toggle { display: none; }
  .nav__menu .view-toggle { display: inline-flex; align-self: flex-start; margin-top: 22px; font-size: 1rem; }
  .logo,
  .nav__burger { position: relative; z-index: 2; }

  .nav__menu {
    position: fixed;
    inset: 0;
    z-index: 1;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 96px var(--gutter) 32px;
    overflow-y: auto;
    overscroll-behavior: contain;
    background:
      radial-gradient(rgb(22 19 15 / 0.12) 1.3px, transparent 1.5px) 0 0 / 14px 14px,
      var(--c-mint);
    counter-reset: menu;
    clip-path: circle(0 at var(--menu-x, calc(100% - 44px)) var(--menu-y, 38px));
    visibility: hidden;
    transition: clip-path 480ms var(--e-out), visibility 0s 480ms;
  }

  .nav__menu[data-open="true"] {
    clip-path: circle(150vmax at var(--menu-x, calc(100% - 44px)) var(--menu-y, 38px));
    visibility: visible;
    transition: clip-path 640ms var(--e-out), visibility 0s;
  }

  /* Big numbered links */
  .nav__link {
    counter-increment: menu;
    display: flex;
    align-items: baseline;
    gap: 14px;
    min-height: 0;
    padding: 14px 2px;
    border-bottom: 2px solid rgb(22 19 15 / 0.16);
    font: 400 clamp(1.9rem, 8.5vw, 3rem)/1 var(--f-display);
    text-transform: uppercase;
    letter-spacing: 0.01em;
  }

  .nav__link::before {
    content: counter(menu, decimal-leading-zero);
    min-width: 2ch;
    font: 700 var(--t-xs)/1 var(--f-label);
    color: var(--c-ink-soft);
  }

  .nav__link::after { left: auto; right: 2px; bottom: 50%; width: 22px; height: 3px; }
  .nav__link[aria-current="true"] { color: var(--c-red); }


  .nav__resume { display: inline-flex; align-self: flex-start; margin-top: 16px; }

  .nav__note {
    display: grid;
    gap: 4px;
    margin-top: auto;
    padding-top: 28px;
    font: 700 var(--t-base)/1.4 var(--f-accent);
  }

  .nav__note a { font: 700 var(--t-sm)/1.4 var(--f-label); text-decoration: underline; text-underline-offset: 4px; }

  /* Everything inside rises in, staggered by --i (set by nav.js) */
  .nav__menu > * {
    opacity: 0;
    translate: 0 22px;
    transition: opacity 200ms var(--e-out), translate 200ms var(--e-out);
  }

  .nav__menu[data-open="true"] > * {
    opacity: 1;
    translate: none;
    transition: opacity 500ms var(--e-out), translate 600ms var(--e-back);
    transition-delay: calc(140ms + var(--i, 0) * 55ms);
  }

  html.has-menu { overflow: hidden; }

  /* No JS: no burger, links simply wrap under the logo. */
  html:not(.js) .nav__burger { display: none; }
  html:not(.js) .nav__inner { flex-wrap: wrap; }
  html:not(.js) .nav__menu {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    background: none;
    clip-path: none;
    visibility: visible;
  }
  html:not(.js) .nav__menu > * { opacity: 1; translate: none; }
  html:not(.js) .nav__link { font-size: 1.1rem; border: 0; }
  html:not(.js) .nav__note { display: none; }
}

@media (max-width: 560px) {
  .nav__inner { min-height: 62px; padding-block: 6px; }
  .nav__menu { padding-top: 84px; }
  .press-strip { font-size: 0.82rem; }
}
