/* The Atlas Plate.
   Scene: an engineer reading technical notes at a desk, usually at night, on
   a screen. Light mode is the plate as printed; dark is the sky it plots.
   Colour strategy: Full palette. A star atlas does not have "an accent" — it
   has a magnitude scale, so three named tints carry the data rather than one
   signal colour over a neutral ground. */
:root {
  color-scheme: light;
  --bg: #e2e5e8;
  --bg-elevated: #eef1f3;
  --ink: #14161f;
  --ink-soft: #3a3d4a;
  --muted: #5c6070;
  --rule: #c3c7cb;
  --grid: #d4d8db;
  --accent: #8a4f11;
  --star-cool: #2f6a80;
  --star-faint: #6b4a86;
  --mark: #d8dbdf;
  --serif-display: "Spectral", Georgia, "Times New Roman", serif;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --mono: "Azeret Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  /* Legacy name: every label in this world is set in the mono face. */
  --sans: var(--mono);
  --measure: 42rem;
  --page: 72rem;
  --code-comment: #6b6f80;
  --code-keyword: #8a4f11;
  --code-string: #2f6a45;
  --code-function: #6b4a86;
  --code-number: #2f6a80;
  --code-punct: #62667a;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0d18;
  --bg-elevated: #121728;
  --ink: #e9e7db;
  --ink-soft: #c3c1b5;
  --muted: #8b8e9c;
  --rule: #232a42;
  --grid: #1b2138;
  --accent: #f0c674;
  --star-cool: #8fb8c9;
  --star-faint: #b892c9;
  --mark: #1a2135;
  --code-comment: #6f7488;
  --code-keyword: #f0c674;
  --code-string: #9ecf9a;
  --code-function: #b892c9;
  --code-number: #8fb8c9;
  --code-punct: #8b8e9c;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.125rem;
  line-height: 1.7;
  font-optical-sizing: auto;
}

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

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

a:hover {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Browser surfaces ship defaults belonging to no design system. */
::selection {
  background: var(--mark);
  color: var(--ink);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  background: var(--accent);
  color: var(--bg);
  padding: 0.6rem 1rem;
  font-family: var(--sans);
  font-size: 0.86rem;
  letter-spacing: 0.04em;
}

.skip-link:focus {
  left: 0;
}

/* The global `a:hover` rule is specificity (0,1,1) and would otherwise beat
   this element's own colour (0,1,0), repainting the skip link accent-on-accent:
   1.0:1, invisible, on the one control the users who need it reach first. */
.skip-link:hover {
  color: var(--bg);
}

.wrap {
  width: min(var(--page), calc(100% - 2.5rem));
  margin: 0 auto;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.6rem 0 1.4rem;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
}

.brand-mark {
  font-family: var(--serif-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--sans);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Vertical padding gives each destination a ~44px hit area without changing
   the visual rhythm; the reduced gap absorbs the horizontal padding. */
.nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.8rem 0.35rem;
}

.nav a:hover,
.nav a.is-active {
  color: var(--ink);
}

.theme-toggle {
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  color: var(--ink);
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.theme-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
}

/* The control now reports its own state: the glyph matches the active theme,
   and `aria-pressed` carries the same fact to screen readers. */
.theme-toggle [data-icon="moon"] {
  display: none;
}

[data-theme="dark"] .theme-toggle [data-icon="sun"] {
  display: none;
}

[data-theme="dark"] .theme-toggle [data-icon="moon"] {
  display: block;
}

.hero {
  padding: 4.5rem 0 2.8rem;
  max-width: var(--measure);
}

.hero h1,
.page-title {
  font-family: var(--serif-display);
  font-weight: 500;
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 0 0 1rem;
}

.lede {
  font-size: 1.28rem;
  color: var(--ink-soft);
  max-width: 38rem;
  margin: 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.4rem;
  padding-top: 0.4rem;
}

.section-head h2 {
  font-family: var(--sans);
  font-size: 0.86rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 500;
  margin: 0;
  color: var(--muted);
}

.section-head a {
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--accent);
  text-decoration: none;
}

.post-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--rule);
  margin-bottom: 5rem;
}

.post-card {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1.6rem;
  padding: 1.7rem 0;
  border-bottom: 1px solid var(--rule);
  text-decoration: none;
}

/* Cards revealed nothing until hover, and touch has no hover. A rest-state
   underline gives the affordance before any interaction; the accent moves it
   to the hover colour. */
