/* ==========================================================
   Base
   ========================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; }
a:hover { color: var(--color-accent); }

/* Visible keyboard focus on everything clickable */
:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Centers content and keeps the side padding consistent */
.container {
  max-width: var(--page-max);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

/* "Skip to content" link: hidden until a keyboard user tabs to it */
.skip-link {
  position: absolute;
  left: 16px;
  top: -100px;
  z-index: 100;
  padding: 12px 20px;
  background: var(--color-ink);
  color: #fff;
  border-radius: var(--radius-pill);
}
.skip-link:focus { top: 16px; color: #fff; }

/* ==========================================================
   Buttons
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 32px;
  border-radius: var(--radius-pill);
  font-weight: 500;
  text-decoration: none;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.btn--primary { background: var(--color-accent); color: var(--color-on-accent); }
.btn--primary:hover { background: var(--color-ink); color: #fff; }

.btn--outline { border: 1.5px solid var(--color-ink); }
.btn--outline:hover { background: var(--color-ink); color: #fff; }

.btn--dark { background: var(--color-ink); color: #fff; }
.btn--dark:hover { background: var(--color-accent); color: #fff; }

/* ==========================================================
   Site header / navigation
   ========================================================== */
.site-header { border-bottom: 1px solid var(--color-line); }

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 20px;
}

.nav__brand {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
}
.nav__role {
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: var(--text-sm);
  color: var(--color-ink-muted);
}

.nav__menu {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-weight: 500;
}
.nav__link {
  display: block;
  padding: 12px 14px;
  text-decoration: none;
}
.nav__link[aria-current="page"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-decoration-color: var(--color-accent);
}
.nav__cta { margin-left: 8px; min-height: 44px; }

/* Menu icon: two lines when closed, a cross when open */
.nav__toggle .icon { width: 22px; height: 22px; }
.nav__toggle .icon-close { display: none; }
.nav__toggle[aria-expanded="true"] .icon-open { display: none; }
.nav__toggle[aria-expanded="true"] .icon-close { display: block; }

/* Menu button: only used on small screens */
.nav__toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--color-ink);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Small screens: collapse the links behind the menu button.
   Only when JavaScript is running (.js on <html>), so the links
   stay reachable if the script ever fails to load. */
@media (max-width: 767px) {
  .js .nav__brand { flex: 1 1 0; min-width: 0; }
  .js .nav__toggle { display: inline-flex; flex: 0 0 auto; }

  .js .nav__menu {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-top: 8px;
  }
  .js .nav__menu.is-open { display: flex; }

  .js .nav__link { padding: 14px 0; border-top: 1px solid var(--color-line); }
  .js .nav__cta { margin: 12px 0 4px; width: 100%; }
}

/* ==========================================================
   Home: hero
   ========================================================== */
.hero {
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding-block: 88px 72px;
}

.hero__title {
  margin: 0;
  max-width: 940px;
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
}
.hero__title em {
  font-style: normal;
  color: var(--color-accent);
}

.hero__lead {
  margin: 0;
  max-width: 600px;
  font-size: var(--text-lead);
  line-height: 1.55;
  color: var(--color-ink-soft);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

@media (max-width: 600px) {
  .hero { padding-block: 48px; gap: 20px; }
  .hero__actions .btn { flex: 1 1 100%; }
}

/* ==========================================================
   Shared building blocks
   ========================================================== */

/* Icons: Material Symbols (Apache 2.0), inlined as SVG.
   They take the text color and scale with the font size. */
.icon {
  flex: none;
  width: 1.25em;
  height: 1.25em;
  fill: currentColor;
}

/* Small mono label, e.g. "Case study · Design system" */
.eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-ink-muted);
}
.eyebrow--plain { font-size: var(--text-sm); text-transform: none; letter-spacing: 0; }

.h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.025em;
}
.h2 em, .h1 em { font-style: normal; color: var(--color-accent); }

.h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-h3);
  font-weight: 700;
  line-height: 1.15;
}
.h3 a { text-decoration: none; }
.h3 a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

/* Standalone text link, e.g. "See all projects" */
.text-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-weight: 500;
  text-underline-offset: 4px;
}

/* Pill-shaped tags */
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.tags li {
  padding: 6px 14px;
  border: 1px solid var(--color-tag-line);
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  line-height: 1.4;
}
.tags--sm { font-size: var(--text-xs); }
.tags--sm li { padding: 4px 12px; }

