/* ==========================================================================
   FOLIO — portfolio kit
   One stylesheet. Order: tokens → base → shared → landing → case → motion.
   Change tokens, not components.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* colour: paper, ink, one highlighter. Nothing else. */
  --paper: #F8F7FA;
  --ink:   #1B1A22;
  --grey:  #84828F;
  --hl:    #E4DDF6;   /* lilac highlighter. Max two <mark> per page. */
  --line:  #E3E1EA;   /* hairlines between rows and figures */
  --plate: #ECE9F5;   /* tinted field behind screenshots */
  --accent: #5b2a86;  /* Kyria's purple: figures and the Internal/External marker */

  /* type */
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono:  "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* scale: every step ≥ 1.6× the one below so nothing competes */
  --fs-mono:     12.5px;
  --fs-caption:  12px;
  --fs-body:     clamp(19px, 2.1vw, 26px);
  --fs-sub:      clamp(22px, 2.5vw, 30px);
  --fs-list:     clamp(28px, 3.3vw, 40px);
  --fs-chapter:  clamp(28px, 3.6vw, 44px);
  --fs-sentence: clamp(36px, 6vw, 72px);
  --fs-numeral:  clamp(56px, 8vw, 96px);
  --fs-title:    clamp(44px, 8.6vw, 104px);
  --fs-big:      clamp(72px, 11.6vw, 140px);
  --fs-quote:    clamp(24px, 3vw, 36px);

  /* layout */
  --max:     1200px;
  --gutter:  clamp(20px, 5vw, 64px);
  --measure: 34ch;    /* running text width on case pages */
  --radius:  6px;
  --radius-plate: 14px;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: var(--fs-body);
  font-weight: 300;
  line-height: 1.4;
  font-optical-sizing: auto;   /* Newsreader is a variable font with an optical-size axis; let the browser pick */
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 2px; }
h1, h2, h3 { font-weight: 300; margin: 0; }
p { margin: 0; }
em { font-style: italic; }

mark {
  background: var(--hl);
  color: inherit;
  padding: 0 .08em;
  border-radius: 3px;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

.wrap { max-width: var(--max); margin: 0 auto; padding-inline: var(--gutter); }
.mono {
  font-family: var(--mono);
  font-size: var(--fs-mono);
  font-weight: 400;
  letter-spacing: .04em;
  line-height: 1.6;
  color: var(--grey);
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Shared: top bar, section head, footer ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  border-bottom: 1px solid var(--ink);
  font-family: var(--mono);
  font-size: var(--fs-mono);
  letter-spacing: .04em;
}
.top a:hover { text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 600px) { .top__mid { display: none; } }

.sect {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
}

.foot {
  margin-top: clamp(56px, 8vw, 80px);
  display: flex;
  justify-content: space-between;
  gap: 12px 24px;
  flex-wrap: wrap;
  border-top: 1px solid var(--ink);
  padding-block: 16px 48px;
  font-family: var(--mono);
  font-size: var(--fs-mono);
  letter-spacing: .04em;
}
.foot a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------- 4. Landing ---------- */
.hero {
  padding-block: clamp(56px, 9vw, 96px) clamp(48px, 8vw, 88px);
  max-width: 1040px;
}
.hero__byline { margin-bottom: clamp(16px, 3vw, 30px); }
.hero__sentence {
  font-size: var(--fs-sentence);
  line-height: 1.03;
  letter-spacing: -.022em;
  font-weight: 300;
  text-wrap: balance;
}
.hero__sentence em { font-weight: 400; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { border-bottom: 1px solid var(--line); }
.row__link {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 24px;
  align-items: baseline;
  padding-block: 28px;
}
.row__n { font-family: var(--mono); font-size: var(--fs-mono); color: var(--grey); }
.row__title {
  font-size: var(--fs-list);
  line-height: 1;
  font-weight: 400;
  letter-spacing: -.015em;
}
.row__title small {
  display: block;
  font-family: var(--mono);
  font-size: var(--fs-mono);
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--grey);
  margin-top: 10px;
}
.row__out {
  font-size: clamp(17px, 1.7vw, 20px);
  font-style: italic;
  font-weight: 300;
  text-align: right;
  max-width: 18ch;
}

/* The shot that follows the cursor on hover devices. Positioned by js/folio.js. */
.row__peek {
  position: fixed;
  top: 0; left: 0;
  width: min(420px, 40vw);
  aspect-ratio: 16 / 10;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -55%) rotate(-2deg);
  transition: opacity .25s ease;
  z-index: 5;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--plate);
  box-shadow: 0 30px 60px rgba(28, 27, 25, .16);
}
.row__peek img { width: 100%; height: 100%; object-fit: cover; }
.row.is-hot .row__peek { opacity: 1; }
.row.is-hot .row__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

