/* Periodic projects page (projects.html) + generated case studies (work/*.html).
   Tokens and header mirror the encyclopedia-style homepage (index.html). */

:root {
  --text: #202122;
  --text-subtle: #54595d;
  --link: #3366cc;
  --link-visited: #6a60b0;
  --border: #a2a9b1;
  --border-light: #c8ccd1;
  --border-faint: #eaecf0;
  --bg: #ffffff;
  --bg-subtle: #f8f9fa;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Lato, Helvetica, Arial, sans-serif;
  --font-serif: "Linux Libertine", "Georgia", "Times", "Source Serif Pro", serif;

  /* element groups: faint tint, rule, ink */
  --g-rdash-bg: #eef3fb;       --g-rdash-line: #b4c7e4;       --g-rdash-ink: #2a4f8f;
  --g-product-bg: #edf5ef;     --g-product-line: #b3cfb9;     --g-product-ink: #2f6b3f;
  --g-interactive-bg: #f9f0e7; --g-interactive-line: #dfc2a3; --g-interactive-ink: #8a4b1c;
  --g-visual-bg: #f4eff9;      --g-visual-line: #cbbade;      --g-visual-ink: #5f3f8a;

  --gap: 6px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-sans); font-size: 16px; line-height: 1.6; }
a { color: var(--link); text-decoration: none; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
img { max-width: 100%; height: auto; display: block; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link { position: absolute; left: -9999px; top: 0; }
.skip-link:focus { left: 8px; top: 8px; background: #fff; padding: 6px 10px; z-index: 100; border: 1px solid var(--border); }

.wrap { max-width: 1246px; margin: 0 auto; padding: 0 24px; }

/* ───────── header (same as homepage, minus search) ───────── */
.site-header { position: relative; z-index: 20; border-bottom: 1px solid var(--border-faint); }
.header-inner { max-width: 1246px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 12px; }
.icon-btn {
  display: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: transparent; border: 1px solid transparent; border-radius: 2px;
  color: var(--text); cursor: pointer;
}
.icon-btn:hover { background: rgba(0,24,73,.027); border-color: var(--border-faint); }
.icon-btn svg { width: 20px; height: 20px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); flex-shrink: 0; }
.brand:visited { color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 40px; height: 40px; flex-shrink: 0; }
.brand-words { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font-family: var(--font-serif); font-size: 19px; letter-spacing: .08em; font-variant: small-caps; text-transform: lowercase; }
.brand-tag { font-family: var(--font-serif); font-size: 11.5px; margin-top: 4px; letter-spacing: .02em; }
.top-nav { margin-left: auto; }
.top-nav ul { display: flex; gap: 18px; list-style: none; margin: 0; padding: 0; font-size: 14px; }
.top-nav a, .top-nav a:visited { color: var(--link); }
.top-nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.main-menu {
  display: none; position: absolute; top: 52px; left: 12px; width: 220px;
  background: #fff; border: 1px solid var(--border); box-shadow: 0 2px 6px -1px rgba(0,0,0,.2);
  padding: 8px 0; font-size: 14px;
}
.main-menu.open { display: block; }
.main-menu ul { list-style: none; margin: 0; padding: 0; }
.main-menu a { display: block; padding: 9px 14px; }

/* ───────── page intro ───────── */
.intro { padding: 36px 0 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 40px; align-items: end; border-bottom: 1px solid var(--border-light); }
.eyebrow { margin: 0 0 10px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-subtle); }
.intro h1 { margin: 0; font-family: var(--font-serif); font-weight: 400; font-size: clamp(32px, 4.6vw, 52px); line-height: 1.05; letter-spacing: -.01em; }
.intro-copy { margin: 14px 0 0; max-width: 60ch; color: var(--text-subtle); font-size: 15px; }
.intro-stats { margin: 0; display: flex; gap: 22px; font-size: 13px; color: var(--text-subtle); }
.intro-stats div { display: flex; flex-direction: column; align-items: flex-end; }
.intro-stats dt { order: 2; }
.intro-stats dd { margin: 0; font-family: var(--font-serif); font-size: 30px; line-height: 1; color: var(--text); }

/* ───────── filters ───────── */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 16px 0 22px; }
.filters[hidden] { display: none; }
.filters-label { font-size: 13px; color: var(--text-subtle); margin-right: 6px; }
.filter {
  min-height: 32px; padding: 4px 12px;
  font: 13px var(--font-sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--border-light); border-radius: 2px; cursor: pointer;
}
.filter:hover { border-color: var(--text); }
.filter[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.filter-status { margin-left: auto; font-size: 13px; color: var(--text-subtle); }
.noscript-gap { height: 22px; }

/* ───────── the table ───────── */
.ptable { padding-bottom: 40px; }
.pgroup { margin-bottom: 22px; }
.pgroup-label { margin: 0 0 8px; display: flex; align-items: baseline; gap: 10px; font-size: 13px; font-weight: 600; }
.pgroup-num { font-family: var(--font-serif); font-weight: 400; font-size: 18px; color: var(--g-ink); }
.pgroup-note { font-weight: 400; color: var(--text-subtle); }
.pgroup-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: var(--gap); }