/* ==========================================================
   Stats (number + caption, 2px line on top)
   ========================================================== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 16px;
  border-top: 2px solid var(--color-ink);
}
.stat__value {
  font-family: var(--font-display);
  font-size: var(--text-stat);
  font-weight: 700;
  line-height: 1;
}
.stat__label {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-ink-soft);
}
/* Smaller pair used next to text */
.stats--sm { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stats--sm .stat { padding-top: 12px; }
.stats--sm .stat__value { font-size: 2.25rem; }
.stats--sm .stat__label { font-size: var(--text-xs); }
.stat__value--accent { color: var(--color-accent); }

/* Home: stats row */
.highlights { padding-bottom: 24px; }

/* ==========================================================
   Project cards (Home + Projects)
   ========================================================== */
.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-end;
}

.projects {
  display: flex;
  flex-direction: column;
  gap: 36px;
  padding-block: 88px 56px;
  scroll-margin-top: 16px;
}

/* auto-fill keeps cards the same size when a new case study is added */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  padding: 16px 16px 28px;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.project-card:hover { box-shadow: 0 12px 32px rgba(15, 23, 32, .08); transform: translateY(-2px); }
/* Whole card is clickable through the title link */
.project-card .h3 a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius-card); }
.project-card:focus-within { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.project-card .h3 a:focus-visible { outline: none; }

.project-card__media {
  order: -1;
  aspect-ratio: 16 / 9;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: var(--radius-media);
  background: var(--color-placeholder);
}
.project-card__media img { width: 100%; height: 100%; object-fit: cover; }
.project-card__media--contain img { object-fit: contain; }
.project-card > :not(.project-card__media) { padding-inline: 12px; }
.project-card p { margin: 0; font-size: var(--text-card); line-height: 1.55; color: var(--color-ink-soft); }

/* ==========================================================
   Home: about
   ========================================================== */
.about {
  display: grid;
  grid-template-columns: 1fr;
  gap: 40px;
  align-items: center;
  padding-block: 56px;
  scroll-margin-top: 16px;
}
/* Wide screens: photo column is exactly as wide as the photo,
   text takes the rest, so there's no empty gap in the middle. */
@media (min-width: 800px) {
  .about { grid-template-columns: minmax(300px, 440px) minmax(0, 1fr); gap: 64px; }
}
.about__portrait {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 0;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-placeholder);
}
.about__portrait img { width: 100%; height: 100%; object-fit: cover; }
.about__badge {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  width: fit-content;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  background: var(--color-surface);
  font-size: var(--text-md);
  font-weight: 500;
  line-height: 1.4;
}
.about__body { display: flex; flex-direction: column; gap: 20px; align-items: flex-start; }
.about__body p { margin: 0; color: var(--color-ink-soft); max-width: 62ch; }
.about__body .h2 { line-height: 1.1; }

/* ==========================================================
   Dark closing block ("Have a project in mind?")
   ========================================================== */
.cta-wrap { padding-top: 32px; }
.cta {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  justify-content: space-between;
  align-items: center;
  padding: 72px 48px;
  border-radius: var(--radius-xl);
  background: var(--color-ink);
  color: var(--color-on-dark);
}
.cta__text { display: flex; flex-direction: column; gap: 16px; max-width: 620px; }
.cta__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
}
.cta p { margin: 0; color: var(--color-on-dark-soft); }
.cta__actions { display: flex; flex-wrap: wrap; gap: 14px; }
.cta--stack { flex-direction: column; align-items: flex-start; }
.cta__quote {
  margin: 0;
  max-width: 900px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.6vw, 2.75rem);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
.cta__quote p { color: inherit; }

/* Buttons on dark backgrounds */
.btn--light { background: var(--color-on-dark); color: var(--color-ink); }
.btn--light:hover { background: var(--color-accent); color: #fff; }
.btn--outline-light { border: 1.5px solid var(--color-on-dark); color: var(--color-on-dark); }
.btn--outline-light:hover { background: var(--color-on-dark); color: var(--color-ink); }
.cta :focus-visible { outline-color: var(--color-on-dark); }

@media (max-width: 600px) {
  .cta { padding: 48px 24px; border-radius: var(--radius-lg); }
  .cta .btn { flex: 1 1 100%; }
  .cta__actions { width: 100%; }
}

/* ==========================================================
   Footer
   ========================================================== */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 48px;
  justify-content: space-between;
  align-items: center;
  padding-block: 48px 56px;
  color: var(--color-ink-muted);
}
.site-footer--line { border-top: 1px solid var(--color-line); }
.site-footer__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 28px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer__links a { display: inline-block; padding: 10px 0; color: var(--color-ink-muted); }
.site-footer__links a:hover { color: var(--color-accent); }
.site-footer__copy { margin: 0; font-family: var(--font-mono); font-size: var(--text-sm); }

