/* ==========================================================================
   Shell, backdrop, header, footer, sections
   ========================================================================== */

.shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100svh;
}

.main {
  flex: 1;
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding-inline: var(--shell-pad);
  padding-block: clamp(4.5rem, 8vw, 7rem) var(--space-2xl);

  /* Sections number themselves — see .section-head__eyebrow. */
  counter-reset: sec;
}

.main:focus-visible { outline: none; }

/* Sections are separated by a ruled hairline rather than by whitespace alone.
   It is the strongest single cue that this is a printed page: the eye reads
   the rule as a column break in a journal.

   :first-of-type has no rule — the hero opens the page, it does not follow
   anything. */
.section {
  position: relative;
  margin-block-start: clamp(3.5rem, 7vw, 5.5rem);
  padding-block-start: clamp(2rem, 4vw, 3rem);
  border-block-start: var(--rule) solid var(--border);
}

.section--flush { border-block-start: none; padding-block-start: 0; }
.section--stats { margin-block-start: clamp(2.5rem, 5vw, 3.5rem); }

/* ==========================================================================
   Backdrop
   --------------------------------------------------------------------------
   Three layers, all fixed so they never scroll with the content and never
   trigger layout work: an engineering grid, a drifting particle field and a
   film grain.

   No colour gradients anywhere. Depth comes from the ruled grid and the grain
   sitting over a flat surface — the same way depth works on paper.
   ========================================================================== */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.backdrop__particles { position: absolute; inset: 0; width: 100%; height: 100%; }

/* An engineering grid: a fine 16px rule with a heavier one every 96px, the
   way graph paper is printed. Four linear-gradients, each a 1px-hard step
   rather than a colour ramp, so the surface stays flat. */
.backdrop__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    linear-gradient(color-mix(in oklab, var(--grid-line) 45%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in oklab, var(--grid-line) 45%, transparent) 1px, transparent 1px);
  background-size: 96px 96px, 96px 96px, 16px 16px, 16px 16px;
}

.backdrop__grain {
  position: absolute;
  inset: 0;
  opacity: var(--grain-opacity);
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ==========================================================================
   Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out);
  border-bottom: var(--rule) solid transparent;
}

.site-header.is-stuck {
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom-color: var(--border-strong);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding: 0.85rem var(--shell-pad);
}

/* ---- brand ---------------------------------------------------------------
   A stamped initial block. Square, filled with the accent, mono initials —
   it reads as an instrument label plate rather than a logo.                */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  margin-inline-end: auto;
}

.brand__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  background: var(--accent);
  color: var(--accent-ink);
  overflow: hidden;
  transition: background-color var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-spring);
}

.brand:hover .brand__mark { transform: translateY(-2px); }

