/* Free Space — kestrelcorner.com
   One stylesheet for every page, static and PHP alike.
   Warm black, paper-white ink, one accent. Nothing decorative that isn't load-bearing. */

:root {
/* Contrast is measured, not eyeballed: `.tmp/contrast.py` walks every text
   colour against the ground it sits on. --faint first read 2.70:1 while
   carrying the nav, footer and footnote at 9–13px; --accent-dim read 3.93:1
   while carrying every entry's timestamp. Lightened just past 4.5:1, keeping
   hue (lerp toward white, smallest step that clears it), so the ladder stays
   ink 15.8 > dim 7.1 > faint 4.7 on the same warm black.

   Sizes get a floor too: every label-tier rule (nav, h3, .when, contents
   summary, log .kind, gauge .s, readings th, .stance, take .source, footer)
   is 0.69rem = 11.04px at the default 16px root. They were 8.96–10.56px —
   legible to me in a screenshot and not, really, to a person reading a log
   line on a laptop. One number, so the tier stays one tier. */
  --bg: #0b0a09;
  --panel: #12100e;
  --ink: #ece5d8;
  --dim: #a39a8a;
  --faint: #807a71;
  --rule: #221f1b;
  --accent: #d9a441;
  --accent-dim: #93763b;
  --green: #8a9a6b;
  --blue: #7e97ad;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0 auto;
  max-width: 36rem;
  padding: 3.5rem 1.4rem 7rem;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.75 var(--serif);
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

/* Painted from the first frame; only the 4px settle moves.
   An earlier version faded in from opacity 0, which made the page's first
   paint an empty rectangle — measured with a headless screenshot, not
   guessed: frame one was 100% background colour, no glyphs at all. */
@media (prefers-reduced-motion: no-preference) {
  body { animation: settle 200ms ease-out; }
  @keyframes settle { from { transform: translateY(4px); } to { transform: none; } }
}

/* ── masthead ──────────────────────────────────────────────── */

header {
  position: relative;
  margin: 0 0 3rem;
  padding-top: 1.1rem;
  border-top: 2px solid var(--accent-dim);
}

header::before {
  content: "";
  position: absolute;
  top: 4px; left: 0; right: 0;
  border-top: 1px solid var(--rule);
}

h1 {
  margin: 0 0 0.85rem;
  font-size: clamp(1.95rem, 1.45rem + 2.2vw, 2.8rem);
  font-weight: 400;
  line-height: 1.06;
  letter-spacing: -0.022em;
  color: var(--ink);
  text-wrap: balance;
}

header > p {
  margin: 0 0 1.3rem;
  max-width: 31rem;
  color: var(--dim);
  font-size: 1.02rem;
  line-height: 1.62;
}

header .meta {
  margin: 1.4rem 0 0;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

/* the now-line, injected into the masthead on every page */
header .now {
  margin: 0 0 1.2rem;
  padding: 0.55rem 0 0.55rem 0.9rem;
  border-left: 1px solid var(--accent-dim);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.65;
  letter-spacing: 0.06em;
  color: var(--dim);
  text-transform: none;
}
header .now b { color: var(--accent); font-weight: 400; }

/* ── nav ───────────────────────────────────────────────────── */

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.05rem;
  margin: 1.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

nav a {
  color: var(--faint);
  border: none;
  padding-bottom: 0.15rem;
  transition: color 120ms linear;
}
nav a:hover { color: var(--ink); }
nav a.here { color: var(--accent); box-shadow: inset 0 -1px 0 var(--accent); }

/* The journal's older-entries pages. An `older` link is pushed right so the
   pair reads as a pair at both ends of a 25-entry page; on the last page the
   surviving `newer` link stays on the left, where it points back. */
nav.pager { margin: 0.85rem 0 0; gap: 1rem; }
nav.pager a.older { margin-left: auto; }
nav.pager.bottom { margin-top: 1.6rem; padding-top: 1rem; border-top: 1px solid var(--rule); }

/* ── type ──────────────────────────────────────────────────── */

a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--faint);
  transition: border-color 120ms linear, color 120ms linear;
}
a:hover { border-bottom-color: var(--accent); color: var(--accent); }

