/* ============================================================
   GLYPH — research instrument
   Tokens
   ============================================================ */
:root {
  /* palette — OKLCH, dark "calibrated charcoal" canvas + magenta signal */
  --bg:        oklch(0.15 0 0);
  --bg-deep:   oklch(0.12 0 0);
  --surface:   oklch(0.19 0.004 340);
  --surface-2: oklch(0.23 0.006 340);
  --ink:       oklch(0.96 0.004 340);
  --muted:     oklch(0.74 0.012 340);
  --faint:     oklch(0.58 0.012 340);
  --line:      oklch(0.30 0.006 340);
  --line-soft: oklch(0.24 0.005 340);
  --signal:    oklch(0.64 0.205 350);
  --signal-dim:oklch(0.50 0.16 350);
  --signal-glow: oklch(0.64 0.205 350 / 0.5);

  /* type */
  --display: "Saira", system-ui, sans-serif;
  --body: "Saira", system-ui, sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, monospace;

  /* assets */
  --logo: url("/logo.png");

  /* scale */
  --step--1: clamp(0.78rem, 0.74rem + 0.2vw, 0.86rem);
  --step-0:  clamp(0.98rem, 0.93rem + 0.25vw, 1.08rem);
  --step-1:  clamp(1.2rem, 1.08rem + 0.6vw, 1.5rem);
  --step-2:  clamp(1.5rem, 1.25rem + 1.2vw, 2.2rem);
  --step-3:  clamp(2.1rem, 1.6rem + 2.4vw, 3.4rem);
  --step-4:  clamp(2.8rem, 1.9rem + 4.4vw, 5.4rem);

  /* spacing rhythm */
  --gutter: clamp(1.25rem, 0.8rem + 2.2vw, 3rem);
  --section-y: clamp(4.5rem, 3rem + 6vw, 8.5rem);
  --maxw: 1200px;

  /* motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);

  /* z */
  --z-nav: 100;
  --z-ring: 1;
}

/* ============================================================
   Reset / base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

::selection { background: var(--signal); color: oklch(0.14 0 0); }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 3px;
  border-radius: 2px;
}

/* shared label / instrument readout */
.label {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--faint);
}
.label .tick { color: var(--signal); }

.shell {
  width: min(100% - var(--gutter) * 2, var(--maxw));
  margin-inline: auto;
}

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.02; letter-spacing: -0.03em; text-wrap: balance; }
p { text-wrap: pretty; }
.measure { max-width: 60ch; }

/* ============================================================
   Background field — faint instrument grid
   ============================================================ */
.field {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(120% 80% at 70% 0%, #000 0%, transparent 75%);
          mask-image: radial-gradient(120% 80% at 70% 0%, #000 0%, transparent 75%);
  opacity: 0.5;
}
.page { position: relative; z-index: 1; }

/* ============================================================
   Nav
   ============================================================ */
.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  backdrop-filter: blur(10px);
  background: oklch(0.15 0 0 / 0.72);
  border-bottom: 1px solid var(--line-soft);
}
.nav__in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand__mark {
  width: 26px; height: 26px;
  background: var(--ink);
  -webkit-mask: var(--logo) center / contain no-repeat;
          mask: var(--logo) center / contain no-repeat;
}
.brand__name {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}
.nav__links { display: flex; align-items: center; gap: clamp(1rem, 2vw, 2rem); }
.nav__links a {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  color: var(--muted);
  transition: color 0.25s var(--ease);
}
.nav__links a:hover { color: var(--ink); }
.nav__cta {
  color: var(--ink) !important;
  border: 1px solid var(--line);
  padding: 0.45rem 0.85rem;
  border-radius: 2px;
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.nav__cta:hover { border-color: var(--signal); background: oklch(0.64 0.205 350 / 0.08); }
@media (max-width: 640px) {
  .nav__links a:not(.nav__cta) { display: none; }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.8rem 1.3rem;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease), border-color 0.3s var(--ease), color 0.3s var(--ease);
}
.btn--primary { background: var(--signal); color: oklch(0.14 0 0); font-weight: 600; }
.btn--primary:hover { transform: translateY(-2px); background: oklch(0.69 0.205 350); }
.btn--ghost { border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--signal); color: var(--ink); background: oklch(0.64 0.205 350 / 0.06); }
.btn .arrow { transition: transform 0.3s var(--ease); }
.btn:hover .arrow { transform: translateX(4px); }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  position: relative;
  padding-top: clamp(2.5rem, 1rem + 6vw, 6rem);
  padding-bottom: var(--section-y);
}
.hero__grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: clamp(2rem, 4vw, 5rem);
}
.hero__coord {
  display: flex; gap: 1.2rem; flex-wrap: wrap;
  margin-bottom: 1.6rem;
}
.hero h1 {
  font-size: var(--step-4);
  text-transform: uppercase;
  letter-spacing: -0.04em;
  margin-bottom: 1.5rem;
}
.hero h1 .em { color: var(--signal); }
.hero__lead {
  font-size: var(--step-1);
  color: var(--muted);
  max-width: 46ch;
  margin-bottom: 2.2rem;
  font-weight: 400;
  line-height: 1.5;
}
.hero__actions { display: flex; gap: 0.9rem; flex-wrap: wrap; }