.brand__initials {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand__name {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-variation-settings: var(--wonk-off);
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

@media (max-width: 32rem) {
  .brand__name { display: none; }
}

/* ---- primary nav ---------------------------------------------------------
   Mono, uppercase, letterspaced — the nav is a control strip, not prose.   */
.site-nav { position: relative; }

.site-nav__list { display: flex; gap: 0.1rem; }

.site-nav__link {
  position: relative;
  display: block;
  padding: 0.55rem 0.85rem;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.site-nav__link:hover { color: var(--ink); }
.site-nav__link.is-current { color: var(--ink); }

/* One marker that slides between items rather than four that fade. It is a
   2px underscore rather than a filled pill — a cursor on a control strip. */
.site-nav__indicator {
  position: absolute;
  left: 0;
  bottom: 0.15rem;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transform: translateX(var(--indicator-x, 0));
  width: var(--indicator-w, 0);
  transition: transform var(--dur-base) var(--ease-spring),
              width var(--dur-base) var(--ease-spring),
              opacity var(--dur-fast) var(--ease-out);
  pointer-events: none;
}

.site-nav__indicator.is-visible { opacity: 1; }

@media (max-width: 46rem) {
  .site-nav { display: none; }
}

/* ---- header actions ------------------------------------------------------ */
.site-header__actions { display: flex; align-items: center; gap: 0.4rem; }

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 2.2rem;
  padding-inline: 0.6rem;
  border: var(--rule) solid var(--border);
  color: var(--ink-3);
  background: transparent;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}

.icon-button svg { width: 1rem; height: 1rem; }

.icon-button:hover {
  color: var(--ink);
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.icon-button__kbd {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.1rem 0.32rem;
  border: var(--rule) solid var(--border);
  color: var(--ink-3);
}

@media (max-width: 46rem) {
  .icon-button__kbd { display: none; }
}

/* ---- theme toggle -------------------------------------------------------- */
.theme-toggle { position: relative; width: 2.2rem; padding-inline: 0; justify-content: center; }

.theme-toggle svg {
  position: absolute;
  width: 1rem;
  height: 1rem;
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-spring);
}

:root[data-theme="dark"] .theme-toggle__sun,
:root:not([data-theme="light"]) .theme-toggle__sun { opacity: 1; transform: rotate(0) scale(1); }
:root[data-theme="dark"] .theme-toggle__moon,
:root:not([data-theme="light"]) .theme-toggle__moon { opacity: 0; transform: rotate(-70deg) scale(0.4); }

:root[data-theme="light"] .theme-toggle__sun { opacity: 0; transform: rotate(70deg) scale(0.4); }
:root[data-theme="light"] .theme-toggle__moon { opacity: 1; transform: rotate(0) scale(1); }

/* ---- mobile menu --------------------------------------------------------- */
.menu-button {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.2rem;
  height: 2.2rem;
  border: var(--rule) solid var(--border);
  background: transparent;
}

.menu-button__bar {
  display: block;
  width: 1rem;
  height: 1.5px;
  margin-inline: auto;
  background: var(--ink-2);
  transition: transform var(--dur-base) var(--ease-spring), opacity var(--dur-fast) linear;
}

.menu-button[aria-expanded="true"] .menu-button__bar:first-child { transform: translateY(3.25px) rotate(45deg); }
.menu-button[aria-expanded="true"] .menu-button__bar:last-child { transform: translateY(-3.25px) rotate(-45deg); }

@media (max-width: 46rem) {
  .menu-button { display: flex; }
}

.mobile-nav {
  position: fixed;
  inset: 3.9rem 0 auto;
  z-index: 99;
  padding: var(--space-s) var(--shell-pad) var(--space-l);
  background: var(--surface-glass);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: var(--rule) solid var(--border-strong);
  animation: sheet-in var(--dur-base) var(--ease-out);
}

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mobile-nav__list { display: grid; }

.mobile-nav__link {
  display: block;
  padding: 0.9rem 0;
  border-block-end: var(--rule) solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-2);
  transition: color var(--dur-fast) var(--ease-out), padding-inline-start var(--dur-fast) var(--ease-out);
}

.mobile-nav__list li:last-child .mobile-nav__link { border-block-end: none; }

.mobile-nav__link.is-current,
.mobile-nav__link:hover { color: var(--accent); padding-inline-start: 0.5rem; }

/* ---- scroll progress ----------------------------------------------------- */
.progress-bar {
  position: absolute;
  left: 0; bottom: -1px;
  height: 2px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--progress, 0));
  background: var(--accent);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.site-header.is-stuck .progress-bar { opacity: 1; }

/* ==========================================================================
   Footer
   --------------------------------------------------------------------------
   Set like a colophon: the note in the display serif, everything else in
   mono, separated by a heavy rule.
   ========================================================================== */

.site-footer {
  margin-block-start: clamp(4rem, 9vw, 7rem);
  border-top: 2px solid var(--ink);
  background: color-mix(in oklab, var(--surface) 35%, transparent);
}

.site-footer__inner {
  display: grid;
  gap: var(--space-l);
  grid-template-columns: 1.5fr 1fr 1fr;
  align-items: start;
  width: 100%;
  max-width: var(--shell-max);
  margin-inline: auto;
  padding: var(--space-xl) var(--shell-pad);
}

@media (max-width: 46rem) {
  .site-footer__inner { grid-template-columns: 1fr; gap: var(--space-m); }
}

.site-footer__name {
  display: block;
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-variation-settings: var(--wonk-on);
  font-size: var(--step-2);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
}

.site-footer__note {
  margin-block-start: 0.5rem;
  max-width: 34ch;
  font-size: var(--step--1);
  color: var(--ink-3);
}

.site-footer__nav ul { display: grid; gap: 0.55rem; }

.site-footer__nav a {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.site-footer__nav a:hover { color: var(--accent); }

.site-footer__meta { display: grid; gap: 0.7rem; justify-items: start; }

.site-footer__github {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--ink-3);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out);
}

.site-footer__github svg { width: 0.95rem; height: 0.95rem; }
.site-footer__github:hover { color: var(--accent); }

.site-footer__copyright {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  letter-spacing: var(--tracking-wide);
  color: var(--ink-3);
}
