/* =========================================================
   Yichen Shi — Portfolio
   Dark theme by default, light theme via [data-theme="light"].
   Edit the tokens below to restyle.
   ========================================================= */
/* ---------- Web fonts (self-hosted, Latin only; Chinese falls back to system fonts) ----------
   Inter (sans) and Instrument Serif (serif), both free under the SIL Open Font License
   (licence files in assets/fonts/). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/inter-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../assets/fonts/instrument-serif-400.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --edge: clamp(16px, 2.4vw, 36px);  /* side gutter for full-width areas */
  /* Colours (night). Very slightly tinted toward lavender; the old neutral
     values were bg #0d0d0f, bg-elev #17171b, line #2a2a30, text-dim #9a9aa3. */
  --bg: #0e0d12;
  --bg-elev: #18171e;
  --line: #2b2933;
  --text: #ebe9f0;
  --text-dim: #9d9aa8;
  --accent: #c4b5fd;                        /* soft light purple: progress line, current page, links */
  --header-bg: rgba(14, 13, 18, 0.85);      /* mobile menu */
  --glass-bg: rgba(18, 16, 24, 0.62);       /* top bar after scrolling ("liquid glass") */
  --glass-filter: blur(20px) saturate(1.6) brightness(0.75);   /* darkens bright video behind it */
  --glass-line: rgba(255, 255, 255, 0.08);
  --glass-shine: rgba(255, 255, 255, 0.07);
  --header-h: 60px;
  --shadow: rgba(0, 0, 0, 0.5);
  --max: 1200px;
  --gutter: clamp(16px, 4vw, 48px);
  --radius: 6px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --font-serif: "Instrument Serif", "Iowan Old Style", Georgia, "Songti SC", "SimSun", serif;
  --font: var(--font-sans);                 /* body text */

  /* Headings: serif (default) or sans. To switch the whole site to sans,
     copy the three lines from :root[data-font="sans"] below into here. */
  --font-display: var(--font-serif);
  --display-weight: 400;                    /* Instrument Serif has one weight only */
  --display-tracking: 0;
}
:root[data-font="sans"] {
  --font-display: var(--font-sans);
  --display-weight: 650;
  --display-tracking: -0.02em;
}
:root[data-font="serif"] {
  --font-display: var(--font-serif);
  --display-weight: 400;
  --display-tracking: 0;
}

/* Light theme (white background). Toggled by the sun/moon button in the header. */
:root[data-theme="light"] {
  color-scheme: light;
  /* old neutral values: bg #ffffff, bg-elev #f1f1f4, line #e3e3e8, accent #5b3fd1 */
  --bg: #fcfbfe;
  --bg-elev: #f2f0f8;
  --line: #e5e2ee;
  --text: #131218;
  --text-dim: #67647a;
  --accent: #7b5fd6;                        /* darker than night's, so links stay readable on white */
  --header-bg: rgba(252, 251, 254, 0.9);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-filter: blur(20px) saturate(1.6) brightness(1.15);
  --glass-line: rgba(30, 20, 60, 0.08);
  --glass-shine: rgba(255, 255, 255, 0.7);
  --shadow: rgba(0, 0, 0, 0.12);
}

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

html { scroll-behavior: smooth; }

/* Always reserve the scrollbar's space, so pages with and without a
   scrollbar lay out identically (the header never shifts between pages). */
html { scrollbar-gutter: stable; scroll-padding-top: var(--header-h); }
@supports not (scrollbar-gutter: stable) { html { overflow-y: scroll; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

/* Big headings use the heading font. Small titles (h3, card titles) stay in the
   body font: a display serif gets cramped at 16px. */
h1, h2,
.brand-name {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
}

.card-title,
.section-title {
  font-family: var(--font);
  letter-spacing: normal;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---------- Header / Nav ----------
   Three columns: identity block left, links centred, day/night button right.
   The middle column is centred on the window whatever the sides contain,
   so the links sit in exactly the same place on every page.
   States (js/main.js): at the top it is transparent; once you scroll it
   turns into frosted glass (.is-scrolled); scrolling further down hides it
   (.is-hidden) and only the thin progress line stays; scrolling up brings it back. */
body { padding-top: var(--header-h); }
body[data-page="home"]:has(.hero-reel) { padding-top: 0; }      /* the reel runs under the bar (home page only, not project pages) */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 0.35s ease, border-color 0.35s ease, box-shadow 0.35s ease,
    transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.site-header.is-scrolled {
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-filter);
  backdrop-filter: var(--glass-filter);
  border-bottom-color: var(--glass-line);
  box-shadow: inset 0 1px 0 var(--glass-shine), 0 10px 30px -18px var(--shadow);
}
.site-header.is-hidden { transform: translateY(-100%); }
/* On glass the small text needs more contrast than on the plain page. */
.site-header.is-scrolled .brand-tag,
.site-header.is-scrolled .nav-links a { color: color-mix(in srgb, var(--text) 80%, transparent); }
.site-header.is-scrolled .nav-links a:hover,
.site-header.is-scrolled .nav-links a[aria-current="page"] { color: var(--text); }
.site-header.is-scrolled .theme-toggle { color: var(--text); border-color: color-mix(in srgb, var(--text) 45%, transparent); }

/* Home, before scrolling: the bar sits on the video, so its text is white in both themes. */
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) { color: #fff; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35); }
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) .brand-tag,
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) .nav-links a { color: rgba(255, 255, 255, 0.78); }
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) .nav-links a:hover,
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) .nav-links a[aria-current="page"] { color: #fff; }
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) .theme-toggle,
body[data-page="home"]:has(.hero-reel) .site-header:not(.is-scrolled) .menu-btn { color: #fff; border-color: rgba(255, 255, 255, 0.55); }

/* Thin reading-progress line along the very top edge. */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  height: 2px;
  background: var(--accent);
  transform: scaleX(var(--progress, 0));
  transform-origin: 0 50%;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.scroll-progress.is-on { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .site-header, .scroll-progress { transition: none; }
}

.nav {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: var(--header-h);
  padding-top: 3px;   /* the 2px progress line covers the top edge, so centre on the area below it */
  gap: 24px;
}

/* Identity block: name on one line, title right under it, both small. */
.brand { grid-column: 1; justify-self: start; display: flex; flex-direction: column; gap: 3px; line-height: 1.1; }
/* Instrument Serif has no bold weight, so a hairline stroke in the text colour
   thickens it a little ("semi-bold") without the smeared look of fake bold. */
.brand-name { font-size: 1.42rem; line-height: 1; -webkit-text-stroke: 0.4px currentColor; }
:root[data-font="sans"] .brand-name { font-size: 1.15rem; font-weight: 650; -webkit-text-stroke: 0; }
.brand-tag { font-size: 0.8rem; color: var(--text-dim); letter-spacing: 0.01em; }

/* Optical alignment, fitted with tools/optical/measure.js (blur 4px, cut 0.5):
   after blurring, the three groups' visual centres all sit at 31px, the
   middle of the bar below the 2px progress line; the name's left edge and the
   button's right edge are the same distance from the window sides. */
.brand { position: relative; top: var(--oy-brand, 1.5px); }
.nav-links { position: relative; top: var(--oy-links, -1.5px); }
.nav-tools { position: relative; top: var(--oy-tools, -1px); margin-right: var(--ox-tools, -6px); }

.nav-links {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  font-size: 0.88rem;
  color: var(--text-dim);
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text); }
.nav-links a[aria-current="page"] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 6px;
}

