:root {
  --ink: #1d2328;
  --muted: #56616b;
  --line: #d8d2c2;
  --line-soft: rgba(29, 35, 40, 0.22);
  --paper: #fbfaf5;
  --paper-soft: #fffaf0;
  --wash: #f3ead1;
  --teal: #12a6b7;
  --teal-dark: #0b6f7a;
  --coral: #d95f4b;
  --gold: #c58b28;
  --green: #4b8f67;
  --white: #ffffff;
  --code: #f0f3f4;
  --font-display: "Antic", "Avenir Next", Avenir, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Antic", "Avenir Next", Avenir, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

a {
  color: inherit;
  text-decoration-color: rgba(18, 166, 183, 0.45);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: var(--teal);
}

code,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

code {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--code);
  padding: 0.08rem 0.28rem;
  font-size: 0.88em;
}

pre {
  margin: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172025;
  color: #f7f2df;
  padding: 1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

pre code {
  display: block;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

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

.site-header {
  display: grid;
  grid-template-columns: minmax(170px, 0.62fr) minmax(190px, 0.44fr) minmax(0, 1.72fr);
  gap: clamp(12px, 1.8vw, 24px);
  align-items: center;
  border-bottom: 2px solid var(--line);
  background: rgba(251, 250, 245, 0.92);
  padding: 18px min(44px, 5vw);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.55rem;
  text-decoration: none;
}

.site-brand img {
  display: block;
  width: clamp(150px, 14vw, 210px);
  height: auto;
}

.header-search {
  position: relative;
  min-width: 0;
}

.header-search::before {
  position: absolute;
  top: 50%;
  left: 14px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  content: "";
  pointer-events: none;
  transform: translateY(-50%);
  -webkit-mask:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='m21.53 20.47-4.8-4.8A8.2 8.2 0 1 0 15.67 16.73l4.8 4.8a.75.75 0 0 0 1.06-1.06ZM4.5 10.25a5.75 5.75 0 1 1 11.5 0 5.75 5.75 0 0 1-11.5 0Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='black' d='m21.53 20.47-4.8-4.8A8.2 8.2 0 1 0 15.67 16.73l4.8 4.8a.75.75 0 0 0 1.06-1.06ZM4.5 10.25a5.75 5.75 0 1 1 11.5 0 5.75 5.75 0 0 1-11.5 0Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.header-search input[type="search"] {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 12px 10px 42px;
  font: inherit;
}

.header-search input[type="search"]::placeholder {
  color: var(--muted);
}

.header-search input[type="search"]:focus {
  border-color: var(--line);
  outline: 0;
  background: rgba(251, 250, 245, 0.72);
}

.site-nav {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  justify-self: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  border: 2px solid var(--line);
  background: rgba(243, 234, 209, 0.58);
}

.site-nav a {
  display: inline-flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-left: 1px solid var(--line-soft);
  padding: 13px clamp(8px, 0.92vw, 18px);
  color: var(--muted);
  font-size: clamp(0.84rem, 0.58vw + 0.34rem, 0.96rem);
  font-weight: 650;
  line-height: 1.2;
  overflow: hidden;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-nav a:first-child {
  border-left: 0;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  background: var(--ink);
  color: var(--paper-soft);
}

.github-link {
  display: inline-flex;
  gap: 9px;
  align-items: center;
}

.github-link > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.star-link {
  gap: 12px;
}

.star-badge {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 5px;
  align-items: center;
  border-left: 1px solid currentColor;
  padding-left: 10px;
  color: var(--ink);
  font-size: 0.88em;
  font-weight: 760;
  white-space: nowrap;
}

.site-nav a:hover .star-badge,
.site-nav a[aria-current="page"] .star-badge {
  color: var(--paper-soft);
}

.github-link::before {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.08em;
  height: 1.08em;
  background: currentColor;
  content: "";
  -webkit-mask:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.65 7.65 0 0 1 8 3.86c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82A7.65 7.65 0 0 1 8 3.86c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8Z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.85fr);
  gap: clamp(1.6rem, 5vw, 4rem);
  align-items: center;
  min-height: calc(100vh - 86px);
  padding: clamp(3rem, 8vw, 6rem) 0 3rem;
}

.hero-copy {
  max-width: 720px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.55rem;
  color: var(--teal-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.06;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(3rem, 8vw, 6.9rem);
  max-width: 920px;
}

h2 {
  font-size: clamp(2rem, 4.5vw, 4rem);
}

h3 {
  font-size: 1.25rem;
}

.lede {
  max-width: 760px;
  color: var(--muted);
  font-size: clamp(1.14rem, 2vw, 1.42rem);
}

.hero-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  border-radius: 6px;
  padding: 0.66rem 0.95rem;
  font-weight: 800;
  text-decoration: none;
}

.primary-link {
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--white);
}

.secondary-link {
  border: 2px solid var(--ink);
  background: var(--white);
}

.hero-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.hero-figure {
  margin: 0;
}

.hero-figure img,
.wide-figure img,
.story-card img,
.article-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--wash);
}

.hero-figure figcaption,
.article-figure figcaption {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 0.65rem;
}

.section {
  padding: clamp(3rem, 7vw, 5.5rem) 0;
  border-top: 1px solid rgba(29, 35, 40, 0.13);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  align-items: end;
  margin-bottom: 1.5rem;
}

.section-heading p {
  max-width: 590px;
  color: var(--muted);
}

