/* Portfolio, dark "grid" version (spec: portfolio-design-tokens.md, 2026-11-04).
 *
 * Desktop: the content is a 12-column grid of square cells. The design is drawn
 * at 1440px (120px cells); everything is sized in --px, one design pixel. The
 * scale is the smaller of "12 cells fill the width" and "the 8-row hero fills
 * the viewport height", so the hero (and its Contact button) always fits on
 * screen. When the height wins, the content stays centered and the background
 * grid keeps going to the left and right, aligned with the content's cells.
 * Phones (< 900px): a 4-column grid; blocks stack and snap to whole cells
 * (main.js sets --rows on [data-snap] blocks whose height depends on text).
 */

/* Geist Serif isn't on Google Fonts yet; self-hosted from the geist npm
   package 1.9.2 (OFL, assets/fonts/LICENSE-Geist.txt). */
@font-face {
  font-family: "Geist Serif";
  src: url("assets/fonts/GeistSerifVF.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --color-page: #121212;
  --color-cell-highlight: #1f1f1f;
  --color-grid-line: transparent; /* grid hidden; corner handles replace it (was #272727) */
  --color-white-pure: #ffffff;
  --color-accent-green: #09fd42;
  --color-text-muted: #b8b8b8;
  --color-text-label: #626161;
  --color-placeholder-number: #3c3c3c;

  --font-display: var(--font-serif); /* was "Geist", system-ui, sans-serif */
  --font-mono: "Geist Mono", ui-monospace, monospace;
  --font-serif: "Geist Serif", Georgia, serif;
  --font-sans: "Geist", system-ui, sans-serif;

  color-scheme: dark;
}

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

html { background: var(--color-page); }

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-white-pure);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ol { margin: 0; }
ol { padding: 0; list-style: none; }
img, svg { display: block; }
a { color: inherit; }

/* ---------- Page grid ---------- */

.page {
  container-type: inline-size;
  position: relative;
  overflow-x: clip;
  /* Unregistered custom properties resolve where they're used, so 100cqw
     is measured against .page by every descendant. */
  --px: min(calc(100cqw / 1440), calc(100svh / 960));
  --cell: calc(120 * var(--px));
  /* Side fade: the grid outside the 12 content columns fades out toward the
     window edges, so cut squares at the edges never show. */
  --side: calc((100cqw - 12 * var(--cell)) / 2);
  --side-fade: linear-gradient(90deg,
    transparent 0,
    #000 var(--side),
    #000 calc(100cqw - var(--side)),
    transparent 100cqw);
}

.page-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--color-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-grid-line) 1px, transparent 1px);
  background-size: var(--cell) var(--cell);
  /* align the lines with the centered content's columns */
  background-position: calc((100cqw - 12 * var(--cell)) / 2) 0;
  -webkit-mask-image: var(--side-fade);
  mask-image: var(--side-fade);
  pointer-events: none;
}

.section {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, var(--cell));
  grid-auto-rows: var(--cell);
  width: calc(12 * var(--cell));
  margin-inline: auto;
}

/* Spacing between blocks, in whole rows.
   .gap   = the 2-row section gap: 1 row of squares, then a "flat band" (page
            color, lines on its top and bottom edges only, full width) right
            above the block.
   .space = 1 empty row of squares. */
.gap { margin-top: calc(2 * var(--cell)); }
.space { margin-top: var(--cell); }
.gap::before {
  content: "";
  position: absolute;
  top: calc(-1 * var(--cell));
  left: calc((12 * var(--cell) - 100cqw) / 2);
  width: 100cqw;
  height: var(--cell);
  background: var(--color-page);
  box-shadow: inset 0 1px var(--color-grid-line), inset 0 -1px var(--color-grid-line);
  /* the band spans the window like the grid, so its lines fade the same way */
  -webkit-mask-image: var(--side-fade);
  mask-image: var(--side-fade);
  pointer-events: none;
}

/* Placement helper for case-study cells: style="--c: 2 / 9; --r: 1" */
.g { grid-column: var(--c); grid-row: var(--r, auto); }

