/* Agrojatra — the publication.
 *
 * Hand-written, on the variables from @aj/tokens. No Tailwind here: a
 * publication is prose typography, where the utility payoff is near zero and
 * the cost is putting Node in the middle of a Go build. The app and this site
 * still cannot drift, because both resolve to the same --aj-* tokens.
 *
 * Budget: this file plus a story's markup stays under 20KB. There is no JS on
 * the reading path beyond the ~15-line theme toggle.
 */

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

*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, h3, h4, p, ul, ol, li, figure, blockquote { margin: 0; padding: 0; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }

/* ---------- accessibility ---------- */

/* Keyboard users got nothing before this. :focus-visible rather than :focus so
   a mouse click on a link does not leave a ring behind it. */
:focus-visible {
  outline: 2px solid var(--aj-ring);
  outline-offset: 3px;
  border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visible only once focused — the first tab stop on a story skips the masthead. */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: var(--aj-space-3) var(--aj-space-5);
  background: var(--aj-accent);
  color: var(--aj-on-accent);
  z-index: 10;
}
.skip:focus { left: 0; }

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

body {
  background: var(--aj-canvas);
  color: var(--aj-ink);
  font-family: var(--aj-font-sans);
  font-size: var(--aj-text-base);
  line-height: var(--aj-leading-relaxed);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.shell {
  width: 100%;
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 var(--aj-space-5);
}

/* ---------- masthead ---------- */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--aj-space-4);
  padding: var(--aj-space-6) 0;
  border-bottom: 1px solid var(--aj-line);
}
.masthead__mark { display: block; }
.masthead__mark .mark { width: 132px; }

/* The wordmark ships in two inks. Swap the FILE — do not filter one of them:
   the arrow is ochre, and invert() turns ochre cyan. */
.mark--dark { display: none; }
:root[data-theme="dark"] .mark--light { display: none; }
:root[data-theme="dark"] .mark--dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .mark--light { display: none; }
  :root:not([data-theme="light"]) .mark--dark { display: block; }
}

.masthead__nav {
  display: flex;
  align-items: center;
  gap: var(--aj-space-5);
  font-size: var(--aj-text-sm);
  color: var(--aj-muted);
}
.masthead__nav a { text-decoration: none; }
.masthead__nav a:hover { color: var(--aj-accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--aj-line);
  color: var(--aj-muted);
  border-radius: 999px;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
  font-size: var(--aj-text-sm);
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--aj-line-strong); color: var(--aj-ink); }

/* ---------- the hearth: the only fire on the site ----------
 *
 * Ink ground, clay and ochre light. Below this section the page turns to cream
 * and becomes the publication — night into morning, in one scroll. Story pages
 * stay calm throughout; this is the only place that burns.
 */

.hearth {
  position: relative;
  overflow: hidden;
  background: #16110F;
  color: #FAF6F0;
  padding: clamp(5rem, 18vh, 9rem) var(--aj-space-5) clamp(4rem, 14vh, 7rem);
  text-align: center;
  isolation: isolate;
}

/* The heat itself: two soft radial pools, clay under ochre. No image and no
   gradient-mesh library — a few hundred bytes, and it scales to any viewport. */
.hearth::before {
  content: "";
  position: absolute;
  inset: -20% -10% auto;
  height: 140%;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 50% 8%, rgba(217, 160, 44, 0.22), transparent 70%),
    radial-gradient(70% 55% at 50% 0%, rgba(193, 80, 46, 0.35), transparent 72%);
}

.hearth__mark { margin: 0 auto var(--aj-space-8); width: 220px; }
.hearth__line {
  font-size: clamp(2.25rem, 7vw, 3.75rem);
  font-weight: 600;
  line-height: var(--aj-leading-tight);
  letter-spacing: var(--aj-tracking-tight);
}
.hearth__sub {
  margin-top: var(--aj-space-4);
  color: rgba(250, 246, 240, 0.62);
  font-size: var(--aj-text-md);
}

/* ---------- story list ---------- */

.cards { padding: var(--aj-space-8) 0; }
.card + .card { border-top: 1px solid var(--aj-line); }
.card__link { display: block; padding: var(--aj-space-6) 0; text-decoration: none; }
.card__title {
  font-size: var(--aj-text-xl);
  font-weight: 600;
  line-height: var(--aj-leading-snug);
  letter-spacing: var(--aj-tracking-tight);
}
.card__link:hover .card__title { color: var(--aj-accent); }
.card__standfirst { margin-top: var(--aj-space-2); color: var(--aj-muted); }
.card__meta { margin-top: var(--aj-space-3); color: var(--aj-subtle); font-size: var(--aj-text-sm); }
.cards__empty { padding: var(--aj-space-8) 0; color: var(--aj-subtle); }

/* ---------- story ---------- */

