/* Departure — example stylesheet
   Mirrors the tokens in ../DESIGN.md as plain CSS custom properties so these
   files open with file:// and no build step. ../theme.css is the Tailwind v4
   @theme export of the same tokens; browsers ignore @theme without Tailwind,
   which is why this file restates them. */

@font-face {
  font-family: "Departure Mono";
  src: url("./fonts/DepartureMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  font-feature-settings: "locl";
}

/* ---------------------------------------------------------------- reset -- */

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

html,
body,
h1,
h2,
h3,
h4,
p,
ul,
ol,
li,
figure,
blockquote,
pre,
dl,
dd {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

/* ----------------------------------------------------------- palette ----- */
/* Raw materials. Mode-invariant — these never change value. */

:root {
  --amber: #ffa133;
  --pumpkin: #e47b1a;
  --flux: #c8be50;
  --foam: #bccabb;
  --enamel: #eeeeee;
  --cement: #c0c0c0;
  --aluminum: #cccccc;
  --ash: #8e8e8e;
  --mud: #8a8a6f;
  --clay: #6c6c58;
  --smoke: #666666;
  --dark: #444444;
  --soot: #333333;
  --carbon: #222222;
  --black: #141414;

  /* type scale */
  --text-display: 88px;
  --text-h1: 44px;
  --text-h2: 33px;
  --text-h3: 22px;
  --text-body-md: 16.5px;
  --text-body-sm: 14px;
  --text-code: 14px;
  --text-label-caps: 11px;
  --text-caption: 11px;

  --leading-display: 88px;
  --leading-h1: 44px;
  --leading-h2: 33px;
  --leading-h3: 22px;
  --leading-body-md: 24.75px;
  --leading-body-sm: 21px;
  --leading-code: 22px;
  --leading-label-caps: 14px;
  --leading-caption: 14px;

  --tracking-display: -0.02em;
  --tracking-h1: -0.01em;
  --tracking-label-caps: 0.09em;

  /* the 11px lattice */
  --space-hair: 2px;
  --space-xs: 4px;
  --space-sm: 11px;
  --space-md: 22px;
  --space-lg: 44px;
  --space-xl: 88px;
  --space-xxl: 132px;

  --radius-none: 0px;
  --radius-sm: 2px;
  --radius-md: 4px;

  --b: 2px;
  --measure: 66ch;
}

/* ------------------------------------------------------------ palettes --- */
/* The semantic role layer (--ground, --ink, --accent, --line, ...) now lives in
   palettes.css, which is generated by scripts/gen-palettes.py so the values
   can't drift from their verified contrast ratios. Load palettes.css BEFORE
   this file. Everything below consumes roles only and never touches a raw
   material name, which is what lets all eight palettes swap cleanly.

   Two things the palettes encode that are worth knowing:

   1. Recession is filled on dark, drawn on light. Dark grounds recess to a
      darker surface; light grounds have nothing lighter to recess *to*, so
      they keep the ground and take a border instead.

   2. The accent is not always ink. In departure-light, amber is 1.74:1 on
      enamel and pumpkin is 2.53:1 — neither is readable as text. There the
      accent survives as a fill and an underline (7.88:1 as a block). The
      --accent-is-ink flag records which palettes can use it as text. */

:root {
  --rule-strong: var(--ink-muted);
}

/* -------------------------------------------------------------- base ----- */

html {
  font-family: "Departure Mono", ui-monospace, monospace;
  font-synthesis: none; /* one weight only — never let the browser fake a bold */
  font-feature-settings: "locl";
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  background-color: var(--ground);
  color: var(--ink);
  font-size: var(--text-body-md);
  line-height: var(--leading-body-md);
  padding: var(--space-lg) var(--space-md) var(--space-xxl);
}

::selection {
  background-color: var(--ink);
  color: var(--ground);
}

.page {
  max-width: 748px; /* 68 × 11 */
  margin: 0 auto;
}

/* --------------------------------------------------------- typography ---- */

.display,
h1,
h2,
h3 {
  color: var(--ink-bright);
  font-weight: 400;
}

.display {
  font-size: var(--text-display);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
}

h1 {
  font-size: var(--text-h1);
  line-height: var(--leading-h1);
  letter-spacing: var(--tracking-h1);
}

h2 {
  font-size: var(--text-h2);
  line-height: var(--leading-h2);
}

h3 {
  font-size: var(--text-h3);
  line-height: var(--leading-h3);
}

p {
  max-width: var(--measure);
}

p + p {
  margin-top: var(--space-md);
}

small,
.caption {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--ink-muted);
}

.label {
  font-size: var(--text-label-caps);
  line-height: var(--leading-label-caps);
  letter-spacing: var(--tracking-label-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
}

.meta {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--ink-muted);
}

.annotation {
  color: var(--ink-annotation);
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
}

/* Emphasis without a bold. Departure Mono ships one weight, so <strong> steps
   up in value (ink -> ink-bright) and <em> spaces out, the way a terminal has
   always emphasised. Tracking is set in whole pixels, not em, so the glyphs
   stay on the lattice. */

strong,
b {
  color: var(--ink-bright);
  font-weight: 400;
  letter-spacing: 1px;
}

em,
i {
  font-style: normal; /* no italic face exists — never let one be synthesised */
  letter-spacing: 2px;
}

mark {
  background-color: var(--highlight);
  color: var(--on-highlight);
  padding: 0 var(--space-xs);
}

/* --------------------------------------------------------------- flow ---- */
/* Vertical rhythm for rendered markdown. A Post is authored as plain markdown,
   so nothing in the content can carry spacing of its own — every gap has to be
   a rule here. Defaults to 22px between blocks; a heading takes 44px above and
   keeps the 22px below, so it binds to the text it introduces rather than
   floating between two paragraphs. */

.prose > * + * {
  margin-top: var(--space-md);
}

.prose > :is(h2, h3) {
  margin-top: var(--space-lg);
}

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

.prose li {
  position: relative;
  padding-left: var(--space-md);
}

.prose li + li {
  margin-top: var(--space-sm);
}

.prose ul > li::before {
  content: "—";
  position: absolute;
  left: 0;
  color: var(--ink-muted);
}

.prose ol {
  counter-reset: prose-item;
}

.prose ol > li::before {
  content: counter(prose-item) ".";
  counter-increment: prose-item;
  position: absolute;
  left: 0;
  color: var(--ink-muted);
}

/* -------------------------------------------------------------- links ---- */

a {
  color: var(--link-ink);
  text-decoration: underline;
  text-decoration-thickness: var(--b);
  text-underline-offset: var(--space-xs);
  text-decoration-color: var(--accent);
}

a:hover {
  color: var(--link-ink-hover);
}

/* Palettes where the accent fails as ink (--accent-is-ink: 0) express hover as
   a fill instead. Only departure-light needs this today. */
[data-palette="departure-light"] a:hover {
  background-color: var(--accent);
  color: var(--on-accent);
  text-decoration-color: transparent;
}

a:visited {
  color: var(--link-ink-visited);
  text-decoration-color: var(--accent-spent);
}

/* ---------------------------------------------------------------- nav ---- */

.masthead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: var(--b) solid var(--rule);
  margin-bottom: var(--space-xl);
}

