/* ---------------------------------------------------------------------------
 * Layout, type and elements. No colour literals live here — every colour is a
 * var(--token) from tokens.css, and test/tokens.test.mjs enforces it.
 * ------------------------------------------------------------------------- */

:root {
  --font-display: "Newsreader", Georgia, "Times New Roman", serif;
  --font-text: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
    monospace;

  --measure: 34rem;      /* comfortable reading column                       */
  --gutter: 1.25rem;     /* side gutter; never let text touch the viewport   */
  --step: 1.5rem;        /* vertical rhythm unit                             */
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: 1.0625rem;
  line-height: 1.65;
}

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
  padding-block: calc(var(--step) * 2) calc(var(--step) * 3);
}

/* --- type ---------------------------------------------------------------- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  text-wrap: balance;
  margin-block: calc(var(--step) * 1.5) var(--step);
}

h1 {
  font-size: clamp(2rem, 1.4rem + 3vw, 3rem);
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.2rem;
}

p,
ul,
ol {
  margin-block: 0 var(--step);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

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

blockquote {
  margin-inline: 0;
  padding-inline-start: var(--step);
  border-inline-start: 2px solid var(--rule);
  color: var(--ink-muted);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-sunk);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

pre {
  background: var(--bg-sunk);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: var(--step);
  overflow-x: auto;
}

pre code {
  background: none;
  padding: 0;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin-block: calc(var(--step) * 2);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-block: 0 var(--step);
}

th,
td {
  text-align: start;
  padding: 0.5em 0.6em;
  border-bottom: 1px solid var(--rule);
}

th {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* --- shared furniture ---------------------------------------------------- */

/* The small mono label above a heading: "ISSUE 001 · HARDWARE". */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-block: 0 0.5rem;
}

/* A row of metadata: date, tags, reading time. */
.meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: baseline;
  margin-block: 0 var(--step);
}

/* The standfirst under a post title. */
.lede {
  font-family: var(--font-display);
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--ink-muted);
  margin-block: 0 var(--step);
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  padding-block-end: var(--step);
  border-bottom: 1px solid var(--rule);
  margin-block-end: calc(var(--step) * 2);
}

.masthead__name {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.masthead__name a {
  color: inherit;
  text-decoration: none;
}

.masthead__tagline {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0;
}

.masthead__nav {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  display: flex;
  gap: 1rem;
}

/* --- front page index ---------------------------------------------------- */

.index-year {
  padding-block-end: 0.4rem;
  border-bottom: 1px solid var(--rule);
  margin-block: calc(var(--step) * 2) var(--step);
}

.index-entries {
  list-style: none;
  margin: 0;
  padding: 0;
}

.index-entry + .index-entry {
  margin-block-start: calc(var(--step) * 1.25);
}

.index-entry__title {
  font-size: 1.3rem;
  margin-block: 0 0.3rem;
}

.index-entry__title a {
  text-decoration: none;
  color: var(--ink);
}

.index-entry__title a:hover,
.index-entry__title a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.index-entry__summary {
  color: var(--ink-muted);
  margin-block: 0 0.3rem;
}

.index-entry .meta {
  margin-block: 0;
}

/* --- Jelly UI ------------------------------------------------------------
 * Jelly is loaded from its own CDN and is enhancement only. If that CDN is
 * unreachable — or gone, years from now — the custom elements are never
 * upgraded and stay permanently :not(:defined). These rules are what they look
 * like in that state: flat, gruvbox, deliberate.
 *
 * Every Jelly element used anywhere in the site needs a rule here.
 * test/site.test.mjs scans the built HTML and fails if one is missing.
 * ---------------------------------------------------------------------- */

jelly-chip:not(:defined) {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.3em 0.6em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-lift);
  color: var(--ink-muted);
}

/* Until the module evaluates, an un-upgraded element would otherwise flash as
 * unstyled inline text. Both states are styled, so there is nothing to flash. */
jelly-chip {
  vertical-align: baseline;
}

/* --- style guide --------------------------------------------------------- */

.swatches {
  list-style: none;
  margin: 0 0 var(--step);
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.swatch {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.swatch__chip {
  inline-size: 2.5rem;
  block-size: 1.5rem;
  border-radius: 4px;
  border: 1px solid var(--rule);
  flex: none;
}

.swatch__note {
  color: var(--ink-muted);
}

/* Mirrors jelly-chip:not(:defined) exactly, so the style guide can show the
 * fallback state on a page where Jelly has in fact loaded. If you change the
 * fallback above, change this with it. */
.force-undefined .as-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.3em 0.6em;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--bg-lift);
  color: var(--ink-muted);
}

.favicon-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-block: 0 var(--step);
}

.favicon-row img {
  border-radius: 0;
  flex: none;
}
