/* Lab Notes (issue #547): static data essays under /lab-notes/.

   Every page links gafferlab.css first, so these rules read its :root
   tokens and its dark-mode block themes the pre-rendered SVG too (the
   charts' colours are var(--token) strings). No hex here: see CLAUDE.md
   "Style through :root tokens".

   The look is the app's "Matchday Journal" language (docs/frontend/
   design-system.md): warm paper, Fraunces headlines, borderless cards with
   near-flat shadows, uppercase letter-spaced eyebrows, and the Overview
   card's footer link. An essay is read, not scanned, so the body gets a
   reading measure and a larger size than the dashboard's. */

body.lab-note {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
}

/* One column for everything: the bar, the hero, the body and the footer
   share an edge, so nothing sits out of line with the headline. */
.ln-site-inner,
.ln-hero-inner,
.ln-body,
.ln-footer-inner {
  max-width: 720px;
  margin-inline: auto;
  padding-inline: 1rem;
}

/* ---- Site bar: the app header's wordmark and glass, one row ---------- */

.ln-site {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.ln-site-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
}
.ln-site a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.ln-wordmark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--text);
}
.ln-site-sep {
  color: var(--text-muted);
}
.ln-site-link {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.ln-site-link[aria-current='page'] {
  color: var(--text);
  font-weight: 600;
}
.ln-site-app {
  margin-inline-start: auto;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}
.ln-site a:hover {
  color: var(--primary);
}
/* One row on a 320px phone: the three links never wrap inside themselves,
   and below 360px the gaps tighten and the decorative arrow goes. */
.ln-site a {
  white-space: nowrap;
}
@media (max-width: 359px) {
  .ln-site-inner { gap: 0.4rem; }
  .ln-site-app [aria-hidden='true'] { display: none; }
}

/* ---- Hero ------------------------------------------------------------ */

.ln-hero {
  padding: 2.75rem 0 1.75rem;
}
.ln-eyebrow {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary);
}
.ln-hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 3.25rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 0.9rem;
  text-wrap: balance;
}
.ln-dek {
  margin: 0;
  font-size: clamp(1.1rem, 3.4vw, 1.3rem);
  line-height: 1.5;
  color: var(--text-secondary);
  text-wrap: pretty;
}
.ln-byline {
  margin: 1.25rem 0 0;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ---- Body: an essay's reading measure -------------------------------- */

.ln-body {
  padding-block: 0.5rem 3rem;
  font-size: 1.0625rem;
  line-height: 1.7;
  counter-reset: ln-figure;
}
.ln-body > p:first-child {
  font-size: 1.2rem;
  line-height: 1.6;
  color: var(--text);
}
.ln-body p {
  margin: 0 0 1.1em;
}
/* A reading measure for running text only: figures, stat tiles and cards
   keep the full column, but a line of prose stops near 70 characters
   (at 1280px the column alone set 17px text at ~85, captions at ~100).
   In em, not ch: Space Grotesk's "0" is wide, so 68ch was ~680px and
   capped nothing. */
.ln-body > p,
.ln-body > ul,
.ln-chart figcaption,
.ln-falsifier p,
.ln-method p {
  max-width: 35em;
}
/* A figure or heading reached by its #fragment clears the sticky site bar. */
.ln-body [id] {
  scroll-margin-top: 4.5rem;
}
.ln-body h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.55rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 2.75rem 0 0.75rem;
  text-wrap: balance;
}
.ln-body ul {
  margin: 0 0 1.25em;
  padding-inline-start: 1.25rem;
}
.ln-body li {
  margin: 0.45rem 0;
}
.ln-body li::marker {
  color: var(--primary);
}
.ln-body strong {
  font-weight: 600;
}
.ln-body a {
  color: var(--primary);
  text-underline-offset: 0.18em;
}
.ln-body code {
  font-family: var(--font-data);
  font-size: 0.85em;
  padding: 0.05em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--surface-secondary);
  overflow-wrap: anywhere;
}

/* ---- Stat tiles: Overview cards, the number first --------------------- */

.ln-stats {
  display: grid;
  /* Two across at most in the 688px column, so four tiles sit 2×2 rather
     than three and an orphan; one across on a phone. */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: 0.75rem;
  margin: 1.75rem 0 2rem;
}
.ln-stat {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1.05rem;
}
.ln-stat-value {
  font-family: var(--font-data);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.ln-stat-label {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-muted);
}

/* ---- Figures: a card whose inner edge lines up with the text ---------- */

.ln-chart {
  margin: 1.75rem -0.5rem 2rem;
  padding: 0.9rem 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  color: var(--text);
  counter-increment: ln-figure;
}
.ln-chart svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin-inline: auto;
}
.ln-chart figcaption {
  margin: 0.75rem 0.5rem 0;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
}
.ln-chart figcaption::before {
  content: 'Figure ' counter(ln-figure) '. ';
  font-weight: 600;
  color: var(--text);
}
/* Each chart ships at two widths (render.mjs WIDTHS). Showing the one that
   fits keeps axis text legible on a phone instead of scaling 680px down.
   The narrow one is drawn for the 320px phone's 288px figure, so it only
   ever scales up (12px text at 320, ~14px at 375), capped so a tablet does
   not get a poster. */