/* ==========================================================
   Page heading (Projects, Contact)
   ========================================================== */
.page-head {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-block: 88px 48px;
}
.h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-h1);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
}
.page-head .h1 { font-size: clamp(2.75rem, 6vw, 5rem); }
.page-head__lead {
  margin: 0;
  max-width: 600px;
  font-size: var(--text-lead);
  line-height: 1.55;
  color: var(--color-ink-soft);
}
.work-list { padding-bottom: 72px; }

@media (max-width: 600px) {
  .page-head { padding-block: 48px 32px; }
}

/* ==========================================================
   Contact page
   ========================================================== */
.contact-main { padding-block: 88px 72px; display: flex; flex-direction: column; gap: 56px; }
.contact-main .page-head { padding: 0; gap: 24px; max-width: 820px; }
.contact-main .h1 { font-size: clamp(2.875rem, 7vw, 5.5rem); }

.status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--color-ink-soft);
}
.status::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-success);
}

.contact-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.contact-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  height: 100%;
  min-height: 180px;
  padding: 28px;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  text-decoration: none;
  transition: box-shadow .25s var(--ease), transform .25s var(--ease);
}
.contact-card:hover { color: var(--color-ink); box-shadow: 0 12px 32px rgba(15, 23, 32, .08); transform: translateY(-2px); }
.contact-card__value {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.contact-card:hover .contact-card__value { color: var(--color-accent); }
.contact-card__value .icon { vertical-align: -0.25em; }
.contact-card--dark { background: var(--color-ink); color: var(--color-on-dark); }
.contact-card--dark .eyebrow { color: var(--color-on-dark-muted); }
.contact-card--dark:hover { color: var(--color-on-dark); }
.contact-card--dark:hover .contact-card__value { color: var(--color-on-dark); text-decoration: underline; text-underline-offset: 4px; }

@media (max-width: 600px) {
  .contact-main { padding-block: 48px; gap: 40px; }
}

/* ==========================================================
   Info strip: white cells split by 1px lines.
   The lines are the grey background showing through a 1px gap,
   so they stay correct however the cells wrap.
   Used for: Experience contacts, case-study facts.
   ========================================================== */
.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: hidden;
  border-radius: var(--radius-card);
  background: var(--color-line);
  font-size: var(--text-md);
  line-height: 1.55;
}
.strip > * {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px;
  background: var(--color-surface);
}
.strip dd { margin: 0; color: var(--color-ink-soft); }
.strip dd.strip__lead { font-weight: 500; color: var(--color-ink); }
.strip a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-block: -9px;
  font-size: var(--text-base);
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* ==========================================================
   Experience page
   ========================================================== */
.profile { display: flex; flex-direction: column; gap: 24px; padding-block: 88px 64px; }
.profile__top {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
}
.profile__id { display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.profile__photo {
  flex: 0 0 auto;
  width: 112px;
  height: 112px;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-placeholder);
}
.profile__photo img { width: 100%; height: 100%; object-fit: cover; }
.profile__name { display: flex; flex-direction: column; gap: 6px; }
.profile .h1 { font-size: clamp(2.25rem, 4.6vw, 3.5rem); letter-spacing: -0.03em; }
.profile__tagline { margin: 0; color: var(--color-ink-muted); }

/* Section with the title on the left and content on the right */
.split { padding-bottom: 72px; }
.split__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 48px;
  padding-top: 24px;
  border-top: 2px solid var(--color-line-soft);
}
.split__title {
  flex: 1 1 240px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.split__body {
  flex: 999 1 560px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.split__body p { margin: 0; color: var(--color-ink-soft); }
.split__body .statement {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}

.jobs { gap: 0; }
.job {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-block: 32px;
  border-top: 1px solid var(--color-line-soft);
}
.job:first-child { padding-top: 0; border-top: 0; }
.job:last-child { padding-bottom: 0; }
.job__head {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 24px;
  justify-content: space-between;
  align-items: baseline;
}
.job__dates { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-ink-muted); }
.job .job__role { font-weight: 500; color: var(--color-ink); }
.job p { font-size: var(--text-card); }
.job .tags { margin-top: 4px; }

.school .h3 { font-size: 1.375rem; line-height: 1.2; }
.school p { font-size: var(--text-card); margin-top: 4px; }

.skills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 20px 32px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-card);
  color: var(--color-ink-soft);
}
.skills strong { display: block; font-weight: 500; color: var(--color-ink); }

