/* Base: what the artifact skeleton gives its first page, so every page has it. */
:root { color-scheme: light; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden]:not([hidden=until-found i]) { display: none !important; }

/* Layout: one reading column for words, a wider column for screens. Each before/after pair is a drag-to-compare frame with its notes underneath. */
:root {
  --bg: #f1f2f0;
  --surface: #ffffff;
  --ink: #16181b;
  --muted: #5b6168;
  --line: #d9dcdf;
  --accent: #c8202f;
  --accent-ink: #ffffff;
  --before: #4c5a78;
  --shade: rgba(22, 24, 27, 0.06);

  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --text: 1.0625rem;
  --small: 0.875rem;
  --tiny: 0.75rem;
  --h3: 1.375rem;
  --h2: clamp(1.9rem, 4.2vw, 2.9rem);
  --h1: clamp(2.6rem, 7.5vw, 5.4rem);

  --read: 40rem;
  --wide: 72rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113;
    --surface: #171a1d;
    --ink: #eceef0;
    --muted: #9aa1a9;
    --line: #2b2f34;
    --accent: #ef4651;
    --accent-ink: #12090a;
    --before: #9fb0d4;
    --shade: rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1113;
  --surface: #171a1d;
  --ink: #eceef0;
  --muted: #9aa1a9;
  --line: #2b2f34;
  --accent: #ef4651;
  --accent-ink: #12090a;
  --before: #9fb0d4;
  --shade: rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.page {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: clamp(2.5rem, 6vw, 5rem) 3rem;
}
.wide { max-width: var(--wide); margin-inline: auto; }
.read { max-width: var(--read); }

h1, h2, h3 { font-family: var(--display); font-stretch: 118%; text-wrap: balance; margin: 0; }
h1 { font-size: var(--h1); font-weight: 800; line-height: 0.95; letter-spacing: -0.02em; }
h2 { font-size: var(--h2); font-weight: 750; line-height: 1.05; letter-spacing: -0.01em; }
h3 { font-size: var(--h3); font-weight: 700; line-height: 1.2; font-stretch: 110%; }
p { margin: 0; }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.label {
  font-family: var(--mono);
  font-size: var(--tiny);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Header */
.intro { display: grid; gap: 1.75rem; }
.intro .lede { font-size: 1.25rem; line-height: 1.5; color: var(--muted); max-width: 36rem; }
.intro .lede strong { color: var(--ink); font-weight: 600; }
.contact { display: flex; flex-wrap: wrap; gap: 0.75rem 1.5rem; align-items: center; font-size: var(--small); }
.email {
  display: inline-flex; align-items: center; gap: 0.6rem;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 0.35rem 0.4rem 0.35rem 1rem;
}
.email span { font-family: var(--mono); font-size: 0.82rem; user-select: all; overflow-wrap: anywhere; }
.copy {
  font: 600 var(--tiny) var(--body); letter-spacing: 0.04em;
  border: 0; border-radius: 999px; padding: 0.4rem 0.8rem; cursor: pointer;
  background: var(--ink); color: var(--bg);
}
.where { color: var(--muted); }

.rule { border: 0; border-top: 1px solid var(--line); margin: clamp(3rem, 7vw, 5rem) 0; }

/* Case study head */
.case-head { display: grid; gap: 1.5rem; }
.case-head .summary { font-size: 1.15rem; }
.meta {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
}
.meta div { background: var(--surface); padding: 0.9rem 1rem; display: grid; gap: 0.2rem; min-width: 0; }
.meta b { font-weight: 600; font-size: 0.98rem; line-height: 1.35; }
.stats { display: flex; flex-wrap: wrap; gap: 0.5rem 2.25rem; }
.stat { display: grid; }
.stat b { font-family: var(--display); font-stretch: 112%; font-weight: 750; font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--small); color: var(--muted); }

section { display: grid; gap: 1.5rem; }
.block { margin-top: clamp(3rem, 7vw, 4.5rem); }
.section-intro { display: grid; gap: 0.6rem; }
.section-intro p { color: var(--muted); }

/* Sidebar then/now */
.navs { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 2fr); gap: 1rem; align-items: start; }
.nav-card { border-radius: 12px; padding: 1.1rem 1.1rem 1.2rem; display: grid; gap: 0.9rem; min-width: 0; }
.nav-card.old { background: #151a33; color: #d9ddea; }
.nav-card.new { background: #141518; color: #e8e9ec; }
.nav-card .label { color: inherit; opacity: 0.6; }
.nav-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.15rem; }
.nav-card li { font-size: 0.92rem; padding: 0.22rem 0.55rem; border-radius: 6px; }
.nav-card.old li:first-child { background: rgba(255,255,255,0.08); }
.nav-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: 1rem 1.25rem; }
.nav-groups h4 { margin: 0 0 0.3rem; font: 500 0.66rem var(--mono); letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.55; }
.nav-card.new li.on { background: #c8202f; color: #fff; }
.nav-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.nav-head strong { font-family: var(--display); font-stretch: 115%; font-weight: 700; letter-spacing: 0.25em; font-size: 0.85rem; }
.nav-card.new .nav-head strong { letter-spacing: 0; font-size: 1rem; }

/* Compare */
.pair { display: grid; gap: 1.1rem; }
.pair + .pair { margin-top: clamp(2.5rem, 6vw, 4rem); }
.pair-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1rem; }
.pair-title .label { white-space: nowrap; }
.compare {
  position: relative; aspect-ratio: 1600 / 816; max-width: 100%;
  border-radius: 12px; overflow: hidden; background: #0d0e10;
  box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px var(--shade);
  touch-action: pan-y; user-select: none; cursor: ew-resize;
}
.compare img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top center; pointer-events: none; }
.compare .after { clip-path: inset(0 0 0 var(--pos, 50%)); }
.compare .tag {
  position: absolute; top: 0.75rem; z-index: 2;
  font: 500 var(--tiny) var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.3rem 0.6rem; border-radius: 6px; pointer-events: none;
}
.compare .tag.b { left: 0.75rem; background: #e9ecf3; color: #2b3550; }
.compare .tag.a { right: 0.75rem; background: #c8202f; color: #fff; }
.handle {
  position: absolute; top: 0; bottom: 0; left: var(--pos, 50%); z-index: 3;
  width: 2.75rem; margin-left: -1.375rem; display: grid; place-items: center;
  background: none; border: 0; padding: 0; cursor: ew-resize;
}
.handle::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0,0,0,0.25); }
.handle span {
  position: relative; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: #fff; color: #16181b; display: grid; place-items: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35); font: 600 0.8rem var(--body);
}
.notes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 2rem; }
.note { display: grid; gap: 0.3rem; min-width: 0; }
.note .label.b { color: var(--before); }
.note .label.a { color: var(--accent); }
.note p { font-size: 0.98rem; }
.hint { font-size: var(--small); color: var(--muted); }

