/* ---------- Tokens ---------- */
:root {
  --bg: #ffffff;
  --fg: #151515;
  --muted: #6d6d6a;
  --line: #e4e4e0;
  --tile-bg: #eeeeeb;
  --accent: var(--fg);
  --font: "Open Sans", Helvetica, Arial, sans-serif;
  --step-0: 0.9375rem;                             /* body, meta */
  --step-1: clamp(1.0625rem, 0.95rem + 0.4vw, 1.25rem); /* tile titles, h2 */
  --step-2: clamp(1.75rem, 1.3rem + 1.8vw, 2.75rem);   /* page titles */
  --gutter: 16px;
  --gap: 16px;
  --max: 1280px;
  --text: 680px;
  --wide: 1100px;
}
@media (min-width: 600px)  { :root { --gutter: 24px; --gap: 20px; } }
@media (min-width: 1024px) { :root { --gutter: 40px; --gap: 28px; } }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 400 var(--step-0)/1.6 var(--font);
  overflow-x: hidden;
}
img, video, iframe { display: block; max-width: 100%; }
img, video { height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3 { font-weight: 500; line-height: 1.2; margin: 0; }
.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Header ---------- */
.site-header { padding-top: 24px; padding-bottom: 12px; }
.site-header .wrap { display: flex; flex-direction: column; gap: 8px; }
.site-name {
  font-size: var(--step-1); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  text-decoration: none; display: inline-flex; align-items: center; min-height: 44px;
}
.site-id { display: flex; flex-direction: column; align-items: flex-start; }
.site-email { color: var(--muted); text-decoration: none; font-size: .875rem; margin-top: -6px; }
@media (hover: hover) { .site-email:hover { color: var(--fg); text-decoration: underline; } }
@media (min-width: 1024px) {
  .site-header { padding-top: 36px; padding-bottom: 20px; }
  .site-header .wrap { flex-direction: row; align-items: center; justify-content: space-between; gap: 24px; }
}

/* ---------- Filter chips ---------- */
.filters {
  display: flex; gap: 4px 18px; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter);
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.filters::-webkit-scrollbar { display: none; }
@media (min-width: 600px) { .filters { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; } }
.chip {
  flex: none; min-height: 44px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--muted); white-space: nowrap;
  text-decoration: none; text-underline-offset: 6px;
}
.chip[aria-pressed="true"] { color: var(--fg); text-decoration: underline; text-decoration-thickness: 1px; }
.chip:focus-visible, .tile:focus-visible, a:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }
@media (hover: hover) { .chip:hover { color: var(--fg); } }

/* ---------- Home: filter sidebar ---------- */
@media (min-width: 1024px) {
  :root { --side-w: 96px; --side-gap: 40px; }
  .home { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); gap: var(--side-gap); align-items: start; }
  .home-page .site-id { margin-left: calc(var(--side-w) + var(--side-gap)); } /* name/email line up with the images */
  .home .grid { column-gap: var(--side-gap); } /* space between tiles = space between sidebar and grid */
  .home-page .site-footer .wrap { padding-left: calc(var(--gutter) + var(--side-w) + var(--side-gap)); } /* © lines up with the images */
  .home-side { position: sticky; top: 24px; padding-top: 4px; }
  .home-side .filters { flex-direction: column; flex-wrap: nowrap; gap: 0; align-items: flex-end; } /* right-aligned, next to the grid */
  .home-side .chip { min-height: 36px; text-align: right; }
}

/* ---------- Home: filter dropdown (phones/tablets) ---------- */
.filter-menu { display: none; }
@media (max-width: 1023px) {
  .home-side { display: none; }                                   /* sidebar list is desktop-only */
  .home-page .site-header .wrap { align-items: flex-start; gap: 4px; } /* dropdown sits under the name/email, left-aligned */
  /* name, email and filter stay pinned while scrolling */
  .home-page .site-header { position: sticky; top: 0; z-index: 20; background: var(--bg); padding-bottom: 2px;
    border-bottom: 1px solid transparent; transition: border-color .2s ease; }
  .home-page .site-header.scrolled { border-bottom-color: var(--line); } /* same line as the footer's top border */
  .home-page .grid { padding-top: 6px; }
  /* left-anchored under the name, so the triangle stays put whatever the label; the label never wraps */
  .filter-menu { display: block; position: relative; flex: none; }
  .filter-toggle {
    display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0; white-space: nowrap;
    border: 0; background: none; font: inherit; color: var(--fg); cursor: pointer; text-align: left;
  }
  .filter-current { font-weight: 500; color: var(--muted); } /* same as the tile titles */
  /* triangle points right at the filter name when closed, down when open */
  .filter-toggle .caret { font-size: 1.2em; line-height: 1; color: var(--muted); transition: transform .2s ease; }
  .filter-toggle[aria-expanded="true"] .caret { transform: rotate(90deg); }
  .filter-panel {
    position: absolute; left: -12px; top: 100%; z-index: 10; width: max-content; min-width: 148px; padding: 4px 12px;
    background: var(--bg); box-shadow: 0 8px 24px rgba(0, 0, 0, .08);
  }
  .filter-panel .filters { flex-direction: column; flex-wrap: nowrap; gap: 0; margin: 0; padding: 0; overflow: visible; align-items: flex-start; }
  .filter-panel .chip { min-height: 32px; text-align: left; }
}

