/* M. Doyle, Vol. V — site styles (projectplan.md §3): Broadsheet+.
   Rules and whitespace, not cards and shadows. Motion only answers the visitor
   (hover, focus, open), plus the front page's dateline tick (§2). */

/* ---------- Fonts ---------- */

@font-face {
  font-family: "Doyle Serif";
  src: url("/assets/fonts/doyle-serif-roman.woff2") format("woff2");
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Doyle Serif";
  src: url("/assets/fonts/source-serif-4-latin-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  --paper: #f3f2ee;
  --ink: #121212;
  --ink-muted: #5d5d58;
  --rule: #c9c7bf;
  --accent: #c8102e;
  --tint: rgba(200, 16, 46, 0.07);

  --serif: "Doyle Serif", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --measure: 65ch;
  --page: 72rem;
  --gutter: 1rem;

  color-scheme: light dark;
  interpolate-size: allow-keywords;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121211;
    --ink: #ecebe6;
    --ink-muted: #a3a29b;
    --rule: #34332f;
    --accent: #ff7a70;
    --tint: rgba(255, 122, 112, 0.09);
  }
}

/* ---------- Base ---------- */

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

html {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 100%;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0 auto;
  max-width: var(--page);
  padding: 0 var(--gutter);
  background: var(--paper);
  font-size: 1.125rem;
  font-optical-sizing: auto;
  hyphens: auto;
  overflow-wrap: break-word;
}

