/* ==========================================================================
   karinabrown.xyz
   Tokens are defined once, here. Reference them; do not hard-code values.
   ========================================================================== */

/* --- Fonts: self-hosted, Latin subset. No third-party requests. ---------- */

/* Variable fonts, Latin subset, weight range 400-500. Newsreader carries an
   optical-size axis; font-optical-sizing defaults to auto, which is wanted. */

@font-face {
  font-family: 'Schibsted Grotesk';
  src: url('/fonts/schibsted-grotesk-var.woff2') format('woff2-variations'),
    url('/fonts/schibsted-grotesk-var.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/newsreader-var.woff2') format('woff2-variations'),
    url('/fonts/newsreader-var.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Newsreader';
  src: url('/fonts/newsreader-var-italic.woff2') format('woff2-variations'),
    url('/fonts/newsreader-var-italic.woff2') format('woff2');
  font-weight: 400 500;
  font-style: italic;
  font-display: swap;
}

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

:root {
  /* Colour */
  --ground: #F2F3EF;
  --ground-sunk: #EAECE4;
  --ink: #23303A;
  --ink-soft: #5D6B66;
  --ink-mute: #78857C;
  --accent: #5B7A58;
  --accent-deep: #3F5E45;
  --rule: #D6DACE;

  /* Deliberate addition to the brief's closed palette. --card-2 darkened
     along its own hue until it can hold text: the tint itself measures
     1.84:1 on --ground, this measures 3.17:1 — above the 3:1 floor for text
     at this size, and the one-liner is 76px desktop, 32px mobile. Used only
     on the second full stop, to tie it to the Current projects card. */
  --accent-cool: #768C92;

  /* The flip-card reverse is pinned rather than derived from --accent-deep,
     so the signature element looks the same whichever way the page is set. */
  --card-back: #3F5E45;
  --card-back-ink: #F2F3EF;

  /* Card tints — home page flip cards only */
  --card-1: #C6D4B6;
  --card-2: #9DBAC2;
  --card-3: #8FAF93;
  --card-4: #C9D0C2;

  /* Type */
  --font-display: 'Schibsted Grotesk', system-ui, sans-serif;
  --font-text: 'Newsreader', Georgia, serif;

  --size-meta: 13px;
  --size-caption: 15px;
  --size-body: 17px;
  --size-lead: 20px;
  --size-h3: 22px;
  --size-h2: 28px;
  --size-h1: 40px;
  --size-oneliner: 76px;

  /* Layout */
  --measure: 680px;
  --margin-col: 140px;
  --container: 1100px;
  --gutter: 24px;
  --nav-h: 64px; /* nav block height, so the hero can fill the rest */

  /* Spacing — multiples of 4. Use nothing in between. */
  --space-4: 4px;
  --space-8: 8px;
  --space-12: 12px;
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
  --space-48: 48px;
  --space-64: 64px;
  --space-96: 96px;
  --space-128: 128px;

  --radius-control: 4px;
  --radius-card: 8px;
}

/* Home-page invert, reached by clicking the mark. Every value re-measured
   against the dark ground: text 12.11:1, --ink-soft 5.90:1, --accent 6.40:1
   (the light sage from the logo handoff), --accent-cool 6.58:1 — which is
   --card-2 raw, the tint that could not carry text on the light ground. */
:root[data-theme='dark'] {
  --ground: #23303A;
  --ink: #F2F3EF;
  --ink-soft: #A3AEA8;
  --ink-mute: #A3AEA8;
  --accent: #A8B7A1;
  --accent-deep: #C6D4B6;
  --accent-cool: #9DBAC2;
  --rule: #414E57;
}

/* Colour carries across; .card__inner is left alone so its 400ms flip is not
   overwritten. Scoped to [data-theme], which only the home page carries. */
:root[data-theme] body,
:root[data-theme] body *:not(.card__inner) {
  transition-property: background-color, color, border-color, fill,
    text-decoration-color;
  transition-duration: 250ms;
  transition-timing-function: ease-out;
}

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

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

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--size-body);
  font-weight: 400;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-48) 0;
}

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

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: var(--space-8);
  transform: translateY(-200%);
  background: var(--ground-sunk);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: var(--size-caption);
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-control);
  z-index: 20;
}