.nav-tools { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: none;
  border: 1px solid color-mix(in srgb, var(--text) 30%, transparent);
  border-radius: 50%;
  color: var(--text-dim);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-dim); }
.theme-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
/* dark theme shows a sun (switch to light); light theme shows a moon (switch to dark) */
.theme-toggle .i-moon { display: none; }
:root[data-theme="light"] .theme-toggle .i-sun { display: none; }
:root[data-theme="light"] .theme-toggle .i-moon { display: block; }

/* Day/night switch: the whole page cross-fades as one picture (View
   Transitions), so every colour changes at exactly the same moment.
   While switching, per-element colour transitions are turned off, otherwise
   some text (links, the top bar) would catch up a moment later.
   Browsers without View Transitions simply switch instantly. */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after { transition: none !important; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.35s; animation-timing-function: ease; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

.menu-btn {
  display: none;
  background: none;
  border: 0;
  color: var(--text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

@media (max-width: 720px) {
  .menu-btn { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    padding: 8px var(--edge) 16px;
  }
  .nav-links.open { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 10px 0; }
}

/* ---------- Sections ---------- */
.section { padding-block: clamp(40px, 7vw, 80px); }
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin: 0 0 24px;
}
.page-title { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 0 0 8px; }
.page-lead { color: var(--text-dim); margin: 0 0 40px; max-width: 60ch; }

/* ---------- Demo reel ---------- */
.reel { padding-top: clamp(24px, 4vw, 40px); }
.reel-frame {
  position: relative;
  padding-top: 56.25%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
}
.reel-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---------- Card grid (projects / photos) ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.card { display: block; }
.card-thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s; }
.card:hover .card-thumb img { transform: scale(1.04); }
.card:hover .card-thumb { border-color: var(--text-dim); }
.card-title { margin: 12px 0 2px; font-size: 1rem; font-weight: 600; }
.card-meta { margin: 0; font-size: 0.85rem; color: var(--text-dim); }

.grid.photos { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.photos .card-thumb { aspect-ratio: 4 / 5; }

/* ---------- Blog list ---------- */
.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.post-item a {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: baseline;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}
.post-item a:hover .post-title { color: var(--accent); }
.post-title { margin: 0; font-size: 1.15rem; transition: color 0.2s; }
.post-desc { margin: 4px 0 0; color: var(--text-dim); font-size: 0.9rem; }
.post-tag {
  font-size: 0.75rem;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  white-space: nowrap;
}

/* ---------- About ---------- */
.about {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(24px, 5vw, 64px);
  align-items: center;
}
.about-photo { width: 100%; height: auto; border-radius: var(--radius); }
.about-body p { margin: 0 0 16px; color: var(--text); }
.about-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px !important; }
.btn {
  display: inline-block;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-ghost { background: none; color: var(--text); border: 1px solid var(--line); font-weight: 400; }
.btn-ghost:hover { border-color: var(--text-dim); opacity: 1; }
@media (max-width: 860px) {
  .about { grid-template-columns: 1fr; }
  .about-photo { order: -1; }
}

/* ---------- Resume (About page) ---------- */
.resume { max-width: 900px; margin: clamp(48px, 8vw, 96px) auto 0; }
.resume-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.resume-head .section-title { margin: 0; }
.resume-dl { font-size: 0.9rem; color: var(--text-dim); border-bottom: 1px solid var(--line); padding-bottom: 2px; transition: color 0.2s, border-color 0.2s; }
.resume-dl:hover { color: var(--text); border-color: var(--text-dim); }
.resume-sheet {
  display: block;
  background: #fff;                       /* the PDF is a white page */
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 20px 60px var(--shadow);
}
.resume-sheet img { display: block; width: 100%; height: auto; }

/* ---------- Project detail ---------- */
.project-hero {
  aspect-ratio: 16 / 9;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  color: var(--text-dim);
  margin-bottom: 32px;
}
.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 32px;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 24px;
}
.back-link { display: inline-block; color: var(--text-dim); margin-bottom: 24px; font-size: 0.9rem; }
.back-link:hover { color: var(--text); }

/* ---------- Case study pages (projects/_template.html) ----------
   Order on the page: video (or its placeholder) → title, one-line lead, meta →
   .case-facts → .post article with breakdown sections → .case-credits → .project-nav. */

/* Video slot before the final film is uploaded: a still with a small label.
   To publish the film, replace the whole <div class="project-hero video-placeholder">
   with <div class="project-hero"><iframe src="https://www.youtube-nocookie.com/embed/ID?rel=0" ...></iframe></div>. */
.video-placeholder { position: relative; }
.video-placeholder > img { filter: brightness(0.55) saturate(0.9); }
.video-placeholder-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 8px 18px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.88);     /* sits on the darkened still in both themes */
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.25);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.case-lead { font-size: clamp(1.05rem, 1.6vw, 1.2rem); line-height: 1.55; max-width: 62ch; margin: 4px 0 20px; }

