/* ==========================================================================
   dan.dsgns — site stylesheet
   1.  Theme tokens (light / dark)
   2.  Base
   3.  Layout
   4.  Header
   5.  Hero
   6.  Buttons
   7.  Holofoil panels
   8.  Study cards (+ mirrored variant)
   9.  Other works (home page grid)
   10. Gallery page (grid + image viewer)
   11. Article
   12. Footer
   13. Theme toggle
   14. Cursor trail
   15. Text selection
   16. Custom cursor
   17. Scrollbar
   18. Reveal animations
   19. Reduced motion
   ========================================================================== */


/* 1. Theme tokens ========================================================= */

:root {
  /* Palette: every raw colour on the site, defined once. Don't use these in
     rules directly; use the theme tokens below, which say what a colour is for.
     JS reads colours from here too (js/holofoil.js, js/smoke.js). */
  --white: #fff;
  --gray-50: #f2f2f2;
  --gray-100: #e4e4e4;
  --gray-200: #d6d6d6;
  --gray-300: #bbb;
  --gray-500: #808080;
  --gray-700: #444;
  --gray-800: #333;
  --gray-900: #262626;
  --gray-950: #0e0e0e;
  --black: #000;
  --white-75: #ffffffbf;
  --black-75: #000000bf;

  --blue-50: #f2f6fe;
  --blue-200: #d0defb;

  /* Holo pastels: foil panels, lede highlights */
  --holo-pink: #f5cce0;
  --holo-peach: #fadbc9;
  --holo-lime: #e3f2c9;
  --holo-mint: #c9f0e6;
  --holo-sky: #ccdef5;
  --holo-lavender: #dbcff2;

  /* Neon: cursor trail */
  --neon-violet: #ae00ff;
  --neon-purple: #7105ff;
  --neon-indigo: #5900ff;
  --neon-blue: #4642ff;
  --neon-green: #00ff95;

  /* Theme tokens: what rules use. The dark theme remaps these below. */
  --bg: var(--white);
  --ink: var(--black);                 /* h1, h5, h6, wordmark, strong text */
  --ink-heading: var(--gray-800);      /* h2–h4 */
  --ink-body: var(--gray-800);         /* default text */
  --ink-muted: var(--black-75);        /* paragraphs, nav + footer links */
  --rule: var(--black);                /* article divider */
  --quote-border: var(--gray-100);

  --button-bg: var(--gray-100);
  --button-bg-hover: var(--gray-300);
  --button-ink: var(--black);

  --scroll-track: var(--gray-100);
  --scroll-thumb: var(--black);

  /* Filter chips (gallery): resting / hover follow the buttons; the selected
     chip inverts to page ink on page background, so it works in both themes */
  --chip-bg: var(--button-bg);
  --chip-bg-hover: var(--button-bg-hover);
  --chip-ink: var(--button-ink);
  --chip-active-bg: var(--ink);
  --chip-active-ink: var(--bg);
  --chip-disabled-opacity: .35;

  /* Cards and their tags look the same in both themes */
  --card-bg: var(--blue-50);
  --card-display-hover: var(--blue-200);
  --card-ink: var(--black);
  --tag-bg: var(--black);
  --tag-ink: var(--white);

  /* Theme switch (section 13): plate in page ink, rocker in page background */
  --switch-plate: var(--ink);
  --switch-plate-hover: color-mix(in srgb, var(--switch-plate) 70%, transparent);
  --switch-rocker: var(--bg);
  --switch-cap: var(--gray-500);       /* shaded top edge of the rocker */

  /* Text selection (section 15) */
  --selection-bg: var(--black);
  --selection-ink: var(--white);

  /* Holofoil gradient (section 7, js/holofoil.js), in order */
  --foil-1: var(--holo-pink);
  --foil-2: var(--holo-peach);
  --foil-3: var(--holo-lime);
  --foil-4: var(--holo-mint);
  --foil-5: var(--holo-sky);
  --foil-6: var(--holo-lavender);

  /* Cursor trail (js/smoke.js): colour per movement direction; base is also the glow */
  --trail-base: var(--neon-violet);
  --trail-up: var(--neon-purple);
  --trail-right: var(--neon-green);
  --trail-down: var(--neon-blue);
  --trail-left: var(--neon-indigo);

  --font-serif: "Libre Caslon Text", serif;
  --font-mono: "Share Tech Mono", monospace;
  --font-display: Akshar, sans-serif;
  --font-sans: Arial, sans-serif;  /* base body text; fallback for anything without its own font */

  /* Type scale: 1.200 (minor third) from a 1rem (16px) base.
     Every font-size in this file uses one of these steps. */
  --step--1: .833rem;          /* 13.3px  small UI: hints, base body text */
  --step-0:  1rem;             /* 16px    paragraphs, tags */
  --step-1:  1.2rem;           /* 19.2px  h6, nav, compact buttons, captions */
  --step-2:  1.44rem;          /* 23px    h5, buttons, hero eyebrow */
  --step-3:  1.728rem;         /* 27.6px  h4 */
  --step-4:  2.074rem;         /* 33.2px  h3, gallery title */
  --step-5:  2.488rem;         /* 39.8px  h2, wordmark */
  --step-6:  2.986rem;         /* 47.8px  h1 */
  --step-7:  3.583rem;         /* 57.3px */
  --step-8:  4.3rem;           /* 68.8px  hero tagline (mobile) */
  --step-9:  5.16rem;          /* 82.6px  hero tagline */

  /* Spacing: 4px grid. --space-N = N × 4px (in rem, so it follows the
     visitor's font-size setting). Every margin, padding, gap and offset uses
     one of these; only sub-grid optical nudges (marked "exempt") don't. */
  --space-1:  .25rem;          /* 4px */
  --space-2:  .5rem;           /* 8px */
  --space-3:  .75rem;          /* 12px */
  --space-4:  1rem;            /* 16px */
  --space-5:  1.25rem;         /* 20px */
  --space-6:  1.5rem;          /* 24px */
  --space-7:  1.75rem;         /* 28px */
  --space-8:  2rem;            /* 32px */
  --space-10: 2.5rem;          /* 40px */
  --space-12: 3rem;            /* 48px */
  --space-14: 3.5rem;          /* 56px */
  --space-16: 4rem;            /* 64px */
  --space-20: 5rem;            /* 80px */
  --space-24: 6rem;            /* 96px */
  --space-28: 7rem;            /* 112px */
  --space-32: 8rem;            /* 128px */
  --space-40: 10rem;           /* 160px */

  /* Line height: snapped to the 4px grid for whatever font-size the element
     has (CSS round(), so it stays on grid if a size changes). The ratio is the
     target; the result is the nearest 4px multiple (tight rounds up so tall
     glyphs are never clipped). */
  --leading-tight:  round(up, 1em, var(--space-1));    /* headings, buttons, quotes */
  --leading-snug:   round(1.2em, var(--space-1));      /* long titles, article blocks */
  --leading-normal: round(1.5em, var(--space-1));      /* UI text, card titles, captions */
  --leading-loose:  round(2em, var(--space-1));        /* paragraphs */

  /* Corner radii: on the 4px grid */
  --radius-sm: 4px;            /* tags, card info panels */
  --radius-md: 8px;            /* lightbox image */
  --radius-lg: 12px;           /* cards, tiles, buttons, gallery items */

  /* Strokes: hairlines may use 2px; everything else is a 4px multiple */
  --stroke-focus: 2px;         /* keyboard focus ring */
  --stroke-focus-offset: 4px;
  --stroke-quote: 4px;         /* blockquote bar */
  --scrollbar-size: 12px;

  /* Component sizes: all multiples of 4px */
  --header-height: 7rem;           /* 112px  sticky header row; anchor offset + theme toggle follow it */
  --header-link-width: 7rem;       /* 112px */
  --logo-width: 17.5rem;           /* 280px */
  --logo-height: 5.25rem;          /* 84px */
  --container-width: 58.75rem;     /* 940px  (page + article) */
  --container-width-md: 45.5rem;   /* 728px  below 992px */
  --reading-width: 42.5rem;        /* 680px  reading column: articles, case study + overview pages */
  --study-card-height: 26.25rem;   /* 420px */
  --study-tag-size: 3rem;          /* 48px */
  --gallery-intro-min: 12.25rem;   /* 196px */
  --gallery-intro-min-sm: 9.5rem;  /* 152px  phones */
  --divider-width: 4.5rem;         /* 72px   article divider */
  --divider-height: var(--space-1);
  --chip-height: var(--space-10);  /* 40px   filter chip: 8 + 24 line + 8 */

  /* Media: inspectable images (gallery tiles, article figures) */
  --media-bg: var(--card-bg);              /* behind the image while it loads */
  --media-radius: var(--radius-lg);
  --media-hover-scale: 1.05;               /* image zoom on hover / focus */
  --media-caption-ink: var(--ink-muted);
  --media-preview-ratio: 4 / 3;            /* overview gallery previews */
  --media-fill-dark: var(--black);         /* behind a contained image with its own black ground */
  --media-fill-light: var(--white);        /* …or its own white ground (same in both themes) */
  --media-outline: var(--quote-border);    /* hairline round a white-ground image on the light page */
  --media-letterbox: var(--media-bg);      /* round a contained preview (dark theme: dark) */

  /* Breakpoints (CSS can't use variables in media queries, so they're written
     out in each @media; use only these three, always as max-width):
       61.9375em  991px  tablet: narrower container, theme toggle to the corner
       47.9375em  767px  small tablet: stacked layouts
       29.9375em  479px  phone */

  --ease-expo: cubic-bezier(.19, 1, .22, 1);
  --ease-out-quart: cubic-bezier(.165, .84, .44, 1);

  /* Custom cursors (vector SVGs, 30x39px), see section 16. Numbers after url()
     are the hotspot in px (arrow tip / index fingertip); the keyword after the
     comma is used if the image can't load. */
  --cursor-default: url("../images/cursor-default.svg") 1 1, auto;
  --cursor-pointer: url("../images/cursor-pointer.svg") 9 1, pointer;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: var(--gray-950);
  --ink: var(--gray-50);
  --ink-heading: var(--gray-50);
  --ink-body: var(--gray-200);
  --ink-muted: var(--white-75);
  --rule: var(--gray-50);
  --quote-border: var(--gray-800);

  --button-bg: var(--gray-900);
  --button-bg-hover: var(--gray-700);
  --button-ink: var(--gray-50);

  --scroll-track: var(--gray-900);
  --scroll-thumb: var(--white);

  --media-letterbox: var(--gray-900);

  --selection-bg: var(--white);
  --selection-ink: var(--gray-950);
}


