/* Realyz — shared styles for all public/ pages.
   Page-specific rules stay in each page's inline <style> block,
   which loads after this file and therefore wins on equal specificity. */

:root {
  --bg: #f7f2e7;
  --bg-warm: #efe5d0;
  --text: #2a2218;
  --muted: #5a4f3c;
  --rule: #d8cdb3;
  --ink: #a53f22;

  --serif: "Source Serif 4", Charter, "Iowan Old Style", Georgia, serif;
  --sans:
    "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 680px;
}

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  font-feature-settings: "kern", "liga", "calt";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  max-width: var(--measure);
  margin: 0;
  padding: 2.5rem clamp(1.25rem, 5vw, 3rem);
}
@media (min-width: 980px) {
  .wrap {
    margin-left: clamp(3rem, 10vw, 8rem);
  }
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-decoration-color: color-mix(in oklab, var(--text) 35%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color 120ms ease;
}
a:hover,
a:focus-visible {
  text-decoration-color: var(--ink);
}
a:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 1px;
}

/* ----- masthead ----- */
header.mast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 3rem;
}
.brand {
  display: flex;
  align-items: center;
  line-height: 0;
  color: var(--text);
  text-decoration: none;
}
.brand svg {
  display: block;
  width: auto;
  height: 1.35rem;
}
nav.top {
  display: flex;
  gap: 1.25rem;
}
nav.top a {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration-color: transparent;
  /* 44px tap target; negative margin keeps the masthead height unchanged */
  padding: 0.75rem 0;
  margin: -0.75rem 0;
}
nav.top a:hover,
nav.top a:focus-visible {
  text-decoration-color: var(--ink);
}
/* current page — accent color + persistent underline */
nav.top a[aria-current="page"] {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

/* ----- typography ----- */
h1,
h3 {
  hyphens: manual;
  -webkit-hyphens: manual;
}
h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(1.5rem, 1.2vw + 1.1rem, 1.875rem);
  line-height: 1.18;
  letter-spacing: -0.008em;
  color: var(--text);
  margin: 0 0 1rem;
  max-width: 28ch;
  text-wrap: balance;
  hyphens: manual;
  -webkit-hyphens: manual;
}
h3 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.375rem;
  line-height: 1.3;
  color: var(--text);
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.005em;
}
h3:first-of-type {
  margin-top: 1.25rem;
}
p {
  margin: 0 0 1rem;
  max-width: 64ch;
}
p + p {
  margin-top: 0;
}
.subtitle {
  font-family: var(--sans);
  font-size: clamp(1.05rem, 0.5vw + 1rem, 1.25rem);
  line-height: 1.45;
  color: var(--text);
  max-width: 52ch;
  margin: 0 0 1rem;
  font-weight: 400;
}
.ink-text {
  color: var(--ink);
}

/* ----- CJK typography -----
   Source Serif 4 has no CJK glyphs; without an explicit Chinese stack the
   browser falls through to OS Songti/SimSun. That fallback only ships one
   real weight, so h2 (500) and h3 (500) collapse to identical-looking text.
   In Chinese, weight contrast carries hierarchy more reliably than size. */
:lang(zh) {
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", serif;
  --sans:
    "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    sans-serif;
}
:lang(zh) h1,
:lang(zh) h2,
:lang(zh) h3,
:lang(zh) .subtitle {
  letter-spacing: 0;
  hyphens: none;
}
:lang(zh) h2,
:lang(zh) h3,
:lang(zh) .subtitle {
  text-wrap: initial;
}
/* h1 keeps balance — at narrow viewports it prevents orphan characters
   ("根植实体，智驱未\n来") that hurt brand polish more than balance's
   imperfect CJK punctuation handling does */
:lang(zh) h1 {
  text-wrap: balance;
}
:lang(zh) h2 {
  font-weight: 700;
}
:lang(zh) h3 {
  font-weight: 600;
}

/* ----- display h1 -----
   Shared across landing, about, residency. Margin-bottom varies per page
   (about uses 1.75rem, others 1.5rem) — override in inline <style> if needed. */
h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2.25rem, 5.5vw + 0.5rem, 3.75rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 1.25rem 0 1.5rem;
  text-wrap: balance;
}
/* Landing hero subtitle spacing */
.manifesto .subtitle {
  margin-bottom: 2.5rem;
}

/* ----- inline numbers (mono, tabular) ----- */
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
}

