/* Sigma Handbook — Bauhaus-on-dark editorial, adapted from the Sigma Design
   Foundations tokens (sigma-explainer.tokens.json). Single theme, light + dark.

   Dark is the signature look: a warm near-black canvas, off-white ink, accents
   as punctuation (red leads; blue/yellow support). Light is a warm-paper
   counterpart with the same ink/accent relationships inverted.

   Type voices: Fraunces (display + headings) · Hanken Grotesk (body) ·
   Space Mono (labels/eyebrows). */

:root {
  --measure: 68ch;
  --page: 1080px;
  --gutter: clamp(1rem, 4vw, 1.5rem);
  --radius-card: 16px;
  --radius: 9px;
  --radius-pill: 50px;
  --header-height: 60px;

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-heading: "Fraunces", ui-serif, Georgia, serif;
  --font-body: "Hanken Grotesk", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Accents — constant across modes (red leads). */
  --red: #e8503a;
  --blue: #3d6bff;
  --yellow: #f2c14e;

  /* Theme bridge for the <doc-outline> web component. */
  --color-border: var(--line);
  --color-heading: var(--ink);
  --color-dim: var(--ink-dim);
  --color-accent: var(--red);
  --color-accent-hover: var(--ink);

  /* Light — warm paper. */
  --bg: #f5f1e7;
  --surface: #fffdf6;
  --surface-2: #efe9da;
  --ink: #211e1a;
  --ink-dim: #6b675c;
  --ink-faint: #a7a094;
  --line: rgba(33, 30, 26, 0.12);
  --line-2: rgba(33, 30, 26, 0.22);
  --link: #c0432c;
  --link-hover: #211e1a;
  --selection: rgba(232, 80, 58, 0.18);
  --atmos-1: radial-gradient(circle at 12% 8%, rgba(61, 107, 255, 0.06), transparent 40%);
  --atmos-2: radial-gradient(circle at 88% 96%, rgba(232, 80, 58, 0.05), transparent 42%);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100f0d;
    --surface: #1a1916;
    --surface-2: #232220;
    --ink: #eceae1;
    --ink-dim: #8d8a80;
    --ink-faint: #4f4d47;
    --line: rgba(236, 234, 225, 0.10);
    --line-2: rgba(236, 234, 225, 0.18);
    --link: #f0a18f;
    --link-hover: #eceae1;
    --selection: rgba(232, 80, 58, 0.30);
    --atmos-1: radial-gradient(circle at 12% 8%, rgba(61, 107, 255, 0.07), transparent 40%);
    --atmos-2: radial-gradient(circle at 88% 96%, rgba(232, 80, 58, 0.06), transparent 42%);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--atmos-1), var(--atmos-2);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection); }

.wrap {
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

main.wrap { padding-block: 3rem 4rem; }

/* ─── Skip link ───────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -10000px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  position: fixed;
  left: 1rem;
  top: 1rem;
  width: auto;
  height: auto;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  z-index: 100;
}

/* ─── Header ──────────────────────────────────────────────────────────────── */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--header-height);
}
.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.primary {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.primary a {
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.25s ease;
}
.primary a:hover { color: var(--ink); }

@media (max-width: 620px) {
  .primary { gap: 0.9rem; font-size: 0.68rem; }
  .brand span { display: none; }
}

/* ─── Footer (two-level) ──────────────────────────────────────────────────── */

.site-footer {
  margin-top: 5rem;
}
.site-footer .wrap { padding-bottom: 4rem; }
.foot-top {
  border-top: 1px solid var(--line);
  padding-top: 2rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  align-items: baseline;
}
.foot-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.colophon {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin: 0;
}
.foot-nav {
  margin-top: 1.25rem;
  padding-top: 1.15rem;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.foot-nav a {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.25s ease;
}
.foot-nav a:hover { color: var(--ink); }

/* ─── Eyebrow (mono label + accent bar) ───────────────────────────────────── */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0 0 1.3rem !important;
}
.eyebrow::before {
  content: "";
  width: 34px;
  height: 2px;
  background: var(--red);
  flex: none;
}
/* In .prose, the generic `.prose p` rule would bump the eyebrow to 1rem; pin it back to
   the eyebrow size so it matches the landing eyebrows exactly. */
.prose .eyebrow { font-size: 0.78rem; }

.eyebrow a,
.prose .eyebrow a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.eyebrow a:hover,
.prose .eyebrow a:hover {
  border-bottom-color: currentColor;
}

/* ─── Prose ───────────────────────────────────────────────────────────────── */

.prose { max-width: var(--measure); }

/* Doc-page two-column layout: prose + sticky <doc-outline> rail (rail self-hides < 1100px).
   On wide screens the prose fills to the rail's gutter, so the rail's outer edge lines up
   with the page (nav) edge; padding-top matches the hero so the eyebrow sits at the same
   height as on landing pages. */
.doc-layout { display: flex; gap: 4rem; align-items: flex-start; padding-top: 2rem; }
.doc-layout .prose { flex: 1 1 auto; min-width: 0; }
@media (min-width: 1100px) {
  .doc-layout .prose { max-width: none; }
}

.prose > * + * { margin-top: 1rem; }
.prose > * + h2 { margin-top: 2.75rem; }
.prose > * + h3 { margin-top: 2rem; }

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.01em;
  /* Roomy line height so headings with descenders (g, p, y) and the odd
     two-line heading sit comfortably. */
  line-height: 1.4;
  color: var(--ink);
}
.prose h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-optical-sizing: auto;
  font-size: clamp(2.1rem, 4.5vw, 3rem);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-top: 0.25rem;
}
.prose h2 { font-size: 1.5rem; padding-top: 0.4rem; }
.prose h3 { font-size: 1.18rem; }
.prose h4 { font-size: 1rem; }