.tools {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 24px 32px;
}
.tools .h3 { font-size: 1.25rem; margin-bottom: 10px; }
.tools ul {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  font-size: var(--text-md);
  color: var(--color-ink-soft);
}

@media (max-width: 600px) {
  .profile { padding-block: 48px 48px; }
  .profile__top .btn { flex: 1 1 100%; }
  .split { padding-bottom: 56px; }
}

/* ==========================================================
   Case study: header, hero, intro
   ========================================================== */
.cs-head { display: flex; flex-direction: column; gap: 22px; padding-block: 48px 40px; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -4px;
  width: fit-content;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}
.cs-head .h1 { max-width: 960px; font-size: clamp(2.75rem, 6.5vw, 5.25rem); }
.cs-head__sub {
  margin: 0;
  max-width: 720px;
  font-size: clamp(1.1875rem, 2vw, 1.375rem);
  line-height: 1.4;
  color: var(--color-ink-soft);
}

.cs-hero__media {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}
.cs-hero__media img { width: 100%; height: 100%; object-fit: cover; }
.cs-hero__media--contain img { object-fit: contain; }

.cs-intro { display: flex; flex-direction: column; gap: 40px; padding-block: 64px 24px; }
.cs-intro__text { display: flex; flex-direction: column; gap: 16px; max-width: 900px; }
.cs-intro__text p { margin: 0; max-width: 720px; color: var(--color-ink-soft); }
.cs-intro__text .statement {
  max-width: none;
  font-family: var(--font-display);
  font-size: clamp(1.375rem, 2.6vw, 1.875rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--color-ink);
}
.cs-intro__text .statement + .statement { margin-top: -4px; }

/* Generic block with standard vertical rhythm */
.cs-block { padding-block: 24px; }
.cs-block--lg { padding-top: 56px; }

/* White card: executive summary, media */
.card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  border-radius: var(--radius-card);
  background: var(--color-surface);
}
.card--summary { padding: 36px; }
.card p { margin: 0; color: var(--color-ink-soft); }
.card .card__desc { font-size: var(--text-card); }
.card .card__strong { font-weight: 500; color: var(--color-ink); }
.card__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}
.card--summary .card__title { font-size: 1.75rem; line-height: 1.15; }
.card .eyebrow + .eyebrow,
.card .card__gap { margin-top: 12px; }
.card__hint { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-muted); }

@media (max-width: 600px) {
  .card, .card--summary { padding: 20px; }
  .cs-head { padding-block: 32px 32px; }
  .cs-intro { padding-top: 48px; }
}

/* ==========================================================
   Case study: numbered chapters (760px reading column)
   ========================================================== */
.chapters {
  display: flex;
  flex-direction: column;
  gap: 56px;
  max-width: var(--read-max);
  margin-inline: auto;
  padding: 72px var(--page-pad) 24px;
  box-sizing: content-box;
}
.chapters--tight { padding-top: 56px; }
.chapter { display: flex; flex-direction: column; gap: 14px; }
.chapter__num { font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-ink-muted); }
.chapter__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-h2-sm);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.025em;
}
.chapter p { margin: 0; color: var(--color-ink-soft); }
.chapter a { color: var(--color-accent); }
.chapter a:hover { color: var(--color-ink); }
.chapter ul:not(.stats) { display: flex; flex-direction: column; gap: 10px; margin: 0; padding-left: 20px; color: var(--color-ink-soft); }
.chapter strong { font-weight: 500; color: var(--color-ink); }
.cs-intro__text a { color: var(--color-accent); }

/* Section head used by "Impact" and Deka Office context blocks */
.cs-section { display: flex; flex-direction: column; gap: 32px; padding-block: 56px 24px; }
.cs-section__head { display: flex; flex-direction: column; gap: 6px; }