.wordmark {
  font-size: var(--text-h3);
  line-height: var(--leading-h3);
  color: var(--ink-bright);
  text-decoration: none;
}

.nav {
  display: flex;
  gap: var(--space-hair);
}

.nav a {
  font-size: var(--text-label-caps);
  line-height: var(--leading-label-caps);
  letter-spacing: var(--tracking-label-caps);
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-muted);
  padding: 8px 12px;
  border: var(--b) solid transparent;
}

.nav a:hover,
.nav a[aria-current="page"] {
  background-color: var(--invert-fill);
  color: var(--on-invert);
}

/* ------------------------------------------------------------ buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: inherit;
  font-size: var(--text-label-caps);
  line-height: var(--leading-label-caps);
  letter-spacing: var(--tracking-label-caps);
  text-transform: uppercase;
  text-decoration: none;
  height: 33px;
  padding: 6px 22px;
  border: var(--b) solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background-color: transparent;
  color: var(--ink);
}

.btn--primary {
  background-color: var(--accent);
  color: var(--on-accent);
}

.btn--primary:hover {
  background-color: var(--accent-spent);
}

.btn--secondary {
  background-color: var(--ground);
  color: var(--ink);
  border-color: var(--rule-strong);
}

.btn--secondary:hover {
  border-color: var(--accent);
}

.btn--ghost {
  background-color: transparent;
  color: var(--ink-muted);
  border-radius: var(--radius-none);
}

.btn--ghost:hover {
  color: var(--ink-bright);
}

/* -------------------------------------------------------------- focus ---- */
/* Corner brackets, not a ring — four conic gradients painted as crop marks.
   Uses background-image (not the background shorthand) so a component's own
   background-color survives underneath. */