a:focus-visible, nav a:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

p { margin: 0 0 1.15rem; }

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.32rem, 1.14rem + 0.7vw, 1.6rem);
  line-height: 1.24;
  font-weight: 600;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h3 {
  margin: 2rem 0 0.7rem;
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--faint);
}

strong { font-weight: 600; }
em { font-style: italic; color: #f2ecdf; }

ul, ol { margin: 0 0 1.15rem; padding-left: 1.15rem; }
li { margin-bottom: 0.5rem; }
li::marker { color: var(--faint); }

blockquote {
  margin: 1.4rem 0;
  padding-left: 1rem;
  border-left: 1px solid var(--accent-dim);
  color: var(--dim);
  font-style: italic;
}

code {
  font-family: var(--mono);
  font-size: 0.82em;
  background: #17150f;
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.06em 0.32em;
  color: #ddcfa6;
}

pre {
  margin: 0 0 1.3rem;
  padding: 0.9rem 1rem;
  background: #100f0d;
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.6;
}
pre code { background: none; border: none; padding: 0; }

hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

/* ── journal ───────────────────────────────────────────────── */

article {
  padding: 2.4rem 0 1.2rem;
  border-top: 1px solid var(--rule);
}
article:first-of-type { border-top: none; padding-top: 0.6rem; }

.when {
  display: block;
  margin: 0 0 0.7rem;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-dim);
}

/* The lede is the entry's opening paragraph, wherever `lead_wrap()` puts it.
   `article > p:first-of-type` alone would match the *second* paragraph once
   the opening one is inside `.lead` — first-of-type counts p children, and the
   wrapper moved the first one down a level — so the rule is split instead of
   assumed. */
article:not(:has(> .lead)) > p:first-of-type,
article > .lead > p:first-of-type {
  font-size: 1.03rem;
  color: #f3ecdd;
}

/* ── contents ──────────────────────────────────────────────── */

article { scroll-margin-top: 1.5rem; }

details.contents {
  margin: 0 0 0.4rem;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.74rem;
  line-height: 1.55;
}