/* Key numbers: a quiet row of figures, wraps on phones. Text only, no animation. */
.case-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px clamp(28px, 5vw, 64px);
  margin: 0 0 8px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  list-style: none;
}
.case-facts li { display: flex; flex-direction: column; gap: 2px; }
.case-facts b {
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.1;
}
.case-facts span { font-size: 0.82rem; color: var(--text-dim); }

/* Case pages use <article class="post case-body">: text stays in the 860px column,
   a .media-wide child (one figure or a .post-row) spans the full 1200px page width. */
.post.case-body { max-width: none; }
.case-body > * { max-width: 860px; }
.case-body > .media-wide { max-width: none; }
.case-body > .media-wide img,
.case-body > .media-wide video { width: 100%; max-height: none; }
/* Portrait references and small diagrams: keep them from filling the screen. */
.case-body .media-small img { max-height: 520px; }

/* Small technical tables (methods, numbers). */
.post table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: 0.9rem; }
.post th, .post td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.post th { color: var(--text-dim); font-weight: 500; }
.post td:first-child { white-space: nowrap; }
/* Wide tables scroll sideways on phones instead of squeezing the columns. */
.post .table-scroll { overflow-x: auto; margin: 24px 0; }
.post .table-scroll table { margin: 0; }
.post .table-scroll table:has(th:nth-child(3)) { min-width: 560px; }

/* Formulas and short code in the technical notes (blog/f26/). */
.post code { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: 0.86em; }
.post pre {
  margin: 20px 0;
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--bg-elev);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.55;
}
.post pre code { font-size: inherit; }
/* "Technical notes →" line under a project page section, and "← project" at the top of a note. */
.note-link { font-size: 0.92rem; }
.note-link a { color: var(--accent); }

.case-credits {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--text-dim);
  font-size: 0.85rem;
}
.post .case-credits h2 { font-family: var(--font); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.18em; margin: 0 0 12px; }
.post .case-credits p { margin: 0 0 6px; line-height: 1.6; }
.post .case-credits a { color: inherit; }

/* Previous / next project at the bottom. */
.project-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.project-nav a { display: flex; flex-direction: column; gap: 2px; color: var(--text-dim); transition: color 0.2s; }
.project-nav a:hover { color: var(--text); }
.project-nav a span { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.project-nav a b { font-family: var(--font-display); font-weight: var(--display-weight); font-size: 1.35rem; color: var(--text); }
.project-nav .next { text-align: right; align-items: flex-end; grid-column: 2; }

.section-heading {
  font-size: 1.5rem;
  margin: 56px 0 20px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.post-section:first-child .section-heading { margin-top: 8px; }

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.post-nav a { color: var(--text-dim); }
.post-nav a:hover { color: var(--text); }

/* ---------- Simple posts & project pages (blog/_templates, projects/_template.html) ----------
   One column: text, then full-width images / clips. .post-row puts 2–3 items side by side. */
.post { max-width: 860px; margin-top: 32px; }
.post p, .post li { line-height: 1.7; }
.post p { margin: 0 0 16px; }
.post h2 { font-size: 1.35rem; margin: 48px 0 12px; }
.post a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post a:has(img) { text-decoration: none; }
.post-media { margin: 28px 0; }
.post-media img,
.post-media video,
.post-media iframe {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 3px;
  background: var(--bg-elev);
}
.post-media iframe { aspect-ratio: 16 / 9; }
/* Tall (portrait) images and clips never get taller than the screen. */
.post-media img,
.post-media video { width: auto; max-width: 100%; max-height: 90vh; margin-inline: auto; }
.post-media figcaption { margin-top: 8px; font-size: 0.85rem; color: var(--text-dim); }
.post p.media-credit { margin-top: -16px; font-size: 0.85rem; color: var(--text-dim); }
.post-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; margin: 28px 0; }
.post-row .post-media { margin: 0; }
/* --cols: one fr per item, proportional to its aspect ratio, so a row of
   mixed shapes lines up at one height (Group Research weeks use it) */
.post-row[style*="--cols"] { grid-auto-flow: row; grid-template-columns: var(--cols); }
.post-row[style*="--cols"] .post-media img,
.post-row[style*="--cols"] .post-media video { width: 100%; height: auto; max-height: none; }
.post img { cursor: zoom-in; }
.post a img { cursor: pointer; }
.project-hero:has(> iframe, > img, > video) { display: block; overflow: hidden; }
.project-hero > iframe,
.project-hero > img,
.project-hero > video { display: block; width: 100%; height: 100%; border: 0; object-fit: cover; }
@media (max-width: 720px) {
  .post-row { grid-auto-flow: row; }
  .post-row[style*="--cols"] { grid-template-columns: 1fr; }
  .post-row.ref-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  display: grid;
  place-items: center;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 32px 0;
  margin-top: 40px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px 28px;
  color: var(--text-dim);
  font-size: 0.9rem;
}
/* Social icons: each SVG is cropped to its own shape (tight viewBox in
   js/main.js) and given its own height, so the four look the same size even
   though their shapes differ (outline square, solid letters, wide logo). */
.socials { display: flex; align-items: center; gap: 22px; }
.socials a { display: flex; align-items: center; color: var(--text-dim); transition: color 0.2s; }
.socials a:hover { color: var(--text); }
.socials svg { display: block; width: auto; height: 18px; fill: currentColor; }
/* optical-icons:start (values fitted with tools/optical/measure.js) */
.socials a[aria-label="linkedin"] svg { height: 16.75px; transform: translateY(1px); }
.socials a[aria-label="behance"] svg { height: 14.5px; transform: translateY(0.5px); }
.socials a[aria-label="instagram"] svg { height: 16.5px; transform: translateY(1px); }
.socials a[aria-label="youtube"] svg { height: 14.75px; transform: translateY(0.75px); }
/* optical-icons:end */
.footer-email:hover { color: var(--text); }

.media-missing {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--bg-elev);
  border: 1px dashed var(--line);
  border-radius: 3px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Full-width areas (header, home hero, work grid) share one side gutter. */
.site-header .nav.container,
.edge { max-width: none; padding-inline: var(--edge); }

/* =========================================================
   Home: full-screen demo reel with the particle name on top
   ========================================================= */
.hero-reel {
  position: relative;
  aspect-ratio: 16 / 9;          /* the reel's own ratio, full width: nothing is cropped
                                    (on wide windows the last few rows sit just below the fold) */
  overflow: hidden;
  background: #000;
}
.hero-video {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hero-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.hero-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.15) 18%, rgba(0, 0, 0, 0) 40%);
}
.hero-content {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  padding-top: calc(var(--header-h) + clamp(8px, 1.6vw, 28px));   /* clear the top bar */
}
.hero-content[data-hero="none"] { display: none; }
/* ---------- Name block on the reel ----------
   Off by default (data-hero="none": the reel is clean, the name lives in the
   top bar). Three optional layouts, chosen with data-hero in index.html:
   a = name on top (smaller than before), title right under it (much bigger than before)
   b = title is the headline, name is a small line above it
   c = name small in the top-left corner, title large in the bottom-left corner
   Both lines use the heading font and the dust/particle effect (js/home.js). */
