/*
  VOICE   Calm and precise, like an Apple product page written by a researcher.
  IDEA    The portfolio behaves like a trained model you can probe: denoise it,
          run attention over it, condition it on a role, query its memory, listen to it.
  PICTURE One particle field that diffuses from noise into a name, then re-forms into
          a loss landscape and ORBITUNE's orbit as you scroll.
  COLOUR  True black, Apple greys. Colour appears only as data, always via the
          magma colormap: noise, attention weight, score, proximity.
  TYPE    Google Fonts. Unbounded for display (titles, captions, big numbers),
          Manrope for reading, JetBrains Mono for code and measured values,
          STIX Two Text italic for mathematics. See typography.css.
  LAYOUT  Apple rhythm: full-bleed chapters, big headline openers, content on a
          1200px measure, tiles with radii that step down with hierarchy.
*/

:root {
  color-scheme: dark;
  --bg: #000;
  --ink: #f5f5f7;
  --ink-2: #c7c7cc;
  --mute: #8e8e93;
  --hair: rgba(255, 255, 255, 0.1);
  --hair-2: rgba(255, 255, 255, 0.18);
  --tile: #0e0e10;
  --tile-2: #19191c;
  --tile-3: #232327;

  /* magma colormap stops — use for data only */
  --m1: #3b0f70;
  --m2: #8c2981;
  --m3: #de4968;
  --m4: #fe9f6d;
  --m5: #fcfdbf;
  --magma: linear-gradient(90deg, #3b0f70, #8c2981 30%, #de4968 58%, #fe9f6d 82%, #fcfdbf);

  --display: 'Unbounded', 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sans: 'Manrope', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --math: 'STIX Two Text', 'Cambria Math', 'Times New Roman', serif;

  --fs-hero: clamp(40px, 6vw, 84px);
  --fs-h2: clamp(36px, 5vw, 68px);
  --fs-h3: clamp(26px, 2.6vw, 36px);
  --fs-para: clamp(26px, 3.3vw, 46px);
  --fs-lead: clamp(19px, 1.5vw, 22px);
  --fs-body: 17px;
  --fs-small: 14px;

  --r-xl: 32px;
  --r-l: 22px;
  --r-m: 14px;
  --r-s: 10px;

  --measure: 1200px;
  --gutter: max(5vw, 20px);
  --nav-h: 52px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--nav-h) + 16px);
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--fs-body) / 1.55 var(--sans);
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
  text-rendering: optimizeLegibility;
}