[data-group="rdash"]       { --g-bg: var(--g-rdash-bg);       --g-line: var(--g-rdash-line);       --g-ink: var(--g-rdash-ink); }
[data-group="product"]     { --g-bg: var(--g-product-bg);     --g-line: var(--g-product-line);     --g-ink: var(--g-product-ink); }
[data-group="interactive"] { --g-bg: var(--g-interactive-bg); --g-line: var(--g-interactive-line); --g-ink: var(--g-interactive-ink); }
[data-group="visual"]      { --g-bg: var(--g-visual-bg);      --g-line: var(--g-visual-line);      --g-ink: var(--g-visual-ink); }

.cell { position: relative; }
.cell:hover, .cell:focus-within { z-index: 5; }

.tile {
  position: relative; display: block; aspect-ratio: 1 / 1; min-height: 96px;
  padding: 8px 9px;
  background: var(--g-bg); border: 1px solid var(--g-line);
  color: var(--text);
  transition: border-color .15s, opacity .2s, filter .2s;
}
.tile:visited { color: var(--text); }
.tile:hover { text-decoration: none; border-color: var(--text); }
.tile:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.tile-index { position: absolute; top: 7px; left: 9px; font-size: 12px; font-variant-numeric: tabular-nums; }
.tile-year { position: absolute; top: 7px; right: 9px; font-size: 11px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.tile-symbol {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-serif); font-size: clamp(34px, 3.4vw, 46px); line-height: 1; letter-spacing: .01em;
  color: var(--g-ink); padding-bottom: 4px;
}
.tile-cat, .tile-name {
  position: absolute; left: 9px; right: 9px; bottom: 7px;
  font-size: 11px; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-cat { color: var(--text-subtle); }
.tile-name { display: none; color: var(--text); font-weight: 600; }

/* filtering: non-matching elements recede but stay in place, like a highlighted family */
.cell.is-dimmed .tile { opacity: .3; filter: grayscale(1); }
.cell.is-dimmed .tile:hover, .cell.is-dimmed .tile:focus-visible { opacity: 1; filter: none; }

/* hover / focus preview: the element grows into the 2×2 space beside it */
.tile-preview {
  --clip-from: inset(0 50% 50% 0);
  position: absolute; top: -1px; left: -1px;
  width: calc(200% + var(--gap) + 4px); min-height: calc(200% + var(--gap) + 4px);
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 12px 12px;
  background: #fff; border: 1px solid var(--text);
  box-shadow: 0 10px 28px -8px rgba(0,0,0,.25);
  color: var(--text);
  opacity: 0; visibility: hidden; pointer-events: none;
  clip-path: var(--clip-from);
  transition: clip-path .22s cubic-bezier(.2,.7,.2,1), opacity .12s, visibility 0s .22s;
}
.cell.flip-x .tile-preview { left: auto; right: -1px; --clip-from: inset(0 0 50% 50%); }
.cell.flip-y .tile-preview { top: auto; bottom: -1px; --clip-from: inset(50% 50% 0 0); }
.cell.flip-x.flip-y .tile-preview { --clip-from: inset(50% 0 0 50%); }
.pv-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.pv-head b { color: var(--text); font-weight: 400; }
.pv-symbol { font-family: var(--font-serif); font-size: 34px; line-height: 1; color: var(--g-ink); margin-top: 2px; }
.pv-title { font-family: var(--font-serif); font-size: 19px; line-height: 1.2; margin-top: 4px; }
.pv-cats { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--g-ink); }
.pv-desc { font-size: 13px; line-height: 1.45; color: var(--text-subtle); }
.pv-cue { margin-top: auto; padding-top: 6px; font-size: 13px; color: var(--link); }

@media (min-width: 700px) {
  .tile:focus-visible .tile-preview { opacity: 1; visibility: visible; clip-path: inset(0); transition: clip-path .22s cubic-bezier(.2,.7,.2,1), opacity .12s; }
}
@media (min-width: 700px) and (hover: hover) {
  .tile:hover .tile-preview { opacity: 1; visibility: visible; clip-path: inset(0); transition: clip-path .22s cubic-bezier(.2,.7,.2,1), opacity .12s; }
}

