/* ====================================================================
   Shared brand mark + sticky topbar + primary nav
   --------------------------------------------------------------------
   Used by: index.html, case-01.html, case-02.html, case-03.html
   Mounted into:  <header class="topbar" id="topbar" data-brand-href="…">
   Driven by:     assets/nav.js (injects markup, toggles is-scrolled)

   Type spec:     Satoshi Bold (700) regular, Bold Italic (700i) for the I's.
                  Loaded via Fontshare on each page.

   Tokens used:   --bg, --ink, --line, --accent, --ease, --font-body,
                  --font-mono. Defined per-page in :root, so this file
                  stays font-system-agnostic and themable.
   ==================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: border-color 500ms var(--ease);
}

/* Background animates in as a separate layer so it slides + fades
   without disturbing the nav content sitting above it. */
.topbar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  opacity: 0;
  transition: opacity 400ms var(--ease);
  z-index: -1;
}

.topbar.is-scrolled::before {
  opacity: 1;
}

.topbar.is-scrolled {
  border-bottom-color: var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;                    /* 64px — 8pt-aligned */
}

/* ---------- Brand mark — CHIMIAK → CII ----------
   On scroll, the four "shaped" letters (H, M, A, K) collapse and the
   remaining C + two italic I's tighten into a compact monogram.
   The italic "I" reads as a slash — a deliberate signature mark.

   Architecture notes:
   - Only .brand-letter--drop carries overflow:hidden, so the italic I's
     slant isn't truncated against its visible neighbours.
   - Spacing uses per-letter padding (not parent letter-spacing) so the
     italic I has breathing room and tightening on collapse is clean. */
.brand {
  font-family: "Satoshi", var(--font-body, sans-serif);
  font-size: 1.25rem;              /* 20px */
  font-weight: 700;
  letter-spacing: 0;
  color: var(--ink);
  display: inline-flex;
  align-items: baseline;
  line-height: 1;
  text-decoration: none;
  transition: color 200ms var(--ease);
}
.brand:hover { color: inherit; }

.brand-letter {
  display: inline-block;
  white-space: pre;
  padding-right: 0.06em;
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 320ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 650ms cubic-bezier(0.7, 0, 0.2, 1),
    padding 650ms cubic-bezier(0.7, 0, 0.2, 1);
}
.brand-letter--i {
  font-style: italic;
  font-weight: 700;
  padding-right: 0.18em;           /* italic slant needs more right-side room */
  padding-left: 0.04em;
  transition: padding 650ms cubic-bezier(0.7, 0, 0.2, 1);
}
.brand-letter--drop {
  overflow: hidden;
  max-width: 1.6em;                /* roomy for widest letter (M) */
  transition:
    max-width 650ms cubic-bezier(0.7, 0, 0.2, 1),
    padding 650ms cubic-bezier(0.7, 0, 0.2, 1),
    opacity 320ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 650ms cubic-bezier(0.7, 0, 0.2, 1);
}

/* Scroll state — drop the H, M, A, K */
/* Tighten CII only — CHIMIAK spacing untouched */
.topbar.is-scrolled .brand .brand-letter:nth-child(1) { padding-right: 0.01em; }
.topbar.is-scrolled .brand .brand-letter--i { padding-left: 0; padding-right: 0.03em; }

.topbar.is-scrolled .brand-letter--drop {
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
  opacity: 0;
  transform: translateX(-3px);
}

/* Stagger so letters peel away rather than vanishing as a block.
   Order: K → A → M → H → C → (sp) → K → E → D → O → L, right-to-left.
   Children: 1=W 2=L 3=O 4=D 5=E 6=K 7=(sp) 8=C 9=H 10=I 11=M 12=I 13=A 14=K */
.topbar.is-scrolled .brand .brand-letter:nth-child(14) { transition-delay:   0ms; } /* K */
.topbar.is-scrolled .brand .brand-letter:nth-child(13) { transition-delay:  30ms; } /* A */
.topbar.is-scrolled .brand .brand-letter:nth-child(11) { transition-delay:  60ms; } /* M */
.topbar.is-scrolled .brand .brand-letter:nth-child(9)  { transition-delay:  90ms; } /* H */
.topbar.is-scrolled .brand .brand-letter:nth-child(8)  { transition-delay: 120ms; } /* C */
.topbar.is-scrolled .brand .brand-letter:nth-child(7)  { transition-delay: 150ms; } /* (space) */
.topbar.is-scrolled .brand .brand-letter:nth-child(6)  { transition-delay: 180ms; } /* K */
.topbar.is-scrolled .brand .brand-letter:nth-child(5)  { transition-delay: 210ms; } /* E */
.topbar.is-scrolled .brand .brand-letter:nth-child(4)  { transition-delay: 240ms; } /* D */
.topbar.is-scrolled .brand .brand-letter:nth-child(3)  { transition-delay: 270ms; } /* O */
.topbar.is-scrolled .brand .brand-letter:nth-child(2)  { transition-delay: 300ms; } /* L */

@media (prefers-reduced-motion: reduce) {
  .brand,
  .brand-letter { transition: none; }
  .topbar.is-scrolled .brand-letter { transition-delay: 0ms !important; }
}

/* ---------- Primary nav ---------- */
.nav {
  display: flex;
  gap: 2rem;                       /* 32px — 8pt-aligned */
}
.nav a {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.8125rem;            /* 13px */
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  padding: 0.25rem 0;              /* 4px */
  position: relative;
  transition: color 200ms var(--ease);
}
.nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 250ms var(--ease);
}
.nav a:hover { color: var(--accent); }
.nav a:hover::after { transform: scaleX(1); }
.nav a.is-active { color: var(--accent); }
.nav a.is-active::after { transform: scaleX(1); }
@media (max-width: 720px) { .nav { display: none; } }