.skip-link:focus {
  transform: none;
}

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

/* --- Typography ---------------------------------------------------------- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: var(--size-h1);
  font-weight: 400;
  line-height: 1.2;
}

h2 {
  font-size: var(--size-h2);
  font-weight: 500;
  line-height: 1.25;
}

h3 {
  font-size: var(--size-h3);
  font-weight: 500;
  line-height: 1.3;
}

p {
  margin: 0 0 var(--space-24);
}

.meta {
  font-family: var(--font-display);
  font-size: var(--size-meta);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.4;
  /* --ink-soft, not --ink-mute: 13px metadata needs 4.5:1 (see README) */
  color: var(--ink-soft);
  margin: 0;
}

.caption {
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-soft);
  margin: var(--space-12) 0 0;
}

.lead {
  font-size: var(--size-lead);
  line-height: 1.6;
}

/* Links inside body copy keep the serif face. */
.prose a,
.link {
  color: var(--accent-deep);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: text-decoration-color 200ms ease-out;
}

.prose a:hover,
.link:hover {
  text-decoration-color: var(--accent-deep);
}

.prose > *:last-child {
  margin-bottom: 0;
}

/* Only 400 and 500 are loaded, so bold must resolve to 500 rather than let
   the browser synthesise a heavier face the brief does not use. */
.prose strong,
strong {
  font-weight: 500;
}

.prose h3 {
  margin: var(--space-48) 0 var(--space-12);
}

.prose ul,
.prose ol {
  margin: 0 0 var(--space-24);
  padding-left: var(--space-24);
}

.prose li {
  margin-bottom: var(--space-8);
}

/* --- Grid ---------------------------------------------------------------- */
/* One grid across the site: a narrow left margin column plus the text column. */

.row {
  display: grid;
  grid-template-columns: var(--margin-col) minmax(0, var(--measure));
  column-gap: var(--space-48);
  justify-content: center;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.row__margin {
  grid-column: 1;
}

.row__main {
  grid-column: 2;
  min-width: 0;
}

/* Spans the margin column and the text column together. */
.row__full {
  grid-column: 1 / -1;
  min-width: 0;
}

/* Full-bleed: home hero and the flip-card band only. */
.bleed {
  width: 100%;
  padding-inline: var(--gutter);
}

/* --- Navigation ---------------------------------------------------------- */
/* Not sticky. It scrolls away. */

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-24);
  min-height: var(--nav-h);
  padding: var(--space-16) var(--gutter) 0;
}

/* The KB mark. Inlined at build time, so the fill follows `color` and can
   darken on hover and focus rather than fading. Aspect is 100 x 139, so only
   the height is set — width follows, and the mark cannot distort. */
.nav__home {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--accent);
  text-decoration: none;
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: color 180ms ease-out;
}

.nav__home:hover,
.nav__home:focus-visible {
  color: var(--accent-deep);
}

.nav__home svg {
  display: block;
  width: auto;
  height: 44px;
}

/* The file carries a literal fill so it works standalone in an <img>. When
   inlined here, hand control back to `color` so hover and the invert work. */
.nav__home svg path {
  fill: currentColor;
}