.prose p, .prose ul, .prose ol, .prose blockquote { font-size: 1rem; }

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}
.prose a:hover { color: var(--link-hover); }

.prose ul, .prose ol { padding-left: 1.5rem; }
.prose li + li { margin-top: 0.35rem; }
.prose li > ul, .prose li > ol { margin-top: 0.4rem; }

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1rem;
  border-left: 2px solid var(--red);
  color: var(--ink-dim);
  font-style: italic;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2.5rem 0;
}

.prose strong { font-weight: 600; color: var(--ink); }
.prose em { font-style: italic; }

/* ─── Code ────────────────────────────────────────────────────────────────── */

.prose code {
  font-family: var(--font-mono);
  font-size: 0.84em;
  background: var(--surface-2);
  padding: 0.08em 0.35em;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.prose pre {
  margin: 1.5rem 0;
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--blue);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 32rem;
  font-size: 0.84rem;
  line-height: 1.6;
}
.prose pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* ─── Copy-to-clipboard button (injected by copy.js) ──────────────────────── */

.code-block { position: relative; }
.code-block > pre {
  margin: 0;
  padding-top: 2.6rem;
}
.prose > .code-block { margin: 1.5rem 0; }
.copy-btn {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  padding: 0.3rem 0.6rem;
  font: 400 0.7rem/1 var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.code-block:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--ink); border-color: var(--red); }
.copy-btn.is-copied { color: var(--red); border-color: var(--red); opacity: 1; }

/* ─── Tables ──────────────────────────────────────────────────────────────── */

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.prose th, .prose td {
  text-align: left;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.prose th {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--ink-dim);
  border-bottom: 1px solid var(--line-2);
}
.prose td.name, .prose tr:hover td { color: var(--ink); }

/* ─── Document header (eyebrow + h1 on doc pages) ─────────────────────────── */

.doc-header {
  padding: 1rem 0 2.5rem;
  margin-bottom: 2.5rem;
  border-bottom: 1px solid var(--line);
  opacity: 0;
  animation: rise 0.7s 0.05s ease forwards;
}

/* ─── Home / hero ─────────────────────────────────────────────────────────── */

.home { max-width: var(--page); }
.hero {
  padding: 2rem 0 2.5rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
  opacity: 0;
  animation: rise 0.8s 0.05s ease forwards;
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-optical-sizing: auto;
  font-size: clamp(2.8rem, 7.5vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: -0.025em;
  margin: 0;
}
.hero h1 em {
  font-style: italic;
  font-weight: 600;
  color: var(--ink-faint);
}
.hero .lede {
  font-family: var(--font-body);
  max-width: 60ch;
  color: var(--ink-dim);
  font-size: 1.08rem;
  margin: 1.6rem 0 0;
}
.hero .meta {
  margin-top: 1.4rem;
  font-size: 0.95rem;
  color: var(--ink-dim);
  max-width: 60ch;
}
.hero .lede a,
.ethos a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s ease;
}
.hero .lede a:hover,
.ethos a:hover { color: var(--link-hover); }

/* ─── Pillars (home + section landings) ───────────────────────────────────── */