.story { padding: var(--aj-space-10) 0 var(--aj-space-8); }
.story__head { margin-bottom: var(--aj-space-8); }
.story__title {
  font-size: clamp(1.9rem, 5.5vw, 2.75rem);
  font-weight: 600;
  line-height: var(--aj-leading-tight);
  letter-spacing: var(--aj-tracking-tight);
}
.story__standfirst {
  margin-top: var(--aj-space-4);
  color: var(--aj-muted);
  font-size: var(--aj-text-md);
  line-height: var(--aj-leading-relaxed);
}
.story__meta { margin-top: var(--aj-space-5); color: var(--aj-subtle); font-size: var(--aj-text-sm); }

/* Long measure, generous leading — that is the whole design of a reading page. */
.prose {
  max-width: 34rem;
  font-size: var(--aj-text-md);
  line-height: 1.75;
}
.prose > * + * { margin-top: var(--aj-space-5); }
.prose h2, .prose h3 {
  margin-top: var(--aj-space-10);
  font-weight: 600;
  line-height: var(--aj-leading-snug);
  letter-spacing: var(--aj-tracking-tight);
}
.prose h2 { font-size: var(--aj-text-xl); }
.prose h3 { font-size: var(--aj-text-lg); }
.prose a { color: var(--aj-accent); text-underline-offset: 0.2em; }
.prose blockquote {
  border-left: 2px solid var(--aj-flame);
  padding-left: var(--aj-space-5);
  color: var(--aj-muted);
  font-style: italic;
}
.prose ul, .prose ol { padding-left: var(--aj-space-6); }
.prose ul li { list-style: disc; }
.prose ol li { list-style: decimal; }
.prose li + li { margin-top: var(--aj-space-2); }
.prose hr { border: 0; border-top: 1px solid var(--aj-line); margin: var(--aj-space-10) 0; }
.prose figcaption { margin-top: var(--aj-space-3); color: var(--aj-subtle); font-size: var(--aj-text-sm); }

/* ---------- dithered imagery ----------
 *
 * The mask is a 2-entry PNG: transparent where paper, opaque where ink. The
 * COLOUR comes from a token, so one asset is correct in both themes — an <img>
 * would need two.
 *
 * `pixelated` is not decoration. A dithered image resampled by the browser
 * turns to grey mud; the generator emits at 2x and this stops any further
 * smoothing, so the pattern lands on the physical pixel grid.
 */
.dither {
  background-color: var(--aj-ink);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  image-rendering: pixelated;
  aspect-ratio: 3 / 2;
  width: 100%;
}
.dither--wide { margin: var(--aj-space-8) 0; }
.dither--flame { background-color: var(--aj-flame); }

/* The renderer emits the mask as a child div inside a figure, because the mask
   element carries role="img" + aria-label and a <figure> wrapping a caption
   cannot also be the image. */
.figure { margin: var(--aj-space-8) 0; }
.figure .dither { margin: 0; }

/* ---------- the app CTA, on every story ---------- */

.ember {
  margin: var(--aj-space-10) 0;
  padding: var(--aj-space-8) var(--aj-space-6);
  border: 1px solid var(--aj-line);
  border-radius: var(--aj-radius-lg);
  background: var(--aj-surface);
}
.ember__line { font-size: var(--aj-text-lg); line-height: var(--aj-leading-snug); font-weight: 500; }
.ember__sub { margin-top: var(--aj-space-3); color: var(--aj-muted); font-size: var(--aj-text-sm); }
.ember__cta {
  display: inline-block;
  margin-top: var(--aj-space-5);
  padding: 0.6rem 1.1rem;
  border-radius: var(--aj-radius-md);
  background: var(--aj-accent);
  color: var(--aj-on-accent);
  font-weight: 600;
  font-size: var(--aj-text-sm);
  text-decoration: none;
}
.ember__cta:hover { background: var(--aj-accent-hi); }

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

.footer {
  padding: var(--aj-space-8) 0 var(--aj-space-10);
  border-top: 1px solid var(--aj-line);
  color: var(--aj-subtle);
  font-size: var(--aj-text-sm);
}
.footer__promise { color: var(--aj-muted); }
.footer__nav { display: flex; flex-wrap: wrap; gap: var(--aj-space-5); margin-top: var(--aj-space-5); }
.footer__nav a { text-decoration: none; }
.footer__nav a:hover { color: var(--aj-accent); }

/* ---------- newsletter ---------- */

.subscribe { margin-top: var(--aj-space-5); }
.subscribe__label {
  display: block;
  font-size: var(--aj-text-sm);
  color: var(--aj-muted);
  margin-bottom: var(--aj-space-2);
}
.subscribe__row { display: flex; flex-wrap: wrap; gap: var(--aj-space-3); }
.subscribe__input {
  flex: 1 1 14rem;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--aj-line-strong);
  border-radius: var(--aj-radius-md);
  background: var(--aj-canvas);
  color: var(--aj-ink);
  font: inherit;
  font-size: var(--aj-text-sm);
}
.subscribe__input::placeholder { color: var(--aj-subtle); }
.subscribe__submit { margin-top: 0; border: 0; cursor: pointer; font-family: inherit; }

/* Honeypot. Not `display:none` — some bots skip hidden inputs, and some
   password managers do too. Off-screen but focusable-by-bot is the shape that
   actually catches things. aria-hidden keeps it away from screen readers. */
.subscribe__hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