.nav__home-text {
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.nav__links {
  display: flex;
  gap: var(--space-32);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__link {
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: var(--space-4);
  transition: border-color 200ms ease-out, color 200ms ease-out;
}

.nav__link:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

.nav__link[aria-current='page'] {
  border-bottom-color: var(--accent);
}

.nav__toggle {
  display: none;
  position: relative;
  z-index: 12;
  width: 44px;
  height: 44px;
  padding: 0;
  margin-right: -10px;
  background: none;
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.nav__toggle-bar {
  display: block;
  width: 22px;
  height: 1.5px;
  margin: 5px auto;
  background: var(--ink);
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}

@media (max-width: 899px) {
  .nav {
    padding-top: var(--space-24);
  }

  .nav__toggle {
    display: block;
  }

  .nav__links {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(340px, 82vw);
    flex-direction: column;
    justify-content: center;
    gap: var(--space-24);
    background: var(--ground-sunk);
    padding: var(--space-96) var(--space-32) var(--space-48);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 300ms ease-out, visibility 300ms ease-out;
    z-index: 10;
  }

  .nav__link {
    font-size: var(--size-h3);
    font-weight: 500;
  }

  .nav.is-open .nav__links {
    transform: translateX(0);
    visibility: visible;
  }

  .nav.is-open .nav__toggle-bar:nth-child(1) {
    transform: translateY(6.5px) rotate(45deg);
  }

  .nav.is-open .nav__toggle-bar:nth-child(2) {
    opacity: 0;
  }

  .nav.is-open .nav__toggle-bar:nth-child(3) {
    transform: translateY(-6.5px) rotate(-45deg);
  }
}

/* --- Footer -------------------------------------------------------------- */
/* Aligned to --container, so the copyright and its rule line up with the
   one-liner and the card band above. */

.footer {
  margin-top: var(--space-128);
  padding: 0 var(--gutter) var(--space-48);
}

.footer__line {
  max-width: var(--container);
  margin-inline: auto;
  border-top: 1px solid var(--rule);
  padding-top: var(--space-32);
  font-family: var(--font-display);
  font-size: var(--size-meta);
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

/* --- Home ---------------------------------------------------------------- */

.hero {
  min-height: calc(100svh - var(--nav-h));
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  padding-bottom: var(--space-32);
}

.hero__inner {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
}

.hero__line {
  font-family: var(--font-display);
  font-size: var(--size-oneliner);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

.hero__line-a,
.hero__line-b {
  display: block;
  text-wrap: pretty;
}

/* The greeting takes a line of its own, then the sentence wraps to three
   against --container. That keeps it to four lines with nothing hanging. */

/* The two full stops carry the only colour above the fold: sage, then the
   cool blue. Card tints cannot be used raw — every one measures under 2.2:1
   as text on --ground, and a full stop that cannot be seen changes where the
   sentence appears to end. */
.stop--a {
  color: var(--accent);
}

.stop--b {
  color: var(--accent-cool);
}

/* Scroll cue. Static — the flip cards are the only thing on the site that
   moves on interaction. */
.hero__scroll {
  justify-self: start;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-block: var(--space-16);
  color: var(--ink-soft);
  border-radius: var(--radius-control);
  transition: color 200ms ease-out;
}

.hero__scroll:hover {
  color: var(--accent-deep);
}

.hero__scroll-arrow {
  width: 16px;
  height: 28px;
}

/* --- Flip cards ---------------------------------------------------------- */
/* The one thing on the site that moves on interaction. */

.cards {
  padding-bottom: var(--space-64);
}

/* Held to --container so the band lines up with the one-liner above it,
   rather than running the full width of the viewport. */
.cards__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-16);
  max-width: var(--container);
  margin-inline: auto;
  list-style: none;
  margin-block: 0;
  padding: 0;
}

.card {
  display: block;
  height: 180px;
  perspective: 1200px;
  text-decoration: none;
  border-radius: var(--radius-card);
}

.card__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 400ms ease-out;
}

.card:hover .card__inner,
.card:focus-visible .card__inner {
  transform: rotateY(180deg);
}

.card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: var(--space-24);
  border-radius: var(--radius-card);
  backface-visibility: hidden;
  font-family: var(--font-display);
}

.card__face--front {
  background: var(--card-tint);
  color: var(--ink);
}

.card__face--back {
  background: var(--card-back);
  color: var(--card-back-ink);
  transform: rotateY(180deg);
}

.card__title {
  font-size: var(--size-h3);
  font-weight: 500;
  line-height: 1.3;
}

.card__desc {
  font-size: var(--size-caption);
  font-weight: 400;
  line-height: 1.5;
}

/* Kept in the accessibility tree on desktop, revealed in the static treatment. */
.card__desc--static {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.card--1 { --card-tint: var(--card-1); }
.card--2 { --card-tint: var(--card-2); }
.card--3 { --card-tint: var(--card-3); }
.card--4 { --card-tint: var(--card-4); }

/* Layout is a question of width: two up once there is no room for four. */
@media (max-width: 899px) {
  .cards__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Whether the card flips is a question of capability, not width. A narrow
   desktop window can still hover, so it keeps the flip. A touch device
   cannot, at any width, so it gets the static face — as does anyone who
   asked for less motion. Not a fallback; it is the design for those inputs.

   The transform is reset through the same :hover and :focus-visible
   selectors that set it. A bare .card__inner would lose to them on
   specificity, leave the card mid-rotation with its back face display:none,
   and the card would vanish on hover. */
@media (hover: none), (prefers-reduced-motion: reduce) {
  .cards__grid {
    grid-auto-rows: 1fr;
  }

  .card {
    height: 100%;
    perspective: none;
  }

  .card__inner,
  .card:hover .card__inner,
  .card:focus-visible .card__inner {
    transform: none;
    transition: none;
    transform-style: flat;
  }

  .card__face {
    position: static;
    justify-content: flex-start;
    gap: var(--space-12);
    height: 100%;
    min-height: 150px;
    backface-visibility: visible;
  }

  .card__desc {
    font-size: var(--size-meta);
    letter-spacing: 0;
  }

  .card__face--back {
    display: none;
  }

  .card__desc--static {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
  }
}

/* --- Page furniture ------------------------------------------------------ */

/* Page titles borrow the home one-liner's size, and start at the left edge
   of the grid — flush with the margin column, so they line up with the date
   ranges on Experience rather than with the prose they sit above. Widths
   mirror .row exactly at both breakpoints; see the checks in README. */
.page-head {
  padding-top: var(--space-96);
  padding-bottom: var(--space-48);
}

.page-head__inner {
  width: 100%;
  max-width: calc(var(--margin-col) + var(--space-48) + var(--measure));
  margin-inline: auto;
}

.page-head__title {
  font-size: var(--size-oneliner);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-24);
  text-wrap: pretty;
}

/* The lead is reading copy, so it keeps the reading measure. */
.page-head__lead {
  max-width: var(--measure);
}

.section {
  padding-block: var(--space-48);
}

.band--sunk {
  background: var(--ground-sunk);
  padding-block: var(--space-64);
}

.chapter {
  padding-block: var(--space-48);
}

.chapter__heading {
  margin-bottom: var(--space-24);
}

/* Reading copy, so it takes the body face and the reading measure. */
.contact-intro {
  font-family: var(--font-text);
  font-size: var(--size-lead);
  line-height: 1.6;
  max-width: var(--measure);
  margin-bottom: var(--space-48);
}

/* --- Contact actions ----------------------------------------------------- */
/* Two channels, primary and secondary. Both are links, not buttons — they
   navigate rather than act. Filled treatment reuses --accent-deep on
   --ground, the pairing already used by the flip-card reverse, rather than
   inventing a button colour. 44px minimum for touch. */

.contact-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  max-width: 360px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  min-height: 48px;
  padding: var(--space-12) var(--space-24);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: background-color 200ms ease-out, border-color 200ms ease-out,
    color 200ms ease-out;
}

.btn--primary {
  background: var(--accent-deep);
  color: var(--ground);
}

.btn--primary:hover {
  background: var(--ink);
}

.btn--secondary {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.btn--secondary:hover {
  border-color: var(--accent-deep);
  color: var(--accent-deep);
}

.btn__ext {
  font-size: 0.9em;
}

/* mailto: fails silently for anyone without a mail handler — webmail in a
   browser, most often. The address in plain text is their way through. */
.contact-address {
  max-width: 360px;
  margin: var(--space-16) 0 0;
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 400;
  color: var(--ink-soft);
  text-align: center;
  user-select: all;
}

/* --- About photograph ---------------------------------------------------- */
/* Roughly half the column, breaking left into the margin column. */

.figure-break {
  float: left;
  width: calc(50% + var(--margin-col) + var(--space-48));
  margin: var(--space-8) var(--space-32) var(--space-24)
    calc(-1 * (var(--margin-col) + var(--space-48)));
}

.figure-break img {
  border-radius: var(--radius-control);
}

/* --- Organisations wall -------------------------------------------------- */
/* Logos, muted to sit with the palette rather than shout brand colours.
   Each carries its own --s scale: at equal height a solid mark like IKEA
   measures nine times the ink of an open one like Wärtsilä, so sizes are
   normalised toward equal ink coverage — halfway, since full correction
   over-corrects and balloons the sparse marks. Values are measured, not
   guessed; see README for how to recompute them. */

/* Set apart from the chapters by a rule and a good deal of space. */
.orgs-section {
  padding-top: var(--space-64);
  padding-bottom: var(--space-48);
}

.orgs-section .row__full {
  border-top: 1px solid var(--rule);
  padding-top: var(--space-64);
}

/* Caption size: small enough not to compete with the logos below it, but
   without the letter-spacing and metadata colouring it carried originally,
   which made it read as a label rather than as a heading. */
.orgs__label {
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
  color: var(--ink-soft);
  margin: 0 0 var(--space-32);
}

.orgs {
  --logo-h: 44px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-32) var(--space-24);
  list-style: none;
  margin: 0;
  padding: 0;
}

.orgs__item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  margin: 0;
}