/* New modules */
.mods { display: grid; gap: clamp(2rem, 5vw, 3rem); }
.mod { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr); gap: 1.25rem 2rem; align-items: start; }
.mod-text { display: grid; gap: 0.5rem; }
.mod-text p { color: var(--muted); font-size: 0.98rem; }
.shot {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in;
  border-radius: 12px; overflow: hidden; box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px var(--shade);
}
.shot img { display: block; width: 100%; height: auto; }

/* Player app */
.app-pairs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: 2.75rem 2.5rem; }
.app-pair { display: grid; gap: 0.9rem; align-content: start; }
.phones { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.phone { display: grid; gap: 0.5rem; min-width: 0; align-content: start; }
.phone .shot { border-radius: 18px; background: #000; }
.phone p { font-size: 0.92rem; }
.phone .label.b { color: var(--before); }
.phone .label.a { color: var(--accent); }

/* Build notes */
.decisions { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.decision { background: var(--surface); padding: 1.25rem; display: grid; gap: 0.5rem; align-content: start; min-width: 0; }
.decision h3 { font-size: 1.05rem; font-stretch: 105%; }
.decision p { font-size: 0.95rem; color: var(--muted); }
.stack { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; padding: 0; margin: 0; }
.stack li { font: 500 0.78rem var(--mono); border: 1px solid var(--line); border-radius: 6px; padding: 0.25rem 0.55rem; background: var(--surface); }

.privacy { font-size: var(--small); color: var(--muted); border-left: 2px solid var(--line); padding-left: 0.9rem; }

footer { display: grid; gap: 1rem; }
footer p { color: var(--muted); }

/* Lightbox */
dialog.lb { border: 0; padding: 0; background: transparent; max-width: min(96vw, 1600px); width: 100%; }
dialog.lb::backdrop { background: rgba(8, 9, 10, 0.86); }
dialog.lb img { display: block; width: auto; max-width: 100%; height: auto; max-height: 86vh; margin: 0 auto; border-radius: 8px; }
dialog.lb form { display: flex; justify-content: flex-end; margin-bottom: 0.5rem; }
dialog.lb button { font: 600 var(--small) var(--body); background: #fff; color: #16181b; border: 0; border-radius: 999px; padding: 0.4rem 0.9rem; cursor: pointer; }

@media (max-width: 760px) {
  .navs, .mod, .notes { grid-template-columns: minmax(0, 1fr); }
  .compare .tag { top: 0.5rem; font-size: 0.62rem; }
  .compare .tag.b { left: 0.5rem; }
  .compare .tag.a { right: 0.5rem; }
}
@media (prefers-reduced-motion: no-preference) {
  .compare.nudge .after, .compare.nudge .handle { transition: clip-path 0.6s ease, left 0.6s ease; }
}

/* Pages: a quiet top link on the case study, and the title at section size. */
.crumb { font-family: var(--mono); font-size: var(--tiny); letter-spacing: 0.08em; text-transform: uppercase; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--ink); }
.case-title { font-size: var(--h2); font-weight: 750; line-height: 1.05; letter-spacing: -0.01em; }
.more-link { font-size: var(--small); }

/* Home: the one case study is the single card on the page; everything else sits on the ground. */
.home-section { display: grid; gap: 1.5rem; }
.home-section + .home-section { margin-top: clamp(3rem, 7vw, 4.5rem); }
.case-card {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); align-items: stretch;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  text-decoration: none; color: inherit;
  box-shadow: 0 18px 40px -28px var(--shade);
}
.case-card-text { display: grid; gap: 1rem; align-content: start; padding: clamp(1.25rem, 3vw, 2rem); min-width: 0; }
.case-card-text p { color: var(--muted); }
.case-card .stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem 1.25rem; }
.case-card .stat b { font-size: 1.5rem; }
.case-card .go { font-weight: 600; color: var(--accent); }
.case-card-img { background: #0d0e10; min-width: 0; }
.case-card-img img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: top left; }
.case-card:hover .go, .case-card:focus-visible .go { text-decoration: underline; text-underline-offset: 3px; }
.case-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.1fr); gap: 1rem 2rem; align-items: start; }
.prose { display: grid; gap: 1rem; }
.prose p { color: var(--muted); }
.prose p:first-child { color: var(--ink); font-size: 1.15rem; }

.timeline { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.timeline li { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.25rem 1.25rem; padding: 0.85rem 0; border-bottom: 1px solid var(--line); }
.timeline .years { font-family: var(--mono); font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 0.15rem; }
.timeline b { font-weight: 600; }
.timeline span.org { color: var(--muted); }

.skills { margin: 0; display: grid; gap: 0.9rem; }
.skills div { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); gap: 0.25rem 1.25rem; }
.skills dt { font-family: var(--mono); font-size: var(--tiny); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding-top: 0.25rem; }
.skills dd { margin: 0; }

@media (max-width: 760px) {
  .case-card, .split { grid-template-columns: minmax(0, 1fr); }
  .case-card-img { order: -1; aspect-ratio: 1563 / 784; max-width: 100%; }
  .timeline li, .skills div { grid-template-columns: minmax(0, 1fr); }
}