/* 2. Base ================================================================= */

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  cursor: var(--cursor-default);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink-body);
  background-color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--step--1);
  /* Unitless so it inherits as a ratio (13.3px × 1.5 = 20px, on grid). The
     leading tokens resolve to lengths, which would inherit as a fixed 20px;
     every element with its own font-size sets its own leading token instead. */
  line-height: 1.5;
}

img {
  display: inline-block;
  max-width: 100%;
  height: auto;                /* keeps the width/height attributes' ratio when scaled */
  vertical-align: middle;
}

/* Images fade in as they finish loading, instead of popping in. js/site.js
   marks each one .is-loaded when it loads (or fails); without JS they just
   show. The custom cursor is left out. */
.js img:not(.is-loaded, .cursor-img) {
  opacity: 0;
}

.js img.is-loaded {
  animation: img-fade-in .6s var(--ease-out-quart);
}

@keyframes img-fade-in {
  from { opacity: 0; }
}

/* The hidden attribute always wins. Without this, rules that set display
   (like img above) override it, so "hidden" images still show; e.g. the
   viewer's image stayed visible behind a playing video. */
[hidden] {
  display: none !important;
}

a {
  text-decoration: none;
}

button {
  margin: 0;
  color: inherit;
  font: inherit;
}

h1, h2, h3, h4, h5, h6 {
  margin-bottom: var(--space-3);
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: var(--leading-tight);
}

h1 {
  margin-top: 0;
  color: var(--ink);
  letter-spacing: -.05em;
  font-size: var(--step-6);
}

h2 {
  margin-top: var(--space-5);
  color: var(--ink-heading);
  font-size: var(--step-5);
}

h3 {
  margin-top: var(--space-5);
  color: var(--ink-heading);
  font-size: var(--step-4);
}

h4 {
  margin-top: var(--space-3);
  color: var(--ink-heading);
  font-size: var(--step-3);
}

h5 {
  margin-top: 0;
  color: var(--ink);
  letter-spacing: -.035em;
  text-transform: uppercase;
  font-size: var(--step-2);
}

h6 {
  margin-top: 0;
  color: var(--ink);
  font-size: var(--step-1);
}

p {
  margin-top: 0;
  margin-bottom: var(--space-3);
  color: var(--ink-muted);
  letter-spacing: -.03em;
  font-family: var(--font-serif);
  font-size: var(--step-0);
  line-height: var(--leading-loose);
}

/* Text for screen readers only */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Inline code (class names, values in case studies): the site's mono face,
   sized relative to the surrounding text */