.highlight,
.heading,
.hero-line,
.hero-subtext,
.cta-line { background: var(--color-cell-highlight); }

/* Clear blocks (MK graphic, name): page color, no grid lines inside, but
   the neighbours' lines stay on the top and left edges. */
.hero-name,
.mk {
  background: var(--color-page);
  border-top: 1px solid var(--color-grid-line);
  border-left: 1px solid var(--color-grid-line);
}
.mk { overflow: hidden; }
.mk img { width: 100%; height: 100%; object-fit: fill; }

/* Section headings (Display: Geist Bold 148/121/-4%) */
.heading {
  display: flex;
  align-items: center;
  grid-row: 1;
  font: 400 calc(148 * var(--px)) / var(--cell) var(--font-display);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Buttons: default highlight with green label; hover/focus inverts */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-cell-highlight);
  color: var(--color-accent-green);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
/* Hover styles live in @media (hover: hover) so a tap on a phone doesn't
   leave them stuck on. */
.btn:active,
.btn:focus-visible {
  background: var(--color-accent-green);
  color: var(--color-cell-highlight);
}
@media (hover: hover) {
  .btn:hover { background: var(--color-accent-green); color: var(--color-cell-highlight); }
}
.btn svg { flex: none; fill: currentColor; }

:focus-visible {
  outline: 2px solid var(--color-white-pure);
  outline-offset: 2px;
}
.btn:focus-visible { outline-offset: -4px; outline-color: var(--color-cell-highlight); }

/* ---------- Hero: rows 1–8 ---------- */

.hero { grid-template-rows: repeat(8, var(--cell)); }

.hero-logo {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  color: var(--color-white-pure);
}
.hero-logo svg { width: calc(52 * var(--px)); height: auto; }