/* touch devices and narrow screens: no hover, so the name is always shown */
@media (hover: none), (max-width: 699px) {
  .tile .tile-cat { display: none; }
  .tile-name { display: block; }
  .tile-name::after { content: " \2192"; color: var(--link); font-weight: 400; }
}

/* ───────── key / legend ───────── */
.key { margin: 4px 0 40px; padding: 14px 16px; border: 1px solid var(--border-light); background: var(--bg-subtle); font-size: 13px; }
.key h2 { margin: 0 0 10px; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-subtle); font-weight: 600; }
.key-body { display: flex; gap: 18px; align-items: flex-start; }
.key-tile { position: relative; flex: 0 0 104px; height: 104px; background: #fff; border: 1px solid var(--text); }
.key-tile .tile-symbol { color: var(--text); font-size: 40px; }
.key-tile .tile-cat { display: block; }
.key dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.key dt { font-weight: 600; }
.key dd { margin: 0; color: var(--text-subtle); }
.key-groups { list-style: none; margin: 12px 0 0; padding: 10px 0 0; border-top: 1px solid var(--border-light); display: flex; flex-wrap: wrap; gap: 6px 16px; }
.key-groups li { display: flex; align-items: center; gap: 7px; }
.swatch { width: 14px; height: 14px; background: var(--g-bg); border: 1px solid var(--g-line); }

/* desktop: one continuous table. Groups become periods (rows); the key sits in the gap, as on a real periodic table */
@media (min-width: 1000px) {
  .ptable {
    display: grid; gap: var(--gap);
    grid-template-columns: 9.5rem repeat(8, minmax(0, 1fr));
    padding-bottom: 48px;
  }
  .pgroup, .pgroup-tiles { display: contents; }
  .pgroup-label {
    grid-column: 1; margin: 0; padding: 8px 10px 0 0;
    flex-direction: column; gap: 2px; align-items: flex-start;
    border-top: 2px solid var(--g-line);
  }
  .pgroup-num { font-size: 22px; line-height: 1; }
  .pgroup-note { font-size: 12px; line-height: 1.35; }
  .key { grid-column: 7 / span 3; grid-row: 2 / span 2; margin: 0 0 0 calc(var(--gap) * 3); align-self: stretch; }
  .key-tile { flex-basis: 96px; height: 96px; }
}

/* ───────── entrance ───────── */
@keyframes tileIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.ptable .cell { animation: tileIn .4s cubic-bezier(.2,.7,.2,1) both; animation-delay: calc(var(--i, 0) * 22ms); }

@media (prefers-reduced-motion: reduce) {
  .ptable .cell { animation: none; }
  .tile, .tile-preview { transition: none !important; }
  .tile-preview { clip-path: none; }
}

/* ───────── case study template ───────── */
.crumbs { padding: 14px 0 0; font-size: 13px; color: var(--text-subtle); }
.crumbs ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.crumbs li + li::before { content: "›"; margin-right: 4px; color: var(--border); }

.cs-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 24px; align-items: center; padding: 22px 0 22px; border-bottom: 1px solid var(--border-light); }
.cs-element { position: relative; width: 132px; height: 132px; background: var(--g-bg); border: 1px solid var(--g-line); }
.cs-element .tile-symbol { font-size: 58px; }
.cs-element .tile-cat { display: block; }
.cs-hero h1 { margin: 0; font-family: var(--font-serif); font-weight: 400; font-size: clamp(30px, 4.2vw, 46px); line-height: 1.08; }
.cs-summary { margin: 10px 0 0; font-size: 17px; color: var(--text-subtle); max-width: 60ch; }

.cs-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 40px; padding: 26px 0 40px; }
.cs-main { min-width: 0; max-width: 720px; }
.cs-main h2 { margin: 34px 0 10px; padding-bottom: 4px; font-family: var(--font-serif); font-weight: 400; font-size: 26px; line-height: 1.25; border-bottom: 1px solid var(--border-light); }
.cs-main h2:first-child { margin-top: 0; }
.cs-main h3 { margin: 18px 0 4px; font-size: 16px; }
.cs-main p, .cs-main li { font-size: 16px; }
.cs-main p { margin: 0 0 12px; }
.hatnote { font-style: italic; color: var(--text-subtle); font-size: 14px; padding-left: 16px; margin: 0 0 14px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; margin-bottom: 14px; }
.steps li::before { content: counter(step, decimal-leading-zero); position: absolute; left: 0; top: 1px; font-family: var(--font-serif); font-size: 18px; color: var(--g-ink); }
.steps h3 { margin: 0 0 2px; }
.steps p { margin: 0; }