code {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 1.05em;
  overflow-wrap: anywhere;
}

blockquote {
  margin: 0 0 var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-left: var(--stroke-quote) solid var(--quote-border);
  font-family: var(--font-serif);
  font-size: var(--step-1);
  line-height: var(--leading-tight);
}

figure {
  margin: 0 0 var(--space-3);
}

ul, ol {
  margin-top: 0;
  margin-bottom: var(--space-3);
  padding-left: var(--space-10);
}

/* Keyboard focus ring for the custom controls */
.button-compact:focus-visible,
.theme-toggle:focus-visible,
.work-tile:focus-visible,
.gallery-item:focus-visible,
.filter-chip:focus-visible,
.article-figure-media:focus-visible,
.lightbox-img:focus-visible {
  outline: var(--stroke-focus) solid var(--ink);
  outline-offset: var(--stroke-focus-offset);
}


/* 3. Layout =============================================================== */

/* Centred content column used by every section (the article has its own,
   section 11) */
.container {
  width: 70vw;
  max-width: var(--container-width);
  margin: 0 auto;
}

@media screen and (max-width: 61.9375em) /* 991px */ {
  .container {
    width: 90vw;
    max-width: var(--container-width-md);
  }
}

@media screen and (max-width: 47.9375em) /* 767px */ {
  .container {
    max-width: none;
  }
}

/* Blog-width column (same as the article page's text): for pages whose text
   and images should share one comfortable reading width, e.g. pete.html.
   Everything inside lines up on the same two edges. */
.container-reading {
  width: 90vw;
  max-width: var(--reading-width);
  margin: 0 auto;
}

.container-reading :is(.overview-intro, .case-section > *) {
  max-width: none;               /* the column itself sets the measure */
}


/* 4. Header =============================================================== */

/* Anchor targets (#studies, #footer…) stop below the sticky header instead of
   underneath it (--header-height). Used by native jumps and by
   js/smooth-scroll.js. */
[id] {
  scroll-margin-top: var(--header-height);
}

.section-header {
  position: sticky;
  top: 0;
  z-index: 1;
  background-color: var(--bg);
}

.header-div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-height);
}

.header-link-div {
  display: flex;
  align-items: center;
  width: var(--header-link-width);
  max-width: 100%;
  transition: all 1s var(--ease-expo);
}

.header-link-div.div-left {
  justify-content: flex-start;
}

.header-link-div.div-right {
  justify-content: flex-end;
}

.header-link-div:hover {
  letter-spacing: .5em;
}

/* Plain text (a span, not a heading): navigation, not page structure */
.header-link {
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: var(--step-1);
  line-height: var(--leading-normal);
}

.header-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  width: var(--logo-width);
  max-width: 100%;
  height: var(--logo-height);
}

/* A span, not a heading: each page has one h1 (its own title), so the
   wordmark carries the heading look itself */
.header-wordmark {
  display: block;
  margin: 0;
  color: var(--ink);
  letter-spacing: -.07em;
  font-family: var(--font-serif);
  font-size: var(--step-5);
  font-weight: 400;
  line-height: var(--leading-tight);
}

/* Logo heat haze on hover: the wordmark is run through the SVG filter
   #heat-haze (defined at the top of <body> on each page). Wobbling noise
   displaces the letters, mostly sideways, like air shimmering above a hot
   road, for as long as the logo is hovered. */
.header-logo:hover .header-wordmark,
.header-logo:focus-visible .header-wordmark {
  filter: url("#heat-haze");
}

/* Holds SVG definitions (filters) without affecting layout. Not display:none,
   which would stop the filter from working in some browsers. */
.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}


/* 5. Hero ================================================================= */

.section-hero {
  margin-top: var(--space-7);
  margin-bottom: var(--space-7);
}

.hero-div {
  display: flex;
  flex-direction: column;
}

.hero-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--step-2);
}

.hero-tagline {
  font-size: var(--step-9);
  transition: all 1.2s var(--ease-expo);
}

.hero-tagline:hover {
  letter-spacing: .1em;
}

.hero-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-top: var(--space-7);
}

.hero-subtitle {
  word-break: keep-all;
  font-family: var(--font-mono);
  font-size: var(--step-1);
}

.hero-ctas {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-top: var(--space-14);
}

@media screen and (max-width: 29.9375em) /* 479px */ {
  .hero-tagline {
    font-size: var(--step-8);
  }

  .hero-ctas {
    flex-wrap: wrap;
  }
}


/* 404 page (404.html): the home hero on its own, filling the screen below
   the sticky header with its content centred vertically */
.section-404 {
  display: flex;
  align-items: center;
  min-height: calc(100svh - var(--header-height));
  margin-top: 0;
  margin-bottom: 0;
  padding: var(--space-10) 0;
}

/* 6. Buttons ==============================================================
   Label sits in the bottom-left corner; letters spread out on hover.
   .button-primary / .button-secondary: full size ("Download CV", "Back to
   works"). .button-compact: smaller (gallery viewer, Inspect hints). */

.button-primary,
.button-secondary,
.button-compact {
  display: flex;
  align-items: flex-end;
  border: 0;
  border-radius: var(--radius-lg);
  background-color: var(--button-bg);
  color: var(--button-ink);
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--leading-tight);
  text-transform: uppercase;
  transition: all .6s var(--ease-expo);
}

.button-primary,
.button-secondary {
  padding: var(--space-8) var(--space-40) var(--space-2) var(--space-4);
  font-size: var(--step-2);
}

.button-compact {
  padding: var(--space-4) var(--space-10) var(--space-2) var(--space-2);
  font-size: var(--step-1);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.button-primary:hover,
.button-secondary:hover,
.button-compact:hover {
  letter-spacing: .35em;
  background-color: var(--button-bg-hover);
}


/* 7. Holofoil panels ======================================================
   Pastel foil behind .study-info, .work-tile-info and .gallery-intro (all
   carry the `holofoil` class). js/holofoil.js draws it in WebGL into a canvas
   behind the content and adds .has-holofoil; without WebGL the texture image
   shows instead. */

.holofoil {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-image: url("../images/holofoil-texture.webp");
  background-position: 50%;
  background-size: cover;
}

.holofoil.has-holofoil {
  background-image: none;
}

/* Sized by js/holofoil.js to the whole card, not the panel, so it doesn't
   have to be resized while the panel grows on hover; the panel's
   overflow: hidden clips it. */
.holofoil-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: -1;
  pointer-events: none;
}


/* 8. Study cards ========================================================== */

.section-studies {
  margin-top: var(--space-28);
}

