/* ==========================================================================
   Stefano Rainieri, portfolio
   Editorial minimal: Instrument Serif display + Inter text, paper light /
   ink dark, one accent. Tokens first, then components.
   ========================================================================== */

@font-face {
  font-family: 'Instrument Serif';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/instrument-serif-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Instrument Serif';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/instrument-serif-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/inter-var.woff2') format('woff2');
}

/* --- tokens ------------------------------------------------------------- */

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f3f0ea;
  --ink: #16130f;
  --ink-2: #5c554d;
  --rule: #e2ddd5;
  --rule-strong: #cdc6bb;
  --edge: #948c81; /* interactive borders: >=3:1 per WCAG 1.4.11 */
  /* The brand yellow has a relative luminance of 0.80, so it can never carry
     text on a light background (1.18:1). It is a fill colour. --accent is its
     text-weight sibling; --highlight is the yellow itself, always paired with
     --on-highlight. */
  --accent: #705800;
  --accent-soft: #fefadf;
  --highlight: #feea39;
  --on-highlight: #231f20;
  /* a small yellow shape on paper is only 1.18:1, so it gets an edge from the
     same family. On a dark ground the yellow is already 15:1, so none is needed. */
  --highlight-edge: #705800;
  --shadow: 0 1px 2px rgb(22 19 15 / 4%), 0 12px 32px -20px rgb(22 19 15 / 22%);

  --serif: 'Instrument Serif', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1.0625rem;
  --step-1: clamp(1.125rem, 0.4vw + 1.03rem, 1.3125rem);
  --step-2: clamp(1.375rem, 1vw + 1.15rem, 1.75rem);
  --step-3: clamp(1.75rem, 1.6vw + 1.35rem, 2.35rem);
  --step-4: clamp(2rem, 2.4vw + 1.4rem, 3rem);
  --step-5: clamp(2.5rem, 4.2vw + 1.35rem, 4.5rem);

  --gap: clamp(1.25rem, 2vw, 2rem);
  --pad-x: clamp(1.25rem, 5vw, 4rem);
  --sec-y: clamp(3.5rem, 8vw, 7rem);
  --measure: 66ch;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12110f;
    --surface: #1a1917;
    --surface-2: #211f1c;
    --ink: #f3efe9;
    --ink-2: #a8a199;
    --rule: #2b2926;
    --rule-strong: #403c37;
    --edge: #6f6960; /* interactive borders: >=3:1 per WCAG 1.4.11 */
    /* on a dark ground the yellow carries text at 15.3:1, so here it is the accent */
    --accent: #feea39;
    --accent-soft: #2a2410;
    --highlight: #feea39;
    --on-highlight: #231f20;
    --highlight-edge: transparent;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 14px 34px -22px rgb(0 0 0 / 70%);
  }
}

/* explicit choice always beats the OS preference */
:root[data-theme='light'] {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --surface-2: #f3f0ea;
  --ink: #16130f;
  --ink-2: #5c554d;
  --rule: #e2ddd5;
  --rule-strong: #cdc6bb;
  --edge: #948c81; /* interactive borders: >=3:1 per WCAG 1.4.11 */
  /* The brand yellow has a relative luminance of 0.80, so it can never carry
     text on a light background (1.18:1). It is a fill colour. --accent is its
     text-weight sibling; --highlight is the yellow itself, always paired with
     --on-highlight. */
  --accent: #705800;
  --accent-soft: #fefadf;
  --highlight: #feea39;
  --on-highlight: #231f20;
  /* a small yellow shape on paper is only 1.18:1, so it gets an edge from the
     same family. On a dark ground the yellow is already 15:1, so none is needed. */
  --highlight-edge: #705800;
  --shadow: 0 1px 2px rgb(22 19 15 / 4%), 0 12px 32px -20px rgb(22 19 15 / 22%);
}
:root[data-theme='dark'] {
  --bg: #12110f;
  --surface: #1a1917;
  --surface-2: #211f1c;
  --ink: #f3efe9;
  --ink-2: #a8a199;
  --rule: #2b2926;
  --rule-strong: #403c37;
  --edge: #6f6960; /* interactive borders: >=3:1 per WCAG 1.4.11 */
  --accent: #feea39;
  --accent-soft: #2a2410;
  --highlight: #feea39;
  --on-highlight: #231f20;
  --highlight-edge: transparent;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 14px 34px -22px rgb(0 0 0 / 70%);
}