h1, h2, h3 { font-weight: 500; line-height: 1.15; hyphens: manual; text-wrap: balance; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible, button:focus-visible, summary:focus-visible, canvas:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

time, .tabular { font-variant-numeric: tabular-nums; }

code, pre, kbd, samp { font-family: var(--mono); font-size: 0.875em; }
pre { overflow-x: auto; padding: 0.75rem 0; border-block: 1px solid var(--rule); }

main > *, footer { max-width: 100%; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* Copy slots are highlighted only by `npm run serve` (projectplan.md §7). */
mark.todo-copy { background: #ffe066; color: #1c1a16; font-family: var(--mono); font-size: 0.8em; }

/* ---------- Masthead and dateline ---------- */

.masthead { padding-top: 2rem; }

.masthead__name {
  margin: 0;
  font-size: clamp(3.5rem, 17vw, 8rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.masthead__name a { color: inherit; text-decoration: none; }

.masthead__standing {
  margin: 0.5rem 0 0;
  color: var(--ink-muted);
  font-style: italic;
}

.dateline {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0 1rem;
  margin: 1.25rem 0 0;
  padding: 0.4rem 0;
  border-top: 1px solid var(--ink);
  border-bottom: 3px double var(--ink);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}
.dateline__hash { font-family: var(--mono); letter-spacing: 0; text-transform: none; }

/* Late Edition: shown only in dark mode, CSS only (projectplan.md §3). */
.dateline__late { display: none; }
@media (prefers-color-scheme: dark) {
  .dateline__late { display: inline; }
}

.index-strip {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: 0.8125rem;
  letter-spacing: 0.04em;
}
.index-strip a {
  color: var(--ink);
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  transition: background-size 0.2s ease, color 0.2s ease;
}
.index-strip a:hover, .index-strip a:focus-visible { color: var(--accent); background-size: 100% 1px; }

/* Inner pages carry a smaller masthead; the front page gets the full nameplate. */
.masthead--compact .masthead__name { font-size: clamp(2rem, 8vw, 2.75rem); }

/* ---------- Front page ---------- */

.positioning {
  max-width: var(--measure);
  margin: 1.5rem 0 0;
  font-size: 1.375rem;
  line-height: 1.35;
}

.section { margin-top: 2.5rem; }

.section__head {
  margin: 0 0 1rem;
  padding-top: 0.4rem;
  border-top: 3px solid var(--ink);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.entry { padding-bottom: 1.25rem; }
.entry + .entry { padding-top: 1.25rem; border-top: 1px solid var(--rule); }

.entry__kicker {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  margin: 0 0 0.25rem;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}
/* Red means clickable, so kickers are ink, not accent. */
.entry__kicker .k { color: var(--ink); font-weight: 600; }

.entry__title { margin: 0; font-size: 1.5rem; }
.entry__title a {
  color: inherit;
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat;
  transition: background-size 0.25s ease, color 0.2s ease;
}
/* Only the link itself lights up, so the highlight matches what you can click. */
.entry__title a:hover, .entry__title a:focus-visible { color: var(--accent); background-size: 100% 1px; }

/* The lead story: the site's one `lead: true` entry, set larger. */
.lead .entry__title { font-size: clamp(1.9rem, 6vw, 2.75rem); }
.lead .entry__summary { font-size: 1.25rem; line-height: 1.45; }
.lead + .entries { padding-top: 1.25rem; border-top: 1px solid var(--rule); }

.entry__meta {
  margin: 0.25rem 0 0;
  color: var(--ink-muted);
  font-size: 0.9375rem;
  font-variant-numeric: tabular-nums;
}

.entry__summary { max-width: var(--measure); margin: 0.5rem 0 0; }

.section__more { margin: 0.75rem 0 0; }

/* Text buttons: actions (more, live/source, PDF, contact) in small caps, not
   underlined prose links. Links inside sentences stay underlined. */
:is(.section__more, .project-links, .contact, .actions) a {
  color: var(--accent);
  text-decoration: none;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 0.2s ease;
}
:is(.section__more, .project-links, .contact, .actions) a:hover,
:is(.section__more, .project-links, .contact, .actions) a:focus-visible { background-size: 100% 1px; }
:is(.project-links, .contact) { color: var(--ink-muted); }

/* Expand in place: native <details>, animated where the browser supports it. */
.more { max-width: var(--measure); margin-top: 0.5rem; font-size: 0.9375rem; }
.more summary {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  list-style: none;
  cursor: pointer;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+"; display: inline-block; width: 1ch; font-family: var(--mono); transition: transform 0.2s ease; }
.more[open] summary::before { transform: rotate(45deg); }
.more summary:hover { color: var(--accent); }
.more::details-content { block-size: 0; overflow: clip; transition: block-size 0.25s ease, content-visibility 0.25s allow-discrete; }
.more[open]::details-content { block-size: auto; }
.more .facts { margin: 0.5rem 0 0; padding: 0.5rem 0; }

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

/* Two columns only where the content benefits: entry lists with more than one item. */
@media (min-width: 48rem) {
  .entries:has(> .entry + .entry) {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .entries:has(> .entry + .entry) > .entry { padding: 1.25rem 1.5rem 1.25rem 0; border-top: 1px solid var(--rule); }
  .entries:has(> .entry + .entry) > .entry:nth-child(-n + 2) { padding-top: 0; border-top: 0; }
  .entries:has(> .entry + .entry) > .entry:nth-child(even) { padding-right: 0; padding-left: 1.5rem; border-left: 1px solid var(--rule); }
  .verify-key { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem 2rem; align-items: start; }
  .verify-key .art { grid-column: 2; grid-row: 1; }
}

/* ---------- Article pages ---------- */

article { max-width: var(--measure); margin-top: 2rem; }
article h1 { font-size: clamp(2rem, 7vw, 3rem); margin: 0 0 1rem; }
article h2 { font-size: 1.375rem; margin: 2rem 0 0.5rem; }

.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0 0 1.5rem;
  padding: 0.75rem 0;
  border-block: 1px solid var(--rule);
  font-size: 0.9375rem;
}
.facts dt {
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding-top: 0.2rem;
}
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; } /* long values (key fingerprint) wrap instead of widening the page */

/* ---------- Resume: a ledger ---------- */

.resume h2 {
  margin: 2.5rem 0 1rem;
  padding-top: 0.4rem;
  border-top: 3px solid var(--ink);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.resume h3 { margin: 1.25rem 0 0; padding-top: 1.25rem; border-top: 1px solid var(--rule); font-size: 1.3rem; }
.resume h2 + h3 { padding-top: 0; border-top: 0; }
/* Role and dates, set as a kicker: role in ink, dates muted. */
.resume h3 + p {
  margin: 0.25rem 0 0.5rem;
  color: var(--ink-muted);
  font-family: var(--sans);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.resume h3 + p em { color: var(--ink); font-style: normal; font-weight: 600; }
.resume ul { max-width: var(--measure); margin: 0.5rem 0 0; padding-left: 1rem; border-left: 2px solid var(--rule); list-style: none; }
.resume li { position: relative; }
.resume li + li { margin-top: 0.45rem; }
.resume li::before { content: ""; position: absolute; top: 0.75em; left: -1rem; width: 0.45rem; border-top: 2px solid var(--rule); }

/* ---------- Working figure (one per entry page at most) ---------- */

.fig { margin: 1.5rem 0 0; }
.fig__stage { position: relative; border: 1px solid var(--rule); background: var(--tint); color: var(--ink-muted); touch-action: none; }
.fig__wave { display: block; width: 100%; height: 132px; }
.fig canvas { display: block; width: 100%; height: 132px; cursor: ew-resize; }
.fig__bar { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.5rem; font-family: var(--sans); font-size: 0.8125rem; }
.fig__bar[hidden] { display: none; }
.fig__bar button { min-width: 5.5rem; padding: 0.35rem 0.8rem; border: 0; border-radius: 3px; background: var(--ink); color: var(--paper); font: inherit; cursor: pointer; }
.fig__bar label { display: inline-flex; gap: 0.5rem; align-items: center; color: var(--ink-muted); }
.fig__bar input[type="range"] { width: 9rem; accent-color: var(--accent); }
.fig__tv, .fig__read { font-family: var(--mono); font-size: 0.75rem; font-variant-numeric: tabular-nums; }
.fig__read { color: var(--ink-muted); }
.fig figcaption { margin-top: 0.4rem; color: var(--ink-muted); font-size: 0.875rem; }

/* ---------- Randomart (/verify/ only) ---------- */

.art { margin: 0 0 1.5rem; }
.art pre { margin: 0; padding: 0; border: 0; overflow: visible; font-size: 12px; line-height: 1.15; }
.art figcaption { margin-top: 0.35rem; color: var(--ink-muted); font-family: var(--sans); font-size: 0.6875rem; letter-spacing: 0.06em; text-transform: uppercase; }

/* ---------- Entry pages: numbered sections and "Next" ---------- */

article:has(> .facts) { counter-reset: section; }
article:has(> .facts) > h2 {
  counter-increment: section;
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  margin-top: 2.25rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
}
article:has(> .facts) > .facts + h2 { padding-top: 0; border-top: 0; } /* the facts box already rules it off */
article:has(> .facts) > h2::before { content: counter(section, decimal-leading-zero); color: var(--ink-muted); font: 600 0.75rem/1 var(--mono); }

.continue { margin-top: 3rem; padding-top: 0.4rem; border-top: 3px solid var(--ink); }
.continue__label { margin: 0; font-family: var(--sans); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.continue a { display: block; padding-top: 0.75rem; color: inherit; text-decoration: none; }
.continue__kicker { display: block; color: var(--ink-muted); font-family: var(--sans); font-size: 0.6875rem; letter-spacing: 0.08em; text-transform: uppercase; }
.continue__title { display: block; margin: 0.2rem 0; font-size: 1.75rem; line-height: 1.15; transition: color 0.2s ease; }
.continue a:hover .continue__title, .continue a:focus-visible .continue__title { color: var(--accent); }
.continue__summary { display: block; color: var(--ink-muted); }

/* ---------- Lead figure (front page) ---------- */

.lead__fig { display: block; margin-top: 1rem; border: 1px solid var(--rule); background: var(--tint); color: var(--ink-muted); }
.lead__fig svg { display: block; width: 100%; height: 6rem; }
.lead__fig:hover { color: var(--accent); }
@media (min-width: 56rem) {
  .lead .entry:has(.lead__fig) { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 2.5rem; }
  .lead .entry:has(.lead__fig) > :not(.lead__fig) { grid-column: 1; }
  .lead .lead__fig { grid-column: 2; grid-row: 1 / span 5; align-self: center; margin-top: 0; }
  .lead .lead__fig svg { height: 10rem; }
}

/* ---------- Footer: a closing band, full bleed ---------- */

.site-footer {
  margin-top: 4rem;
  padding: 1.75rem 0 1.5rem;
  background: var(--ink);
  color: var(--paper);
  box-shadow: 0 0 0 100vmax var(--ink);
  clip-path: inset(0 -100vmax -100vmax);
  font-size: 0.9375rem;
}
.site-footer p { margin: 0.25rem 0; }
.site-footer a { color: var(--paper); }
.site-footer__mark { font-size: 2rem; font-weight: 500; line-height: 1.1; }
.site-footer .site-footer__mark { margin-bottom: 0.75rem; }

.attestation {
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Page transitions (projectplan.md §2: motion answers navigation) ----------
   Cross-document view transitions, CSS only. The incoming page styles them:
   pages rise in from below; the front page settles in from above (going home).
   The masthead and entry titles carry `view-transition-name`s, so they morph
   between list and page. Browsers without support simply navigate. */

@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: 0.4s; animation-timing-function: cubic-bezier(0.2, 0, 0, 1); }
@keyframes vt-in-up { from { opacity: 0; transform: translateY(24px); } }
@keyframes vt-in-down { from { opacity: 0; transform: translateY(-24px); } }
@keyframes vt-out-up { to { opacity: 0; transform: translateY(-16px); } }
@keyframes vt-out-down { to { opacity: 0; transform: translateY(16px); } }
::view-transition-old(root) { animation: vt-out-up 0.25s ease both; }
::view-transition-new(root) { animation: vt-in-up 0.4s cubic-bezier(0.2, 0, 0, 1) both; }
html:has(.masthead:not(.masthead--compact))::view-transition-old(root) { animation-name: vt-out-down; }
html:has(.masthead:not(.masthead--compact))::view-transition-new(root) { animation-name: vt-in-down; }

/* ---------- Reduced motion (projectplan.md §2) ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
