/* David Young portfolio
   Layout: one reading column with wide figures that break out of it; work listed as full-width rows.
   Color: cool paper and navy ink, with editor's blue pencil as the single accent. */
:root {
  --paper: #f5f6f8;
  --surface: #ffffff;
  --ink: #131a2b;
  --ink-soft: #3a4357;
  --muted: #5d667a;
  --line: #dde1e8;
  --accent: #2350b8;
  --pencil: #9cc8ec;
  --pencil-soft: rgba(156, 200, 236, 0.35);
  --shadow: 0 1px 2px rgba(19, 26, 43, 0.06), 0 14px 36px rgba(19, 26, 43, 0.08);

  --font-display: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;

  --measure: 40rem;
  --wide: 68rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f131c; --surface: #161b27; --ink: #e8ecf4; --ink-soft: #c3cada; --muted: #98a2b7;
    --line: #283041; --accent: #8fb0ff; --pencil: #5d93c7; --pencil-soft: rgba(93, 147, 199, 0.28);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0f131c; --surface: #161b27; --ink: #e8ecf4; --ink-soft: #c3cada; --muted: #98a2b7;
  --line: #283041; --accent: #8fb0ff; --pencil: #5d93c7; --pencil-soft: rgba(93, 147, 199, 0.28);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 18px 40px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.7 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
img { max-width: 100%; height: auto; display: block; }
code { font-family: var(--font-mono); font-size: 0.86em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.35em; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; text-wrap: balance; margin: 0; }
p { margin: 0; }

.wrap {
  max-width: calc(var(--wide) + 32px);
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Site header */
.site-head { border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding-block: 1rem; }
.name-mark { display: inline-flex; align-items: center; gap: 0.65rem; font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; color: var(--ink); text-decoration: none; }
.name-mark img { width: 2.25rem; height: 2.25rem; border-radius: 50%; object-fit: cover; background: var(--line); box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.site-nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; font-size: 0.95rem; }
.site-nav a { color: var(--ink-soft); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; }

/* Labels */
.label {
  font-family: var(--font-mono); font-size: 0.76rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
/* Editor's blue-pencil underline, used once per page on the key phrase */
.pencil { background: linear-gradient(transparent 62%, var(--pencil-soft) 62%, var(--pencil-soft) 92%, transparent 92%); padding: 0 0.08em; }

/* Home: intro */
.intro { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 2.25rem; align-items: start; padding-block: 4.5rem 3.5rem; }
.portrait { width: 9.5rem; aspect-ratio: 1; border-radius: 50%; object-fit: cover; background: var(--line); box-shadow: 0 0 0 6px var(--surface), 0 0 0 7px var(--line); }
.intro h1 { font-size: clamp(2.3rem, 5vw, 3.4rem); letter-spacing: -0.015em; }
.intro .role { margin-top: 0.5rem; font-size: 1.15rem; color: var(--ink-soft); }
.intro .bio { margin-top: 1.4rem; max-width: var(--measure); display: grid; gap: 1rem; color: var(--ink-soft); }
.intro .links { margin-top: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; font-size: 0.95rem; }

/* Section heads */
.section { padding-block: 3rem; border-top: 1px solid var(--line); }
.section-head { display: grid; gap: 0.5rem; margin-bottom: 2rem; max-width: var(--measure); }
.section-head h2 { font-size: clamp(1.6rem, 3vw, 2.1rem); }
.section-head p { color: var(--ink-soft); }

/* Work rows */
.work-list { display: grid; gap: 2.5rem; }
.work {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 2rem; align-items: center;
  color: inherit; text-decoration: none;
}
.work-shot { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); }
.work-shot img { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; transition: transform 0.4s ease; }
a.work:hover .work-shot img { transform: scale(1.015); }
.work-body { display: grid; gap: 0.8rem; min-width: 0; }
.work-body h3 { font-size: 1.7rem; }
a.work:hover h3 { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.15em; }
.work-body p { color: var(--ink-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0; padding: 0; list-style: none; }
.tags li { font-family: var(--font-mono); font-size: 0.74rem; padding: 0.15rem 0.5rem; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--surface); }
.work-cta { font-weight: 600; color: var(--accent); }
.status { font-family: var(--font-mono); font-size: 0.74rem; color: var(--muted); }
.work--pending .work-shot { display: grid; place-items: center; aspect-ratio: 16 / 10; box-shadow: none; border-style: dashed; background: transparent; color: var(--muted); font-size: 0.9rem; padding: 1rem; text-align: center; }

/* Evidence table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
caption { caption-side: top; text-align: left; font-weight: 600; padding: 0.9rem 1rem 0.6rem; color: var(--ink); }
th, td { text-align: left; vertical-align: top; padding: 0.7rem 1rem; border-top: 1px solid var(--line); }
th { font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 500; }
td code { white-space: nowrap; }

/* Case study */
.cs-hero { padding-block: 4rem 2.5rem; display: grid; gap: 1.1rem; }
.cs-hero h1 { font-size: clamp(2.6rem, 6vw, 4.2rem); letter-spacing: -0.02em; }
.cs-hero .dek { max-width: 42rem; font-size: 1.22rem; line-height: 1.55; color: var(--ink-soft); }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; border-block: 1px solid var(--line); margin: 1.5rem 0 0; }
.facts div { padding: 1rem 1.25rem 1rem 0; min-width: 0; }
.facts div + div { padding-left: 1.25rem; border-left: 1px solid var(--line); }
.facts dt { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0.35rem 0 0; font-size: 0.95rem; }

.figure { margin: 2.25rem 0; }
.figure .frame { border-radius: 10px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); }
.figure figcaption { margin-top: 0.7rem; font-size: 0.88rem; color: var(--muted); max-width: var(--measure); }
.figure--pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; }
.figure--pair figure { margin: 0; }
.figure video { display: block; width: 100%; height: auto; background: #0c0e11; }
.tutorial-frame { position: relative; }
.tutorial-play { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%, -50%); display: grid; place-items: center; width: 4.25rem; height: 4.25rem; border: 2px solid #fff; border-radius: 50%; background: rgba(12, 14, 17, .82); color: #fff; cursor: pointer; }
.tutorial-play:hover { background: #0c0e11; }
.tutorial-play:focus-visible { outline: 3px solid #3ddc97; outline-offset: 3px; }
.tutorial-play[hidden], .tutorial-volume[hidden] { display: none; }
.tutorial-play svg { display: block; width: 2rem; height: 2rem; fill: currentColor; margin-left: .2rem; }
.tutorial-volume { display: flex; align-items: center; gap: .65rem; margin-top: .65rem; color: var(--ink-soft); font-size: .9rem; }
.tutorial-volume input { width: min(10rem, 50%); accent-color: var(--pencil); cursor: pointer; }

.video-note { margin: 0.6rem 0 0; color: var(--muted); font-size: 0.95rem; }
.figure--tall .frame { max-width: var(--measure); }

.chapter { padding-block: 3rem; border-top: 1px solid var(--line); display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 1rem 3rem; }
.chapter > .label { padding-top: 0.55rem; }
.chapter-body { min-width: 0; }
.prose { max-width: var(--measure); display: grid; gap: 1.1rem; }
.prose h2 { font-size: clamp(1.55rem, 3vw, 2rem); margin-bottom: 0.2rem; }
.prose p { color: var(--ink-soft); }
.prose strong { color: var(--ink); }

.quote {
  margin: 0.5rem 0; padding: 1rem 1.2rem; border-left: 3px solid var(--pencil); background: var(--surface); border-radius: 0 8px 8px 0;
  font-size: 0.98rem; color: var(--ink-soft);
}
.quote .label { display: block; margin-bottom: 0.35rem; }

.swatches { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.swatch { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); font-size: 0.85rem; }
.swatch span { display: block; height: 3.5rem; }
.swatch p { padding: 0.55rem 0.7rem; display: grid; gap: 0.1rem; color: var(--ink-soft); }
.swatch b { color: var(--ink); font-weight: 600; }
.swatch code { border: 0; background: none; padding: 0; color: var(--muted); }

.next { padding-block: 3rem 4rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: baseline; }
.next a { font-family: var(--font-display); font-size: 1.4rem; font-weight: 600; }

.site-foot { border-top: 1px solid var(--line); }
.site-foot .wrap { padding-block: 1.5rem 2.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; font-size: 0.88rem; color: var(--muted); }

@media (max-width: 820px) {
  .intro { grid-template-columns: 1fr; gap: 1.5rem; padding-block: 3rem 2.5rem; }
  .portrait { width: 7rem; }
  .work { grid-template-columns: 1fr; gap: 1.1rem; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .facts div:nth-child(3) { padding-left: 0; border-left: 0; }
  .facts div:nth-child(n+3) { border-top: 1px solid var(--line); }
  .chapter { grid-template-columns: 1fr; gap: 0.75rem; }
  .chapter > .label { padding-top: 0; }
  .figure--pair { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Sticky "On this page" bar on case studies */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
.toc { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper); border-block: 1px solid var(--line); margin-top: 2rem; }
.toc-inner { display: flex; align-items: center; gap: 0.35rem 1.1rem; overflow-x: auto; padding-block: 0.65rem; scrollbar-width: thin; }
.toc .label { flex: none; }
.toc a { flex: none; font-size: 0.9rem; color: var(--ink-soft); text-decoration: none; padding: 0.15rem 0; border-bottom: 2px solid transparent; }
.toc a:hover, .toc a[aria-current="true"] { color: var(--ink); border-bottom-color: var(--pencil); }
.chapter { scroll-margin-top: 4rem; }
.skill-chips { margin-top: 0.5rem; }

/* Home: readers */
.audiences { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.audience { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; display: grid; gap: 0.6rem; align-content: start; min-width: 0; }
.audience h3 { font-size: 1.3rem; }
.audience p { color: var(--ink-soft); font-size: 0.97rem; }
.audience .see { font-size: 0.9rem; display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; }

/* Home: case study cards, newest first */
.case-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.case-card { display: grid; gap: 0.7rem; align-content: start; padding: 1.4rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: inherit; text-decoration: none; transition: border-color 0.15s ease, transform 0.15s ease; min-width: 0; }
.case-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.case-card h3 { font-size: 1.45rem; }
.case-card p { color: var(--ink-soft); }
.case-card .when { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.25rem 1rem; }

/* Home: skills */
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr)); gap: 1rem; }
.skill-group { display: grid; gap: 0.6rem; align-content: start; padding: 1.1rem 1.2rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.skill-group h3 { font-size: 1.1rem; }
.skill-group .where { font-size: 0.86rem; color: var(--muted); }

/* Case pages: sample callout and prev/next */
.sample-card { display: grid; gap: 0.6rem; padding: 1.2rem 1.3rem; border: 1px solid var(--line); border-left: 4px solid var(--pencil); border-radius: 8px; background: var(--surface); max-width: var(--measure); }
.sample-card a { font-weight: 600; }
.pager { padding-block: 2.5rem 4rem; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pager a { display: grid; gap: 0.2rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-decoration: none; color: var(--ink); }
.pager a:hover { border-color: var(--accent); }
.pager a.next { text-align: right; }
.pager b { font-family: var(--font-display); font-size: 1.2rem; font-weight: 600; }

@media (max-width: 820px) {
  .audiences, .case-grid { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager a.next { text-align: left; }
}

/* Links that open in a new tab get an icon; screen readers hear the same note as text */
.new-tab { display: inline-block; margin-left: 0.35em; vertical-align: -0.1em; }
.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; }

/* Organization logos on case cards and case pages, drawn in the ink color so they follow the theme */
/* --logo-scale evens out visual weight: a dense wordmark needs less height than a stacked logo */
.org-logo { display: block; height: calc(1.6rem * var(--logo-scale, 1)); width: auto; max-width: 100%; background: var(--ink); -webkit-mask-position: left center; mask-position: left center; -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; }
.cs-hero .org-logo { height: calc(2.25rem * var(--logo-scale, 1)); margin-bottom: 0.5rem; }
/* Center each card logo in a 2rem slot so card text lines up whatever the logo's height */
.case-card .org-logo { margin-block: calc((2rem - 1.6rem * var(--logo-scale, 1)) / 2); }
@media (forced-colors: active) { .org-logo, .tech-mark { forced-color-adjust: none; background: CanvasText; } }

/* Tools row: small monochrome technology marks beside each tool name */
.tech-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; }
.tech-list li { display: inline-flex; align-items: center; gap: 0.4rem; }
.built-with { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); font-size: 0.95rem; }
.tags li .tech-mark { display: inline-block; vertical-align: -0.15em; margin-right: 0.35em; }
.tech-mark { flex: none; width: 1.05em; height: 1.05em; background: var(--ink); -webkit-mask-size: contain; mask-size: contain; -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat; -webkit-mask-position: center; mask-position: center; }

/* Click-to-enlarge figures and the image viewer (site.js) */
.zoom-trigger { display: block; position: relative; width: 100%; padding: 0; border: 0; background: none; color: inherit; cursor: zoom-in; }
.zoom-trigger:focus-visible { outline-offset: -4px; }
.zoom-badge {
  position: absolute; right: 0.75rem; bottom: 0.75rem; display: grid; place-items: center; width: 2.25rem; height: 2.25rem;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  opacity: 0; transition: opacity 0.15s ease;
}
.zoom-trigger:hover .zoom-badge, .zoom-trigger:focus-visible .zoom-badge { opacity: 1; }
@media (hover: none) { .zoom-badge { opacity: 1; } }

html:has(.viewer[open]) { overflow: hidden; }
.viewer { width: 100%; height: 100%; max-width: 100%; max-height: 100%; margin: 0; padding: 0; border: 0; background: var(--paper); color: var(--ink); }
.viewer[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer::backdrop { background: rgba(19, 26, 43, 0.6); }
.viewer-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; border-bottom: 1px solid var(--line);
  padding: max(0.6rem, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 0.6rem max(16px, env(safe-area-inset-left, 0px));
}
.viewer-tools { display: flex; align-items: center; gap: 0.3rem; margin-left: auto; }
.viewer-tools button { display: grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); cursor: pointer; }
.viewer-tools button:hover { border-color: var(--accent); }
.viewer-pct { min-width: 3.5rem; text-align: center; font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); }
.viewer-stage { position: relative; overflow: hidden; touch-action: none; }
.viewer-stage.can-pan { cursor: grab; }
.viewer-stage.panning { cursor: grabbing; }
.viewer-stage img { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; user-select: none; -webkit-user-drag: none; }
.viewer-caption {
  border-top: 1px solid var(--line); font-size: 0.88rem; color: var(--muted);
  padding: 0.6rem max(16px, env(safe-area-inset-right, 0px)) max(0.8rem, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.viewer-caption:empty { display: none; }
@media (max-width: 820px) { .viewer-hint { display: none; } }