.particle-text {
  --particle-color: #fff;
  position: relative;
  display: inline-block;
  margin: 0;
  color: var(--particle-color);
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  letter-spacing: var(--display-tracking);
  line-height: 1;
  white-space: nowrap;
}
.particle-text.is-particles { color: transparent; }
.particle-canvas { position: absolute; pointer-events: none; }
.hero-content { display: flex; flex-direction: column; align-items: flex-start; }

/* a: name stays on top but smaller; title much bigger, the two sizes are close */
.hero-content[data-hero="a"] { gap: clamp(6px, 0.8vw, 12px); }
.hero-content[data-hero="a"] .hero-name { font-size: clamp(28px, 3.6vw, 58px); }
.hero-content[data-hero="a"] .hero-title { font-size: clamp(18px, 2.4vw, 38px); opacity: 0.92; }

/* b: title is the headline, name is a small line above it */
.hero-content[data-hero="b"] { gap: clamp(6px, 0.8vw, 12px); }
.hero-content[data-hero="b"] .hero-name { font-size: clamp(15px, 1.4vw, 22px); font-family: var(--font-sans); font-weight: 500; letter-spacing: 0.02em; opacity: 0.85; }
.hero-content[data-hero="b"] .hero-title { font-size: clamp(30px, 5.4vw, 88px); }

/* c: name top-left, title bottom-left */
.hero-content[data-hero="c"] {
  bottom: 0;
  justify-content: space-between;
  padding-bottom: clamp(16px, 3vw, 44px);
}
.hero-content[data-hero="c"] .hero-name { font-size: clamp(20px, 2.2vw, 34px); }
.hero-content[data-hero="c"] .hero-title { font-size: clamp(28px, 5vw, 80px); }
.hero-reel:has([data-hero="c"]) .hero-shade {
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 25%),
    linear-gradient(to top, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 35%);
}

/* The header name stays hidden while the big name is on screen. */
.brand { transition: opacity 0.35s ease, transform 0.35s ease; }
body.hero-visible .brand { opacity: 0; transform: translateY(-6px); pointer-events: none; }

/* =========================================================
   Home: work grid (static, full width)
   ========================================================= */
.work { padding: var(--edge) var(--edge) clamp(40px, 6vw, 80px); }
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 1024px) { .work-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .work-grid { grid-template-columns: 1fr; } }