/* ==========================================================
   Case study: dark figure (workflow steps + video / code)
   ========================================================== */
.flow {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin: 0;
  padding: 40px;
  border-radius: var(--radius-lg);
  background: var(--color-ink);
  color: var(--color-on-dark);
}
.flow .eyebrow { color: var(--color-on-dark-muted); }
.flow__steps {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: var(--text-md);
}
.flow__steps li { padding: 10px 18px; border: 1px solid var(--color-dark-line); border-radius: var(--radius-pill); line-height: 1.3; }
.flow__steps li:last-child { border-color: var(--color-accent); background: var(--color-accent); }
.flow__arrow { display: flex; padding: 0 !important; border: 0 !important; background: none !important; color: var(--color-on-dark-muted); }
.flow figcaption, .flow p { margin: 0; font-size: var(--text-md); color: var(--color-on-dark-soft); }

.video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-media);
  background: var(--color-dark-raised);
  object-fit: cover;
}

.code {
  margin: 0;
  padding: 20px;
  overflow: auto;
  border-radius: 14px;
  background: var(--color-dark-raised);
  color: var(--color-on-dark-soft);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  tab-size: 2;
}
.code .code__comment { color: #8B95A5; }
.code:focus-visible { outline-color: var(--color-on-dark); }

@media (max-width: 600px) {
  .flow { padding: 24px 20px; border-radius: var(--radius-card); }
  .flow__steps { font-size: var(--text-sm); }
}

/* ==========================================================
   Case study: JSON preview (Universal Design Engine)
   ========================================================== */
.json-panel {
  position: relative;
  border-radius: 14px;
  background: var(--color-ink);
}
.json-panel .code { max-height: 440px; background: transparent; border-radius: 14px; }
.json-panel__status { margin: 0; padding: 20px; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--color-on-dark-soft); }
.json-panel__copy {
  position: absolute;
  top: 10px;
  right: 10px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--color-dark-line);
  border-radius: var(--radius-pill);
  background: var(--color-ink);
  color: var(--color-on-dark);
  font: 500 var(--text-sm) var(--font-body);
  cursor: pointer;
}
.json-panel__copy:hover { background: var(--color-accent); border-color: var(--color-accent); }
.json-panel__copy:focus-visible { outline-color: var(--color-on-dark); outline-offset: 2px; }

.download-row { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; }
.download-row .btn { min-height: 48px; padding: 0 28px; font-size: var(--text-md); }
.download-row span { font-size: var(--text-md); color: var(--color-ink-muted); }

.lab-frame {
  display: block;
  width: 100%;
  height: 520px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-frame);
  background: var(--color-bg);
}

/* ==========================================================
   Tabs (UDE token demo). Without JS all panels are shown in a stack;
   js/main.js adds .is-tabbed and shows one panel at a time.
   ========================================================== */
.tabs { display: flex; flex-direction: column; gap: 16px; }
.tabs__list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-bg);
}
.tabs:not(.is-tabbed) .tabs__list { display: none; }
.tabs__tab {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-ink-soft);
  font: 500 var(--text-md) var(--font-body);
  cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.tabs__tab span { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 400; color: var(--color-ink-muted); }
.tabs__tab:hover { color: var(--color-ink); }
.tabs__tab[aria-selected="true"] { background: var(--color-ink); color: var(--color-on-dark); }
.tabs__tab[aria-selected="true"] span { color: var(--color-on-dark-muted); }
.tabs__panel { display: flex; flex-direction: column; gap: 14px; }
.tabs__panel:focus-visible { outline-offset: 6px; }
.tabs.is-tabbed .tabs__panel[hidden] { display: none; }
.tabs__panel .embed { aspect-ratio: 16 / 9; }

@media (max-width: 600px) {
  .tabs__list { width: 100%; flex-wrap: nowrap; }
  .tabs__tab { flex: 1 1 0; justify-content: center; padding-inline: 8px; font-size: var(--text-sm); white-space: nowrap; }
  .tabs__tab span { display: none; }
}

/* ==========================================================
   Case study: Figma embeds
   ========================================================== */