:where(a, button, [tabindex]):focus-visible {
  outline: none;
  --_g: #0000 90deg, var(--accent) 0;
  background-image: conic-gradient(from 90deg at top var(--b) left var(--b), var(--_g)),
    conic-gradient(from 180deg at top var(--b) right var(--b), var(--_g)),
    conic-gradient(from 0deg at bottom var(--b) left var(--b), var(--_g)),
    conic-gradient(from -90deg at bottom var(--b) right var(--b), var(--_g));
  background-position: 0 0, 100% 0, 0 100%, 100% 100%;
  background-size: 8px 8px;
  background-repeat: no-repeat;
  background-origin: border-box;
}

/* --------------------------------------------------------------- code ---- */

pre,
code {
  font-family: inherit;
  font-size: var(--text-code);
  line-height: var(--leading-code);
}

code {
  color: var(--ink-bright);
}

pre {
  background-color: var(--recess-bg);
  border: var(--b) solid var(--recess-border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin: var(--space-md) 0;
  overflow-x: auto;
}

pre .c {
  color: var(--ink-annotation);
}

/* -------------------------------------------------------------- rules ---- */

hr,
.rule {
  border: 0;
  height: var(--b);
  background-color: var(--rule);
  margin: var(--space-lg) 0;
}

blockquote {
  border-left: var(--b) solid var(--accent);
  padding-left: var(--space-md);
  margin: var(--space-md) 0;
  color: var(--ink-muted);
  max-width: var(--measure);
}

/* -------------------------------------------------------------- lists ---- */

.entries {
  display: flex;
  flex-direction: column;
}

.entry {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: var(--space-md);
  align-items: baseline;
  padding: var(--space-sm) 0;
  border-bottom: var(--b) solid var(--rule);
}

.entry:first-child {
  border-top: var(--b) solid var(--rule);
}

.entry__date {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.entry__title {
  font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm);
}

.entry__tags {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-xs);
}

.tag {
  font-size: var(--text-label-caps);
  line-height: var(--leading-label-caps);
  letter-spacing: var(--tracking-label-caps);
  text-transform: uppercase;
  color: var(--ink-annotation);
}

.section {
  margin-bottom: var(--space-xl);
}

.section__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

/* ---------------------------------------------------- palette picker ----- */

.picker {
  position: fixed;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background-color: var(--ground);
  border: var(--b) solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-xs) var(--space-sm);
}

.picker__label {
  font-size: var(--text-label-caps);
  letter-spacing: var(--tracking-label-caps);
  text-transform: uppercase;
  color: var(--ink-muted);
}

.picker__select {
  font: inherit;
  font-size: var(--text-label-caps);
  letter-spacing: var(--tracking-label-caps);
  text-transform: uppercase;
  background-color: var(--ground);
  color: var(--ink);
  border: 0;
  border-radius: var(--radius-sm);
  padding: var(--space-xs);
  cursor: pointer;
}

.picker__hint {
  font-size: var(--text-label-caps);
  color: var(--ink-annotation);
}

/* ------------------------------------------------------------- footer ---- */

.colophon {
  margin-top: var(--space-xxl);
  padding-top: var(--space-md);
  border-top: var(--b) solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  justify-content: space-between;
}

/* ------------------------------------------------------------ mobile ---- */

@media (max-width: 640px) {
  body {
    padding: var(--space-md) var(--space-md) var(--space-xl);
  }

  .display {
    font-size: var(--text-h1);
    line-height: var(--leading-h1);
  }

  h1 {
    font-size: var(--text-h2);
    line-height: var(--leading-h2);
  }

  .entry {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .masthead {
    flex-direction: column;
    align-items: flex-start;
  }
}