.cs-figure { margin: 0 0 8px; }
.cs-figure img { border: 1px solid var(--border-faint); width: auto; max-width: 100%; }
.cs-figure figcaption, .cs-gallery-caption { margin-top: 6px; font-size: 13px; color: var(--text-subtle); }
.cs-gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.cs-gallery img { border: 1px solid var(--border-faint); width: 100%; }

.outcomes { margin: 0 0 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.outcome { display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--border-light); background: var(--bg-subtle); }
.outcome dd { margin: 0; }
.outcome-value { order: -1; font-family: var(--font-serif); font-size: 32px; line-height: 1.1; }
.outcome dt { font-size: 14px; font-weight: 600; margin-top: 2px; }
.outcome-note { font-size: 13px; color: var(--text-subtle); }
.badge { display: inline-block; margin-top: 6px; padding: 1px 6px; font-size: 11px; letter-spacing: .04em; border: 1px solid var(--border); color: var(--text-subtle); }
.badge.verified { border-color: var(--g-product-ink); color: var(--g-product-ink); }
.footnote { font-size: 13px; color: var(--text-subtle); }

.infobox { position: sticky; top: 16px; border: 1px solid var(--border); background: var(--bg-subtle); font-size: 14px; line-height: 1.45; border-collapse: collapse; width: 100%; }
.infobox caption { caption-side: top; text-align: left; padding: 8px 10px; font-weight: 600; background: var(--g-bg); border: 1px solid var(--border); border-bottom: 0; }
.infobox th, .infobox td { padding: 6px 10px; vertical-align: top; text-align: left; border-top: 1px solid var(--border-faint); }
.infobox th { width: 40%; font-weight: 600; }

.pn { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 24px 0; border-top: 1px solid var(--border-light); }
.pn a { display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--border-light); color: var(--text); }
.pn a:hover { border-color: var(--text); text-decoration: none; }
.pn a:visited { color: var(--text); }
.pn .next { justify-content: flex-end; text-align: right; }
.pn-mini { position: relative; flex: 0 0 56px; height: 56px; background: var(--g-bg); border: 1px solid var(--g-line); }
.pn-mini .tile-symbol { font-size: 24px; }
.pn-mini .tile-index, .pn-mini .tile-year, .pn-mini .tile-cat { display: none; }
.pn small { display: block; font-size: 12px; color: var(--text-subtle); }
.pn span.pn-title { font-family: var(--font-serif); font-size: 18px; line-height: 1.2; }
.pn a.pn-all { grid-column: 1 / -1; justify-self: center; font-size: 14px; border: 0; padding: 4px; color: var(--link); }

.cta { margin: 0 0 32px; padding: 20px; border: 1px solid var(--border-light); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.cta p { margin: 0; font-family: var(--font-serif); font-size: 20px; }
.cta a.cta-btn { padding: 8px 14px; border: 1px solid var(--text); color: var(--text); font-size: 14px; }
.cta a.cta-btn:hover { background: var(--text); color: #fff; text-decoration: none; }

/* ───────── footer ───────── */
.site-footer { border-top: 1px solid var(--border-light); padding: 14px 0 32px; font-size: 12px; line-height: 1.5; }
.site-footer p { margin: 0 0 6px; }
.site-footer ul { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }

/* ───────── responsive ───────── */
@media (max-width: 999px) {
  .cs-body { grid-template-columns: 1fr; }
  .cs-aside { order: -1; }
  .infobox { position: static; }
}
@media (max-width: 760px) {
  .wrap, .header-inner { padding: 0 16px; }
  .site-header { position: sticky; top: 0; background: var(--bg); }
  .icon-btn { display: inline-flex; }
  .top-nav { display: none; }
  .intro { grid-template-columns: 1fr; padding-top: 24px; }
  .intro-stats div { align-items: flex-start; }
  .filter-status { flex-basis: 100%; margin-left: 0; }
  .key-body { flex-direction: column; }
  .key-tile { flex: none; width: 104px; }
  .cs-hero { grid-template-columns: 1fr; gap: 16px; }
  .cs-element { width: 96px; height: 96px; }
  .cs-element .tile-symbol { font-size: 42px; }
  .pn { grid-template-columns: 1fr; }
  .pn .next { justify-content: flex-start; text-align: left; flex-direction: row-reverse; }
}
@media (max-width: 699px) {
  .pgroup-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tile { min-height: 0; }
  .tile-symbol { font-size: clamp(28px, 9vw, 40px); }
}
@media (max-width: 560px) {
  .brand-words { display: none; }
}