@media (max-width: 860px) {
  .hero__grid { grid-template-columns: 1fr; gap: 3rem; }
  .hero__instrument-wrap { order: -1; }
}

/* Instrument */
.instrument {
  position: relative;
  width: 100%;
  max-width: 420px;
  margin-inline: auto;
  aspect-ratio: 1;
}
.instrument__ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.instrument__ring .tick-ring {
  fill: none;
  stroke: var(--line);
  stroke-width: 1;
}
.instrument__ring .tick-marks {
  fill: none;
  stroke: var(--faint);
  stroke-width: 1;
}
.instrument__ring .scan {
  fill: none;
  stroke: var(--signal);
  stroke-width: 2;
  stroke-linecap: round;
  filter: drop-shadow(0 0 6px var(--signal-glow));
  transform-origin: center;
  animation: scan 16s linear infinite;
}
.instrument__ring .cross { stroke: var(--line); stroke-width: 1; }
.instrument__bracket { stroke: var(--muted); stroke-width: 1.5; fill: none; }

.instrument__core {
  position: absolute;
  inset: 26%;
  display: grid;
  place-items: center;
}
.instrument__glow {
  position: absolute; inset: -30%;
  background: radial-gradient(circle, var(--signal-glow) 0%, transparent 60%);
  opacity: 0.55;
  animation: pulse 4.5s var(--ease) infinite;
}
.instrument__mark {
  position: relative;
  width: 100%; height: 100%;
  background: var(--ink);
  -webkit-mask: var(--logo) center / contain no-repeat;
          mask: var(--logo) center / contain no-repeat;
}

@keyframes scan { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.35; transform: scale(0.95); } 50% { opacity: 0.6; transform: scale(1.05); } }