.pillars { margin: 0; }
.pillar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1.5rem 2.2rem;
  padding: 3rem 0;
  border-top: 1px solid var(--line);
  opacity: 0;
  animation: rise 0.7s ease forwards;
}
.pillar:nth-child(1) { animation-delay: 0.12s; }
.pillar:nth-child(2) { animation-delay: 0.18s; }
.pillar:nth-child(3) { animation-delay: 0.24s; }
.pnum {
  font-family: var(--font-display);
  font-weight: 900;
  font-optical-sizing: auto;
  font-size: clamp(2.6rem, 6vw, 4rem);
  line-height: 0.85;
}
.pnum.red { color: var(--red); }
.pnum.blue { color: var(--blue); }
.pnum.yellow { color: var(--yellow); }
.pbody h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  margin: 0;
  letter-spacing: -0.01em;
}
.pbody h2 a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.25s ease;
}
.pbody h2 a:hover { color: var(--ink-dim); }
.ethos {
  color: var(--ink-dim);
  font-size: 1.05rem;
  margin: 0.55rem 0 1.3rem;
  max-width: 56ch;
}
.plinks {
  display: flex;
  gap: 1.3rem;
  flex-wrap: wrap;
  align-items: center;
}
.plinks a {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  border-bottom: 1px solid var(--line-2);
  padding-bottom: 3px;
  transition: color 0.25s ease, border-color 0.25s ease;
}
.plinks a:hover { color: var(--ink); border-color: var(--red); }

@media (max-width: 680px) {
  .pillar { grid-template-columns: 1fr; gap: 0.6rem; }
}

/* ─── Entry list (cards) ──────────────────────────────────────────────────── */

.section-block + .section-block { margin-top: 3rem; }
.section-block h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 0 0 0.4rem;
}
.section-lede {
  color: var(--ink-dim);
  font-size: 0.96rem;
  margin: 0 0 1.4rem;
  max-width: 56ch;
}

.entry-list,
.prose .entry-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
.entry-list li { margin: 0; }
.entry-list a {
  display: block;
  height: 100%;
  padding: 1.2rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.3s ease, transform 0.3s ease;
}
.entry-list a:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
}
.entry-list .entry-title {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
@media (max-width: 680px) {
  .entry-list { grid-template-columns: 1fr; }
}

/* ─── Standards landing: feature + language cards ─────────────────────────── */

.std-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.std-card {
  display: flex;
  gap: 1rem;
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.3s ease, transform 0.3s ease;
}
.std-card:hover {
  border-color: var(--accent, var(--line-2));
  transform: translateY(-2px);
}
.std-feature {
  grid-column: span 2;
  align-items: flex-start;
}
.std-lang {
  grid-column: span 1;
  flex-direction: column;
  gap: 0.85rem;
}
.std-icon {
  flex: none;
  color: var(--ink-dim);
  transition: color 0.3s ease;
}
.std-feature .std-icon { width: 30px; height: 30px; }
.std-lang .std-icon { width: 26px; height: 26px; }
.std-card:hover .std-icon { color: var(--accent, var(--red)); }
.std-icon svg { display: block; width: 100%; height: 100%; }

/* Per-language brand accent (border + icon on hover) and Go logo sizing —
   the Go mark is wider than tall, so it needs a nudge to read the same height. */
.std-ts { --accent: #f7df1e; }
.std-go { --accent: #00add8; }
.std-kotlin { --accent: #7f52ff; }
.std-godot { --accent: #478cbf; }
.std-go .std-icon { width: 68px; }

/* Divider between the two feature cards and the rest of the grid. */
.std-divider {
  grid-column: 1 / -1;
  height: 1px;
  border: 0;
  margin: 0.4rem 0;
  background: var(--line);
}
.std-card-text { display: flex; flex-direction: column; gap: 0.3rem; }
.std-card-title {
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.std-feature .std-card-title { font-size: 1.15rem; }
.std-lang .std-card-title { font-size: 1rem; }
.std-card-desc {
  color: var(--ink-dim);
  font-size: 0.875rem;
  line-height: 1.45;
  text-wrap: pretty;
}
.std-feature .std-card-desc { font-size: 0.92rem; }

@media (max-width: 860px) {
  .std-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .std-grid { grid-template-columns: 1fr; }
  .std-feature { grid-column: span 1; }
}

/* ─── Motion ──────────────────────────────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .hero, .pillar, .doc-header { opacity: 1; }
  html { scroll-behavior: auto; }
}

/* ─── Print ───────────────────────────────────────────────────────────────── */

@media print {
  .site-header, .site-footer, .skip-link { display: none; }
  body { font-size: 11pt; background: #fff; color: #000; }
  .prose { max-width: none; }
}