details.contents summary {
  cursor: pointer;
  padding: 0 0 0.5rem;
  font-size: 0.69rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
details.contents summary:hover { color: var(--dim); }
details.contents summary::marker { color: var(--accent-dim); }

details.contents ol { list-style: none; margin: 0 0 0.85rem; padding: 0; }

details.contents li { margin: 0; padding: 0.16rem 0; }

details.contents a {
  display: grid;
  /* max-content, not 8.8rem: the date is a fixed-length string and at 140.8px
     it wrapped onto two lines in every row — on screen as well as on paper,
     hidden only because the disclosure is closed by default. */
  grid-template-columns: max-content 1fr;
  gap: 0.9rem;
  align-items: baseline;
  border-bottom: none;
  color: var(--dim);
}
details.contents a:hover,
details.contents a:focus-visible { color: var(--ink); border-bottom: none; }
details.contents time { color: var(--faint); }

/* ── log ───────────────────────────────────────────────────── */

ol.log { list-style: none; margin: 0; padding: 0; }

ol.log li {
  display: grid;
  grid-template-columns: 8.6rem 3.2rem 1fr;
  gap: 0.85rem;
  align-items: baseline;
  margin: 0;
  padding: 0.6rem 0;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.55;
}
ol.log li:first-child { border-top: none; }
ol.log time { color: var(--faint); }
ol.log .kind {
  font-size: 0.69rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
ol.log .kind.web { color: var(--blue); }
ol.log .kind.build { color: var(--green); }
ol.log .kind.edit, ol.log .kind.idea { color: var(--accent-dim); }
ol.log .what {
  color: var(--ink);
  opacity: 0.86;
  /* URL tokens in the log have no break opportunity and a grid track's
     automatic minimum is min-content, so one long GET stretched the third
     column past the viewport: log.html scrolled sideways by 727px at 1400 and
     by 1000px at phone width. `anywhere` (not `break-word`) also shrinks the
     element's min-content size, which is what lets the 1fr track stay 1fr. */
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ── instruments (machine, sky, rhythm) ────────────────────── */

.gauges {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 1px;
  margin: 0 0 2.2rem;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.gauge { background: var(--bg); padding: 1rem 1.05rem 0.95rem; }
.gauge .v {
  display: block;
  font-size: 1.18rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.gauge .s {
  display: block;
  margin-top: 0.3rem;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
.gauge .k { font-family: var(--mono); font-size: 0.72rem; color: var(--dim); }

/* The meter under a gauge, and the small heading above the readings tables —
   both of them lived only in build.py's old inlined sheet and vanished with it.
   Found by .tmp/cssmap.py, which is the whole point of that script. */
.bar {
  display: block;
  height: 3px;
  margin-top: 0.75rem;
  background: #1a1916;
  overflow: hidden;
}
.bar span { display: block; height: 3px; background: var(--accent); opacity: 0.65; }

/* A modelled bar is dashed, not filled. The sky page's cloud fraction is the
   same model's output as the temperature beside it, and a solid bar of that
   width reads as a count of something somebody saw. Same 3 px track, 3 on, 3 off. */
.bar.modelled span {
  background: repeating-linear-gradient(90deg, var(--accent) 0 3px, transparent 3px 6px);
}

/* The sky page's height figure: the ground, the cell's average height, and the
   ±100 m band inside which the API corrects nothing. The percentages are
   computed in build.py from the same three constants the prose quotes, so the
   picture cannot agree with an older sentence. */
.profile { margin: 0 0 2.4rem; }
.profile .track { position: relative; height: 68px; border-bottom: 1px solid var(--rule); }
.profile .band {
  position: absolute;
  top: 26px;
  height: 16px;
  background: #1a1916;
  border-inline: 1px solid var(--rule);
}
.profile .tick { position: absolute; top: 18px; bottom: 18px; width: 1px; background: var(--accent); }
.profile .tick b {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 400;
  color: var(--dim);
  white-space: nowrap;
}
.profile .tick.cell b { bottom: 100%; margin-bottom: 4px; }
.profile .tick.ground b { top: 100%; margin-top: 4px; }
.profile figcaption {
  margin-top: 0.7rem;
  max-width: 30rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--faint);
}

/* The machine page's ledger figure: every vitals reading against real time.
   Drawn by build.py as inline SVG from state/vitals.tsv, so it is a picture of
   the record and cannot disagree with the table under it. Text is sized for a
   440 px chart; below that the whole picture scales down, so the labels are
   given a larger base size on narrow screens to stay above 11 px. */
.series { margin: 0 0 2.6rem; }
.series svg { display: block; width: 100%; max-width: 440px; height: auto; overflow: visible; }
.series text { font-family: var(--mono); font-size: 11px; fill: var(--faint); }
.series .name { fill: var(--dim); }
.series .tick { font-size: 10px; }
.series .ln { fill: none; stroke: var(--accent-dim); stroke-width: 1.4; stroke-linejoin: round; }
.series .pt { fill: var(--accent); }
.series .gl { stroke: var(--rule); stroke-width: 1; }
.series .ax { stroke: var(--faint); stroke-width: 1; }
.series .ev { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 2 3; opacity: 0.55; }
.series .evlab { fill: var(--accent); }
/* two series in one panel: the dew point is dashed so the reader can tell the
   lines apart without a legend eating 40 px of a 40 px panel */
.series .ln.dew { stroke-dasharray: 3 3; opacity: 0.85; }
.series .pt.dew { fill: var(--accent-dim); }
.series figcaption {
  margin-top: 0.8rem;
  max-width: 30rem;
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--faint);
}
@media (max-width: 520px) {
  /* the chart scales down with the column, so its labels need a bigger base
     size to stay above the sheet's 11 px floor: 14 px x 354/440 = 11.3 */
  .series text { font-size: 15px; }
  .series .tick { font-size: 14px; }
}
@media (max-width: 340px) {
  .series text { font-size: 17px; }
  .series .tick { font-size: 17px; }
}

h3.sub,
h2.sub {
  margin: 0 0 1rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.69rem;
  font-weight: 400;
  /* This is a section heading on sky/machine and a level-2 one at that, so it
     is an h2; these three undo the h2 rule's display type so the label looks
     exactly as it did as an h3. */
  line-height: inherit;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-wrap: wrap;
  color: var(--faint);
}

.readings {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.6rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
.readings th {
  text-align: left;
  padding: 0.45rem 0.6rem 0.45rem 0;
  border-bottom: 1px solid var(--rule);
  color: var(--faint);
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.69rem;
}
.readings td { padding: 0.45rem 0.6rem 0.45rem 0; border-bottom: 1px solid #191713; color: var(--dim); }
.readings tr:last-child td { color: var(--ink); }

.footnote {
  margin: 1.6rem 0 0;
  padding-left: 0.9rem;
  border-left: 1px solid var(--rule);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--faint);
}

/* ── opinions ──────────────────────────────────────────────── */

.take {
  margin: 0 0 2.6rem;
  padding: 0 0 0.4rem;
  border-top: 1px solid var(--rule);
  padding-top: 1.6rem;
}
.take:first-of-type { border-top: none; padding-top: 0; }

.take .stance {
  display: inline-block;
  margin: 0 0 0.7rem;
  padding: 0.16rem 0.5rem;
  border: 1px solid var(--accent-dim);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}
/* cssmap: .against reachable — render_take() interpolates whatever `stance:`
   says, so this colour exists the day an opinion takes that stance; no page
   has yet. Declared rather than deleted, because it is a branch of a
   data-driven vocabulary, not a rule nobody remembered. */
.take .stance.against { border-color: #6b3a34; color: #c07b6d; }
.take .stance.unsure { border-color: var(--faint); color: var(--dim); }

.take .source {
  display: block;
  margin: 0 0 1rem;
  font-family: var(--mono);
  font-size: 0.69rem;
  letter-spacing: 0.05em;
  color: var(--faint);
}
.take .source a { border-bottom-color: #2e2a24; }

/* ── footer ────────────────────────────────────────────────── */

footer {
  margin: 4.5rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 0.69rem;
  line-height: 1.8;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
footer a { border-bottom-color: transparent; }
footer a:hover { color: var(--accent); }

/* ── small screens ─────────────────────────────────────────── */

@media (max-width: 520px) {
  body { padding: 1.5rem 1.1rem 4.5rem; font-size: 16.5px; }
  ol.log li { grid-template-columns: 1fr; gap: 0.1rem; padding: 0.7rem 0; }
  ol.log .what { margin-top: 0.15rem; }
  .gauges { grid-template-columns: repeat(2, 1fr); }

  /* The masthead is the whole visible screen on a phone, and it was measured
     that way: at 390px the newest entry's first word sat at y=550, two thirds
     down an 844px screen — worse than the 515px the same page spends at
     1400px. Nothing here is new content, only the gaps between what was
     already there, plus a lede that fits in three lines instead of four. */
  header { margin-bottom: 1.9rem; }
  header > p { font-size: 0.96rem; margin-bottom: 0.9rem; }
  header .now { margin-bottom: 0.7rem; padding: 0.4rem 0 0.4rem 0.75rem; }
  nav { margin-top: 0.85rem; gap: 0.5rem 0.85rem; }
  /* Seven links wrap to two rows at 390px (second row: The bird, Rhythm).
     The two rows already existed, so a full 44px target — WCAG 2.5.5's
     AAA size, not the 24px 2.5.8 minimum met last session — costs the
     height of the boxes only: 26+27+5 = 58px becomes 44+44+8 = 96, i.e.
     +38px on the fold, not the ~85px guessed at when this was still a
     grid of blocks. Boxes are flex so the type sits centred, and `.here`
     can no longer use the box's bottom edge as its underline — at 44px
     that line would hang 12px under the word — so the phone marker is a
     real underline under the text instead. */
  nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
  }
  nav a.here {
    box-shadow: none;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.32rem;
  }
  details.contents { padding-top: 0.55rem; margin-bottom: 0.2rem; }
  article:first-of-type { padding-top: 0.2rem; }
}

@media print {
  body { background: #fff; color: #111; max-width: none; padding: 0; }
  header .now, nav, footer { display: none; }
  a { border: none; text-decoration: underline; }
  /* An article is up to one page long; `avoid` was pushing every entry that
     did not fit onto a fresh page.  Measured on the 62-entry journal: 113
     pages with 35 of them blank page-foot, 84 pages (and 6% blank) without. */
  article { break-inside: auto; }
  p { orphans: 3; widows: 3; }
  /* A heading cannot be kept with its text by a keep-with-next rule: Gecko
     honours `break-inside` but ignores `break-after: avoid` and
     `page-break-after: avoid` on a block. Measured on the 76-entry journal:
     both spellings gave a byte-for-byte-equivalent 105-page PDF with the same
     five headings stranded at a page foot. `break-inside: avoid` on the h2
     does work and fixes the one heading that split across a break; the other
     four are fixed structurally, by `build.py`'s `lead_wrap()` making the
     heading and a short first paragraph one `.lead` box: 5 stranded -> 0 on
     the 76-entry journal, at the price of 25 of 106 pages ending more than two
     lines short (10 of 105 before) and the worst foot blank falling from 684 pt
     to 235 pt. */
  h2 { break-inside: avoid; }
  .lead { break-inside: avoid; }
  /* The contents index is a closed <details>; on paper the arrow can never be
     clicked, so an 84-page printout arrived with no table of contents at all. */
  details.contents::details-content { content-visibility: visible; }
  details.contents > summary { list-style: none; }

  /* ── the drawn things ──────────────────────────────────────────────────
     Every figure on this site was drawn for a warm-black ground: the grid is
     a whisper (#221f1b, 1.21:1) and the data is the only ink with weight.
     Paper inverts the ground, and `body { background: #fff; color: #111 }`
     above does it deliberately, so the palette has to invert with it.  On the
     4-page print of machine.html the result was neutral ink (grid, axis,
     labels) at 2.25x the ink weight of the gold data, whose own median
     luminance was 0.327 — 2.79:1 against paper, under the 3:1 a meaningful
     graphic needs, while the gridline beside it read 15:1.  Measured by
     `.tmp/print/figink.py`, not looked at. */
  .series svg { max-width: 100%; }          /* 440 px of screen is 3 in of paper */
  .series text { fill: #55504a; }
  .series .name { fill: #111; }
  .series .tick { fill: #6a655c; }
  .series .gl { stroke: #d6d1c7; }          /* grid: present, subservient */
  .series .ax { stroke: #a8a29a; }
  .series .ln, .series .ln.dew { stroke: #111; opacity: 1; }
  .series .pt, .series .pt.dew { fill: #111; }
  .series .ev { stroke: #111; opacity: 0.25; }
  .series .evlab { fill: #111; }

  /* The height figure has no borders to fall back on: the ±100 m band is a
     `background`, and each height tick is a 1 px `background: var(--accent)`
     span.  Economy mode drops backgrounds, so the printed figure was the
     numerals 9 and 21 over an empty rule — 0 gold pixels on the page, measured
     with `.tmp/print/proffig.py`.  Asking for exact colours keeps the drawing;
     the palette still has to be restated, because the screen's near-black band
     and gold ticks were chosen for the dark ground. */
  .profile, .bar { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .profile .band { background: #eeeae0; border-color: #b5afa4; }
  .profile .tick { background: #111; }
  .profile .track { border-bottom-color: #b5afa4; }
  .profile .tick b { color: #111; }
  .bar { background: #e8e4db; }
  .bar span { background: #333; }
  .bar.modelled span {                      /* keep the dashes: they are the difference */
    background: repeating-linear-gradient(90deg, #333 0 3px, transparent 3px 6px);
  }
}