.post-card h2,
.post-card h3,
.project h2,
.project h3 {
  text-decoration: underline;
  /* --rule would be ~1.1:1 here, well under the 3:1 floor for a UI affordance;
     --muted lands at roughly 4:1 light and 6:1 dark. */
  text-decoration-color: var(--muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.post-card:hover h2,
.post-card:hover h3,
.project:hover h2,
.project:hover h3 {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

.post-meta {
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.post-card h2,
.post-card h3 {
  font-family: var(--serif-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 0.45rem;
}

.post-card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.article {
  width: min(var(--measure), 100%);
  margin: 0 auto;
  padding: 3.4rem 0 5rem;
}

.article-meta {
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 1rem;
}

.article h1 {
  font-family: var(--serif-display);
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  line-height: 1.12;
  letter-spacing: -0.035em;
  font-weight: 500;
  margin: 0 0 1.1rem;
}

.article .deck {
  font-size: 1.28rem;
  color: var(--ink-soft);
  margin: 0 0 2.2rem;
}

.article p {
  margin: 0 0 1.2rem;
}

.article h2 {
  font-family: var(--serif-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 2.2rem 0 0.8rem;
}

.article blockquote {
  margin: 1.8rem 0;
  padding: 0 0 0 1.2rem;
  border-left: 2px solid var(--accent);
  color: var(--ink-soft);
  font-style: italic;
}

.article em {
  font-style: italic;
}

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 20;
}

.about-grid {
  padding: 3.5rem 0 5rem;
}

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

.about-copy h1 {
  font-family: var(--serif-display);
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  font-weight: 500;
  letter-spacing: -0.03em;
  margin: 0 0 1rem;
}

.about-copy .about-role {
  font-family: var(--sans);
  font-size: 0.86rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0 0 1.6rem;
}

.about-copy p {
  color: var(--ink-soft);
}

.about-points {
  margin: 0;
  padding-left: 1.2rem;
  display: grid;
  gap: 0.6rem;
}

.about-points li {
  color: var(--ink-soft);
  line-height: 1.6;
}

.about-points li::marker {
  color: var(--accent);
}

.site-footer {
  border-top: 1px solid var(--rule);
  padding: 1.6rem 0 2.4rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--sans);
  font-size: 0.86rem;
  color: var(--muted);
}

.article ul,
.article ol {
  margin: 0 0 1.3rem;
  padding-left: 1.2rem;
  color: var(--ink-soft);
}

.article li {
  margin: 0 0 0.4rem;
}

.article code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--mark);
  padding: 0.08em 0.32em;
}

.article pre {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.6;
  background: var(--mark);
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  margin: 0 0 1.4rem;
}

.article pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

/* Figures: diagrams and illustrations get a caption and room to breathe. */
.article figure {
  margin: 2.4rem 0;
}

.article figure svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

.article figcaption {
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  margin-top: 0.9rem;
}

/* Writer's note at the foot of a post — disclosure and provenance, not prose. */
.article .colophon {
  margin-top: 3.2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--muted);
}

/* Inline illustrations scale with the column, so their labels are sized from a
   variable that grows on narrow screens — otherwise a wide SVG's text becomes
   unreadable once it shrinks to a phone width. */
.article figure svg.figure-art {
  --fig-fs: 15px;
}

.article figure svg.figure-art text {
  font-size: var(--fig-fs);
}

/* Secondary labels — panel headings, edge labels, sub-captions. */
.article figure svg.figure-art text.sm {
  font-size: calc(var(--fig-fs) * 0.8);
}

@media (max-width: 44rem) {
  .article figure svg.figure-art {
    --fig-fs: 24px;
  }
}

.article pre code .token.comment,
.article pre code .token.prolog,
.article pre code .token.doctype,
.article pre code .token.cdata {
  color: var(--code-comment);
  font-style: italic;
}

.article pre code .token.keyword,
.article pre code .token.boolean,
.article pre code .token.important,
.article pre code .token.atrule {
  color: var(--code-keyword);
}

.article pre code .token.string,
.article pre code .token.char,
.article pre code .token.attr-value,
.article pre code .token.regex {
  color: var(--code-string);
}

.article pre code .token.function,
.article pre code .token.class-name,
.article pre code .token.builtin {
  color: var(--code-function);
}

.article pre code .token.number,
.article pre code .token.constant,
.article pre code .token.symbol {
  color: var(--code-number);
}

.article pre code .token.punctuation,
.article pre code .token.operator {
  color: var(--code-punct);
}

.article pre code .token.property,
.article pre code .token.tag,
.article pre code .token.attr-name,
.article pre code .token.selector,
.article pre code .token.parameter {
  color: var(--code-keyword);
}

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.4rem;
  font-family: var(--sans);
  font-size: 0.86rem;
  margin: 1.6rem 0 0;
}

