/* Portfolio shared stylesheet. Every page's content, text and figures alike,
   fills one frame, 60rem at most (--wide), with a fluid side gutter
   (--gutter). --measure only sizes the narrow figure (the patent drawing).
   Also pinned to the light palette regardless of the viewer's prefers-
   color-scheme (Milena 22 Oct). */
:root {
  --bg: #f6f8f9;
  --surface: #ffffff;
  --fg: #16212b;
  --muted: #56636f;
  --faint: #66727d; /* small labels: 4.6:1 on --bg, 4.9:1 on --surface (WCAG AA) */
  --rule: #dce2e7;
  --accent: #2f5b82;
  --accent-soft: #e4ecf3;
  --fog: 220, 226, 231;
  --stage: #0f1519;
  --font-display: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-body: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --measure: 48rem;
  /* Side gutter grows with the window instead of stepping at breakpoints. */
  --gutter: clamp(16px, 4vw, 48px);
  --wide: 60rem; /* one width for every page's content */
}

* { box-sizing: border-box; }
/* Keep room for the scrollbar on every page, so the centred masthead stays put
   when moving between a page that scrolls and one that doesn't. */
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 1.25rem; line-height: 1.6;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-block: 0 4rem;
  -webkit-font-smoothing: antialiased;
}
@media (max-width: 760px) {
  body { font-size: 1.0625rem; line-height: 1.65; }
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
a { color: var(--accent); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:focus-visible, button:focus-visible, input:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
/* A column fills the page frame, as the intro's content does. */
.col { max-width: var(--wide); margin-inline: auto; }
.wide { max-width: var(--wide); margin-inline: auto; }

/* ---------- Masthead ---------- */
.mast { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem 1.5rem; max-width: var(--wide); margin: 0 auto; padding-block: 1.5rem; border-bottom: 1px solid var(--rule); }
.mast .name { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; letter-spacing: -0.01em; }
.mast .name a { color: var(--fg); text-decoration: none; }
.mast nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.875rem; }
.mast nav a { color: var(--muted); text-decoration: none; }
.mast nav a:hover, .mast nav a[aria-current="page"] { color: var(--fg); }

/* ---------- Hero ---------- */
.hero { padding-block: 4rem 2.5rem; }
.eyebrow { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 1.25rem; }
.thesis { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.9rem, 4.6vw, 3rem); line-height: 1.15; letter-spacing: -0.015em; margin: 0; text-wrap: balance; max-width: 30ch; }
.hero .lede { margin: 1.75rem 0 0; color: var(--muted); max-width: 36rem; }
.hero .lede a { color: var(--fg); }
.proof { list-style: none; margin: 2rem 0 0; padding: 1rem 0 0; border-top: 1px solid var(--rule); display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 1.5rem; font-size: 0.875rem; color: var(--muted); }
.proof li { min-width: 0; }
.proof .k { display: block; font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: 0.2rem; }
@media (max-width: 640px) { .proof { grid-template-columns: 1fr; } }

/* ---------- Case study card (intro page) ---------- */
.cases { max-width: var(--wide); margin: 3rem auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.cases a.card { display: flex; flex-direction: column; gap: 0.6rem; padding: 1.5rem 1.75rem 1.75rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); text-decoration: none; color: inherit; transition: border-color 160ms ease, transform 160ms ease; }
.cases a.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cases a.card .num { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
.cases a.card h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
.cases a.card p { margin: 0; color: var(--muted); font-size: 0.9375rem; }
.cases a.card .read { margin-top: auto; padding-top: 0.5rem; font-size: 0.8125rem; color: var(--accent); font-weight: 500; }
@media (max-width: 720px) { .cases { grid-template-columns: 1fr; } }

/* ---------- Case study page ---------- */
section.case { padding-block: 3.5rem 1rem; }
.case-head { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; margin-bottom: 2.5rem; }
.case-num { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0; }
.case-head h1 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.9rem, 3.6vw, 2.5rem); line-height: 1.15; letter-spacing: -0.01em; margin: 0; text-wrap: balance; }
.oneline { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.45; margin: 0; }
dl.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem 1.5rem; margin: 0.5rem 0 0; padding: 1rem 0 0; border-top: 1px solid var(--rule); font-size: 0.875rem; }
dl.meta div { min-width: 0; }
dl.meta dt { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }
dl.meta dd { margin: 0.15rem 0 0; color: var(--muted); }
dl.glance { margin: 0 0 1rem; padding: 0.25rem 1.25rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; }
dl.glance > div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0 1.25rem; padding: 0.8rem 0; }
dl.glance > div + div { border-top: 1px solid var(--rule); }
dl.glance dt { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); padding-top: 0.25rem; }
dl.glance dd { margin: 0; min-width: 0; font-size: 0.9375rem; }
@media (max-width: 560px) { dl.glance > div { grid-template-columns: 1fr; gap: 0.2rem; } }

/* Case-page headings, scaled against the 20px body (17px on phones):
   title 40 > part 34 > section 28 > sub-section 22 > body 20. */