/* --- base -------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--step-0);
  line-height: 1.65;
  font-feature-settings: 'cv05' 1, 'ss03' 1;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 400;
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

h1 { font-size: var(--step-5); }
h2 { font-size: var(--step-4); }
h3 { font-size: var(--step-2); }

p { margin: 0 0 1.1em; }
p:last-child { margin-bottom: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--rule-strong);
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}
a:hover { color: var(--accent); text-decoration-color: currentColor; }

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

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

/* The UA sheet sets [hidden] { display: none }, but any author rule that sets
   display (.card is display:flex) beats it, so the attribute silently stops
   working. This restores it. */
[hidden] { display: none !important; }

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

::selection { background: var(--highlight); color: var(--on-highlight); }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--bg);
  padding: 0.75rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

.wrap {
  max-width: 1220px;
  margin-inline: auto;
  padding-inline: var(--pad-x);
}
.wrap--narrow { max-width: 900px; }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.1em; }
.prose a { text-decoration-color: var(--accent); }

.eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0 0 1rem;
}
.eyebrow--accent { color: var(--accent); }

.lede {
  font-size: var(--step-1);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 58ch;
}

.muted { color: var(--ink-2); }
.serif-it { font-family: var(--serif); font-style: italic; }

/* --- buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.6rem 1.15rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.btn:hover {
  background: var(--highlight);
  border-color: var(--highlight-edge);
  color: var(--on-highlight);
  transform: translateY(-1px);
}
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--edge); }
.btn--ghost:hover { background: transparent; color: var(--accent); border-color: var(--accent); }

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.arrow { transition: transform 0.18s ease; }
a:hover .arrow { transform: translateX(3px); }

/* --- header ------------------------------------------------------------ */

.site-head {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--rule);
}
.site-head__in {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
}
.brand {
  font-family: var(--serif);
  font-size: 1.25rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}
.brand span {
  display: inline-block;
  width: 0.34em;
  height: 0.34em;
  margin-left: 0.14em;
  background: var(--highlight);
  box-shadow: 0 0 0 1px var(--highlight-edge);
  vertical-align: baseline;
}

.nav { display: flex; align-items: center; gap: clamp(1rem, 2.5vw, 2rem); }
.nav a {
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--ink-2);
  padding: 0.5rem 0;
}
.nav a:hover, .nav a[aria-current='page'] { color: var(--ink); }
.nav a[aria-current='page'] { box-shadow: inset 0 -1px 0 var(--accent); }

.head-tools { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
:root[data-theme='dark'] .theme-toggle .moon,
:root:not([data-theme='light']) .theme-toggle .moon { display: block; }
:root[data-theme='dark'] .theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle .sun { display: none; }
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme='dark']) .theme-toggle .moon { display: none; }
  :root:not([data-theme='dark']) .theme-toggle .sun { display: block; }
}

.nav-toggle { display: none; }

@media (max-width: 760px) {
  .nav-toggle { display: grid; }
  .nav {
    position: fixed;
    inset: 4.25rem 0 auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    padding: 0.5rem var(--pad-x) 1.5rem;
    transform: translateY(-120%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow);
  }
  .nav[data-open='true'] { transform: translateY(0); }
  .nav a {
    font-size: 1.25rem;
    font-family: var(--serif);
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--rule);
    color: var(--ink);
  }
}

/* --- hero -------------------------------------------------------------- */

.hero { padding-block: clamp(3rem, 8vw, 7rem) clamp(2.5rem, 6vw, 5rem); }
.hero h1 {
  max-width: 20ch;
  /* a full-bleed highlight needs the line box to be at least as tall as the
     glyphs, otherwise the yellow block overlaps the descenders of the line above */
  line-height: 1.16;
}
/* Yellow can carry text only as a fill. Ink on the brand yellow is 15:1 in
   both themes, whereas yellow text on paper would be 1.18:1. */
.hero h1 em {
  font-style: italic;
  background: var(--highlight);
  color: var(--on-highlight);
  padding: 0.02em 0.14em 0.06em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.hero__grid {
  display: grid;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: end;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .hero__grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); }
}
.hero__aside {
  border-top: 1px solid var(--rule);
  padding-top: 1.5rem;
}
.hero__portrait {
  width: 100%;
  max-width: 190px;
  border-radius: 50%;
  filter: grayscale(1) contrast(1.05);
  margin-bottom: 1.5rem;
}
.hero__stats {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-2);
}
.hero__stats div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--rule); padding: 0.4rem 0; }
.hero__stats dt { font-weight: 500; color: var(--ink); }
.hero__stats dd { margin: 0; text-align: right; }