.studies-div {
  display: flex;
  flex-direction: column;
  gap: var(--space-10);
}

/* Two columns: info (left) + mockup display (right) */
.study-card {
  container-type: inline-size;  /* the display's image is sized from the card (cqw) */
  display: grid;
  grid-template-columns: 1fr 2.25fr;
  height: var(--study-card-height);
  overflow: hidden;             /* the panel and image follow the rounded corners */
  isolation: isolate;           /* keeps the clip while the image zooms or fades (Safari) */
  border-radius: var(--radius-lg);
  background-color: var(--card-bg);
  transition: grid-template-columns 1.2s var(--ease-expo),
              background-color 1.2s var(--ease-expo);
}

.study-card:hover {
  grid-template-columns: 1.5fr 2.25fr;
}

.study-info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-8);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  transition: all .2s;
}

.card-title {
  width: 10em;
  max-width: 100%;             /* never wider than a narrow info panel */
  color: var(--card-ink);
  text-transform: uppercase;
  font-size: var(--step-1);
  line-height: var(--leading-normal);
}

.study-info-tags {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}

.info-tag {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-4) var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  background-color: var(--tag-bg);
}

/* Text-only tag (no icon): even padding on both sides */
.info-tag:not(:has(img)) {
  padding-left: var(--space-4);
}

.tag-label {
  margin-bottom: 0;
  color: var(--tag-ink);
  font-family: var(--font-mono);
  font-size: var(--step-0);
}

/* The image fills the display like the Other works covers (.work-tile-cover)
   and gently zooms on hover, on its own layer (::before) so the corner tags
   don't scale with it */
.study-display {
  position: relative;
  display: flex;
  justify-content: flex-end;
  overflow: hidden;
  transition: background-color 1.2s var(--ease-expo);
}

/* Sized from the card's width at rest (the display's 2.25 of 3.25 columns),
   not from the display: on hover the info panel widens and the display gets
   narrower, which would otherwise shrink the image (reads as a zoom-out).
   Anchored to the card's outer edge, so the panel just covers a strip of it. */
.study-display::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: calc(100cqw * 2.25 / 3.25);
  /* Each card can set its own image: style="--study-image: url('/images/...')"
     (a site-root path, so it resolves the same from any page) */
  background-image: var(--study-image, url("../images/beam-mockups.webp"));
  background-position: 50% 0;
  background-repeat: no-repeat;
  background-size: cover;
  transition: transform 1.2s var(--ease-expo);
}

.study-display .study-tags {
  position: relative;          /* above the image layer */
  z-index: 1;
}

/* Triggered by hovering anywhere on the card (info panel or display) */
.study-card:hover .study-display,
.study-card:focus-visible .study-display {
  background-color: var(--card-display-hover);
}

.study-card:hover .study-display::before,
.study-card:focus-visible .study-display::before {
  transform: scale(1.05);
}

/* Icon + counter pill in the display's top corner */
.study-tags {
  display: flex;
  align-self: flex-start;
  align-items: flex-start;
  gap: var(--space-1);
  margin-top: var(--space-5);
  margin-right: var(--space-5);
}

.study-tag {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: var(--study-tag-size);
  height: var(--study-tag-size);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  background-color: var(--tag-bg);
}

.study-tag.tag-right {
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.study-tag-icon {
  max-width: 50%;
}

.study-tag-counter {
  margin-top: 2px;            /* optical nudge, exempt from the grid */
  margin-bottom: 0;
  color: var(--tag-ink);
}

/* Mirrored variant: add `study-card-mirrored` next to `study-card`.
   Same markup (info first, then display); the grid swaps the columns. */
.study-card-mirrored {
  grid-template-columns: 2.25fr 1fr;
}

.study-card-mirrored:hover {
  grid-template-columns: 2.25fr 1.5fr;
}

.study-card-mirrored .study-info {
  grid-column: 2;
  grid-row: 1;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.study-card-mirrored .study-display {
  grid-column: 1;
  grid-row: 1;
  justify-content: flex-start;
}

.study-card-mirrored .study-display::before {
  right: auto;
  left: 0;
}

.study-card-mirrored .study-tags {
  margin-right: 0;
  margin-left: var(--space-5);
}

/* Phones and small tablets: cards stack (info on top, display below),
   mirrored or not; side by side, the info panel gets too narrow for the
   title and tags. The info panel takes the height its title and tags need
   (tags wrap in rows, like the work tiles'); the display is 16:10, like the
   work tile covers. */
@media screen and (max-width: 47.9375em) /* 767px */ {
  .study-card,
  .study-card:hover,
  .study-card-mirrored,
  .study-card-mirrored:hover {
    grid-template-rows: auto auto;
    grid-template-columns: 1fr;
    height: auto;
  }

  .study-info-tags {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .study-display {
    aspect-ratio: 16 / 10;
  }

  .study-info,
  .study-card-mirrored .study-info {
    grid-column: 1;
    grid-row: 1;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  }

  .study-card-mirrored .study-display {
    grid-column: 1;
    grid-row: 2;
  }

  .study-display::before,
  .study-card-mirrored .study-display::before {
    left: 0;
    right: 0;
    width: auto;
  }
}


/* 9. Other works ==========================================================
   Smaller sibling of the study cards, same look and hover behaviour. Two
   tiles per row on a 12-col grid, widths alternating by position:
   row 1 = 7 + 5, row 2 = 5 + 7, repeating every 4 tiles. */

.section-works {
  margin-top: var(--space-28);
}

/* Title reuses .footer-text ("Find me here"), centred the same way */
.works-header {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-5);
}

.works-heading {
  margin-bottom: 0;
}

.works-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: 26em;
  gap: var(--space-3);
}

/* Narrow by default; 1st and 4th of every group of 4 are wide */
.works-grid > .work-tile {
  grid-column: span 5;
}

.works-grid > .work-tile:nth-child(4n + 1),
.works-grid > .work-tile:nth-child(4n) {
  grid-column: span 7;
}

/* A lone tile in the last row fills it instead of leaving a gap */
.works-grid > .work-tile:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

/* Vertical take on .study-card: cover on top (like .study-display), holofoil
   info panel below (like .study-info). Looks the same in both themes. */
.work-tile {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  isolation: isolate;           /* keeps the clip while the cover zooms or fades (Safari) */
  border-radius: var(--radius-lg);
  background-color: var(--card-bg);
}

/* Cover: no padding, image runs to the card edges */
.work-tile-cover {
  position: relative;          /* for the year tag */
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  transition: background-color 1.2s var(--ease-expo);
}

.work-tile-cover img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 0;
  transition: transform 1.2s var(--ease-expo);
}