.orgs__logo {
  width: auto;
  max-width: 100%;
  height: calc(var(--logo-h) * var(--s, 1));
  object-fit: contain;
  filter: grayscale(1) sepia(0.45) hue-rotate(48deg) saturate(0.5)
    brightness(0.97) opacity(0.7);
}

/* Escape hatch for a logo supplied on a white background rather than
   transparency: multiply drops the white out against the light ground.
   Currently unused — every logo on the wall is transparent — but kept,
   since supplied logo files often are not. Opt in with `blend: true`. */
.orgs__logo--blend {
  mix-blend-mode: multiply;
}

/* Organisations with no logo yet keep their name, in the same muted tone. */
.orgs__name {
  font-family: var(--font-display);
  font-size: var(--size-caption);
  font-weight: 400;
  line-height: 1.4;
  text-align: center;
  color: var(--ink-soft);
  opacity: 0.75;
}

@media (max-width: 899px) {
  .orgs {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-24);
  }
}

@media (max-width: 639px) {
  .orgs {
    --logo-h: 36px;
    grid-template-columns: repeat(2, 1fr);
  }
}

/* --- Project index ------------------------------------------------------- */

/* Each project is a row on the site grid: image in the margin column,
   title and copy in the text column — the same shape as an Experience
   chapter. The divider is a grid item so it spans the tracks exactly,
   rather than the full width of the row element. */