/* --- section furniture -------------------------------------------------- */

.sec { padding-block: var(--sec-y); }
.sec--rule { border-top: 1px solid var(--rule); }
/* the hero already carries bottom padding: don't stack two section gaps */
.hero + .sec:not(.sec--rule) { padding-top: 0; }

.sec-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: clamp(2rem, 4vw, 3rem);
}
.sec-head h2 { font-size: var(--step-3); }

.count {
  font-size: var(--step--1);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* --- work grid ---------------------------------------------------------- */

.work-grid {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.5rem) var(--gap);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .work-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1040px) { .work-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  border-top: 1px solid var(--ink);
  padding-top: 1rem;
}
.card__shot {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius);
  aspect-ratio: 37 / 40;
  margin-bottom: 1rem;
}
.card__shot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1), filter 0.4s ease;
}
.card:hover .card__shot img { transform: scale(1.035); }
.card__idx {
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.card h3 {
  font-size: var(--step-2);
  margin: 0.35rem 0 0.5rem;
  transition: color 0.18s ease;
}
.card:hover h3 { color: var(--accent); }
.card__meta {
  font-size: var(--step--1);
  color: var(--ink-2);
  margin: 0 0 0.9rem;
}
.card__tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: auto; }

.tag {
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
}

/* --- pills (delivered / proposed) --------------------------------------- */

/* Standalone marker. Only used where a full text column is available, never
   inside a narrow grid cell: a bordered chip cannot shrink below its label. */