/* Year tag in the cover's top-right corner: same look as the study cards'
   tags (.study-tag), as one pill that fits its text; text one step smaller
   than their counter so it balances with the info tags below */
.work-tile-year {
  position: absolute;
  top: var(--space-5);
  right: var(--space-5);
  z-index: 1;
  display: flex;
  align-items: center;
  height: var(--study-tag-size);
  margin: 0;
  padding: 0 var(--space-3);
  border-radius: var(--radius-lg);
  background-color: var(--tag-bg);
  color: var(--tag-ink);
  letter-spacing: 0;
  white-space: nowrap;
  font-family: var(--font-serif);
  font-size: var(--step-0);       /* same size as the info tags' labels */
  line-height: var(--leading-tight);
}

/* Info panel: same foil, padding and spacing as .study-info */
.work-tile-info {
  display: flex;
  flex: 0 0 42%;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-4);
  min-height: min-content;
  padding: var(--space-6) var(--space-8);
  transition: flex-basis 1.2s var(--ease-expo);
}

/* .card-title is fixed at 10em wide in the study cards; tiles use the full width */
.work-tile .card-title {
  width: auto;
  margin-bottom: 0;
}

/* Tags sit in a row here (study cards stack them) */
.work-tile-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Hover, mirroring the study cards: the info panel grows, the cover tints
   and the image zooms in */
.work-tile:hover .work-tile-info,
.work-tile:focus-visible .work-tile-info {
  flex-basis: 55%;
}

.work-tile:hover .work-tile-cover,
.work-tile:focus-visible .work-tile-cover {
  background-color: var(--card-display-hover);
}

.work-tile:hover .work-tile-cover img,
.work-tile:focus-visible .work-tile-cover img {
  transform: scale(1.05);
}

@media screen and (max-width: 61.9375em) /* 991px */ {
  .works-grid {
    grid-auto-rows: 20em;
  }

  .work-tile-info {
    padding: var(--space-5) var(--space-6);
  }
}

/* Phones: single column, natural heights */
@media screen and (max-width: 29.9375em) /* 479px */ {
  .works-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }

  .works-grid > .work-tile,
  .works-grid > .work-tile:nth-child(n) {
    grid-column: auto;
  }

  .work-tile-cover {
    flex: none;
    aspect-ratio: 16 / 10;
  }

  .work-tile-info,
  .work-tile:hover .work-tile-info,
  .work-tile:focus-visible .work-tile-info {
    flex-basis: auto;
  }
}


/* 10. Gallery page ========================================================
   gallery.html?g=<key>; content in js/gallery-data.js, built by js/gallery.js. */

.section-gallery {
  margin-top: var(--space-7);
}

/* Holofoil header panel, same treatment as .study-info / .work-tile-info */
.gallery-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-7);
  min-height: var(--gallery-intro-min);
  margin-bottom: var(--space-3);  /* back button sits right under it */
  padding: var(--space-8);
  border-radius: var(--radius-lg);
}

.gallery-title {
  width: auto;
  max-width: 18em;
  margin: 0;
  letter-spacing: 0;           /* undo the base h1 tracking; match .card-title */
  font-size: var(--step-4);
  line-height: var(--leading-snug);
}

/* Styled by .button-primary (same as "Download CV"); this only places it.
   On its own (not in a flex row like .hero-ctas) it would stretch full width. */
.gallery-back {
  width: fit-content;
  margin-bottom: var(--space-24); /* space between the intro block and the grid */
}

/* Shown only without JavaScript (<noscript>) */
.gallery-empty {
  margin: var(--space-8) 0;
  font-family: var(--font-mono);
}

/* Grid: tiles alternate 16:9 / 9:16 by position, one of each per row, and
   every other row is mirrored:
     row 1: [  16:9  ][9:16]
     row 2: [9:16][  16:9  ]
   Three tracks: narrow | middle | narrow. A 16:9 tile spans the middle plus a
   narrow track; a 9:16 tile takes the other narrow track. For both to be the
   same height, narrow = (width - gap) x 81/337 (from 16/9 vs 9/16). The middle
   track takes the rest. Thumbnails are cropped to fit; the viewer shows the
   whole image. */
.gallery-grid {
  --gap: var(--space-3);
  --narrow: calc((100% - var(--gap)) * 81 / 337);
  display: grid;
  grid-template-columns: var(--narrow) minmax(0, 1fr) var(--narrow);
  grid-auto-flow: dense;       /* lets the mirrored rows' 9:16 tile backfill column 1 */
  gap: var(--gap);
}

/* js/gallery.js fills the grid just after the page first shows; until then
   it holds a screen's height, so the footer doesn't flash up and get pushed
   down */
.js .gallery-grid:empty {
  min-height: 100svh;
}

/* Row 1 of each pair: 16:9 left, 9:16 right */
.gallery-item:nth-child(4n + 1) { grid-column: 1 / span 2; aspect-ratio: 16 / 9; }
.gallery-item:nth-child(4n + 2) { grid-column: 3;          aspect-ratio: 9 / 16; }
/* Row 2: mirrored */
.gallery-item:nth-child(4n + 3) { grid-column: 2 / span 2; aspect-ratio: 16 / 9; }
.gallery-item:nth-child(4n + 4) { grid-column: 1;          aspect-ratio: 9 / 16; }

.gallery-item {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--media-radius);
  background-color: var(--media-bg);
}

.gallery-item-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* Filters ----------------------------------------------------------------
   Built by js/gallery.js for galleries whose images have a `type`. One row
   of multi-select chips ("All" + values), no visible label (the row is named
   for screen readers). Chips share the tags' shape and type (mono, small
   radius) and the buttons' colours. */

.gallery-back:has(+ .gallery-filters:not([hidden])) {
  margin-bottom: var(--space-14);  /* filters take the rest of the gap above the grid */
}

.gallery-filters {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-10);
}

.gallery-filters[hidden] {
  display: none;
}

.gallery-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
}

.filter-chip {
  height: var(--chip-height);
  margin: 0;
  padding: var(--space-2) var(--space-4);
  border: 0;
  border-radius: var(--radius-sm);
  background-color: var(--chip-bg);
  color: var(--chip-ink);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--step-0);
  line-height: var(--leading-normal);
  transition:
    background-color .6s var(--ease-expo),
    color .6s var(--ease-expo),
    opacity .4s var(--ease-out-quart);
  -webkit-tap-highlight-color: transparent;
}

.filter-chip:hover:not(:disabled) {
  background-color: var(--chip-bg-hover);
}