.work-card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 8px;
  background: var(--bg-elev);
  color: #fff;                 /* text sits on the dark cover gradient in both themes */
  isolation: isolate;
}
.work-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.work-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent 55%);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.work-info {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 18px;
  z-index: 1;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.work-card:hover .work-media,
.work-card:focus-visible .work-media { transform: scale(1.04); }
.work-card:hover::after,
.work-card:focus-visible::after { opacity: 1; }
.work-card:hover .work-info,
.work-card:focus-visible .work-info { opacity: 1; transform: none; }
.work-tags { margin: 0 0 4px; font-size: 0.85rem; color: rgba(255, 255, 255, 0.72); }
.work-title { margin: 0; font-size: clamp(1.05rem, 1.5vw, 1.35rem); font-weight: 600; }
@media (hover: none) {
  .work-card::after, .work-info { opacity: 1; transform: none; }
}

/* =========================================================
   Custom cursor (js/cursor.js)
   ========================================================= */
html.has-cursor,
html.has-cursor * { cursor: none !important; }
.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  mix-blend-mode: difference;
  will-change: transform;
}
.cursor-dot {
  --s: 0.09;        /* 120px * 0.09 ≈ 11px dot */
  position: absolute;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  transform: scale(calc(var(--s) * var(--press, 1)));
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}
.cursor.is-text .cursor-dot { --s: 0.22; }   /* headings / text ≈ 26px */
.cursor.is-link .cursor-dot { --s: 0.3; }    /* nav / links ≈ 36px */
.cursor.is-view .cursor-dot { --s: 0.4; }    /* work cards ≈ 48px */
.cursor.is-down .cursor-dot { --press: 0.8; }
.cursor.is-hidden .cursor-dot { opacity: 0; --s: 0; }
.cursor-label {
  font-size: 28px;   /* shown at 0.4 scale ≈ 11px */
  font-weight: 600;
  color: #000;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.cursor.is-view .cursor-label { opacity: 1; }

/* =========================================================
   Page layouts (chosen 2026-12-04 after the ?layout= experiment, PR #25)
   js/main.js sets <html data-layout> from the page type:
     editorial  home page        big serif title, staggered 2-column work grid
     grid       project pages,   12-column Swiss grid: title left, lead +
                blog pages       meta right, numbered sections and lists, rules
     simple     about, photography and anything else: today's look on one
                spacing / type scale
   js/main.js also adds three helpers: .page-head wraps the page title +
   lead (+ project meta), .page-eyebrow is the small label line above the
   title, .work-label heads the home work grid. See DESIGN.md 2.1.
   ========================================================= */

.page-head { display: contents; }
.page-eyebrow,
.work-label { display: none; }

/* ---------- Shared scale (all three layouts) ----------
   Spacing: 4px steps up to 16, then 24 · 32 · 48 · 64 · 96 · 128.
   Type: ratio 1.25 from 16px (12.8 · 16 · 20 · 25 · 31.25 · 39 · 48.8). */
:root[data-layout] {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px;
  --sp-6: 32px; --sp-7: 48px; --sp-8: 64px; --sp-9: 96px; --sp-10: 128px;
  --t-sm: 0.8rem; --t-lg: 1.25rem; --t-xl: 1.5625rem; --t-2xl: 1.953rem; --t-3xl: 2.441rem; --t-4xl: 3.052rem;
  --img-gap: 12px;            /* one gap between any two images, across and down */
  --radius: 4px;
  --rule: 1px solid var(--line);
  --col-gap: clamp(12px, 1.6vw, 24px);
}

/* Images inside a row never get their own vertical margins */
:root[data-layout] .post-row > .post-media { margin: 0; }

/* Small label line above titles (grid) */
:root[data-layout] .page-eyebrow {
  justify-content: space-between;
  gap: var(--sp-4);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
:root[data-layout="simple"] .page-eyebrow { display: none; }

/* =========================================================
   SIMPLE — about, photography: today's look, one rhythm everywhere
   ========================================================= */
:root[data-layout="simple"] .section { padding-block: var(--sp-8) var(--sp-9); }
:root[data-layout="simple"] .back-link { margin-bottom: var(--sp-6); font-size: 0.875rem; }
:root[data-layout="simple"] .page-title { font-size: clamp(var(--t-3xl), 5vw, var(--t-4xl)); line-height: 1.05; margin: 0 0 var(--sp-3); }
:root[data-layout="simple"] .page-lead { font-size: 1.0625rem; line-height: 1.55; margin: 0 0 var(--sp-7); max-width: 56ch; }

/* Cards: rows breathe more than columns, so each card reads as one unit */
:root[data-layout="simple"] .grid { gap: var(--sp-7) var(--sp-5); }
:root[data-layout="simple"] .card-title { margin: var(--sp-4) 0 var(--sp-1); font-size: 1.0625rem; line-height: 1.3; }
:root[data-layout="simple"] .card-meta { line-height: 1.5; }

/* Home: same grid, same 12px image gap, one radius */
:root[data-layout="simple"] .work { padding: var(--img-gap) var(--edge) var(--sp-9); }
:root[data-layout="simple"] .work-grid { gap: var(--img-gap); }
:root[data-layout="simple"] .work-card { border-radius: var(--radius); }

/* Articles + project pages: shorter text lines, larger section breaks,
   images stacked with the same 12px gap as images side by side */
:root[data-layout="simple"] .post { margin-top: var(--sp-7); }
:root[data-layout="simple"] .post p,
:root[data-layout="simple"] .post li { max-width: 68ch; }
:root[data-layout="simple"] .post h2 { font-size: var(--t-2xl); line-height: 1.15; margin: var(--sp-9) 0 var(--sp-4); }
:root[data-layout="simple"] .post-media,
:root[data-layout="simple"] .post-row { margin: var(--sp-6) 0; }
:root[data-layout="simple"] .post-row { gap: var(--img-gap); }
:root[data-layout="simple"] .post > :is(.post-media, .post-row) + :is(.post-media, .post-row) { margin-top: calc(var(--img-gap) - var(--sp-6)); }
:root[data-layout="simple"] .post-media figcaption { margin-top: var(--sp-2); }
:root[data-layout="simple"] .project-hero { margin-bottom: var(--sp-7); border-radius: var(--radius); }
:root[data-layout="simple"] .case-lead { margin: var(--sp-2) 0 var(--sp-5); }
:root[data-layout="simple"] .project-meta { margin-bottom: var(--sp-7); gap: var(--sp-2) var(--sp-6); }
:root[data-layout="simple"] .case-credits,
:root[data-layout="simple"] .project-nav,
:root[data-layout="simple"] .post-nav { margin-top: var(--sp-9); }
:root[data-layout="simple"] .section-heading { margin: var(--sp-9) 0 var(--sp-5); }

/* About */
:root[data-layout="simple"] .about-body p { max-width: 60ch; }
:root[data-layout="simple"] .about-actions { margin-top: var(--sp-6) !important; }
:root[data-layout="simple"] .resume { margin-top: var(--sp-10); }
:root[data-layout="simple"] .site-footer { margin-top: var(--sp-8); }

/* =========================================================
   GRID — project pages and blog: Swiss / international style
   12 columns, numbers, uppercase labels, hairline rules.
   Text and images snap to the same columns.
   ========================================================= */
:root[data-layout="grid"] main.container { max-width: 1440px; padding-inline: var(--edge); }
:root[data-layout="grid"] .section { padding-block: var(--sp-7) var(--sp-9); }
:root[data-layout="grid"] .back-link { font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: var(--sp-5); }

/* Page head: label line, big title left, lead right, a rule under it */
:root[data-layout="grid"] .page-head {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: var(--sp-4);
  align-items: start;
  padding-bottom: var(--sp-6);
  margin-bottom: var(--sp-7);
  border-bottom: var(--rule);
}
:root[data-layout="grid"] .page-head .page-eyebrow { display: flex; grid-column: 1 / -1; padding-top: var(--sp-3); border-top: var(--rule); }
:root[data-layout="grid"] .page-head .page-title {
  grid-column: 1 / 8;
  grid-row: 2 / span 2;
  align-self: start;
  margin: 0 0 0 -0.07em;       /* serif side bearing, fitted with tools/optical/measure.js (blur 4, cut 0.5): blurred left edge on the column line */
  font-size: clamp(3rem, 7vw, 6.25rem);
  line-height: 0.92;
}
:root[data-layout="grid"] .page-head :is(.page-lead, .case-lead) {
  grid-column: 9 / -1;
  margin: 0;
  max-width: none;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text-dim);
}
:root[data-layout="grid"] .page-head .project-meta {
  grid-column: 9 / -1;
  flex-direction: column;
  gap: 0;
  margin: 0;
  font-size: 0.8rem;
}
:root[data-layout="grid"] .page-head .project-meta span { padding: var(--sp-2) 0; border-top: var(--rule); }

/* Card grids (blog series, notes, weeks) → a numbered index list */
:root[data-layout="grid"] .grid:not(.photos) { grid-template-columns: 1fr; gap: 0; counter-reset: item; border-top: var(--rule); }
:root[data-layout="grid"] .grid:not(.photos) > .card {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  grid-template-rows: auto 1fr;
  padding: var(--sp-4) 0;
  border-bottom: var(--rule);
  counter-increment: item;
}
:root[data-layout="grid"] .grid:not(.photos) > .card::before {
  content: counter(item, decimal-leading-zero);
  grid-column: 1 / 2;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
:root[data-layout="grid"] .grid:not(.photos) .card-thumb { grid-column: 2 / 5; grid-row: 1 / span 2; border: 0; border-radius: 2px; }
:root[data-layout="grid"] .grid:not(.photos) .card-title {
  grid-column: 6 / 11;
  margin: 0;
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: clamp(1.5rem, 2.6vw, 2.25rem);
  line-height: 1.05;
}
:root[data-layout="grid"] .grid:not(.photos) .card-meta { grid-column: 6 / 11; margin-top: var(--sp-3); max-width: 52ch; }
:root[data-layout="grid"] .grid:not(.photos) .card:hover .card-title { color: var(--accent); }
:root[data-layout="grid"] .grid.photos { grid-template-columns: repeat(4, 1fr); gap: var(--img-gap); }

/* Home: label row, then an asymmetric 12-column work grid with captions under the images */
:root[data-layout="grid"] .work { padding-top: var(--sp-8); }
:root[data-layout="grid"] .work-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  padding-top: var(--sp-3);
  margin-bottom: var(--sp-6);
  border-top: var(--rule);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}
:root[data-layout="grid"] .work-label h2 { margin: 0; font: inherit; letter-spacing: inherit; }
:root[data-layout="grid"] .work-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--sp-8) var(--col-gap);
  counter-reset: work;
}
:root[data-layout="grid"] .work-card {
  aspect-ratio: auto;
  overflow: visible;
  border-radius: 0;
  background: none;
  color: var(--text);
  counter-increment: work;
}
/* 8+4, 4+8, 6+6: the small cover is portrait so both bottoms meet */
:root[data-layout="grid"] .work-card:nth-child(1) { grid-column: 1 / 9; }
:root[data-layout="grid"] .work-card:nth-child(2) { grid-column: 9 / -1; }
:root[data-layout="grid"] .work-card:nth-child(3) { grid-column: 1 / 5; }
:root[data-layout="grid"] .work-card:nth-child(4) { grid-column: 5 / -1; }
:root[data-layout="grid"] .work-card:nth-child(5) { grid-column: 1 / 7; }
:root[data-layout="grid"] .work-card:nth-child(6) { grid-column: 7 / -1; }
:root[data-layout="grid"] .work-media { position: relative; height: auto; aspect-ratio: 16 / 10; border-radius: 2px; }
:root[data-layout="grid"] .work-card:is(:nth-child(2), :nth-child(3)) { display: flex; flex-direction: column; }
:root[data-layout="grid"] .work-card:is(:nth-child(2), :nth-child(3)) .work-media { aspect-ratio: auto; flex: 1; height: auto; min-height: 0; }
:root[data-layout="grid"] .work-card::after { display: none; }
:root[data-layout="grid"] .work-card:hover .work-media { transform: none; }
:root[data-layout="grid"] .work-info {
  position: static;
  opacity: 1;
  transform: none;
  display: flex;
  align-items: baseline;
  gap: var(--sp-4);
  padding-top: var(--sp-3);
}
:root[data-layout="grid"] .work-info::before {
  content: counter(work, decimal-leading-zero);
  font-size: 0.8rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
:root[data-layout="grid"] .work-title { order: 1; font-size: 1rem; font-weight: 600; }
:root[data-layout="grid"] .work-tags { order: 2; margin: 0 0 0 auto; font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
:root[data-layout="grid"] .work-card:hover .work-title { color: var(--accent); }

/* Project pages + notes: section titles hang in columns 1–3, text in 4–10,
   images run from column 4 to the right edge (wide ones span all 12) */
:root[data-layout="grid"] .project-hero { margin-bottom: var(--sp-6); border: 0; border-radius: 2px; }
:root[data-layout="grid"] .post {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  max-width: none;
  margin-top: 0;
  counter-reset: sec fig;
}
:root[data-layout="grid"] .post > *,
:root[data-layout="grid"] .case-body > * { grid-column: 4 / 11; max-width: none; }
:root[data-layout="grid"] .post > :is(.post-media, .post-row, .table-scroll, table) { grid-column: 4 / -1; }
:root[data-layout="grid"] .post > .media-wide { grid-column: 1 / -1; }
:root[data-layout="grid"] .post > h2 {
  grid-column: 1 / 4;
  margin: var(--sp-8) 0 0;
  padding-top: var(--sp-3);
  border-top: var(--rule);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  counter-increment: sec;
}
:root[data-layout="grid"] .post > h2::before {
  content: counter(sec, decimal-leading-zero);
  display: block;
  margin-bottom: var(--sp-2);
  font-family: var(--font-display);
  font-size: 2.25rem;
  line-height: 1;
  letter-spacing: 0;
  color: var(--text);
}
:root[data-layout="grid"] .post > h2 + * { margin-top: var(--sp-8); padding-top: var(--sp-3); border-top: var(--rule); }
:root[data-layout="grid"] .post-media,
:root[data-layout="grid"] .post-row { margin: var(--sp-5) 0; }
:root[data-layout="grid"] .post-row { gap: var(--img-gap); }
:root[data-layout="grid"] .post > :is(.post-media, .post-row) + :is(.post-media, .post-row) { margin-top: 0; }
:root[data-layout="grid"] .post-media img,
:root[data-layout="grid"] .post-media video,
:root[data-layout="grid"] .post-media iframe { border-radius: 2px; }
:root[data-layout="grid"] .post-media figcaption { font-size: 0.75rem; letter-spacing: 0.02em; }
:root[data-layout="grid"] .post-media figcaption::before { content: "Fig. " counter(fig, decimal-leading-zero) " — "; color: var(--text); counter-increment: fig; }
:root[data-layout="grid"] .post > .case-credits { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); }
:root[data-layout="grid"] .post .case-credits h2 { grid-column: 1 / 4; }
:root[data-layout="grid"] .post .case-credits p { grid-column: 4 / 11; }
:root[data-layout="grid"] .project-nav a b { font-size: 1.75rem; }

/* About: text in 1–6, portrait in 8–12, resume under a full rule */
:root[data-layout="grid"] .about { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); align-items: start; }
:root[data-layout="grid"] .about-body { grid-column: 1 / 7; }
:root[data-layout="grid"] .about-photo { grid-column: 8 / -1; border-radius: 2px; }
:root[data-layout="grid"] .about-body .page-head { grid-template-columns: 1fr; border-bottom: 0; margin-bottom: var(--sp-4); padding-bottom: 0; }
:root[data-layout="grid"] .about-body .page-head .page-title { grid-column: 1; grid-row: auto; }
:root[data-layout="grid"] .resume { max-width: none; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--col-gap); padding-top: var(--sp-3); border-top: var(--rule); }
:root[data-layout="grid"] .resume-head { grid-column: 1 / -1; }
:root[data-layout="grid"] .resume-sheet { grid-column: 4 / 11; border-radius: 2px; }