.project {
  padding-bottom: var(--space-32);
}

.project::before {
  content: '';
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  margin-bottom: var(--space-32);
}

.project:last-of-type {
  border-bottom: 1px solid var(--rule);
}

.project__figure img {
  width: 100%;
  height: auto;
  /* One shape for all of them: a landscape screenshot and a portrait photo
     otherwise sit at different heights and the column looks accidental.
     Cropping in CSS keeps the source files uncropped and reversible. */
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-control);
  /* Unifies images of different origins. Tuned once, applies to all. */
  filter: saturate(0.85) contrast(1.02);
}

/* A mark has to fit the square, not fill it — cover would crop the logo. */
.project__figure img[src$='.svg'] {
  object-fit: contain;
}

.prose .project__title,
.project__title {
  margin-bottom: var(--space-12);
}

.prose .project__link,
.project__link {
  color: var(--ink);
  text-decoration: none;
  text-decoration-color: transparent;
  border-bottom: 1px solid transparent;
  transition: color 200ms ease-out, border-color 200ms ease-out;
}

.prose .project__link:hover,
.project__link:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

@media (max-width: 899px) {
  .project__figure {
    margin-bottom: var(--space-16);
  }

  .project__figure img {
    max-width: 140px;
  }
}

/* --- Newsletter ---------------------------------------------------------- */
/* Posts are imported from Substack, so the body arrives as a small fixed
   vocabulary: h2, p, em, strong, a, figure and the "If you go" reference
   block. Everything here dresses that vocabulary in the site's own type. */