/* No hover (touch) or narrow: the shot sits under the row instead. */
@media (hover: none), (max-width: 700px) {
  .row__link { grid-template-columns: 40px 1fr; gap: 12px 16px; padding-block: 24px 16px; }
  .row__out { grid-column: 2; text-align: left; max-width: none; }
  .row__peek {
    position: static;
    opacity: 1;
    transform: none;
    width: 100%;
    margin: 0 0 24px;
    box-shadow: none;
  }
  .row.is-hot .row__title { text-decoration: none; }
}

/* ---------- 5. Case page ---------- */
.case-head {
  padding-block: clamp(48px, 7vw, 80px) clamp(36px, 5vw, 56px);
  max-width: 1040px;
}
.case-head__title {
  font-size: var(--fs-title);
  line-height: .94;
  letter-spacing: -.03em;
  margin: 22px 0 24px;
  text-wrap: balance;
}
.case-head__sub {
  margin-bottom: 36px;
  font-size: var(--fs-sub);
  line-height: 1.25;
  font-style: italic;
  max-width: 30ch;
}
.facts {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 14px 36px;
  font-family: var(--mono);
  font-size: var(--fs-mono);
  line-height: 1.6;
  border-top: 1px solid var(--ink);
  padding-top: 14px;
}
.facts dt { color: var(--grey); }
.facts dd { margin: 0; }

/* Chapter: thin oversized numeral on the baseline of an italic title, full width. */
.ch { padding-top: clamp(48px, 6vw, 72px); }
.ch__head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px clamp(12px, 2vw, 22px);
  border-top: 1px solid var(--ink);
  padding-top: 18px;
  margin-bottom: 28px;
}
.ch__num { font-size: var(--fs-numeral); line-height: .8; font-weight: 200; letter-spacing: -.04em; }
.ch__title { font-size: var(--fs-chapter); font-style: italic; letter-spacing: -.015em; }
.ch__when { margin-left: auto; font-family: var(--mono); font-size: var(--fs-mono); color: var(--grey); }
.ch__text {
  margin-bottom: 34px;
  line-height: 1.3;
  letter-spacing: -.01em;
  max-width: var(--measure);
  text-wrap: pretty;
}

.figs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 20px;
}
.fig { margin: 0; display: grid; gap: 10px; min-width: 0; }
.fig--wide { grid-column: 1 / -1; }
.fig > img { border: 1px solid var(--line); border-radius: var(--radius); }
.fig__plate {
  background: var(--plate);
  border-radius: var(--radius-plate);
  padding: clamp(16px, 3.5vw, 36px) clamp(16px, 3.5vw, 36px) 0;
  overflow: hidden;
}
.fig__plate img {
  border: 1px solid var(--line);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}
.fig figcaption { font-family: var(--mono); font-size: var(--fs-caption); color: var(--grey); line-height: 1.5; }

.big { font-size: var(--fs-big); line-height: .9; font-weight: 200; letter-spacing: -.05em; margin-bottom: 10px; }
.quote {
  margin: 24px 0 0;
  font-size: var(--fs-quote);
  line-height: 1.12;
  font-style: italic;
  max-width: 24ch;
}
.quote footer { font-family: var(--mono); font-size: var(--fs-mono); font-style: normal; color: var(--grey); margin-top: 14px; }

.lessons { margin: 0; padding: 0; list-style: none; max-width: 40ch; }
.lessons li {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 14px;
  padding-block: 18px;
  border-top: 1px solid var(--line);
  line-height: 1.25;
}
.lessons li span { font-family: var(--mono); font-size: var(--fs-mono); line-height: 2.2; color: var(--grey); }

.next {
  margin-top: clamp(56px, 8vw, 80px);
  border-top: 1px solid var(--ink);
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px 24px;
  flex-wrap: wrap;
}
.next__title { font-size: clamp(24px, 3vw, 34px); font-style: italic; }
.next a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; }

/* ---------- 6. Motion (only with JS, only without reduced-motion) ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* highlighter paints in once, left to right, when it enters the viewport */
  .js mark {
    background: linear-gradient(var(--hl), var(--hl)) no-repeat 0 0 / 0% 100%;
    transition: background-size .7s cubic-bezier(.2, .7, .2, 1);
  }
  .js mark.is-inked { background-size: 100% 100%; }

  /* figures settle up 12px */
  .js .fig { opacity: 0; transform: translateY(12px); transition: opacity .5s ease, transform .5s ease; }
  .js .fig.is-in { opacity: 1; transform: none; }
}