.hero-name {
  grid-column: 2 / 5;
  grid-row: 1;
  display: flex;
  align-items: center;
  padding-left: calc(34 * var(--px));
  font-size: calc(28 * var(--px));
  font-weight: 300;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.phone-only,
.phone-block { display: none !important; } /* shown below 900px; .desktop-only is the opposite */
a.hero-name { text-decoration: none; } /* case studies: the name links home */
@media (hover: hover) { a.hero-name:hover { color: var(--color-accent-green); } }

.hero-nav { display: contents; }
.hero-nav a {
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(20 * var(--px));
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  transition: color 0.15s ease;
}
@media (hover: hover) { .hero-nav a:hover { color: var(--color-accent-green); } }
.hero-nav a:nth-child(1) { grid-column: 9; }
.hero-nav a:nth-child(2) { grid-column: 10; }
.hero-nav a:nth-child(3) { grid-column: 11; }
.hero-nav a:nth-child(4) { grid-column: 12; }

.hero-headline {
  grid-column: 1 / -1;
  grid-row: 2 / 5;
  display: grid;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
  font: 400 calc(148 * var(--px)) / var(--cell) var(--font-serif); /* Geist Serif has one weight */
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.hero-line {
  position: relative;
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.hero-line--1 { grid-column: 2 / 8; grid-row: 1; } /* cols 2–7 */
.hero-line--2 { grid-column: 2 / 9; grid-row: 2; } /* cols 2–8 */
.hero-line--3 { grid-column: 2 / 7; grid-row: 3; } /* cols 2–6 */
.hero-amp {
  position: absolute;
  left: calc(723 * var(--px)); /* 3px into cell 8 */
  color: rgb(9 253 66 / 0.4);
}

.hero-subtext {
  grid-column: 2 / 6;
  grid-row: 5;
  display: flex;
  align-items: center;
  padding-left: calc(34 * var(--px));
  font-size: calc(20 * var(--px));
  line-height: 1.2857;
}
.hero-subtext p { width: calc(410 * var(--px)); }

.hero-button {
  grid-column: 2 / 5;
  grid-row: 7;
  gap: calc(20 * var(--px));
  font-size: calc(36 * var(--px));
  font-weight: 700;
  letter-spacing: -0.04em;
}
.hero-button-arrow { width: calc(60 * var(--px)); height: auto; overflow: visible; }

.hero-mk { grid-column: 9 / 13; grid-row: 5 / 8; }

/* ---------- Selected Work: rows 11–16 ---------- */

.work { grid-template-rows: repeat(6, var(--cell)); }
/* The hero's last row (8) is already a row of empty squares, so this gap
   only needs the flat band: 1 row of squares + 1 band. (Desktop only: on
   phones the hero ends with the MK graphic, so the full gap stays.) */
@media (min-width: 900px) {
  .hero + main > .work.gap { margin-top: var(--cell); }
}
.work-heading { grid-column: 2 / 12; }

.card {
  grid-row: 3 / 7;
  display: grid;
  grid-template-rows: calc(3 * var(--cell)) var(--cell);
}
.card--1 { grid-column: 2 / 6; }
.card--2 { grid-column: 7 / 11; }

.card-image { background: var(--color-cell-highlight); overflow: hidden; } /* clips zoomed images */
.card-image img { width: 100%; height: 100%; object-fit: cover; }

.card-text {
  display: flex;
  flex-direction: column;
  justify-content: flex-start; /* top-anchored so titles/descriptions line up across cards even if one wraps */
  gap: calc(10 * var(--px));
  padding: calc(28 * var(--px)) calc(16 * var(--px)) 0; /* 28 = (120 - 36 title - 10 gap - 18 desc) / 2 */
  background: var(--color-cell-highlight);
  box-shadow: inset 0 1px var(--color-grid-line), inset 0 -1px var(--color-grid-line);
  letter-spacing: -0.02em;
}
.card-title { font-size: calc(28 * var(--px)); font-weight: 700; line-height: 1.2857; }
.card-desc { font-size: calc(14 * var(--px)); line-height: 1.2857; color: var(--color-text-muted); }
.card { position: relative; }
.card-link {
  color: var(--color-accent-green);
  text-decoration: none;
}
/* Whole card is the click target */
.card-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.card-arrow {
  display: inline-block;
  margin-left: 0.25em;
  font-weight: 400;
  transition: transform 0.24s steps(4, end);
}
@media (hover: hover) {
  .card:hover .card-link { text-decoration: underline; text-underline-offset: 0.15em; text-decoration-thickness: 2px; }
  .card:hover .card-arrow { transform: translate(0.12em, -0.12em); }
}
.card-link:focus-visible { outline: 2px solid var(--color-accent-green); outline-offset: 4px; }

/* ---------- Timeline: rows 19–28 ---------- */

.timeline { grid-template-rows: repeat(10, var(--cell)); }
.timeline-heading { grid-column: 2 / 8; }

.tl-list {
  grid-column: 1 / -1;
  grid-row: 3 / 11;
  display: grid;
  grid-template-columns: subgrid;
  grid-template-rows: subgrid;
}
.tl-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
}

.tl-year,
.tl-desc {
  display: flex;
  align-items: center;
  background: var(--color-cell-highlight);
  /* one shared 1px line between rows; the last row also closes at the bottom */
  box-shadow: inset 0 1px var(--color-grid-line);
}
.tl-row:last-child > * {
  box-shadow: inset 0 1px var(--color-grid-line), inset 0 -1px var(--color-grid-line);
}

.tl-year {
  grid-column: 2 / 5;
  justify-content: center;
  overflow: hidden;
  font-size: calc(148 * var(--px));
  font-weight: 200;
  line-height: var(--cell);
  letter-spacing: -0.04em;
  color: rgb(9 253 66 / calc(0.2 + 0.05 * var(--i))); /* 20% → 55% */
}

.tl-desc {
  grid-column: 6 / 12;
  padding: 0 calc(16 * var(--px));
  font-size: calc(28 * var(--px));
  font-weight: 500;
  line-height: 1.2857;
  letter-spacing: -0.02em;
  color: var(--color-text-muted);
  text-wrap: balance; /* even line lengths, no single word left on the last line */
}

/* ---------- About Me: rows 31–38 ---------- */

.about { grid-template-rows: repeat(8, var(--cell)); }
.about-heading { grid-column: 2 / 8; letter-spacing: -0.05em; }

.about-text {
  grid-column: 2 / 8;
  grid-row: 3 / span 6;
  padding: calc(8 * var(--px));
  background: var(--color-cell-highlight);
  font-size: calc(18 * var(--px));
  line-height: calc(23 * var(--px));
  letter-spacing: -0.02em;
  color: var(--color-text-muted);
}
.about-text p + p { margin-top: calc(23 * var(--px)); }
.about-text strong { font-weight: 700; color: var(--color-white-pure); }

.about-picture {
  overflow: hidden; /* clips zoomed images */
  grid-column: 9 / 13;
  grid-row: 3 / span 4;
  background: var(--color-cell-highlight) center / cover no-repeat;
}
.about-picture img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Contact CTA: rows 41–42 ---------- */

.contact { grid-template-rows: repeat(2, var(--cell)); }

.cta-line {
  display: flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--cell);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.cta-line--1 { grid-column: 2 / 10; grid-row: 1; font-size: calc(96 * var(--px)); }
.cta-line--2 { grid-column: 2 / 12; grid-row: 2; font-size: calc(101 * var(--px)); }
.cta-line a { text-decoration: none; transition: color 0.15s ease; }
@media (hover: hover) { .cta-line a:hover { color: var(--color-accent-green); } }

.cta-arrow { grid-column: 11; grid-row: 1; width: 100%; height: 100%; }

/* ---------- Footer: 3 rows (main page rows 44–46), shared by every page ---------- */

.site-footer { grid-template-rows: repeat(3, var(--cell)); }

.cta-btn {
  gap: calc(24 * var(--px));
  font-size: calc(18 * var(--px));
  letter-spacing: -0.02em;
  /* lines on the top and left of every button; outer edges closed below */
  box-shadow: inset 1px 1px var(--color-grid-line);
}
.cta-btn--top      { grid-column: 2 / 4; grid-row: 1; font-weight: 600;
                     box-shadow: inset 1px 1px var(--color-grid-line), inset -1px 0 var(--color-grid-line); }
.cta-btn--github   { grid-column: 2 / 4; grid-row: 2; }
.cta-btn--x        { grid-column: 4 / 6; grid-row: 2; gap: calc(24 * var(--px)); }
.cta-btn--linkedin { grid-column: 6 / 8; grid-row: 2;
                     box-shadow: inset 1px 1px var(--color-grid-line), inset -1px -1px var(--color-grid-line); }
.cta-btn--github,
.cta-btn--x { box-shadow: inset 1px 1px var(--color-grid-line), inset 0 -1px var(--color-grid-line); }
.cta-btn--github svg,
.cta-btn--linkedin svg { width: calc(24 * var(--px)); height: calc(24 * var(--px)); }
.cta-btn--x svg { width: calc(16 * var(--px)); height: calc(16 * var(--px)); }

.cta-footer {
  grid-column: 2 / 8;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: calc(16 * var(--px));
  padding-left: calc(52 * var(--px));
  font-size: calc(18 * var(--px));
  line-height: 1.2857;
  letter-spacing: -0.02em;
  color: var(--color-text-muted);
  /* hide the grid lines behind the credit, but keep its left edge so the
     square outside it (column 1) stays closed */
  background: var(--color-page);
  box-shadow: inset 1px 0 var(--color-grid-line);
}
.cta-footer strong { font-weight: 600; color: var(--color-white-pure); }

.cta-mk { grid-column: 8 / 12; grid-row: 1 / 4; }

/* ---------- Case-study pages (spec: "Case Study Page (template)") ----------
   Same grid, nav and footer as the main page. Cells are placed with .g. */

.cs-page .site-footer { margin-bottom: var(--cell); } /* one empty row at the end */

.cs-heading {
  display: flex;
  align-items: center;
  margin: 0;
  background: var(--color-cell-highlight);
  font: 400 calc(124 * var(--px)) / var(--cell) var(--font-display);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}
.unit { text-transform: none; } /* units stay lowercase in uppercase headings: 440px, not 440PX */
.cs-heading--sm { font-size: calc(112 * var(--px)); } /* was 116 with Geist Bold */

.cs-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0;
  padding: 0 calc(16 * var(--px));
  background: var(--color-cell-highlight);
  box-shadow: inset 0 1px var(--color-grid-line), inset 0 -1px var(--color-grid-line);
  font-size: calc(20 * var(--px));
  line-height: 1.3;
  font-weight: 400;
  color: var(--color-text-muted);
}

.cs-label { color: var(--color-text-label); text-transform: uppercase; }
.cs-white { color: var(--color-white-pure); }
.cs-body { font-weight: 500; letter-spacing: -0.02em; }

.cs-meta {
  justify-content: flex-start;
  gap: calc(8 * var(--px));
  padding-top: calc(16 * var(--px));
  color: var(--color-white-pure);
}

/* Duration (row 1, cols 10–11) and Deliverables (row 2, cols 7–11) read as one
   L-shaped box: no line where they meet. */
.cs-meta--top { box-shadow: inset 0 1px var(--color-grid-line); }
.cs-meta--bottom { box-shadow: inset 0 -1px var(--color-grid-line); }

.cs-pillar-label { padding-left: calc(60 * var(--px)); }
.cs-pillar-body { font-size: calc(16 * var(--px)); }

.cs-item-title {
  font-size: calc(24 * var(--px));
  font-weight: 700;
  color: var(--color-white-pure); /* like the bold words in About me */
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.cs-small { font-size: calc(18 * var(--px)); letter-spacing: -0.02em; }
.cs-small a { color: var(--color-accent-green); text-decoration: none; }
@media (hover: hover) { .cs-small a:hover { text-decoration: underline; text-underline-offset: 0.15em; } }

.cs-special {
  justify-content: flex-start;
  padding-top: calc(16 * var(--px));
}
.cs-special p + p { margin-top: calc(26 * var(--px)); }
.cs-special strong { font-weight: 700; color: var(--color-white-pure); }

.cs-stat {
  font-size: calc(120 * var(--px));
  font-weight: 300;
  line-height: calc(111 * var(--px));
  letter-spacing: -0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.cs-next-link {
  font-size: calc(120 * var(--px));
  font-weight: 300;
  line-height: calc(111 * var(--px));
  letter-spacing: -0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-white-pure);
  text-decoration: none;
  transition: color 0.15s ease;
}
@media (hover: hover) { .cs-next-link:hover { color: var(--color-accent-green); } }

/* Image slots: placeholder cells with a centered number until real images exist */
.cs-image {
  display: grid;
  place-items: center;
  margin: 0;
  overflow: hidden;
  background: var(--color-cell-highlight);
  font-size: calc(120 * var(--px));
  font-weight: 300;
  color: var(--color-placeholder-number);
}
.cs-image img { width: 100%; height: 100%; object-fit: cover; }
/* Recordings show whole: their #1f1f1f backdrop matches the slot, so the
   letterbox space blends in instead of cropping the UI. */
.cs-image video { display: block; width: 100%; height: 100%; object-fit: contain; }

/* ---------- Phones: 4-column grid, stacked blocks ---------- */

@media (max-width: 899px) {
  .page {
    --cell: calc(100cqw / 4);
    --inset: 12px;
  }

  .section {
    width: auto;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
  }
  .section > *,
  .tl-list,
  .tl-row { width: 100%; height: var(--cell); }
  .gap { margin-top: var(--cell); } /* phones: 1-row section breaks */
  .desktop-only { display: none; }
  .phone-only { display: inline !important; }
  .phone-block { display: flex !important; }
  /* Duration / Role / Deliverables: full-width blocks' corner handles sit
     half off-screen, so a 2px page-colour line marks the split */
  .cs-intro .cs-meta + .cs-meta { border-top: 2px solid var(--color-page); }
  .gap::before { left: 0; }

  /* Blocks whose height depends on their text grow in whole cells */
  [data-snap] { height: calc(var(--rows, 1) * var(--cell)) !important; }

  .heading {
    padding-inline: var(--inset);
    font-size: 15.5cqw;
    white-space: normal;
  }

  /* Hero */
  .hero-logo { width: var(--cell); }
  .hero-logo svg { width: 36%; }
  .hero-name {
    width: calc(3 * var(--cell));
    padding-left: var(--inset);
    font-size: clamp(14px, 4.4cqw, 28px);
  }
  .hero-nav { display: flex; }
  .hero-nav a { width: var(--cell); font-size: clamp(12px, 3.6cqw, 20px); }

  .hero-headline {
    display: block;
    height: auto !important;
    /* Widest line ("Designer &") is ~5.6em wide: size it to fill the row minus the side insets */
    font-size: calc((100cqw - 2 * var(--inset)) / 5.65);
  }
  .hero-line { height: var(--cell); padding-inline: var(--inset); }
  .hero-line--3 { width: calc(3 * var(--cell)); }
  .hero-amp { position: static; margin-left: 0.2em; }

  .hero-subtext {
    padding: 0 var(--inset);
    font-size: clamp(15px, 4.2cqw, 20px);
  }
  .hero-subtext p { width: auto; }

  .hero-button {
    width: calc(3 * var(--cell));
    gap: 0.5em;
    font-size: clamp(20px, 6.2cqw, 36px);
  }
  .hero-button-arrow { width: 1.7em; }

  .mk { height: calc(3 * var(--cell)); margin-top: var(--cell); }
  .cta-mk { display: none; } /* the hero already shows the MK on phones */
  body { padding-bottom: var(--bar-h, 44px); } /* the footer clears the docked key bar */

  /* Selected Work */
  .card {
    display: block;
    height: auto !important;
    margin-top: var(--cell);
  }
  .card + .card { margin-top: var(--cell); }
  .card-image { height: calc(3 * var(--cell)); }
  .card-text { height: var(--cell); gap: 6px; padding: 0 var(--inset); justify-content: center; }
  .card-title { font-size: clamp(17px, 5.2cqw, 28px); }
  .card-desc { font-size: clamp(12px, 3.3cqw, 14px); }

  /* Timeline */
  .tl-list { display: block; height: auto; }
  .tl-row { display: flex; }
  .tl-year,
  .tl-desc { height: 100%; }
  .tl-year { width: calc(2 * var(--cell)); font-size: 14.5cqw; line-height: 1; }
  .tl-desc {
    width: calc(2 * var(--cell));
    padding: 8px;
    /* whole pixels: a fractional line height (16.55px) rounds to 16/17px rows and looks uneven */
    font-size: round(clamp(12px, 3.3cqw, 16px), 1px);
    line-height: round(1.2857em, 1px);
  }

  /* About */
  .about-heading { letter-spacing: -0.05em; }
  .about-text {
    padding: var(--inset);
    font-size: 14px;
    line-height: 20px;
  }
  .about-text p + p { margin-top: 20px; }
  .about-picture { height: calc(4 * var(--cell)); margin-top: var(--cell); }

  /* Contact */
  .cta-line { padding-inline: var(--inset); }
  .cta-line--1 { font-size: 9cqw; }
  .cta-line--2 { font-size: 8cqw; }
  .cta-arrow { display: none; }

  .cta-btn {
    width: calc(2 * var(--cell));
    gap: 10px;
    font-size: clamp(13px, 3.6cqw, 18px);
    box-shadow: inset 1px 1px var(--color-grid-line) !important;
  }
  .cta-btn--github svg,
  .cta-btn--linkedin svg,
  .cs-repo svg { width: 20px; height: 20px; }
  .cs-outcome > .cs-repo { width: 100%; } /* full row, unlike the half-width footer buttons */
  .cta-btn--x svg { width: 14px; height: 14px; }

  .cta-footer {
    padding: 0 var(--inset);
    gap: 8px;
    font-size: clamp(12px, 3.3cqw, 18px);
  }

  /* Case-study pages */
  .cs-heading {
    padding-inline: var(--inset);
    font-size: 12.5cqw;
    white-space: normal;
  }
  .cs-cell { padding: var(--inset); font-size: 15px; }
  .cs-pillar-body,
  .cs-small { font-size: 14px; }
  .cs-item-title { font-size: 17px; }
  /* A label and the text under it share one block: the label sits at the top
     and the text block (snapped by main.js together with it) fills the rest. */
  /* Tight padding so a title + 3 lines fits one 97.5px block (390px phone) */
  .cs-pillar-label,
  .cs-item-title { height: auto !important; padding-top: 10px; padding-bottom: 0; line-height: 1.2; }
  .cs-pillar-label + .cs-pillar-body,
  .cs-item-title + .cs-small {
    justify-content: flex-start;
    padding-top: 4px;
    padding-bottom: 8px;
    height: calc(var(--rows, 1) * var(--cell) - var(--lead, 0px)) !important;
  }
  .cs-pillar-label { box-shadow: inset 0 1px var(--color-grid-line); }
  /* Outcome: the stat (OPEN SOURCE / 85+) and its text are one block */
  .cs-outcome > .cs-stat {
    height: auto !important;
    padding-top: 24px; padding-bottom: 0; /* the block has room to spare, so breathe */
    /* the result reads as a big number, same size and weight as the
       "Next project" link (sized for 14 chars, e.g. "VISUAL BRAIN ↗") */
    font-size: calc((100cqw - 2 * var(--inset)) / (14 * 0.585));
    font-weight: 300; line-height: 1.1; color: var(--color-white-pure);
  }
  .cs-outcome > .cs-stat ~ .cs-small {
    justify-content: flex-start;
    padding-top: 16px;
    padding-bottom: 8px;
    height: calc(var(--rows, 1) * var(--cell) - var(--lead, 0px)) !important;
  }
  .cs-outcome > .cs-stat ~ .cs-small p + p { margin-top: 12px; } /* the repo link */
  /* "Next project" sits in the same block as the link, like CAPTURE */
  .cs-next > .cs-small { height: auto !important; padding-top: 10px; padding-bottom: 0; line-height: 1.2; }
  .cs-next > .cs-small + .cs-cell {
    justify-content: flex-start;
    padding-top: 4px;
    padding-bottom: 8px;
    height: calc(var(--rows, 1) * var(--cell) - var(--lead, 0px)) !important;
  }
  .cs-pillar-label + .cs-pillar-body,
  .cs-item-title + .cs-small { box-shadow: inset 0 -1px var(--color-grid-line); }
  .cs-page .site-footer { margin-bottom: 0; } /* the key-bar clearance is enough; matches the home page */
  .cs-intro.space { margin-top: 0; } /* title right under the nav, like the home hero */
  /* Intro: title, its description right under it, a gap, then Duration /
     Role / Deliverables as three separate blocks with their text centred */
  .cs-intro .cs-heading + .cs-white { margin-top: 0; }
  .cs-intro .cs-meta--top { margin-top: var(--cell); }
  .cs-intro .cs-meta { justify-content: center; padding-block: var(--inset); gap: 6px; }
  .cs-intro .cs-meta--top,
  .cs-intro .cs-meta--bottom { box-shadow: inset 0 1px var(--color-grid-line), inset 0 -1px var(--color-grid-line); }
  /* Next project: one line that fills the width (--chars = the name's length
     including the arrow; Geist Mono glyphs are ~0.58em) */
  .cs-next-link {
    font-size: calc((100cqw - 2 * var(--inset)) / (var(--chars, 17) * 0.585));
    line-height: 1.1;
    white-space: nowrap;
  }
  .cs-image { height: calc(3 * var(--cell)); margin-top: var(--cell); font-size: 20cqw; }
  /* Headings sit directly on their content (the gap goes above the heading
     only), so it's clear which title owns which blocks */
  .work-heading + .card,
  .cs-heading + *,
  .cs-structure + .cs-item,
  .cs-item .cs-image,
  .cs-special-section .cs-image { margin-top: 0; } /* title, text and media are one group */
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Corner handles (handles.js) ----------
   The grid lines are hidden (--color-grid-line: transparent). In their place,
   every block gets a small hollow square on each corner, like a Figma
   selection; clickable blocks' handles turn green on hover. */
.gap::before { background: transparent; }
.corner-marks {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}