.ln-chart-narrow svg {
  width: 100%;
  max-width: 26rem;
}
.ln-chart-wide { display: none; }
/* The wide chart takes over only where its 680px fits at full size: any
   narrower and its 12px text falls under the 0.72rem label floor. */
@media (min-width: 720px) {
  .ln-chart-narrow { display: none; }
  .ln-chart-wide { display: block; }
}
/* Wide enough for the card to step outside the text column: its padding
   then sits in the gutter, and the 680px chart spans the measure. */
@media (min-width: 800px) {
  .ln-chart {
    margin-inline: -1.25rem;
    padding: 1.25rem 1.25rem 1rem;
  }
  .ln-chart figcaption { margin-inline: 0; }
}

/* ---- Falsifier: the note's claim, stated so it can fail --------------- */

.ln-falsifier {
  margin: 3rem 0 1.5rem;
  padding: 1.25rem 1.25rem 0.5rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.ln-falsifier h2 {
  margin: 0 0 0.6rem;
  font-size: 1.3rem;
}
/* The eyebrow every card on the site opens with, in the accent: this is
   the one block a note cannot leave out (render.mjs refuses it). */
.ln-falsifier h2::before {
  content: 'The falsifier';
  /* Decorative: the heading's own text names the block, so the alt-text
     form keeps this out of its accessible name where it is supported. */
  content: 'The falsifier' / '';
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.ln-falsifier ul {
  list-style: none;
  padding: 0;
}
.ln-falsifier li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.6rem;
  padding: 0.6rem 0;
  margin: 0;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}
.ln-cond {
  font-weight: 600;
  color: var(--text);
}
/* This season's value beside the line it must not cross. */
.ln-reading {
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-secondary);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ---- Explore it live: the app's charts this essay explains ------------ */

.ln-related ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.ln-related li {
  margin: 0;
}
.ln-related a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 44px;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: box-shadow var(--transition);
}
.ln-related a:hover {
  box-shadow: var(--shadow-md);
}
.ln-related-title {
  font-weight: 600;
  color: var(--text);
}
.ln-related-title::after {
  content: ' →';
  content: ' →' / '';
  color: var(--primary);
}
.ln-related-where {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ---- Method: a quiet hairline note, not a card ------------------------ */

.ln-method {
  margin-top: 2.5rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}
.ln-method h2 {
  font-size: 1.1rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--text);
}

.ln-meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.ln-back {
  margin-top: 2.5rem;
  font-size: 0.95rem;
}
.ln-back a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 600;
  text-decoration: none;
}

/* ---- Index: one Overview card per note --------------------------------
   Scoped under .ln-cards so the essay's own p/ul/li rules above, which
   out-rank a single class, never reach into a card. */

.ln-body .ln-cards {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}
.ln-cards .ln-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin: 0;
  transition: box-shadow var(--transition);
}
.ln-cards .ln-card:hover {
  box-shadow: var(--shadow-md);
}
.ln-cards .ln-card:has(a:focus-visible) {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.ln-cards .ln-card-eyebrow {
  margin: 0;
  padding: 1rem 1.1rem 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}
.ln-cards .ln-card-title {
  margin: 0.35rem 1.1rem 0.4rem;
  font-size: 1.5rem;
}
.ln-cards .ln-card-title a {
  color: var(--text);
  text-decoration: none;
}
.ln-cards .ln-card-title a:focus-visible {
  outline: none;
}
/* The title's link covers the card, so the whole card is one target with
   one accessible name (the title), not a link wrapped round a paragraph. */
.ln-cards .ln-card-title a::after {
  content: '';
  position: absolute;
  inset: 0;
}
.ln-cards .ln-card-dek {
  margin: 0 1.1rem 0.9rem;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--text-secondary);
}
.ln-cards .ln-card-stat {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.2rem 0.6rem;
  margin: 0 1.1rem 1rem;
}
.ln-cards .ln-card-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
}
.ln-cards .ln-card-stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.ln-cards .ln-card-more {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: auto 0 0;
  padding: 0.75rem 1.1rem;
  border-top: 1px solid var(--border);
  background: var(--surface-secondary);
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 600;
}
.ln-empty {
  color: var(--text-secondary);
}

/* ---- Footer: the app's footer band, short ----------------------------- */

.ln-footer {
  background: var(--surface-secondary);
  border-top: 1px solid var(--border);
  padding: 1.75rem 0;
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
}
.ln-footer p {
  margin: 0 0 0.5rem;
}
.ln-footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.25rem;
  margin-bottom: 0.5rem;
}
.ln-footer-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  text-underline-offset: 0.18em;
}
.ln-footer p:last-child {
  margin-bottom: 0;
}