/* draw-on for ring + reticle (set by JS .is-live) */
.instrument .draw { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); }
.instrument.is-live .draw { animation: draw 1.5s var(--ease-out-expo) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

.instrument__core { opacity: 0; transform: scale(0.82); }
.instrument.is-live .instrument__core { animation: corein 1s 0.4s var(--ease) forwards; }
@keyframes corein { to { opacity: 1; transform: scale(1); } }

/* ============================================================
   Section scaffold
   ============================================================ */
.section { padding-block: var(--section-y); position: relative; }
.section + .section { border-top: 1px solid var(--line-soft); }
.section__head {
  display: flex; align-items: baseline; gap: 1rem;
  margin-bottom: clamp(2rem, 4vw, 3.5rem);
  flex-wrap: wrap;
}
.section__head h2 {
  font-size: var(--step-3);
  text-transform: uppercase;
}
.section__head .label { margin-left: auto; }

/* reveal */
.reveal { opacity: 0; transform: translateY(18px); }
.is-shown .reveal, .reveal.is-shown { opacity: 1; transform: none; transition: opacity 0.7s var(--ease), transform 0.7s var(--ease); }

/* ============================================================
   Disciplines — instrument manifest (not a card grid)
   ============================================================ */
.disc { border-top: 1px solid var(--line); }
.disc__row {
  display: grid;
  grid-template-columns: 5rem 1fr 1.1fr;
  gap: clamp(1rem, 3vw, 3rem);
  padding-block: clamp(1.8rem, 3vw, 2.8rem);
  border-bottom: 1px solid var(--line);
  align-items: start;
  transition: background 0.4s var(--ease);
}
.disc__row:hover { background: oklch(0.19 0.004 340 / 0.5); }
.disc__code {
  font-family: var(--mono);
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  color: var(--signal);
  padding-top: 0.4rem;
}
.disc__name { font-family: var(--display); font-weight: 800; font-size: var(--step-2); text-transform: uppercase; letter-spacing: -0.02em; }
.disc__body p { color: var(--muted); margin-bottom: 1.1rem; }
.disc__tags { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.disc__tags span {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 0.25rem 0.55rem;
  border-radius: 2px;
}
@media (max-width: 760px) {
  .disc__row { grid-template-columns: 1fr; gap: 0.9rem; }
  .disc__code { padding-top: 0; }
}

/* ============================================================
   Approach — statement
   ============================================================ */
.approach__grid { display: grid; grid-template-columns: 0.85fr 1.15fr; gap: clamp(2rem, 5vw, 5rem); align-items: start; }
.approach__statement {
  font-family: var(--display);
  font-weight: 700;
  font-size: var(--step-2);
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.approach__statement .em { color: var(--signal); }
.approach__notes { display: grid; gap: 1.8rem; }
.approach__note { display: grid; grid-template-columns: auto 1fr; gap: 1rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.approach__note .n { font-family: var(--mono); font-size: var(--step--1); color: var(--signal); letter-spacing: 0.08em; }
.approach__note h3 { font-size: var(--step-1); font-weight: 700; margin-bottom: 0.4rem; letter-spacing: -0.01em; text-transform: none; }
.approach__note p { color: var(--muted); }
@media (max-width: 760px) { .approach__grid { grid-template-columns: 1fr; gap: 2.5rem; } }

/* ============================================================
   Open-source band (home teaser)
   ============================================================ */
.band {
  position: relative;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-deep) 100%);
  border-radius: 4px;
  padding: clamp(2.2rem, 5vw, 4.5rem);
  overflow: hidden;
}
.band::after {
  content: "";
  position: absolute; right: -10%; top: -40%;
  width: 60%; aspect-ratio: 1;
  background: radial-gradient(circle, var(--signal-glow) 0%, transparent 65%);
  opacity: 0.4;
  pointer-events: none;
}
.band h2 { font-size: var(--step-3); text-transform: uppercase; margin-block: 1rem; max-width: 18ch; }
.band p { color: var(--muted); max-width: 52ch; margin-bottom: 2rem; }

/* status dot */
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 8px var(--signal-glow); margin-right: 0.5rem; vertical-align: middle; }
.dot--pulse { animation: dotpulse 2.4s var(--ease) infinite; }
@keyframes dotpulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ============================================================
   Footer
   ============================================================ */
.footer { border-top: 1px solid var(--line); padding-block: clamp(3rem, 5vw, 5rem) 2.5rem; }
.footer__top { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 2rem; margin-bottom: 3rem; }
.footer__brand { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1.2rem; }
.footer__brand .brand__mark { width: 30px; height: 30px; }
.footer__brand .brand__name { font-size: 1.3rem; }
.footer p.measure { color: var(--muted); }
.footer__col h4 { font-family: var(--mono); font-size: var(--step--1); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); margin-bottom: 1rem; font-weight: 500; }
.footer__col a, .footer__col span { display: block; color: var(--muted); margin-bottom: 0.6rem; transition: color 0.25s var(--ease); }
.footer__col a:hover { color: var(--signal); }
.footer__bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-top: 1.8rem; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.footer__bar, .footer__bar a { font-family: var(--mono); font-size: var(--step--1); color: var(--faint); letter-spacing: 0.04em; }
.footer__bar a:hover { color: var(--muted); }
@media (max-width: 760px) { .footer__top { grid-template-columns: 1fr 1fr; } .footer__brand { grid-column: 1 / -1; } }