.pill {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  max-width: 100%;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  text-wrap: balance;
}
.pill::before {
  content: '';
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  transform: translateY(-1px);
}
.pill--done {
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.pill--proposed {
  color: var(--ink-2);
  border: 1px dashed var(--edge);
}
.pill--proposed::before { background: transparent; box-shadow: inset 0 0 0 1px currentColor; }

/* Compact status: a dot and text that wraps. Safe in any column width. */
.status {
  display: grid;
  grid-template-columns: 0.5rem 1fr;
  align-items: start;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.45;
}
.status__dot {
  width: 6px;
  height: 6px;
  margin-top: 0.32rem;
  border-radius: 50%;
}
.status.is-done { color: var(--accent); }
.status.is-done .status__dot { background: currentColor; }
.status.is-proposed { color: var(--ink-2); }
.status.is-proposed .status__dot { box-shadow: inset 0 0 0 1px currentColor; }

/* --- process map -------------------------------------------------------- */

/* Separate cards rather than one seamless table: when the phases wrap onto a
   second row the leftover cell stays empty, and empty cells should read as
   space, not as a blank sixth phase. */
.process {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
/* Only go to five columns once each one can actually hold a phase. Between
   those widths the grid steps down rather than squeezing the content. */
@media (min-width: 560px) { .process { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 860px) { .process { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1180px) { .process { grid-template-columns: repeat(5, minmax(0, 1fr)); } }

.phase {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.15rem 1.15rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}
.phase__n {
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.phase h3 {
  font-size: 1.0625rem;
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.25;
  text-wrap: balance;
}
.phase ul {
  margin: 0.15rem 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--ink-2);
}
.phase ul li {
  position: relative;
  padding-left: 0.95rem;
}
.phase ul li + li { margin-top: 0.35rem; }
.phase ul li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
}
.phase ul li.is-done::before { background: var(--accent); }
.phase ul li.is-proposed::before { box-shadow: inset 0 0 0 1px var(--rule-strong); }
.phase ul li em { font-style: italic; }
.phase--proposed { background: var(--surface-2); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.75rem;
  font-size: var(--step--1);
  color: var(--ink-2);
  margin-top: 1rem;
}
.legend__item {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.6rem;
}
.legend .status { flex: none; }

/* --- filters ------------------------------------------------------------ */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 2rem 0 2.5rem;
}
.filter {
  min-height: 44px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}
.filter:hover { color: var(--ink); border-color: var(--rule-strong); }
.filter[aria-pressed='true'] {
  color: var(--on-highlight);
  background: var(--highlight);
  border-color: var(--highlight-edge);
}
/* Size, not opacity, makes this secondary. Dimming with opacity would drop the
   count to 2.8:1 and no automated contrast check would catch it, because
   getComputedStyle reports the colour before the parent's opacity applies. */
.filter__n {
  font-variant-numeric: tabular-nums;
  font-size: 0.75rem;
  margin-left: 0.2rem;
}

/* card tags double as filter shortcuts */
.card .tag {
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
}
.card .tag:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- facts list --------------------------------------------------------- */

.facts {
  display: grid;
  gap: 0;
  margin: clamp(2rem, 4vw, 3rem) 0 0;
  border-top: 1px solid var(--rule);
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gap); } }
@media (min-width: 1040px) { .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.facts > div {
  border-bottom: 1px solid var(--rule);
  padding: 0.85rem 0;
}
.facts dt {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 0.25rem;
}
.facts dd { margin: 0; font-size: 0.9375rem; }
/* a fact value that is only a link is a standalone target, not an inline one:
   grow the hit area to 44px without changing the layout */
.facts dd a {
  display: inline-block;
  padding-block: 0.7rem;
  margin-block: -0.7rem;
}

/* --- case study layout -------------------------------------------------- */

.cs-hero { padding-block: clamp(2.5rem, 6vw, 5rem) clamp(2rem, 4vw, 3rem); }
.cs-hero h1 { max-width: 24ch; margin-bottom: 1.25rem; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 44px;
  padding-right: 0.5rem;
  font-size: var(--step--1);
  color: var(--ink-2);
  text-decoration: none;
  margin-bottom: 1rem;
}
.back:hover { color: var(--accent); }

.cs-layout { display: grid; gap: clamp(2.5rem, 5vw, 4.5rem); grid-template-columns: 1fr; }
@media (min-width: 1080px) {
  .cs-layout { grid-template-columns: 12.5rem minmax(0, 1fr); }
}

.cs-rail { display: none; }
@media (min-width: 1080px) {
  .cs-rail {
    display: block;
    align-self: start;
    position: sticky;
    top: 6.5rem;
    font-size: var(--step--1);
  }
}
.cs-rail p {
  font-size: 0.6875rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
}
.cs-rail ol { list-style: none; margin: 0; padding: 0; counter-reset: r; }
.cs-rail li { counter-increment: r; }
.cs-rail a {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.25rem;
  padding: 0.4rem 0;
  color: var(--ink-2);
  text-decoration: none;
  border-top: 1px solid var(--rule);
  line-height: 1.35;
}
.cs-rail a::before { content: counter(r, decimal-leading-zero); font-variant-numeric: tabular-nums; }
.cs-rail a:hover { color: var(--ink); }
.cs-rail a[data-active='true'] { color: var(--accent); }

.cs-main > .cs-sec + .cs-sec { margin-top: clamp(3rem, 6vw, 5.5rem); }

.cs-sec { scroll-margin-top: 6rem; }
.cs-sec__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--ink);
}
.cs-sec__head h2 { font-size: var(--step-3); }
.cs-sec__n {
  font-size: 0.6875rem;
  letter-spacing: 0.16em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

/* --- figures ------------------------------------------------------------ */

figure { margin: clamp(1.75rem, 3vw, 2.5rem) 0 0; }
figure img {
  width: 100%;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2);
}
figcaption {
  font-size: var(--step--1);
  color: var(--ink-2);
  margin-top: 0.6rem;
  max-width: 62ch;
}
figcaption b { color: var(--ink); font-weight: 500; }

.fig-pair {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .fig-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fig-pair figure { margin-top: 0; }

.fig-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

/* full-page screenshots: cap the height, let them scroll in place */
.fig-tall .shot-frame {
  max-height: 78vh;
  overflow-y: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface-2);
  overscroll-behavior: contain;
}
.fig-tall .shot-frame img { border: 0; border-radius: 0; }

.zoom {
  display: block;
  cursor: zoom-in;
  border: 0;
  padding: 0;
  background: none;
  width: 100%;
}

/* --- content blocks ----------------------------------------------------- */

.callout {
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  padding: 1.15rem 1.35rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: clamp(1.5rem, 3vw, 2rem) 0 0;
  max-width: var(--measure);
}
.callout .eyebrow { margin-bottom: 0.5rem; color: var(--accent); }