/* ---------- Filter list: "Collaborators" subheading (sidebar and dropdown) ---------- */
.filter-heading { flex-basis: 100%; margin: 12px 0 0; color: var(--muted); cursor: default; } /* same as the filters, but plain text */
.filter-panel .filter-heading { margin: 14px 0 2px; }   /* no bottom space: the names sit right under it */
.home-side .filter-heading { margin: 16px 0 2px; text-align: right; }
.filter-panel .chip[data-group="w"] { margin-left: 12px; } /* mobile dropdown only: names indented under their heading */
.home-side .filter-heading, .filter-panel .filter-heading { flex-basis: auto; }
.chip[data-group="w"] { white-space: nowrap; line-height: 1.3; padding: 5px 0; min-height: 0; font-size: 12px; } /* smaller; one line each */
@media (min-width: 1024px) { .home-side .filter-heading { text-align: right; } }

/* ---------- Tile grid ---------- */
.grid {
  position: relative; /* fading tiles are positioned against the grid */
  display: grid; gap: calc(var(--gap) * 1.5) var(--gap);
  grid-template-columns: 1fr;
  padding-top: 12px; padding-bottom: 48px;
}
@media (min-width: 600px)  { .grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } }
.tile { text-decoration: none; display: block; }
.tile-img {
  aspect-ratio: 4 / 3; overflow: hidden; background: var(--tile-bg);
}
.tile-img img { width: 100%; height: 100%; object-fit: cover; transition: opacity .25s ease; }
.tile-img.contain { background: none; }
.tile-img.contain img { object-fit: contain; } /* "fit": "contain" - whole image, no crop */
.tile-meta { display: flex; justify-content: space-between; gap: 12px; padding-top: 10px; }
.tile-title { font-size: var(--step-0); font-weight: 500; color: var(--muted); }
.tile-year { color: var(--muted); font-variant-numeric: tabular-nums; }
.tile-year { display: none; } /* TEMP: years hidden on tiles - delete this line to show them again */
@media (hover: hover) { .tile:hover .tile-img img { opacity: .82; } }
.empty { color: var(--muted); padding: 48px 0; }

/* ---------- Project page ---------- */
.project { padding-bottom: 64px; }
.project-head { max-width: var(--text); padding: 4px 0 24px; }
.project-title { font-size: var(--step-2); letter-spacing: -0.01em; margin-left: -0.05em; } /* optical alignment: offsets the font's left side-bearing at large sizes */
.project-subtitle { font-size: var(--step-1); color: var(--muted); margin-top: 8px; }
.meta {
  list-style: none; margin: 16px 0 0; padding: 0; color: var(--muted);
  display: grid; grid-template-columns: minmax(5.5em, max-content) minmax(0, 1fr); gap: 0 16px;
}
.meta li { display: contents; }
@media (min-width: 600px) { .meta { grid-template-columns: minmax(7.5em, max-content) minmax(0, 1fr); gap: 0 24px; } }
.meta .v { color: var(--fg); }

.prose { max-width: var(--text); }
.prose > * { margin: 0 0 1em; }
.prose h2 { font-size: var(--step-1); margin: 2em 0 .6em; }
.prose h3 { font-size: var(--step-0); font-weight: 600; margin: 1.6em 0 .4em; }
.prose ul { padding-left: 1.2em; }
.prose small { display: block; color: var(--muted); font-size: .8125rem; line-height: 1.5; } /* footnotes, e.g. copyright notices */
.prose > .links { list-style: none; padding: 0; } /* "More information" etc., under the description */
.prose > .links li + li { margin-top: 4px; }
/* blocks and figures in prose may be wider than the text column */
.prose > .block, .prose > p:has(> img:only-child) { max-width: var(--wide); width: min(var(--wide), calc(100vw - 2 * var(--gutter))); }
.prose > .block.specs { width: 100%; max-width: var(--text); }
.prose img { width: 100%; }