.socials a {
  color: var(--accent);
  text-decoration: none;
  padding: 0.4rem 0;
}

.project-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
  margin: 0 0 4.5rem;
}

.project {
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  padding: 1.4rem 1.35rem 1.2rem;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 11rem;
}

.project h2,
.project h3 {
  font-family: var(--serif-display);
  font-size: 1.35rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin: 0;
}

.project p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1.02rem;
  flex: 1;
}

.project .post-meta {
  margin-top: 0.4rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem 1.3rem;
  margin-top: 1.6rem;
  font-family: var(--sans);
  font-size: 0.86rem;
}

.hero-links a {
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.04em;
  padding: 0.4rem 0;
}

/* Comments: a giscus embed, themed to match via css/giscus-light.css and
   css/giscus-dark.css. It sits inside the article measure, below the prose. */
.comments {
  margin-top: 3.5rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--rule);
}

.comments .section-head {
  margin-bottom: 0.5rem;
}

.comments-note {
  font-family: var(--sans);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 1.6rem;
}

.comments-note a {
  color: var(--accent);
}

.comments-embed {
  /* Hold a little space so the embed does not shove the page around on load. */
  min-height: 4rem;
}

/* ── Atlas frame ──────────────────────────────────────────────────────────
   The world owns the frame; the reading column stays calm. The ground is a
   ruled coordinate plate, annotations are mono, and the catalogue is plotted
   rather than merely listed. */

/* The plate is ruled at the page module. --grid sits a hair off --bg so this
   reads as plate paper at reading distance, never as an overlay on prose. */
body {
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 6rem 6rem;
  background-position: center top;
}

/* Spectral is a text face, not a masthead: the tight tracking the serif
   display face wanted would foul it. */
.hero h1,
.page-title,
.article h1,
.about-copy h1 {
  letter-spacing: -0.02em;
}

/* The legend states real counts. A star atlas always ships one, and it is not
   decoration: it tells you the scale of the field you are looking at. */
.atlas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin: 0 0 1.5rem;
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.atlas-legend b {
  color: var(--accent);
  font-weight: 500;
}

/* The magnitude mark: a fixed-size dot whose tint is the entry's magnitude
   band. Size was dropped on purpose -- one linear formula was being applied to
   two quantities with very different ranges (reading minutes span 6-8, stars
   span 0-37), so the same mark read as a subtle step on a post and a 3rem blob
   on a project, and a zero-star entry had no mark at all. Keeping both size and
   tint also double-encoded one value. A fixed dot plus the three-step tint
   scale states the band and stops there. */
.post-meta::before,
.article-meta::before {
  content: "";
  display: inline-block;
  vertical-align: 0.05em;
  margin-right: 0.45rem;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--mag-tint, var(--muted));
}

/* Colour now carries the band alone, so the legend has to key it. */
.legend-key {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.9rem;
}

.legend-key span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-key i {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--muted);
}


.about-section {
  margin: 2.4rem 0 0.6rem;
}

.about-history {
  list-style: none;
  margin: 0;
  padding: 0;
}

.hist-row {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 1.6rem;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--rule);
}

.hist-dates {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0;
  color: var(--muted);
}

.hist-body {
  display: grid;
  gap: 0.15rem;
}

.hist-title {
  font-family: var(--serif);
  font-size: 1.02rem;
  font-weight: 500;
  color: var(--ink);
}

.hist-org {
  font-family: var(--mono);
  font-size: 0.86rem;
  letter-spacing: 0;
  color: var(--muted);
}

.hist-note {
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.55;
  letter-spacing: 0;
  color: var(--muted);
}

.hist-points {
  margin: 0.7rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.5rem;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.hist-points li::marker {
  color: var(--muted);
}

@media (max-width: 820px) {
  .hist-row {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }
}

@media (max-width: 820px) {
  .post-card,
  .project-grid {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .hero {
    padding-top: 3rem;
  }

  .nav {
    gap: 0.85rem;
  }
}

@media (max-width: 560px) {
  .wrap {
    width: min(var(--page), calc(100% - 1.5rem));
  }

  .site-header {
    flex-wrap: wrap;
  }

  .nav {
    width: 100%;
    justify-content: space-between;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