.split {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
  margin-top: clamp(1.5rem, 3vw, 2rem);
}
@media (min-width: 760px) { .split { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.panel {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem 1.5rem;
  background: var(--surface);
}
.panel h3 {
  font-family: var(--sans);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: 0;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.panel h3::before {
  content: '';
  width: 1.35rem;
  height: 1px;
  background: var(--rule-strong);
}

.findings { list-style: none; margin: 0; padding: 0; }
.findings > li { padding: 0.85rem 0; border-top: 1px solid var(--rule); }
.findings > li:first-child { border-top: 0; padding-top: 0; }
.findings b { display: block; font-weight: 600; font-size: 0.9375rem; }
.findings p { margin: 0.3rem 0 0; font-size: 0.9375rem; color: var(--ink-2); }
.findings .ref {
  display: inline-block;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
  margin-top: 0.45rem;
}
.findings .fix {
  margin-top: 0.5rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--accent);
  font-size: 0.9375rem;
}
.findings .fix b { color: var(--accent); font-size: 0.6875rem; letter-spacing: 0.1em; text-transform: uppercase; }

.bullets { margin: 0; padding-left: 1.15em; max-width: var(--measure); }
.bullets li + li { margin-top: 0.4rem; }

.quotes { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.quotes li {
  font-family: var(--serif);
  font-size: var(--step-2);
  line-height: 1.25;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--rule);
}
.quotes li::before { content: '“'; color: var(--accent); }
.quotes li::after { content: '”'; color: var(--accent); }

/* --- skills / certificates --------------------------------------------- */

.cols {
  display: grid;
  gap: clamp(1.75rem, 4vw, 3rem) var(--gap);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
}
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.chips li {
  font-size: 0.875rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  color: var(--ink-2);
}

.certs { list-style: none; margin: 0; padding: 0; }
.certs li {
  display: grid;
  gap: 0.35rem 1.25rem;
  grid-template-columns: 1fr;
  padding: 1.1rem 0;
  border-top: 1px solid var(--rule);
}
@media (min-width: 760px) {
  .certs li { grid-template-columns: 4.5rem minmax(0, 1fr) 9rem; align-items: center; }
}
.certs img { max-height: 30px; width: auto; filter: grayscale(1); opacity: 0.85; }
.certs b { font-weight: 500; font-size: 0.9375rem; }
.certs .who { font-size: var(--step--1); color: var(--ink-2); }
.certs .when { font-size: var(--step--1); color: var(--ink-2); font-variant-numeric: tabular-nums; }
@media (min-width: 760px) { .certs .when { text-align: right; } }

/* --- next project / footer ---------------------------------------------- */

.next {
  border-top: 1px solid var(--ink);
  margin-top: var(--sec-y);
  padding-block: clamp(2rem, 5vw, 3.5rem);
}
.next a {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  text-decoration: none;
}
.next h2 { font-size: var(--step-3); }

.site-foot {
  border-top: 1px solid var(--rule);
  padding-block: clamp(2.5rem, 5vw, 4rem) 2rem;
  font-size: 0.9375rem;
}
.foot-grid {
  display: grid;
  gap: clamp(1.75rem, 4vw, 3rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
}
.site-foot h2 { font-size: var(--step-2); margin-bottom: 0.5rem; }
.site-foot p { color: var(--ink-2); }
.site-foot ul { list-style: none; margin: 0; padding: 0; }
.site-foot li + li { margin-top: 0.35rem; }
.site-foot .eyebrow { margin-bottom: 0.75rem; }
.foot-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
  margin-top: clamp(2rem, 4vw, 3rem);
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
  font-size: var(--step--1);
  color: var(--ink-2);
}

/* --- lightbox ----------------------------------------------------------- */

dialog.lb {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100%;
  height: 100%;
}
dialog.lb::backdrop { background: rgb(12 11 10 / 92%); }
.lb__in {
  display: grid;
  place-items: start center;
  height: 100%;
  overflow: auto;
  padding: clamp(1rem, 4vw, 3rem);
}
.lb__in img { max-width: min(1200px, 100%); border-radius: var(--radius); }
.lb__close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2;
  background: var(--bg);
}

/* --- motion / print ----------------------------------------------------- */

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

@media print {
  .site-head, .cs-rail, .next, .theme-toggle, .nav-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .fig-tall .shot-frame { max-height: none; overflow: visible; }
}