.filter-chip[aria-pressed="true"],
.filter-chip[aria-pressed="true"]:hover {
  background-color: var(--chip-active-bg);
  color: var(--chip-active-ink);
}

/* Would show nothing with the other row's choice */
.filter-chip:disabled {
  opacity: var(--chip-disabled-opacity);
  cursor: var(--cursor-default);
}

.gallery-filter-count {
  margin: 0;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  line-height: var(--leading-normal);
}

/* Filtering: the grid fades out, tiles swap, it fades back in */
.gallery-grid {
  transition: opacity .2s var(--ease-out-quart);
}

.gallery-grid.is-switching {
  opacity: 0;
}

.gallery-item[hidden] {
  display: none;
}

/* Mixed grid ---------------------------------------------------------------
   For galleries with filters or per-image shapes: square cells on a 4-column
   grid (2 on phones). Landscape spans two columns, portrait two rows, square
   one cell; `dense` packs any filtered subset without holes. The cell size
   comes from the container width (cqw), so rows stay square. */

.section-gallery .container {
  container-type: inline-size;
}

.gallery-grid-mixed {
  --cols: 4;
  --cell: calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols));
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  grid-auto-rows: var(--cell);
}

/* Undo the bento's position-based spans and ratios */
.gallery-grid-mixed .gallery-item {
  grid-column: auto;
  grid-row: auto;
  aspect-ratio: auto;
}

.gallery-grid-mixed .gallery-item.is-landscape { grid-column: span 2; }
.gallery-grid-mixed .gallery-item.is-portrait  { grid-row: span 2; }

/* fit: 'contain' in the data: the whole image, on --media-bg, for images
   whose shape would otherwise be cropped noticeably by the tile */
.gallery-item.is-contain .gallery-item-img {
  object-fit: contain;
}

/* Inspectable media (shared by .gallery-item and .article-figure-media) ---
   .media-img zooms on hover / focus; .media-hint is the "Expand" / "Inspect"
   label: a .button-compact (same look as the site's buttons, label
   bottom-left, letters spread on hover) that slides in. The transition list
   keeps the button's own hover animation. */
.media-img {
  transition: transform 1.2s var(--ease-expo);
}

.media-hint {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  gap: var(--space-2);
  opacity: 0;
  transform: translateY(calc(-1 * var(--space-2)));
  transition:
    opacity .4s var(--ease-out-quart),
    transform .8s var(--ease-expo),
    letter-spacing .6s var(--ease-expo),
    background-color .6s var(--ease-expo);
}

/* Arrows icon after the label, sized with the text */
.media-hint svg {
  flex: none;
  width: .75em;
  height: .75em;
  margin-bottom: .1em;         /* optical: sit on the text's baseline (exempt from the grid) */
}

:is(.gallery-item, .article-figure-media):is(:hover, :focus-visible) .media-img {
  transform: scale(var(--media-hover-scale));
}

:is(.gallery-item, .article-figure-media):is(:hover, :focus-visible) .media-hint {
  opacity: 1;
  transform: none;
}

@media screen and (max-width: 47.9375em) /* 767px */ {
  .gallery-title {
    font-size: var(--step-3);
  }
}

@media screen and (max-width: 29.9375em) /* 479px */ {
  .gallery-grid {
    --gap: var(--space-2);
  }

  .gallery-grid-mixed {
    --cols: 2;
  }

  /* Narrow 9:16 tiles: smaller "Expand" button so it still fits */
  .gallery-item .media-hint {
    top: var(--space-1);
    right: var(--space-1);
    gap: var(--space-1);
    padding: var(--space-2) var(--space-2) var(--space-1) var(--space-2);
    font-size: var(--step--1);
  }

  .gallery-intro {
    min-height: var(--gallery-intro-min-sm);
    padding: var(--space-6);
  }
}

/* Image viewer ------------------------------------------------------------
   Three rows: top bar (caption + close), stage (image), bottom bar (prev,
   counter, next). The bars never depend on the image, so the buttons stay
   put whatever its shape. */

html.is-lightbox-open {
  overflow: hidden;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;               /* above the theme toggle; the cursor is higher still */
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-4);
  padding: var(--space-6);
  background-color: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity .4s var(--ease-out-quart);
}

.lightbox[hidden] {
  display: none;
}

/* One image at a time (article figures): no bottom bar */
.lightbox-single {
  grid-template-rows: auto minmax(0, 1fr);
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-4);
}

/* Counter sits in the true centre: the side columns are equal, so a button
   spreading its letters on hover never pushes it */
.lightbox-bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-4);
}

.lightbox-prev  { justify-self: start; }
.lightbox-next  { justify-self: end; }
.lightbox-close { justify-self: end; }

.lightbox-meta {
  min-width: 0;
}

.lightbox-caption,
.lightbox-hint,
.lightbox-counter {
  margin: 0;
  font-family: var(--font-mono);
  line-height: var(--leading-normal);
}

.lightbox-caption {
  overflow: hidden;
  color: var(--ink);
  font-size: var(--step-1);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lightbox-hint {
  font-size: var(--step--1);
}

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

.lightbox-stage {
  position: relative;
  min-height: 0;
  overflow: hidden;            /* zoomed image is clipped to the stage */
  touch-action: none;          /* we handle drag / swipe ourselves */
  transform: scale(.97);
  transition: transform .6s var(--ease-expo);
}

.lightbox.is-open .lightbox-stage {
  transform: none;
}

/* Centred and contained in the stage at any aspect ratio */
.lightbox-img {
  position: absolute;
  inset: 0;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
  border-radius: var(--radius-md);
  transition:
    transform .6s var(--ease-expo),
    transform-origin .35s var(--ease-out-quart),
    opacity .18s linear;
}

.lightbox-img.is-loading {
  opacity: 0;
}

.lightbox.is-zoomed .lightbox-img {
  border-radius: 0;
}

/* Finger-dragging: follow immediately instead of easing */
.lightbox.is-dragging .lightbox-img {
  transition: opacity .18s linear;
}

@media screen and (max-width: 29.9375em) /* 479px */ {
  .lightbox {
    gap: var(--space-3);
    padding: var(--space-4);
  }
}


/* 11. Article ============================================================= */

/* Same reading column as .container-reading (--reading-width), so articles and case
   study pages share one text width. (It used to be 70vw minus 80px padding
   per side, which left phones with a ~100–175px column.) */
.container-article {
  width: 90vw;
  max-width: var(--reading-width);
  margin: 0 auto;
}

.article-div {
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
  margin-top: var(--space-16);
}

/* Links inside article text (e.g. between the Beam.gg studies): the base
   style removes underlines, so restore one here so they read as links */
.article-div p a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  transition: text-decoration-thickness .3s var(--ease-out-quart);
}