.metric-grid,
.use-grid,
.artifact-grid,
.factor-grid,
.source-grid {
  display: grid;
  gap: 1rem;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.use-card,
.factor-card,
.source-card,
.callout-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 1rem;
}

.artifact-card {
  display: grid;
  gap: 0.8rem;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 1.15rem;
  min-height: 245px;
}

.artifact-card h3 {
  font-size: clamp(1.08rem, 1.5vw, 1.3rem);
  line-height: 1.16;
}

.artifact-card h3 code {
  overflow-wrap: anywhere;
}

.metric-card strong {
  display: block;
  color: var(--ink);
  font-size: 2.25rem;
  line-height: 1;
}

.metric-card span,
.use-card span,
.artifact-card span,
.factor-card span {
  display: block;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.metric-card p,
.use-card p,
.artifact-card p,
.factor-card p,
.source-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.artifact-card p {
  margin-top: 0;
}

.artifact-use {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.artifact-use strong {
  color: var(--ink);
}

.use-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.story-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.story-card {
  display: grid;
  gap: 0.8rem;
}

.story-card h3 {
  margin-top: 0.15rem;
}

.story-card p {
  margin: 0;
  color: var(--muted);
}

.process {
  display: grid;
  gap: 0.8rem;
  margin: 1.5rem 0;
}

.process-step {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 1rem;
  align-items: start;
  border-left: 4px solid var(--teal);
  background: var(--white);
  padding: 1rem;
  border-radius: 0 8px 8px 0;
}

.process-step span {
  color: var(--coral);
  font-weight: 800;
}

.code-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.code-grid + .code-grid {
  margin-top: 1rem;
}

.command-stack {
  display: grid;
  gap: 1rem;
}

.command-block {
  display: grid;
  gap: 0.35rem;
}

.artifact-grid,
.factor-grid,
.source-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.band {
  margin: clamp(3rem, 7vw, 5.5rem) calc(50% - 50vw);
  padding: clamp(3rem, 7vw, 5rem) max(1rem, calc(50vw - 590px));
  background: #eef7f6;
  border-top: 1px solid rgba(29, 35, 40, 0.12);
  border-bottom: 1px solid rgba(29, 35, 40, 0.12);
}

.quote-panel {
  max-width: 920px;
  margin: 0 auto;
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1.18;
}

.quote-panel p {
  margin: 0;
}

.article-shell {
  padding-bottom: 4rem;
}

.article-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.75fr);
  gap: clamp(1.6rem, 5vw, 4rem);
  align-items: center;
  padding: clamp(3rem, 7vw, 5rem) 0 2rem;
}

.article-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  padding-top: 2rem;
}

.article-toc {
  position: sticky;
  top: 96px;
  align-self: start;
  display: grid;
  gap: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 0.9rem;
  font-size: 0.95rem;
}

.article-toc a {
  text-decoration: none;
  color: var(--muted);
}

.article-toc a:hover {
  color: var(--ink);
}

.article-body {
  display: grid;
  gap: 3rem;
}

.article-body section {
  border-top: 1px solid rgba(29, 35, 40, 0.13);
  padding-top: 2rem;
}

.article-body p,
.article-body li {
  color: var(--muted);
}

.article-body h2 {
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  margin-bottom: 0.9rem;
}

.formula {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  padding: 1rem;
}

.formula p {
  margin: 0.4rem 0;
}

.formula.math-display {
  overflow-x: auto;
  color: var(--ink);
}

.formula .mjx-container {
  margin: 0.25rem 0 !important;
  min-width: max-content;
}

.callout-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}

.site-footer {
  border-top: 2px solid var(--line);
  background: var(--ink);
  padding: 26px min(44px, 5vw);
}

.site-credit {
  width: min(1180px, 100%);
  margin: 0 auto;
  color: rgba(255, 250, 240, 0.76);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.5;
}

.site-credit a {
  color: var(--paper-soft);
  text-decoration: none;
}

.site-credit a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

@media (max-width: 1280px) {
  .site-header {
    grid-template-columns: minmax(170px, auto) minmax(240px, 1fr);
  }

  .site-nav {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-self: stretch;
    width: 100%;
  }

  .site-nav a {
    padding: 12px 10px;
    font-size: 0.9rem;
  }
}

@media (max-width: 920px) {
  .site-header {
    grid-template-columns: 1fr;
  }

  .header-search {
    width: 100%;
  }

  .site-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .hero,
  .article-hero,
  .article-layout,
  .code-grid {
    grid-template-columns: 1fr;
  }

  .article-toc {
    position: static;
  }

  .metric-grid,
  .story-grid,
  .artifact-grid,
  .factor-grid,
  .source-grid,
  .callout-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .site-header {
    padding: 14px 18px;
  }

  .site-brand img {
    width: min(165px, 58vw);
  }

  .header-search input[type="search"] {
    min-height: 44px;
  }

  .site-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .site-nav a {
    border-top: 1px solid var(--line-soft);
    padding: 10px 12px;
  }

  .site-nav a:nth-child(odd) {
    border-left: 0;
  }

  .shell {
    width: min(100% - 1rem, 1180px);
  }

  .hero {
    min-height: auto;
  }

  .metric-grid,
  .use-grid,
  .story-grid,
  .artifact-grid,
  .factor-grid,
  .source-grid,
  .callout-grid {
    grid-template-columns: 1fr;
  }

  .process-step {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 460px) {
  .site-header {
    padding: 12px 10px;
  }

  .site-nav {
    grid-template-columns: 1fr;
  }

  .site-nav a {
    border-left: 0;
  }
}