img,
svg,
canvas {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

button,
input {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
h4,
p,
dl,
dd,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

::selection {
  background: #8c2981;
  color: #fff;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: #000;
  border-radius: 999px;
  text-decoration: none;
}
.skip:focus {
  top: 12px;
}

.mono {
  font-family: var(--mono);
  font-feature-settings: 'tnum' 1;
  letter-spacing: 0;
}

.math {
  font-family: var(--math);
  font-style: italic;
  letter-spacing: 0;
}

/* ---------- field canvas ---------- */

#field {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100lvh;
  z-index: 0;
  pointer-events: none;
}

main,
.site-foot {
  position: relative;
  z-index: 1;
}

/* ---------- layout primitives ---------- */

.wrap {
  width: min(var(--measure), 100% - 2 * var(--gutter));
  margin-inline: auto;
}

.chapter {
  padding-block: clamp(96px, 14vw, 200px) 0;
}

.chapter__head {
  max-width: 880px;
  margin-bottom: clamp(40px, 6vw, 80px);
}

.chapter__title {
  font-size: var(--fs-h2);
  line-height: 1.04;
  font-weight: 640;
  letter-spacing: -0.035em;
  text-wrap: balance;
}

.chapter__intro {
  margin-top: 20px;
  max-width: 62ch;
  font-size: var(--fs-lead);
  line-height: 1.45;
  color: var(--ink-2);
  text-wrap: pretty;
}

/* ---------- buttons & controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 520;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.btn:active {
  transform: scale(0.97);
}
.btn--light {
  background: var(--ink);
  color: #000;
}
.btn--light:hover {
  background: #fff;
}
.btn--ghost {
  border-color: var(--hair-2);
  background: rgba(255, 255, 255, 0.04);
}
.btn--ghost:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}
.btn svg {
  width: 14px;
  height: 14px;
}

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--hair);
}
.seg button {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.25s var(--ease), color 0.25s;
}
.seg button:hover {
  color: var(--ink);
}
.seg button[aria-pressed='true'],
.seg button[aria-checked='true'] {
  background: var(--ink);
  color: #000;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--hair);
  color: var(--ink-2);
  font-size: 13px;
  white-space: nowrap;
}
button.chip {
  background: transparent;
  min-height: 36px;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}
button.chip:hover {
  border-color: var(--hair-2);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: var(--tile-3);
}
input[type='range']::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--tile-3);
}
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
}
input[type='range']::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  border: 0;
}

.field-input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--r-m);
  border: 1px solid var(--hair-2);
  background: rgba(255, 255, 255, 0.04);
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}
.field-input:focus {
  border-color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.07);
}

/* ---------- navigation ---------- */

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 50;
  height: var(--nav-h);
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s, background-color 0.3s;
}
.nav.is-scrolled {
  border-bottom-color: var(--hair);
  background: rgba(0, 0, 0, 0.72);
}
.nav__in {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
}
.nav__mark {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
}
.nav__links {
  display: flex;
  gap: 4px;
}
.nav__links a {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--ink-2);
  text-decoration: none;
  transition: color 0.2s;
}
.nav__links a:hover,
.nav__links a[aria-current='true'] {
  color: var(--ink);
}
.nav__k {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex: none;
  min-height: 34px;
  padding: 0 8px 0 14px;
  border-radius: 999px;
  border: 1px solid var(--hair-2);
  background: rgba(255, 255, 255, 0.05);
  font-size: 13px;
  color: var(--ink-2);
  transition: color 0.2s, border-color 0.2s;
}
.nav__k:hover {
  color: var(--ink);
  border-color: rgba(255, 255, 255, 0.35);
}
.nav__icon {
  width: 14px;
  height: 14px;
}
.nav__k kbd {
  font: 500 11px/1 var(--mono);
  padding: 5px 6px;
  border-radius: 6px;
  background: var(--tile-3);
  color: var(--ink-2);
}
.nav__menu {
  display: none;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border: 0;
  background: transparent;
}
.nav__menu span {
  display: block;
  width: 18px;
  height: 1.5px;
  margin: 5px auto;
  background: var(--ink);
  transition: transform 0.3s var(--ease);
}
.nav.is-open .nav__menu span:first-child {
  transform: translateY(3.25px) rotate(45deg);
}
.nav.is-open .nav__menu span:last-child {
  transform: translateY(-3.25px) rotate(-45deg);
}

@media (max-width: 900px) {
  .nav__links {
    position: fixed;
    inset: var(--nav-h) 0 auto;
    flex-direction: column;
    gap: 0;
    padding: 8px var(--gutter) 24px;
    background: rgba(0, 0, 0, 0.92);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--hair);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, transform 0.3s var(--ease), visibility 0s 0.3s;
  }
  .nav.is-open .nav__links {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.25s, transform 0.3s var(--ease);
  }
  .nav__links a {
    padding: 14px 0;
    font-size: 22px;
    font-weight: 560;
    letter-spacing: -0.02em;
    border-bottom: 1px solid var(--hair);
  }
  .nav__menu {
    display: block;
  }
  .nav__k span,
  .nav__k kbd {
    display: none;
  }
  .nav__k {
    width: 40px;
    padding: 0;
    justify-content: center;
  }
}

/* ---------- footer ---------- */

.site-foot {
  padding-block: 48px 40px;
  border-top: 1px solid var(--hair);
  color: var(--mute);
  font-size: 13px;
}
.site-foot__in {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px 32px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