.embed {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 360px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-frame);
  background: var(--color-placeholder);
}
.embed-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: 24px; }
.embed-pair > div { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

/* Plain image figure */
.figure { display: flex; flex-direction: column; gap: 12px; margin: 0; }
.figure__media { overflow: hidden; border-radius: var(--radius-lg); background: var(--color-surface); }
.figure__media img { width: 100%; }
.figure figcaption { font-size: var(--text-md); color: var(--color-ink-muted); }

/* ==========================================================
   Case study: before / after slider
   ========================================================== */
.ba {
  --pos: 50%;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-frame);
  background: var(--color-placeholder);
  user-select: none;
  touch-action: pan-y;
}
.ba img { width: 100%; height: 100%; object-fit: cover; object-position: left top; pointer-events: none; }
.ba__before {
  position: absolute;
  inset: 0;
  clip-path: inset(0 calc(100% - var(--pos)) 0 0);
}
/* Vertical divider with a round grip */
.ba__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 2px;
  margin-left: -1px;
  background: var(--color-surface);
  pointer-events: none;
}
.ba__handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960' fill='%230F1720'%3E%3Cpath d='M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z'/%3E%3C/svg%3E") center / 20px no-repeat;
  box-shadow: 0 4px 16px rgba(15, 23, 32, .25);
}
.ba__label {
  position: absolute;
  bottom: 16px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--color-ink);
  color: var(--color-on-dark);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  pointer-events: none;
}
.ba__label--before { left: 16px; }
.ba__label--after { right: 16px; }
/* Invisible range input on top: gives drag, keyboard and screen-reader support */
.ba__range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.ba:has(.ba__range:focus-visible) { outline: 3px solid var(--color-accent); outline-offset: 3px; }
/* Without JavaScript the slider can't move, so hide the control */
html:not(.js) .ba__range,
html:not(.js) .ba__handle,
html:not(.js) .ba-hint { display: none; }

/* ==========================================================
   Case study: screen gallery (thumbnail grid)
   All thumbnails in one gallery share the same frame shape and are
   cropped from the top, so rows line up. The grid wraps instead of
   scrolling sideways. Pick the shape with a modifier:
   --wide (desktop screens), --portrait (panels), --phone (mobile).
   ========================================================== */
.gallery {
  --thumb-min: 240px;
  --thumb-max: 1fr;
  --thumb-ratio: 16 / 10;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--thumb-min)), var(--thumb-max)));
  gap: 24px 16px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.gallery--wide { --thumb-min: 280px; --thumb-ratio: 1950 / 1114; }
.gallery--portrait { --thumb-min: 200px; --thumb-ratio: 4 / 5; }
.gallery--phone { --thumb-min: 150px; --thumb-max: 220px; --thumb-ratio: 375 / 812; }

.gallery__item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  border-radius: var(--radius-media);
}
.gallery__item:focus-visible { outline-offset: 4px; }
.gallery__frame {
  position: relative;
  aspect-ratio: var(--thumb-ratio);
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-media);
  background: var(--color-placeholder);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.gallery__frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top;
  transition: transform .4s var(--ease);
}
/* "Expand" badge in the corner */
.gallery__frame::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960' fill='%23FFFFFF'%3E%3Cpath d='M120-120v-320h80v184l504-504H520v-80h320v320h-80v-184L256-200h184v80H120Z'/%3E%3C/svg%3E") center / 18px no-repeat;
  opacity: 0;
  transform: scale(.85);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.gallery__item:hover .gallery__frame,
.gallery__item:focus-visible .gallery__frame { border-color: var(--color-accent); box-shadow: 0 10px 28px rgba(15, 23, 32, .1); }
.gallery__item:hover .gallery__frame img { transform: scale(1.03); }
.gallery__item:hover .gallery__frame::after,
.gallery__item:focus-visible .gallery__frame::after { opacity: 1; transform: none; }
/* Touch screens have no hover, so always show the badge */
@media (hover: none) {
  .gallery__frame::after { opacity: 1; transform: none; }
}
.gallery__caption { display: flex; gap: 10px; align-items: baseline; font-size: var(--text-md); font-weight: 500; line-height: 1.35; }
.gallery__caption span:first-child { font-family: var(--font-mono); font-size: var(--text-xs); font-weight: 400; color: var(--color-accent); }

@media (max-width: 600px) {
  .gallery { gap: 20px 12px; }
  .gallery--portrait, .gallery--phone { --thumb-min: 130px; --thumb-max: 1fr; }
  .gallery__frame::after { width: 32px; height: 32px; background-size: 16px; }
}

/* ==========================================================
   Full-screen screen viewer (built by js/main.js)
   ========================================================== */