.case h2 { font-family: var(--font-display); font-weight: 600; font-size: clamp(1.45rem, 2.6vw, 1.75rem); line-height: 1.25; margin: 3rem 0 0.75rem; letter-spacing: -0.01em; text-wrap: balance; }
.case h2.feature { margin-top: 3.75rem; }
.case h3 { font-family: var(--font-body); font-weight: 600; font-size: clamp(1.15rem, 1.8vw, 1.375rem); line-height: 1.35; margin: 2.25rem 0 0.5rem; }
.case h3.minor { font-family: var(--font-mono); font-weight: 500; font-size: 0.75rem; line-height: 1.6; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 1.75rem; }
.kicker { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 3.5rem 0 0; padding-top: 1.5rem; border-top: 1px solid var(--rule); }
.kicker + h2 { margin-top: 0.4rem; }
.part { margin: 4.5rem auto 0; padding-top: 2rem; border-top: 2px solid var(--fg); }
.part .kicker { border: 0; padding: 0; margin: 0; }
.case .part h2 { font-size: clamp(1.7rem, 3.2vw, 2.125rem); line-height: 1.2; margin-top: 0.35rem; }
p { margin: 0 0 1rem; }
ul.plain, ol.plain { margin: 0 0 1rem; padding-left: 1.2rem; }
ul.plain li, ol.plain li { margin-bottom: 0.45rem; }
ul.plain li::marker, ol.plain li::marker { color: var(--faint); }
ol.heur { columns: 2; column-gap: 2rem; font-size: 0.95rem; }
ol.heur li { break-inside: avoid; }
@media (max-width: 560px) { ol.heur { columns: 1; } }

/* ---------- Figures ---------- */
figure { margin: 2.25rem auto; max-width: var(--wide); }
figure.narrow > .frame { max-width: var(--measure); }
/* Live Sounding preview iframes. Every figure that embeds the app shares
   this one class, so tweaking width or height in one place updates all of
   them. The iframe keeps a fixed height; the reader scrolls inside it. */
figure.sounding-embed { max-width: var(--wide); }
figure.sounding-embed .embed iframe { height: 820px; }
.frame { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 1.25rem; }
.frame.shot { padding: 0; overflow: hidden; }
.frame.paper { padding: 1rem; background: #ffffff; }
.frame.paper img { display: block; width: 100%; max-width: 26rem; height: auto; margin: 0 auto; }
figcaption { font-size: 0.875rem; color: var(--muted); margin: 0.75rem 0 0; line-height: 1.55; }
figcaption b { font-family: var(--font-mono); font-weight: 500; font-size: 0.75rem; letter-spacing: 0.04em; color: var(--fg); margin-right: 0.35rem; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.pair > * { min-width: 0; }
.sub { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); margin: 0 0 0.4rem; }
@media (max-width: 720px) { .pair { grid-template-columns: 1fr; } }
button.zoom { display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; cursor: zoom-in; }
button.zoom img, .frame.shot > img { display: block; width: 100%; height: auto; }

.embed { border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: var(--bg); }
.embed iframe { display: block; width: 100%; height: 640px; border: 0; }
.embed.sea { background: var(--bg); }
/* Self-contained figures (the 3D reconstructions) draw their own stage, so
   no frame: the stage sits flush with the figure edges and their text lines
   up with the reading column. */
.embed.bare { border: 0; border-radius: 0; overflow: visible; background: none; }
.embed-alt { font-size: 0.8125rem; color: var(--faint); margin: 0.4rem 0 0; }

.table-wrap { overflow-x: auto; }
table.t { border-collapse: collapse; width: 100%; font-size: 0.875rem; font-variant-numeric: tabular-nums; }
table.t th, table.t td { text-align: left; padding: 0.55rem 0.75rem 0.55rem 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.t th { font-family: var(--font-mono); font-weight: 500; font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--faint); }
table.t td.num, table.t th.num { text-align: right; padding-right: 0; padding-left: 0.75rem; }
details.data { margin-top: 1rem; font-size: 0.875rem; }
details.data summary { cursor: pointer; color: var(--accent); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Footer ---------- */
.foot { font-size: 0.875rem; color: var(--muted); }
.srcs { font-size: 0.8125rem; color: var(--muted); padding-left: 1.1rem; }
.srcs li { margin-bottom: 0.3rem; }
dialog.lightbox { padding: 0; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); max-width: min(96vw, 1400px); max-height: 94vh; overflow: auto; }
dialog.lightbox::backdrop { background: rgba(10, 14, 18, 0.72); }
dialog.lightbox img { display: block; width: 100%; height: auto; }
dialog.lightbox .close { position: sticky; top: 0; float: right; margin: 0.5rem; font: inherit; font-size: 0.8125rem; border: 1px solid var(--rule); background: var(--surface); color: var(--fg); border-radius: 999px; padding: 0.3rem 0.8rem; cursor: pointer; }
.also { padding-block: 3rem 0; border-top: 1px solid var(--rule); }
.also h2 { font-size: 1.5rem; margin-bottom: 1rem; }
footer { margin-top: 3.5rem; padding-top: 1.5rem; border-top: 1px solid var(--rule); font-size: 0.875rem; color: var(--muted); }
footer .contact { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 1rem; }

/* ---------- Next-case strip (bottom of each case page) ---------- */
.next-case { max-width: var(--wide); margin: 4rem auto 0; padding-top: 1.5rem; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: 0.9375rem; }
.next-case a { color: var(--fg); text-decoration: none; }
.next-case a:hover { color: var(--accent); }
.next-case .label { font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); display: block; margin-bottom: 0.15rem; }

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