/* ---------- Phones / small tablets: grid and editorial fall back to one column ---------- */
@media (max-width: 720px) {
  :root[data-layout] .page-head > *,
  :root[data-layout] .post > *,
  :root[data-layout] .post > h2 + p,
  :root[data-layout] .post > .post-media:not(.media-wide),
  :root[data-layout] .post > .media-small,
  :root[data-layout] .post .case-credits > *,
  :root[data-layout] .about > *,
  :root[data-layout] .resume > *,
  :root[data-layout] .work-grid > .work-card,
  :root[data-layout="editorial"] .work-card > *,
  :root[data-layout="editorial"] .work-card:nth-child(even) > * { grid-column: 1 / -1 !important; }
  :root[data-layout] .page-head .page-title,
  :root[data-layout] .page-head .project-meta { grid-row: auto; }
  :root[data-layout="grid"] .page-head :is(.page-lead, .case-lead) { margin-top: var(--sp-3); }
  :root[data-layout="grid"] .post > h2 + * { margin-top: var(--sp-4); }
  :root[data-layout="grid"] .work-card:is(:nth-child(2), :nth-child(3)) .work-media { aspect-ratio: 16 / 10; flex: none; }
  :root[data-layout="grid"] .work-info { flex-wrap: wrap; row-gap: var(--sp-1); }
  :root[data-layout="grid"] .work-title { white-space: nowrap; }
  :root[data-layout="grid"] .work-tags { margin-left: auto; }
  :root[data-layout="editorial"] .work-info { grid-row: 2; }
  :root[data-layout="editorial"] .work-info::before { font-size: 2.5rem; margin: var(--sp-4) 0 0; }
  :root[data-layout="editorial"] .work-title { margin-top: var(--sp-2); }
  :root[data-layout="grid"] .grid:not(.photos) .card-thumb { grid-column: 2 / 6; }
  :root[data-layout="grid"] .grid:not(.photos) :is(.card-title, .card-meta) { grid-column: 7 / -1; }
  :root[data-layout="grid"] .grid:not(.photos) .card-title { font-size: 1.25rem; }
  :root[data-layout] .grid.photos { grid-template-columns: 1fr 1fr; }
  :root[data-layout] .grid.photos > * { grid-column: auto !important; }
}