/* The index reuses the project row exactly — photograph in the margin
   column, words in the text column — so the archive reads as another list
   on the same grid rather than a new kind of page. */
.entry {
  padding-bottom: var(--space-32);
}

.entry::before {
  content: '';
  grid-column: 1 / -1;
  border-top: 1px solid var(--rule);
  margin-bottom: var(--space-32);
}

.entry:last-of-type {
  border-bottom: 1px solid var(--rule);
}

.entry__figure img {
  width: 100%;
  height: auto;
  /* Square, like the project thumbnails: the heroes are a mix of landscape
     and portrait and the column looks accidental otherwise. */
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-control);
  filter: saturate(0.85) contrast(1.02);
}

.entry__title {
  margin: var(--space-8) 0 var(--space-12);
}

.entry__link {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 200ms ease-out, border-color 200ms ease-out;
}

.entry__link:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

/* The deck is the standfirst Substack sends in the feed: reading copy, so it
   takes the body face rather than the display one the meta line uses. */
.entry__deck {
  font-family: var(--font-text);
  font-size: var(--size-body);
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0;
}

/* Back to the index, sitting in the post's meta line. */
.meta__back {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 200ms ease-out, border-color 200ms ease-out;
}

.meta__back:hover {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}

.post__figure img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-control);
}

/* Photographs inside the body keep the measure. They are given more room
   above than below, so each one attaches to the paragraph it follows. */
.post__figure {
  margin: var(--space-48) 0 var(--space-32);
}

.post__figure figcaption {
  margin-top: var(--space-12);
}

/* Substack posts have no h1 in the body after import — the page title holds
   that — so h2 is the section level and needs the spacing h3 already had. */
.prose h2 {
  margin: var(--space-64) 0 var(--space-16);
}

.prose h2:first-child {
  margin-top: 0;
}

.prose blockquote {
  margin: var(--space-32) 0;
  padding-left: var(--space-24);
  border-left: 2px solid var(--rule);
  color: var(--ink-soft);
  font-style: italic;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-48) 0;
}

/* --- "If you go" --------------------------------------------------------- */
/* Every review closes with the same run of label-and-value lines. The
   importer turns them into a description list; this sets them as a reference
   block, so the eye can tell at a glance where the prose stops and the
   practical details start. */

.factbox {
  margin-top: var(--space-64);
  padding: var(--space-32);
  background: var(--ground-sunk);
  border-radius: var(--radius-card);
}

/* Scoped past .prose h2, which would otherwise impose the section spacing
   on a heading that sits inside the box's own padding. */
.prose .factbox__heading,
.factbox__heading {
  font-size: var(--size-h3);
  margin: 0 0 var(--space-24);
}