/* ============================================================
   Open source page
   ============================================================ */
.os-hero { padding-top: clamp(3rem, 4vw, 6rem); padding-bottom: var(--section-y); }
.os-hero__in { display: grid; grid-template-columns: 1fr auto; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.os-hero h1 { font-size: var(--step-4); text-transform: uppercase; letter-spacing: -0.04em; margin-block: 1.4rem; }
.os-hero h1 .em { color: var(--signal); }
.os-hero p { font-size: var(--step-1); color: var(--muted); max-width: 50ch; font-weight: 400; }
.os-mark { width: clamp(120px, 22vw, 220px); aspect-ratio: 1; position: relative; }
.os-mark__img { width: 100%; height: 100%; background: var(--line); -webkit-mask: var(--logo) center / contain no-repeat; mask: var(--logo) center / contain no-repeat; }
.os-mark__glow { position: absolute; inset: -20%; background: radial-gradient(circle, var(--signal-glow) 0%, transparent 60%); opacity: 0.3; animation: pulse 5s var(--ease) infinite; }
@media (max-width: 760px) { .os-hero__in { grid-template-columns: 1fr; } .os-mark { order: -1; } }

/* sealed manifest */
.manifest { display: grid; gap: 0; border-top: 1px solid var(--line); }
.manifest__row {
  display: grid; grid-template-columns: auto 1fr auto; gap: clamp(1rem, 3vw, 2.5rem);
  align-items: center;
  padding-block: 1.6rem; border-bottom: 1px solid var(--line);
}
.manifest__idx { font-family: var(--mono); color: var(--faint); font-size: var(--step--1); letter-spacing: 0.08em; }
.manifest__redact { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.manifest__bars { display: flex; gap: 4px; }
.manifest__bars i { display: block; height: 1.1rem; width: clamp(20px, 5vw, 46px); background: var(--surface-2); border-radius: 1px; }
.manifest__kind { font-family: var(--mono); font-size: var(--step--1); color: var(--muted); letter-spacing: 0.05em; }
.manifest__status { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--signal); border: 1px solid var(--signal-dim); padding: 0.25rem 0.6rem; border-radius: 2px; white-space: nowrap; }
@media (max-width: 640px) {
  .manifest__row { grid-template-columns: auto 1fr; }
  .manifest__status { grid-column: 2; justify-self: start; }
}

.notify { margin-top: clamp(2.5rem, 5vw, 4rem); padding: clamp(1.8rem, 4vw, 3rem); border: 1px solid var(--line); border-radius: 4px; background: var(--surface); }
.notify h3 { font-family: var(--display); font-weight: 700; font-size: var(--step-1); margin-bottom: 0.6rem; letter-spacing: -0.01em; }
.notify p { color: var(--muted); margin-bottom: 1.4rem; max-width: 50ch; }
.notify a.mail { font-family: var(--mono); color: var(--signal); letter-spacing: 0.03em; border-bottom: 1px solid var(--signal-dim); padding-bottom: 2px; }
.notify a.mail:hover { color: var(--ink); }

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .instrument__ring .scan { animation: none; }
  .instrument__glow, .os-mark__glow, .dot--pulse { animation: none; }
  .instrument .draw { stroke-dashoffset: 0 !important; }
  .instrument__core { opacity: 1 !important; transform: none !important; }
  .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .btn:hover { transform: none; }
}