.viewer {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(10, 14, 20, .97);
  color: var(--color-on-dark);
  overscroll-behavior: contain;
}
.viewer[open] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto; }
.viewer::backdrop { background: rgba(10, 14, 20, .9); }
html:has(.viewer[open]) { overflow: hidden; }

.viewer__top {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 12px 24px;
}
.viewer__title { display: flex; gap: 14px; align-items: baseline; min-width: 0; margin: 0; font-size: var(--text-md); }
.viewer__count { flex: none; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-on-dark-muted); }
.viewer__caption { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 500; }
.viewer__tools { display: flex; gap: 8px; }

.viewer__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--color-dark-line);
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 32, .7);
  color: var(--color-on-dark);
  cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), opacity .2s var(--ease);
}
.viewer__btn .icon { width: 22px; height: 22px; }
.viewer__btn:hover:not(:disabled) { background: var(--color-accent); border-color: var(--color-accent); }
.viewer__btn:disabled { opacity: 0; pointer-events: none; }
.viewer__btn[hidden] { display: none; }
.viewer :focus-visible { outline-color: var(--color-on-dark); }

.viewer__stage { position: relative; min-width: 0; min-height: 0; }
.viewer__canvas {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 8px 88px;
  overflow: auto;
  touch-action: pan-y;
}
.viewer__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  cursor: zoom-in;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity .2s var(--ease);
}
.viewer__img.is-loading { opacity: .3; }
/* Zoomed: show the image at its real size and let it scroll */
.viewer.is-zoomed .viewer__canvas { align-items: flex-start; justify-content: safe center; touch-action: auto; }
.viewer.is-zoomed .viewer__img { max-width: none; max-height: none; cursor: zoom-out; }

.viewer__nav {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translateY(-50%);
}
.viewer__nav .icon { width: 28px; height: 28px; }
.viewer__nav--prev { left: 20px; }
.viewer__nav--next { right: 20px; }

.viewer__thumbs {
  display: flex;
  gap: 8px;
  justify-content: safe center;
  padding: 12px 16px 16px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.viewer__thumb {
  flex: none;
  height: 64px;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--color-dark-raised);
  opacity: .5;
  cursor: pointer;
  transition: opacity .2s var(--ease), border-color .2s var(--ease);
}
.viewer__thumb img { height: 100%; width: auto; max-width: 140px; object-fit: cover; object-position: top; }
.viewer__thumb:hover { opacity: .85; }
.viewer__thumb[aria-current="true"] { opacity: 1; border-color: var(--color-on-dark); }

@media (max-width: 600px) {
  .viewer__top { padding: 8px 8px 8px 16px; }
  .viewer__canvas { padding: 4px 8px; }
  .viewer__nav { top: auto; bottom: 8px; transform: none; width: 44px; height: 44px; }
  .viewer__nav--prev { left: 12px; }
  .viewer__nav--next { right: 12px; }
  .viewer__thumb { height: 52px; }
}

/* ==========================================================
   Case study: comparison table (Deka Office)
   ========================================================== */
.table-wrap { overflow-x: auto; }
.table { width: 100%; min-width: 480px; border-collapse: collapse; font-size: var(--text-card); }
.table caption { padding-bottom: 8px; text-align: left; }
.table th, .table td { padding: 14px 16px; text-align: left; vertical-align: top; border-top: 1px solid var(--color-line); }
.table thead th {
  padding-block: 10px;
  border-top: 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-ink-muted);
}
.table tbody th { font-weight: 500; }
.table td { color: var(--color-ink-soft); }
.table td:last-child { font-weight: 500; color: var(--color-accent); }

/* ==========================================================
   Case study: next project card
   ========================================================== */
.next { padding-block: 56px 24px; }
.next__card {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  justify-content: space-between;
  align-items: center;
  padding: 28px 32px;
  border-radius: var(--radius-card);
  background: var(--color-surface);
  text-decoration: none;
  transition: box-shadow .25s var(--ease);
}
.next__card:hover { box-shadow: 0 12px 32px rgba(15, 23, 32, .08); }
.next__text { display: flex; flex-direction: column; gap: 4px; }
.next__title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; line-height: 1.15; }
.next__arrow { width: 32px; height: 32px; transition: transform .25s var(--ease); }
.next__card:hover .next__arrow { transform: translateX(6px); }

/* Respect people who turn off animations */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

html { scroll-behavior: smooth; }