.factbox__list {
  display: grid;
  /* Labels are short and repeat post to post, so they get a fixed column and
     the values line up down the block. */
  grid-template-columns: 180px minmax(0, 1fr);
  column-gap: var(--space-24);
  row-gap: var(--space-16);
  margin: 0;
}

.factbox__term {
  font-family: var(--font-display);
  font-size: var(--size-meta);
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.5;
  color: var(--ink-soft);
  /* Nudged onto the baseline of the 17px value beside it. */
  padding-top: 2px;
}

.factbox__detail {
  margin: 0;
  font-size: var(--size-body);
  line-height: 1.6;
}

/* The attribution back to Substack, which stays the place of record. */
.post__foot {
  padding-top: var(--space-32);
  padding-bottom: var(--space-48);
}

.post__foot .row__main {
  border-top: 1px solid var(--rule);
  padding-top: var(--space-24);
}

@media (max-width: 899px) {
  .entry__figure {
    margin-bottom: var(--space-16);
  }

  .entry__figure img {
    max-width: 140px;
  }

  .factbox {
    padding: var(--space-24);
  }

  /* One column: at this width a 180px label column leaves the values too
     narrow to read. */
  .factbox__list {
    grid-template-columns: minmax(0, 1fr);
    row-gap: var(--space-4);
  }

  .factbox__term {
    padding-top: var(--space-12);
  }

  .factbox__term:first-of-type {
    padding-top: 0;
  }
}

/* --- Motion -------------------------------------------------------------- */
/* Applied by JS only when motion is welcome, so no-JS shows everything. */

.js-motion [data-reveal] {
  opacity: 0;
  transform: translateY(12px);
}

.js-motion [data-reveal].is-in {
  opacity: 1;
  transform: none;
  transition: opacity 300ms ease-out, transform 300ms ease-out;
}

@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;
  }
}

/* The mark holds the top-left corner while the page scrolls; the links still
   scroll away. Fixed only from 1244px up, which is where the container first
   has side margin to spare: below it, content sits at the gutter and a fixed
   mark would land on top of the text.
     content left = 24 + (V - 48 - 1100) / 2
     mark ends at 24 + 44 * 100/139 = 55.7, plus 16px clearance = 71.7
     71.7 <= 24 + (V - 1148) / 2  ->  V >= 1244 */
@media (min-width: 1244px) {
  .nav {
    justify-content: flex-end;
  }

  .nav__home {
    position: fixed;
    top: var(--space-16);
    left: var(--gutter);
    z-index: 12;
  }
}

/* --- Breakpoints --------------------------------------------------------- */

@media (max-width: 1199px) {
  :root {
    --size-oneliner: 60px;
  }
}

@media (max-width: 899px) {
  :root {
    --size-h1: 30px;
    --size-h2: 24px;
    --size-oneliner: 32px;
    --nav-h: 68px;
  }

  .row {
    grid-template-columns: minmax(0, 1fr);
    max-width: calc(var(--measure) + var(--gutter) * 2);
  }

  /* The margin column collapses; its content moves inline above its section. */
  .row__margin,
  .row__main {
    grid-column: 1;
  }

  .row__margin {
    margin-bottom: var(--space-12);
  }

  .hero__inner,
  .hero__scroll,
  .cards__grid {
    max-width: calc(var(--measure) + var(--gutter) * 2);
    margin-inline: auto;
  }

  .page-head {
    padding-top: var(--space-64);
    padding-bottom: var(--space-32);
  }

  /* Below 900px .row collapses to a single column capped at --measure, so
     the head has to follow or the title drifts off the text's left edge. */
  .page-head__inner {
    max-width: var(--measure);
  }

  .figure-break {
    float: none;
    width: 100%;
    margin: 0 0 var(--space-24);
  }

  .footer {
    margin-top: var(--space-96);
  }
}

@media (max-width: 639px) {
  .card__face {
    padding: var(--space-16);
  }
}