.hero { margin: 0 0 32px; }
.prose + .hero { margin-top: 16px; } /* standard layout: space between the description and the hero */
.hero img, .hero video { width: 100%; }
.hero.wide { max-width: var(--wide); }
/* don't upscale small or portrait images: natural size, at most 80% of the screen height */
.hero.wide > img, .hero.wide > video { width: auto; max-width: 100%; max-height: 80vh; }
.full-bleed { width: 100vw; margin-left: calc(50% - 50vw); max-width: none; }
.full-bleed img { width: 100%; height: auto; max-height: 88vh; object-fit: contain; background: none; } /* never crop */


/* ---------- Blocks ---------- */
.block { margin: 32px 0; }
.gallery { display: grid; gap: var(--gap); grid-template-columns: 1fr; max-width: var(--wide); }
@media (min-width: 600px) {
  .gallery.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .gallery.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .gallery.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) { .gallery.cols-4 { grid-template-columns: repeat(4, 1fr); } }
.gallery.crop img { aspect-ratio: 4 / 3; object-fit: cover; }
.gallery-group { max-width: var(--wide); }
.gallery-group > .gallery { margin: 0; } /* the group carries the block spacing; its caption sits under the grid */
@media (min-width: 600px) { .gallery.match { display: flex; align-items: flex-start; } .gallery.match figure { flex: 1 1 0%; min-width: 0; } } /* equal heights per row */
figure { margin: 0; }
figure img, figure video { width: 100%; }
figure video { background: var(--tile-bg); } /* no background on images: transparent PNGs would show it */
figcaption { color: var(--muted); font-size: .875rem; padding-top: 6px; }

.video { max-width: var(--wide); }
.video .embed { position: relative; aspect-ratio: 16 / 9; background: var(--tile-bg); }
.video .embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video video { width: 100%; }
.block.video > video { width: auto; max-width: 100%; max-height: 80vh; } /* same sizing as a hero video */

.embed-block iframe { width: 100%; aspect-ratio: 4 / 3; border: 0; background: var(--tile-bg); }

.compare { display: grid; gap: var(--gap); grid-template-columns: 1fr; max-width: var(--wide); }
@media (min-width: 600px) { .compare { grid-template-columns: 1fr 1fr; } }

.specs { width: 100%; max-width: var(--text); border-collapse: collapse; }
.specs th, .specs td { text-align: left; vertical-align: top; padding: 8px 0; border-top: 1px solid var(--line); }
.specs th { font-weight: 400; color: var(--muted); width: 36%; padding-right: 16px; }

/* ---------- Layout: visual ---------- */
.layout-visual .project-head { padding-bottom: 16px; }
.layout-visual .hero { margin-bottom: 32px; }

/* ---------- Layout: case-study ---------- */
@media (min-width: 1024px) {
  .layout-case-study .cs { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 56px; align-items: start; }
  .layout-case-study .cs-side { position: sticky; top: 24px; }
  .layout-case-study .prose > .block:not(.specs), .layout-case-study .prose > p:has(> img:only-child) { width: auto; max-width: 100%; }
  .layout-case-study .prose { max-width: none; }
  .layout-case-study .prose > :not(.block):not(:has(> img:only-child)) { max-width: var(--text); }
}
@media (max-width: 1023px) { .layout-case-study .cs-side { margin-bottom: 48px; } } /* space above the text when stacked */
.layout-case-study .cs-side .meta { margin-top: 0; }
.layout-case-study .cs-side .meta { display: block; }
.layout-case-study .cs-side .meta li { display: block; margin-bottom: 12px; }
.layout-case-study .cs-side .meta .k, .layout-case-study .cs-side .meta .v { display: block; }
.layout-case-study .cs-side .hero { margin-bottom: 24px; }
.layout-case-study .cs-side .links { list-style: none; padding: 0; margin: 4px 0 0; } /* same links as under the text */
.layout-case-study .cs-side .links li + li { margin-top: 4px; }
/* cover (e.g. a paper's first page) is always a small thumbnail, on every screen size */
.layout-case-study .cs-side .hero img { width: 260px; box-shadow: 0 1px 3px rgba(0, 0, 0, .12), 0 6px 16px rgba(0, 0, 0, .10); } /* page shadow on the project page only, not the tile */

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 24px 0 40px; color: var(--muted); font-size: .875rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.site-footer a { color: inherit; min-height: 32px; display: inline-flex; align-items: center; }

.notice { padding: 64px 0; color: var(--muted); }