/* ----- ink underline accent ----- */
.ink-underline {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 14' preserveAspectRatio='none'><path d='M4,8 C40,4 80,11 130,7 C180,3 220,10 270,6 C320,3 360,9 396,6' stroke='%23A53F22' stroke-width='2.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-size: 100% 0.22em;
  background-position: 0 96%;
  padding-bottom: 0.12em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

/* ----- STAT CARDS: cream callouts in column ----- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 1.5rem 0 1.25rem;
  max-width: 64ch;
}
@media (min-width: 540px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
  }
}
.stat {
  background: var(--bg-warm);
  padding: 1.15rem 1.3rem 1.2rem;
  border-left: 3px solid var(--ink);
}
.stat .figure {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 1.6875rem;
  line-height: 1.05;
  color: var(--text);
  letter-spacing: -0.01em;
  margin-bottom: 0.55rem;
}
.stat .figure em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  color: var(--ink);
  font-size: 0.62em;
}
.stat .caption {
  font-family: var(--sans);
  font-size: 0.85rem;
  line-height: 1.5;
  color: var(--muted);
}
.stat .caption strong {
  color: var(--text);
  font-weight: 500;
}

/* ----- section labels (mono metadata + accent number) -----
   Shared across index, about, residency. The vertical rhythm between the
   first label and the second varies per page — set that in the page's inline
   <style> via `section:first-of-type + section .label { margin-top: ... }`. */
.label {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 6rem 0 0.875rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--rule);
  /* Inherit-from-`p` max-width: 64ch would clip the hairline narrower than
     the content column. The inter-section rule is structural — it should
     span the full column, not the 64ch reading measure. */
  max-width: none;
}
.label .num {
  color: var(--ink);
}
section:first-of-type .label {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
/* Section-to-section gap is governed solely by the next .label —
   zero trailing margins so list/paragraph/grid endings don't add drift. */
section > :last-child {
  margin-bottom: 0;
}
.ink-text {
  color: var(--ink);
}

/* ----- hero CTA: serif italic with ink underline + arrow -----
   Margin varies per page (set in inline <style>). Defaults to 0. */
.hero-cta {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.1875rem;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  margin: 0;
  background-image: linear-gradient(var(--ink), var(--ink));
  background-repeat: no-repeat;
  background-size: 100% 1px;
  background-position: 0 100%;
  padding-bottom: 0.18em;
}
.hero-cta .arrow {
  color: var(--ink);
  font-style: normal;
  transition: transform 160ms ease;
}
.hero-cta:hover .arrow,
.hero-cta:focus-visible .arrow {
  transform: translateX(3px);
}
.hero-cta:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 2px;
}

/* ----- LOGO STRIPS -----
   Banded strip lives under the landing hero ("Team from Palantir / Google /
   DeepMind"). Inline strip grid is reserved for the pedigree section. Monochrome
   SVGs from Wikimedia, knocked to black via filter:brightness(0). */
.logo-strip-band {
  margin: 5.5rem 0 0;
  padding: 2rem 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.logo-strip-band .inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 1rem 2.75rem;
}
.logo-strip-band .strip-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
}
/* Two states only: label-on-top through the orphan zone, then everything
   inline once the row fits. Avoids the in-between state where DeepMind
   wraps alone to its own line. */
@media (max-width: 599px) {
  .logo-strip-band .inner {
    gap: 1.25rem 1.75rem;
  }
  .logo-strip-band .strip-label {
    flex-basis: 100%;
    text-align: center;
  }
}
/* Sub-iPhone-standard widths (≤390px): shrink logos so the 1.75rem gap
   still fits all three on one row. Cap-height tuning preserved (Google
   tallest, DeepMind mid, Palantir compact). */
@media (max-width: 419px) {
  .logo-strip-band .logo-mark img[alt="Palantir"] {
    height: 20px !important;
  }
  .logo-strip-band .logo-mark img[alt="Google"] {
    height: 24px;
  }
  .logo-strip-band .logo-mark img[alt="DeepMind"] {
    height: 22px !important;
  }
}
/* Tighten the next section's label after a banded strip */
.logo-strip-band + section .label {
  margin-top: 0;
  padding-top: 1.5rem;
  border-top: none;
}
/* Inline pedigree grid (used in the pedigree section) */
.logo-strip {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem 1.5rem;
  margin: 3.5rem 0 0;
  max-width: 64ch;
  place-items: center;
}
@media (min-width: 540px) {
  .logo-strip {
    grid-template-columns: repeat(3, 1fr);
  }
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.logo-mark img {
  height: 28px;
  width: auto;
  max-width: 100%;
  display: block;
  filter: brightness(0);
  opacity: 0.82;
  transition: opacity 200ms ease;
}
.logo-mark:hover img,
.logo-mark:focus-visible img {
  opacity: 1;
}
/* Per-logo height tuning so visual mass balances across grid cells.
   Square marks (MIT block) need more height; wide wordmarks (Stanford,
   Cornell) need less so they don't dominate their cell. */
.logo-mark.is-square img {
  height: 36px;
}
.logo-mark.is-wide img {
  height: 22px;
}
.logo-mark.is-xwide img {
  height: 19px;
}

/* ----- footer ----- */
footer {
  margin-top: 5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}
.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
}
.foot-brand svg {
  display: block;
  width: auto;
  height: 1rem;
  color: var(--text);
}
footer a {
  color: var(--muted);
  text-transform: uppercase;
  text-decoration-color: transparent;
  /* 44px tap target; negative margin keeps the footer height unchanged */
  padding: 0.75rem 0;
  margin: -0.75rem 0;
}
footer a:hover,
footer a:focus-visible {
  text-decoration-color: var(--ink);
  color: var(--text);
}
footer .spacer {
  flex: 1;
}
/* Narrow screens: footer can't fit one row. Put the links first, then drop the
   brand (logo + New York) onto its own line below them. */
@media (max-width: 559px) {
  footer .spacer {
    display: none;
  }
  footer a {
    order: 1;
  }
  .foot-brand {
    order: 2;
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  body {
    background: white;
    color: black;
  }
  nav.top {
    display: none;
  }
}