.article-div p a:hover,
.article-div p a:focus-visible {
  text-decoration-thickness: 2px;
}

/* Lede: an article's opening paragraph, one step larger with the divider
   line down its side. Key facts in <mark> get a highlighter stroke in the
   holo pastels (the foil gradient), so skimmers catch them. */
.article-lede {
  margin: var(--space-6) 0;    /* room from the heading above and the text below */
  padding-left: var(--space-5);
  border-left: var(--stroke-quote) solid var(--rule);
  color: var(--ink);
  font-size: var(--step-1);
  line-height: var(--leading-normal);
}

.article-lede mark {
  padding: 0 .1em;
  background-color: transparent;
  background-image: linear-gradient(120deg, var(--foil-1), var(--foil-3), var(--foil-5));
  background-repeat: no-repeat;
  background-position: 0 88%;
  background-size: 100% 42%;
  color: inherit;
}

/* Dark theme: light text on a pale stroke loses contrast, so the stroke
   becomes a band under the words instead of behind them */
:root[data-theme="dark"] .article-lede mark {
  background-position: 0 100%;
  background-size: 100% .18em;
}

/* Section headings in an article: h2 for the outline (h1 title, then h2s),
   sized like h3. One consistent gap above every one. */
.article-block h2 {
  font-size: var(--step-4);
}

.article-block h2:not(:first-child) {
  margin-top: var(--space-10);
}

.article-title {
  font-weight: 700;
  line-height: var(--leading-snug);
}

.article-spacer {
  width: var(--divider-width);
  height: var(--divider-height);
  margin: var(--space-10) auto;
  background-color: var(--rule);
}

.article-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  line-height: var(--leading-snug);
}


/* Article figures --------------------------------------------------------
   <figure class="article-figure"> with an <img> and a <figcaption>; see
   js/article-figures.js, which wraps the image in .article-figure-media (a
   button that opens the viewer) and adds the "Inspect" hint. Hover / focus
   zoom and hint come from the shared media rules in section 10. */

.article-figure {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-6) 0;
}

.article-figure-media {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;            /* clips the hover zoom to the rounded frame */
  border: 0;
  border-radius: var(--media-radius);
  background-color: var(--media-bg);
}

.article-figure :is(img, video) {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--media-radius);   /* also rounds it without JS */
}

.article-figure-media :is(img, video) {
  border-radius: 0;            /* the frame clips it */
}

.article-figure figcaption {
  color: var(--media-caption-ink);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  line-height: var(--leading-normal);
}

/* Project overview pages (e.g. esports-business-conference.html) -------
   Gallery-page intro (holofoil panel + back button), the intro paragraph as
   a lede (p.overview-intro.article-lede), then .article-figure items in a
   two-column grid. Every preview has the same 4:3 frame; Inspect opens the
   whole, uncropped image. By default the image fills the frame from the top;
   per figure:
     .preview-left / -center / -bottom fill, anchored left / centred / at the bottom
     .preview-contain                  the whole image inside the frame, on
                                       --media-letterbox (wide graphics, logos)
     + .preview-fill-dark / -light     …on the image's own black / white ground */

.gallery-back:has(+ .overview-intro) {
  margin-bottom: var(--space-14);
}

.overview-intro {
  max-width: var(--container-width-md);
  margin-top: 0;                 /* the back button above sets the gap */
  margin-bottom: var(--space-14);
}

.overview-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: var(--space-8) var(--space-6);
}

.overview-gallery .article-figure {
  margin: 0;
}

.overview-gallery .article-figure :is(img, video) {
  aspect-ratio: var(--media-preview-ratio);
  object-fit: cover;
  object-position: 50% 0;
}

.overview-gallery .preview-left :is(img, video) {
  object-position: 0 0;
}

.overview-gallery .preview-center :is(img, video) {
  object-position: 50% 50%;
}

.overview-gallery .preview-bottom :is(img, video) {
  object-position: 50% 100%;
}

.overview-gallery .preview-contain :is(img, video) {
  object-fit: contain;
  object-position: 50% 50%;
  background-color: var(--media-letterbox);
}

.overview-gallery .preview-fill-dark :is(img, video) {
  background-color: var(--media-fill-dark);
}

.overview-gallery .preview-fill-light :is(img, video) {
  background-color: var(--media-fill-light);
}

.overview-gallery .preview-fill-light .article-figure-media,
.overview-gallery .preview-fill-light > :is(img, video) {
  box-shadow: 0 0 0 1px var(--media-outline);
}

@media screen and (max-width: 29.9375em) /* 479px */ {
  .overview-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Case study sections on gallery-style pages (e.g. pete.html): text at the
   intro's reading width, then a desktop + mobile pair of the same screen. */
.case-section {
  margin-bottom: var(--space-16);
}

.case-section > :is(h2, h3, p) {
  max-width: var(--container-width-md);
}

.case-section > h3 {
  margin-top: 0;
}

.article-figure-pair {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1fr);
  align-items: start;
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.article-figure-pair .article-figure {
  margin: 0;
}

@media screen and (max-width: 29.9375em) /* 479px */ {
  .article-figure-pair {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The phone mockup on its own, at a phone-ish size */
  .article-figure-pair .article-figure:last-child {
    width: 100%;
    max-width: 16rem;
    margin-inline: auto;
  }
}

/* Two figures side by side (wireframe + design, print pieces...); stacks on
   phones. Each figure keeps its own caption and Inspect. */
.article-figure-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: var(--space-6);
  margin: var(--space-6) 0;
}

.article-figure-row .article-figure {
  margin: 0;
}

@media screen and (max-width: 29.9375em) /* 479px */ {
  .article-figure-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* No hover on touch screens: keep the "Inspect" hint visible so it's
   clear the image opens */
@media (hover: none) {
  .article-figure-media .media-hint {
    opacity: 1;
    transform: none;
  }
}


/* 12. Footer ============================================================== */

.footer-div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-32) 0;
}