/* =========================================================
   EDITORIAL — home page only
   A giant "Selected Work" title, then the projects in two staggered
   columns (the right one starts half a card lower), with a big
   outlined number and a serif title under each cover.
   ========================================================= */
/* Home: a giant section title, then one project per spread,
   image and caption swapping sides */
:root[data-layout="editorial"] .work { padding-top: var(--sp-9); }
:root[data-layout="editorial"] .work-label { display: block; margin-bottom: var(--sp-9); }
:root[data-layout="editorial"] .work-label h2 {
  margin: 0 0 0 -0.05em;      /* the round S needs less pull than the straight T/E/B (measure.js) */
  font-size: clamp(3.5rem, 11.5vw, 11rem);
  line-height: 0.86;
  letter-spacing: -0.02em;
}
:root[data-layout="editorial"] .work-label span { display: none; }
:root[data-layout="editorial"] .work-grid { grid-template-columns: 1fr; gap: clamp(64px, 9vw, 144px); counter-reset: work; }
:root[data-layout="editorial"] .work-card {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  align-items: end;
  aspect-ratio: auto;
  overflow: visible;
  border-radius: 0;
  background: none;
  color: var(--text);
  counter-increment: work;
}
:root[data-layout="editorial"] .work-media { position: relative; height: auto; grid-column: 1 / 9; grid-row: 1; aspect-ratio: 16 / 10; }
:root[data-layout="editorial"] .work-info { position: static; grid-column: 9 / -1; grid-row: 1; opacity: 1; transform: none; }
:root[data-layout="editorial"] .work-card:nth-child(even) .work-media { grid-column: 5 / -1; }
:root[data-layout="editorial"] .work-card:nth-child(even) .work-info { grid-column: 1 / 5; }
:root[data-layout="editorial"] .work-card::after { display: none; }
:root[data-layout="editorial"] .work-card:hover .work-media { transform: none; }
:root[data-layout="editorial"] .work-info { display: flex; flex-direction: column; }
:root[data-layout="editorial"] .work-info::before {
  content: counter(work, decimal-leading-zero);
  order: 0;
  margin-bottom: auto;
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 7rem);
  line-height: 0.8;
  color: transparent;
  -webkit-text-stroke: 1px var(--text-dim);
}
:root[data-layout="editorial"] .work-title {
  order: 1;
  margin: var(--sp-5) 0 var(--sp-2);
  font-family: var(--font-display);
  font-weight: var(--display-weight);
  font-size: clamp(2rem, 3.6vw, 3.5rem);
  line-height: 0.95;
}
:root[data-layout="editorial"] .work-tags { order: 2; margin: 0; font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
:root[data-layout="editorial"] .work-card:hover .work-title { color: var(--accent); }

:root[data-layout="editorial"] .work { padding-top: var(--sp-8); }
:root[data-layout="editorial"] .work-label { margin-bottom: var(--sp-7); }
:root[data-layout="editorial"] .work-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--col-gap);
  row-gap: var(--sp-6);
}
/* each card spans two rows; the right column starts half a card lower */
:root[data-layout="editorial"] .work-card {
  display: flex;
  flex-direction: column;
  align-self: start;
  align-items: stretch;
}
:root[data-layout="editorial"] .work-card:nth-child(odd) { grid-column: 1 / 7; }
:root[data-layout="editorial"] .work-card:nth-child(even) { grid-column: 7 / -1; }
:root[data-layout="editorial"] .work-card:nth-child(1) { grid-row: 1 / span 2; }
:root[data-layout="editorial"] .work-card:nth-child(2) { grid-row: 2 / span 2; }
:root[data-layout="editorial"] .work-card:nth-child(3) { grid-row: 3 / span 2; }
:root[data-layout="editorial"] .work-card:nth-child(4) { grid-row: 4 / span 2; }
:root[data-layout="editorial"] .work-card:nth-child(5) { grid-row: 5 / span 2; }
:root[data-layout="editorial"] .work-card:nth-child(6) { grid-row: 6 / span 2; }
:root[data-layout="editorial"] .work-card .work-media,
:root[data-layout="editorial"] .work-card:nth-child(even) .work-media { grid-column: auto; width: 100%; }
:root[data-layout="editorial"] .work-info,
:root[data-layout="editorial"] .work-card:nth-child(even) .work-info {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: var(--sp-4);
  align-items: baseline;
  padding-top: var(--sp-4);
}
:root[data-layout="editorial"] .work-info::before {
  grid-row: 1 / span 2;
  margin: 0;
  font-size: clamp(2.5rem, 4vw, 4rem);
}
:root[data-layout="editorial"] .work-title { grid-column: 2; margin: 0 0 var(--sp-1); font-size: clamp(1.6rem, 2.4vw, 2.4rem); }
:root[data-layout="editorial"] .work-tags { grid-column: 2; }
@media (max-width: 720px) {
  :root[data-layout="editorial"] .work-grid { row-gap: var(--sp-7); }
  :root[data-layout="editorial"] .work-card { grid-row: auto !important; }
  :root[data-layout="editorial"] .work-info::before { font-size: 2.25rem; }
}


/* grid and editorial: portrait images sit on the column line instead of centring */
:root[data-layout="grid"] .post-media :is(img, video),
:root[data-layout="editorial"] .post-media :is(img, video) { margin-inline: 0; }