.footer-text {
  font-size: var(--step-2);
  line-height: var(--leading-normal);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.footer-link {
  padding: var(--space-4);
  opacity: .7;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: var(--step-1);    /* same size as the header links */
  font-weight: 700;
  line-height: var(--leading-normal);
  transition: all .6s var(--ease-expo);
}

.footer-link:hover {
  opacity: 1;
  color: var(--ink);
  letter-spacing: .5em;
}


/* 13. Theme toggle ========================================================
   A light switch (added by js/site.js): a plate in the page ink with a rocker
   in the page background, up in light mode and down in dark mode; it flips
   when clicked. On hover the plate fades to 70% (the footer links' resting
   opacity), with the buttons' easing. The button itself
   is a transparent hit area. Its centre lines up with the header links: half
   of --header-height down. */

.theme-toggle {
  --switch-w: var(--space-7);           /* 28px plate */
  --switch-h: var(--space-12);          /* 48px */
  --rocker-w: var(--space-2);           /* 8px */
  --rocker-h: var(--space-4);           /* 16px */
  --rocker-gap: var(--space-2);         /* plate edge to rocker */
  position: fixed;
  top: calc(var(--header-height) / 2);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  padding: var(--space-2);
  border: 0;
  background: none;
  cursor: pointer;
  transform: translateY(-50%);
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover .theme-toggle-plate {
  background-color: var(--switch-plate-hover);
}

.theme-toggle-plate {
  position: relative;
  display: block;
  width: var(--switch-w);
  height: var(--switch-h);
  background-color: var(--switch-plate);
  transition: all .6s var(--ease-expo);
}

/* Rocker with its shaded top edge (a quarter of its height) */
.theme-toggle-rocker {
  position: absolute;
  top: var(--rocker-gap);
  left: calc(50% - var(--rocker-w) / 2);
  width: var(--rocker-w);
  height: var(--rocker-h);
  background: linear-gradient(var(--switch-cap) 25%, var(--switch-rocker) 25%);
  transition: all .6s var(--ease-expo);
}

:root[data-theme="dark"] .theme-toggle-rocker {
  top: calc(100% - var(--rocker-gap) - var(--rocker-h));
}

/* Below 992px the right gutter is too narrow, so it moves to the corner */
@media screen and (max-width: 61.9375em) /* 991px */ {
  .theme-toggle {
    top: auto;
    bottom: var(--space-4);
    right: var(--space-4);
    transform: none;
  }
}

/* Below 768px the hero buttons reach the corner and scroll under the switch,
   so it's hidden: phones and small tablets follow the system light / dark
   setting (js/site.js), or the choice already saved on a wider screen. */
@media screen and (max-width: 47.9375em) /* 767px */ {
  .theme-toggle {
    display: none;
  }
}


/* 14. Cursor trail ========================================================
   js/smoke.js. Sits behind all page content but above the page background
   (body's background is painted on the root canvas, below this). Elements
   with their own background — the sticky header, cards, buttons — cover it.
   Never blocks clicks. */

.smoke-canvas,
.smoke-mirror {
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.smoke-canvas {
  position: fixed;
}

/* Copy of the trail inside the sticky header: above the header's solid
   background (which still covers scrolling content), below its links.
   The header is already a stacking context (sticky + z-index). */
.smoke-mirror {
  position: absolute;
}


/* 15. Text selection ======================================================
   Solid and high-contrast: a dark highlight with white text in light mode,
   a white highlight with dark text in dark mode (tokens in section 1). */

::selection {
  background-color: var(--selection-bg);
  color: var(--selection-ink);
  text-shadow: none;
}


/* 16. Custom cursor =======================================================
   The native SVG cursors (tokens in section 1) are the fallback; when
   js/cursor.js runs it hides the native cursor and draws a smoothed one
   instead (.cursor). Any rule that wants the hand should use
   var(--cursor-pointer); the list below matches POINTER_SELECTOR in
   js/cursor.js. */

a,
button:not(:disabled),
label,
summary,
[role="button"],
input[type="submit"],
input[type="button"],
input[type="checkbox"],
input[type="radio"],
select {
  cursor: var(--cursor-pointer);
}

/* The native cursor is hidden only once the script has started, so the
   fallback above always works without it. */
html.has-custom-cursor,
html.has-custom-cursor * {
  cursor: none !important;
}

.cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2147483647;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  will-change: transform;
}

.cursor.is-visible {
  opacity: 1;
}

/* Each image is offset by its hotspot so the tip/fingertip sits exactly on
   the cursor position. */
.cursor-img {
  position: absolute;
  top: -1.5px;
  width: 30px;
  height: 39px;
  max-width: none;
}

.cursor-img-default {
  left: -1.5px;
}

.cursor-img-pointer {
  left: -8.6px;
  opacity: 0;
}

.cursor.is-pointer .cursor-img-default {
  opacity: 0;
}

.cursor.is-pointer .cursor-img-pointer {
  opacity: 1;
}


/* 17. Scrollbar =========================================================== */

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background-color: var(--scroll-track);
}

::-webkit-scrollbar-thumb {
  background-color: var(--scroll-thumb);
}

/* Firefox only takes colours + auto/thin. Scoped so Chrome keeps the rules
   above (in Chrome, scrollbar-color would override ::-webkit-scrollbar). */
@supports not selector(::-webkit-scrollbar) {
  html {
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
    scrollbar-width: thin;
  }
}


/* 18. Reveal animations ===================================================
   Elements with data-reveal="top|bottom|left|right" fade + slide 100px in
   when they scroll into view (js/site.js adds .is-revealed). Hidden only when
   JS runs, so the page still shows everything without it. */

.js [data-reveal]:not(.is-revealed) {
  opacity: 0;
}

.js [data-reveal].is-revealed {
  animation: reveal 1s var(--ease-out-quart) var(--reveal-delay, 0ms) both;
}

[data-reveal="top"]    { --reveal-from: 0, -100px; }
[data-reveal="bottom"] { --reveal-from: 0, 100px; }
[data-reveal="left"]   { --reveal-from: -100px, 0; }
[data-reveal="right"]  { --reveal-from: 100px, 0; }

@keyframes reveal {
  from {
    opacity: 0;
    transform: translate(var(--reveal-from));
  }

  to {
    opacity: 1;
    transform: none;
  }
}


/* 19. Reduced motion ====================================================== */

@media (prefers-reduced-motion: reduce) {
  /* No logo distortion */
  .header-logo:hover .header-wordmark,
  .header-logo:focus-visible .header-wordmark {
    filter: none;
  }

  /* Content just appears */
  .js [data-reveal]:not(.is-revealed) {
    opacity: 1;
  }

  .js [data-reveal].is-revealed,
  .js img.is-loaded {
    animation: none;
  }

  .button-compact,
  .theme-toggle-plate,
  .theme-toggle-rocker,
  .work-tile-info,
  .work-tile-cover,
  .work-tile-cover img,
  .study-display::before,
  .media-img,
  .media-hint,
  .filter-chip,
  .gallery-grid,
  .lightbox,
  .lightbox-stage,
  .lightbox-img {
    transition: none;
  }
}
