/* ============================================================
   Daniel Wee Portfolio — Global Stylesheet
   Covers: @font-face, design tokens, CSS reset, view transitions,
   base styles, and utility classes.
   All values from design-specs-system.md (File 1 of 2).
   ============================================================ */


/* ── @font-face — Self-hosted fonts ──────────────────────────
   Files in /fonts/. Hanken Grotesk is a variable font;
   a single file covers the full weight range per subset.
   DM Serif Text has separate files for normal and italic.
   ──────────────────────────────────────────────────────────── */

/* DM Serif Text — normal */
@font-face {
  font-family: 'DM Serif Text';
  font-style: normal;
  font-weight: 400;
  font-display: optional;
  src: url('/fonts/dm-serif-text-normal-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Serif Text';
  font-style: normal;
  font-weight: 400;
  font-display: optional;
  src: url('/fonts/dm-serif-text-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
                 U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

/* DM Serif Text — italic */
@font-face {
  font-family: 'DM Serif Text';
  font-style: italic;
  font-weight: 400;
  font-display: optional;
  src: url('/fonts/dm-serif-text-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Serif Text';
  font-style: italic;
  font-weight: 400;
  font-display: optional;
  src: url('/fonts/dm-serif-text-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
                 U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Hanken Grotesk — variable font, weights 400–600
   Same file per subset covers all three weights. */
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 400 600;
  font-display: optional;
  src: url('/fonts/hanken-grotesk-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7,
                 U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF,
                 U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
                 U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Hanken Grotesk';
  font-style: normal;
  font-weight: 400 600;
  font-display: optional;
  src: url('/fonts/hanken-grotesk-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC,
                 U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
                 U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}


/* ── View transitions ─────────────────────────────────────────
   Cross-page fade using the Navigation API.
   Disabled on mobile — the snapshot-to-live-DOM handoff at the
   end of the transition causes a visible nav flicker on mobile
   GPUs. The entry cascade animation still runs on mobile.
   Respects prefers-reduced-motion via the reset below.
   ──────────────────────────────────────────────────────────── */

@view-transition {
  navigation: auto;
}

@media (max-width: 767px) {
  @view-transition { navigation: none; }
}

::view-transition-old(root) {
  animation: page-fade-out 200ms var(--ease-in) forwards;
}

::view-transition-new(root) {
  animation: page-fade-in 300ms var(--ease-out) forwards;
}

@keyframes page-fade-out { to   { opacity: 0; } }
@keyframes page-fade-in  { from { opacity: 0; } }


/* ── Design tokens (CSS custom properties) ───────────────────
   Single source of truth. All values from design-specs-system.md Part 2.
   Always reference via var(--token-name) — never bare.
   ──────────────────────────────────────────────────────────── */

:root {

  /* Typefaces */
  --font-serif:  'DM Serif Text', Georgia, serif;
  --font-sans:   'Hanken Grotesk', system-ui, sans-serif;

  /* Canvas colours */
  --color-canvas:       #F5F3EF;
  --color-canvas-dark:  #1A1814;
  --color-surface:      #EEECEA;

  /* Text colours */
  --color-text-primary:    #1A1814;
  --color-text-secondary:  #6B6560;
  --color-text-reversed:   #F5F3EF;

  /* Accent — four locations only (C-04 dot, C-02 button, C-13 link hover, C-17 percentage) */
  --color-accent: #A0785A;

  /* Borders */
  --color-border:        rgba(26, 24, 20, 0.10);
  --color-border-strong: rgba(26, 24, 20, 0.20);

  /* Callout tint */
  --color-tint-callout: rgba(160, 120, 90, 0.09);

  /* Image overlays */
  --color-overlay-light:  linear-gradient(to right, #F5F3EF 30%, rgba(245, 243, 239, 0) 100%);
  --color-overlay-mobile: linear-gradient(to top, #F5F3EF 45%, rgba(245, 243, 239, 0.2) 100%);
  --color-overlay-dark:   rgba(26, 24, 20, 0.72);

  /* Type scale — serif (DM Serif Text, no bold) */
  --text-hero:            clamp(36px, 5.5vw, 56px);
  --text-section-heading: clamp(28px, 3.8vw, 44px);
  --text-case-title:      clamp(24px, 3vw, 36px);
  --text-section-subhead: clamp(20px, 2.2vw, 28px);
  --text-pullquote:       clamp(18px, 1.8vw, 22px);

  /* Type scale — sans (Hanken Grotesk) */
  --text-nav:          16px;
  --text-nav-cta:      14px;
  --text-body:         clamp(15px, 1.2vw, 17px);
  --text-subhead-sans: clamp(16px, 1.4vw, 20px);
  --text-metadata:     13px;
  --text-label-caps:   12px;
  --text-caption:      13px;

  /* Line heights */
  --leading-tight:   1.12;
  --leading-heading: 1.20;
  --leading-subhead: 1.35;
  --leading-body:    1.65;
  --leading-label:   1.40;

  /* Letter spacing */
  --tracking-display: -0.025em;
  --tracking-heading: -0.018em;
  --tracking-subhead: -0.010em;
  --tracking-body:     0em;
  --tracking-label:   +0.060em;
  --tracking-nav:     -0.005em;

  /* Spacing (8pt grid) */
  --space-1:    4px;
  --space-2:    8px;
  --space-3:   12px;
  --space-4:   16px;
  --space-5:   24px;
  --space-6:   32px;
  --space-7:   48px;
  --space-8:   64px;
  --space-9:   96px;
  --space-10: 128px;

  /* Layout */
  --container-max:              1200px;
  --container-padding-desktop:   48px;
  --container-padding-tablet:    32px;
  --container-padding-mobile:    24px;

  /* Section dimensions */
  --section-height:             100svh;
  --section-padding-v-desktop:   80px;
  --section-padding-v-mobile:    56px;

  /* Component dimensions */
  --nav-height:               72px;
  --nav-height-mobile:        56px;
  --card-padding-desktop:     32px;
  --card-padding-mobile:      20px;
  --stack-gap-body:           24px;
  --stack-gap-section:        64px;
  --stack-gap-section-mobile: 48px;

  /* Border radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-cta: 6px;
  --radius-dot: 50%;

  /* Motion — easing */
  --ease-out:    cubic-bezier(0.0, 0.0, 0.2, 1.0);
  --ease-in-out: cubic-bezier(0.4, 0.0, 0.2, 1.0);
  --ease-in:     cubic-bezier(0.4, 0.0, 1.0, 1.0);

  /* Motion — duration */
  --duration-fast:    150ms;
  --duration-base:    300ms;
  --duration-enter:   500ms;
  --duration-stagger:  60ms;

}


/* ── Global CSS reset ─────────────────────────────────────────
   From design-specs-system.md Part 3.
   ──────────────────────────────────────────────────────────── */

html {
  scrollbar-gutter: stable;
}

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

img, video {
  max-width: 100%;
  display: block;
}

body {
  margin: 0;
  background-color: var(--color-canvas);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Reduced motion — override all animations and transitions.
   Also disables view transitions. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  @view-transition { navigation: none; }
}


/* ── Skip link ────────────────────────────────────────────────
   First element inside <body> on every page.
   Visible only on keyboard focus.
   ──────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-text-primary);
  color: var(--color-canvas);
  padding: 8px 16px;
  font-size: 14px;
  z-index: 200;
  transition: top 0ms;
}
.skip-link:focus {
  top: 0;
}


/* ── Visually hidden utility ──────────────────────────────────
   Accessible to screen readers, invisible on screen.
   Used on <caption> in C-11 and any other content that must be
   in the DOM for a11y but not visible.
   Never use display:none or visibility:hidden for this purpose.
   ──────────────────────────────────────────────────────────── */

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


/* ── Page entry animation ─────────────────────────────────────
   Inner pages only (not Home page — see design-specs-system.md Part 5).
   Triggered by adding .page-entered to <body> on the fontsReady event.
   Elements start invisible; the class reveals them in a staggered cascade.
   ──────────────────────────────────────────────────────────── */

/* Elements that participate in the entry cascade */
.entry-nav {
  opacity: 0;
  transform: translateY(-12px); /* slides down from above */
}

.entry-eyebrow,
.entry-heading,
.entry-primary,
.entry-first-section {
  opacity: 0;
  transform: translateY(-12px); /* slides down from above — matches nav direction */
}

/* When page-entered is applied, animate each element in sequence */
body.page-entered .entry-nav {
  animation: entry-rise var(--duration-enter) var(--ease-out) 0ms forwards;
}
body.page-entered .entry-eyebrow {
  animation: entry-rise var(--duration-enter) var(--ease-out) 0ms forwards;
}
body.page-entered .entry-heading {
  animation: entry-rise var(--duration-enter) var(--ease-out) 60ms forwards;
}
body.page-entered .entry-primary {
  animation: entry-rise var(--duration-enter) var(--ease-out) 120ms forwards;
}
body.page-entered .entry-first-section {
  animation: entry-rise var(--duration-enter) var(--ease-out) 180ms forwards;
}

@keyframes entry-rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reduced motion: skip stagger, show immediately */
@media (prefers-reduced-motion: reduce) {
  .entry-nav,
  .entry-eyebrow,
  .entry-heading,
  .entry-primary,
  .entry-first-section {
    opacity: 1;
    transform: none;
  }
}



/* ── C-01 · Persistent navigation bar ────────────────────────
   Fixed; appears on all pages.
   Home page: transparent background.
   Inner pages: canvas background + blur, hides on scroll down.
   ──────────────────────────────────────────────────────────── */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--container-padding-desktop);
  transition: transform var(--duration-base) var(--ease-in-out),
              background-color var(--duration-base) var(--ease-out);
}

/* Inner pages: canvas background with blur */
.nav--inner {
  background-color: var(--color-canvas);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Hide on scroll down (inner pages only) */
.nav--hidden {
  transform: translateY(-100%);
}

/* Home page: suppress hide behaviour */
.nav--home {
  background-color: transparent;
}

/* Nav wordmark — serif italic, sized independently from nav links */
.nav__wordmark {
  font-family: var(--font-serif);
  font-size: 21px;
  font-style: italic;
  font-weight: 400;
  color: var(--color-text-primary);
  text-decoration: none;
  letter-spacing: var(--tracking-nav);
  transition: color var(--duration-fast) var(--ease-out);
}

/* Right-side link group */
.nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__link {
  font-family: var(--font-sans);
  font-size: var(--text-nav);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  letter-spacing: var(--tracking-nav);
  transition: color var(--duration-fast) var(--ease-out);
}

.nav__link:hover {
  color: var(--color-text-primary);
}

.nav__link--active {
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Reversed text state (Contact/CV section on Home page) */
.nav--reversed .nav__wordmark,
.nav--reversed .nav__link {
  color: var(--color-text-reversed);
  transition: color var(--duration-base) var(--ease-out);
}

/* When the mobile panel is open while nav is reversed (Contact section),
   restore dark colours so wordmark and hamburger are legible against the
   light panel background. :has() checks the expanded state without JS. */
.nav--reversed:has(.nav__hamburger[aria-expanded="true"]) .nav__wordmark,
.nav--reversed:has(.nav__hamburger[aria-expanded="true"]) .nav__hamburger {
  color: var(--color-text-primary);
}

/* Hamburger button (mobile) */
.nav__hamburger {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--color-text-primary);
  transition: color var(--duration-fast) var(--ease-out);
}

.nav--reversed .nav__hamburger {
  color: var(--color-text-reversed);
}

.nav__hamburger-icon {
  width: 20px;
  height: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.nav__hamburger-icon span {
  display: block;
  width: 100%;
  height: 1.5px;
  background-color: currentColor;
  transition: transform var(--duration-base) var(--ease-out),
              opacity var(--duration-base) var(--ease-out);
}

/* Hamburger → × close icon */
/* translateY values recalculated for 14px icon height:
   line 1 centre = 0.75px, line 3 centre = 13.25px, icon centre = 7px
   offset = 7 − 0.75 = 6.25px (symmetric for both) */
.nav__hamburger[aria-expanded="true"] .nav__hamburger-icon span:nth-child(1) {
  transform: translateY(6.25px) rotate(45deg);
}
.nav__hamburger[aria-expanded="true"] .nav__hamburger-icon span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.nav__hamburger[aria-expanded="true"] .nav__hamburger-icon span:nth-child(3) {
  transform: translateY(-6.25px) rotate(-45deg);
}

/* Mobile nav panel */
.nav-panel {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99;
  background-color: var(--color-canvas);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity var(--duration-base) var(--ease-out),
              transform var(--duration-base) var(--ease-out);
  pointer-events: none;
}

.nav-panel--open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-panel__links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-7);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-panel__link {
  font-family: var(--font-sans);
  font-size: var(--text-section-subhead);
  font-weight: 500;
  color: var(--color-text-primary);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

.nav-panel__link:hover {
  color: var(--color-text-secondary);
}

.nav-panel__cv {
  position: absolute;
  bottom: var(--space-7);
  left: var(--container-padding-mobile);
  right: var(--container-padding-mobile);
}

@media (max-width: 767px) {
  .nav {
    padding: 0 16px;
    height: var(--nav-height-mobile);
  }

  /* Remove backdrop-filter on mobile — GPU-intensive on mobile Safari/Chrome
     and causes stutter when combined with the view transition + entry animation.
     Solid canvas background is visually equivalent at mobile nav heights. */
  .nav--inner {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .nav__links {
    display: none;
  }

  .nav__hamburger {
    display: flex;
    /* Negative margin compensates for invisible tap area on the right side of
       the 44px button. -10px (not the full -12px) accounts for the optical
       left-side bearing of the italic serif wordmark — keeps both sides balanced */
    margin-right: -10px;
  }

  .nav-panel {
    display: flex;
  }

  /* Panel links larger on mobile — token clamps at 20px mobile,
     which is too small for a full-viewport nav overlay */
  .nav-panel__link {
    font-size: 28px;
  }
}


/* ── C-02 · Open CV button ────────────────────────────────────
   Nav bar (desktop) and mobile panel.
   Accent background; canvas text.
   ──────────────────────────────────────────────────────────── */

.btn-cv {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: var(--text-nav-cta);
  font-weight: 600;
  color: var(--color-canvas);
  background-color: var(--color-accent);
  border: none;
  border-radius: var(--radius-cta);
  padding: 8px 18px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.btn-cv:hover {
  background-color: #8A6750;
}

.btn-cv:active {
  transform: scale(0.97);
}

.btn-cv:focus-visible {
  outline: 2px solid var(--color-text-primary);
  outline-offset: 3px;
}

/* Full-width variant for mobile panel */
.btn-cv--full {
  display: flex;
  justify-content: center;
  width: 100%;
  padding: 14px 24px;
  /* Larger label to match proportion of 28px panel nav links above */
  font-size: 16px;
}


/* ── C-03 · Primary CTA button (dark) ────────────────────────
   Dark background; canvas text.
   Used on Home sections, Work cards, end-of-page nav, contact.
   ──────────────────────────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-canvas);
  background-color: var(--color-text-primary);
  border: none;
  border-radius: var(--radius-cta);
  padding: 11px 22px;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.btn-primary:hover {
  background-color: #2E2B27;
}

.btn-primary:active {
  transform: scale(0.97);
}

@media (max-width: 767px) {
  .btn-primary {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }
}


/* ── C-04 · Nav dot indicator ─────────────────────────────────
   Home page only. Fixed, right edge, 7 dots.
   ──────────────────────────────────────────────────────────── */

.nav-dots {
  position: fixed;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 90;
}

/* Flex layout belongs on the <ul>, not the <nav> */
.nav-dots ul {
  display: flex;
  flex-direction: column;
  gap: 1px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-dots__item {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
}

/* Page-load cascade reveal — slide in from right + fade */
.nav-dots--revealed .nav-dots__item {
  animation: dot-slide-in 450ms var(--ease-out) both;
}
.nav-dots--revealed .nav-dots__item:nth-child(1) { animation-delay:   0ms; }
.nav-dots--revealed .nav-dots__item:nth-child(2) { animation-delay:  80ms; }
.nav-dots--revealed .nav-dots__item:nth-child(3) { animation-delay: 160ms; }
.nav-dots--revealed .nav-dots__item:nth-child(4) { animation-delay: 240ms; }
.nav-dots--revealed .nav-dots__item:nth-child(5) { animation-delay: 320ms; }
.nav-dots--revealed .nav-dots__item:nth-child(6) { animation-delay: 400ms; }
.nav-dots--revealed .nav-dots__item:nth-child(7) { animation-delay: 480ms; }

@keyframes dot-slide-in {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Tap area: 44px wide for horizontal reach, 24px tall (WCAG 2.2 minimum) */
.nav-dots__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.nav-dots__dot {
  width: 4px;
  height: 4px;
  border-radius: var(--radius-dot);
  background-color: rgba(26, 24, 20, 0.20);
  transition: width var(--duration-fast) var(--ease-out),
              height var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

.nav-dots__btn:hover .nav-dots__dot {
  width: 5px;
  height: 5px;
}

.nav-dots__btn[aria-pressed="true"] .nav-dots__dot {
  width: 6px;
  height: 6px;
  background-color: var(--color-accent);
}

/* Reversed state on Contact/CV section */
.nav-dots--reversed .nav-dots__dot {
  background-color: rgba(245, 243, 239, 0.40);
}
.nav-dots--reversed .nav-dots__btn[aria-pressed="true"] .nav-dots__dot {
  background-color: var(--color-accent);
}

@media (max-width: 767px) {
  .nav-dots {
    right: 6px;
  }
  /* Narrower tap width moves dot visual closer to the right edge
     to match the hamburger icon's distance (~18px). Dot sizes unchanged. */
  .nav-dots__btn {
    width: 28px;
  }
  .nav-dots__dot {
    width: 3px;
    height: 3px;
  }
  .nav-dots__btn:hover .nav-dots__dot {
    width: 4px;
    height: 4px;
  }
  .nav-dots__btn[aria-pressed="true"] .nav-dots__dot {
    width: 5px;
    height: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-dots__item {
    opacity: 1;
    animation: none !important;
  }
}


/* ── Home page shell ──────────────────────────────────────────
   overflow:hidden + programmatic scroll.
   Applied to <body> on the Home page only.
   ──────────────────────────────────────────────────────────── */

/* scrollbar-gutter: stable is set on html globally (prevents layout shift on
   inner pages). On the home page there is no scrollbar, so we suppress the
   gutter on html too — otherwise it reserves a strip on the right edge.
   The .page-home class is added to <html> by initHome() in main.js. */
html.page-home {
  scrollbar-gutter: auto;
}

body.home {
  overflow: hidden;
  scrollbar-gutter: auto; /* belt-and-suspenders — targets body scroll container */
  overscroll-behavior: none; /* prevents pull-to-refresh and overscroll bounce on mobile */
}

/* Scroll container that holds all 7 sections */
.home-scroll {
  height: 100svh;
  overflow: hidden;
  position: relative;
}

/* The track that gets translated to snap between sections */
.home-track {
  display: flex;
  flex-direction: column;
  transition: transform 700ms var(--ease-in-out);
  will-change: transform;
}

/* Disable track transition during instant snap (e.g. reduced motion) */
.home-track--instant {
  transition: none;
}


/* ── C-05 · Home section — Hero ───────────────────────────────
   Section 1. Full height, centred, canvas background.
   ──────────────────────────────────────────────────────────── */

.section-hero {
  height: var(--section-height);
  background-color: var(--color-canvas);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--section-padding-v-desktop) var(--container-padding-desktop);
  flex-shrink: 0;
}

.hero__headline {
  font-family: var(--font-serif);
  font-size: var(--text-hero);
  font-weight: 400;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  color: var(--color-text-primary);
  max-width: 760px;
  margin-bottom: var(--space-7);
  text-wrap: balance;
  /* Cascade reveal — slides down from above */
  opacity: 0;
  transform: translateY(-12px);
}

.hero__intro {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  max-width: 520px;
  margin-bottom: var(--space-9);
  /* Cascade reveal — slides down from above */
  opacity: 0;
  transform: translateY(-12px);
}

/* Animated down arrow */
.hero__arrow {
  position: absolute;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--color-text-secondary);
  /* Cascade reveal */
  opacity: 0;
  transition: opacity var(--duration-base) var(--ease-out);
}

.hero__arrow svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* Bounce animation (runs after cascade reveal) */
/* Selector specificity matches .hero--revealed .hero__arrow and is declared
   later, so it wins the tie and overrides the hero-rise forwards fill. */
.hero--revealed .hero__arrow--visible {
  animation: arrow-bounce 1.8s var(--ease-in-out) infinite;
}

/* Faded when Hero section is no longer active */
.hero__arrow--faded {
  opacity: 0 !important;
  animation: none;
}

@keyframes arrow-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%       { transform: translateX(-50%) translateY(6px); }
}

/* Hero cascade reveal — fires on load via JS (200ms after nav, then staggered) */
.hero--revealed .hero__headline {
  animation: hero-rise var(--duration-enter) var(--ease-out) 100ms forwards;
}
.hero--revealed .hero__intro {
  animation: hero-rise var(--duration-enter) var(--ease-out) 220ms forwards;
}
.hero--revealed .hero__arrow {
  animation: hero-rise-arrow var(--duration-enter) var(--ease-out) 340ms forwards;
}

@keyframes hero-rise-arrow {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes hero-rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive line-break helpers — used in hero headline */
br.br-desktop { display: none; }
br.br-mobile  { display: none; }

@media (min-width: 768px) {
  br.br-desktop { display: inline; }
}

@media (max-width: 767px) {
  .section-hero {
    padding: var(--section-padding-v-mobile) var(--container-padding-mobile);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero__headline,
  .hero__intro,
  .hero__arrow {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
  .hero__arrow--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    animation: none !important;
  }
}


/* ── C-06 · Home section — Case study anchor ─────────────────
   Sections 2, 3, 4. Full-bleed atmospheric image, centred.
   ──────────────────────────────────────────────────────────── */

.section-case-anchor {
  height: var(--section-height);
  background-color: var(--color-canvas);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

/* Placeholder background while atmospheric image is pending */
.section-case-anchor__placeholder {
  position: absolute;
  inset: 0;
  background-color: var(--color-surface);
}

/* Atmospheric image — full bleed; gradient overlay handles text legibility */
.section-case-anchor__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

/* Overlay — directional gradient: canvas on left, fades to transparent on right */
.section-case-anchor__overlay {
  position: absolute;
  inset: 0;
  background: var(--color-overlay-light);
}

@media (max-width: 767px) {
  /* Mobile: increased solid zone (65%) ensures full content block sits on an
     opaque background. Fades to transparent at 85%, leaving the top 15% as
     pure atmospheric image. Desktop overlay (--color-overlay-light) unchanged. */
  .section-case-anchor__overlay {
    background: linear-gradient(to top, #F5F3EF 65%, rgba(245, 243, 239, 0) 85%);
  }
}

/* Content zone — bottom-left, max 480px */
.section-case-anchor__content {
  position: absolute;
  bottom: var(--section-padding-v-desktop);
  left: var(--container-padding-desktop);
  max-width: 480px;
}

/* Cascade reveal — elements start hidden */
.section-case-anchor__meta,
.section-case-anchor__heading,
.section-case-anchor__body,
.section-case-anchor__cta {
  opacity: 0;
  transform: translateY(16px);
}

/* Fired once by IntersectionObserver */
.section-case-anchor--revealed .section-case-anchor__meta {
  animation: entry-rise var(--duration-enter) var(--ease-out) 0ms forwards;
}
.section-case-anchor--revealed .section-case-anchor__heading {
  animation: entry-rise var(--duration-enter) var(--ease-out) 60ms forwards;
}
.section-case-anchor--revealed .section-case-anchor__body {
  animation: entry-rise var(--duration-enter) var(--ease-out) 120ms forwards;
}
.section-case-anchor--revealed .section-case-anchor__cta {
  animation: entry-rise var(--duration-enter) var(--ease-out) 180ms forwards;
}

.section-case-anchor__meta {
  font-family: var(--font-sans);
  font-size: var(--text-label-caps);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.section-case-anchor__heading {
  font-family: var(--font-serif);
  font-size: var(--text-section-heading);
  font-weight: 400;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
}

.section-case-anchor__body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  max-width: 420px;
  margin-bottom: var(--space-6);
}

.section-case-anchor__body p + p {
  margin-top: var(--space-3);
}

@media (max-width: 1023px) {
  .section-case-anchor__content {
    bottom: var(--section-padding-v-mobile);
    left: var(--container-padding-mobile);
    right: var(--container-padding-mobile);
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-case-anchor__meta,
  .section-case-anchor__heading,
  .section-case-anchor__body,
  .section-case-anchor__cta {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
}


/* ── C-07 · Home section — Typographic anchor ────────────────
   Sections 5 (BTB) and 6 (About). Text only, canvas background.
   ──────────────────────────────────────────────────────────── */

.section-type-anchor {
  height: var(--section-height);
  background-color: var(--color-canvas);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--section-padding-v-desktop) var(--container-padding-desktop);
  flex-shrink: 0;
}

/* Atmospheric image — full bleed, same treatment as case-anchor sections */
.section-type-anchor__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  display: block;
}

/* Overlay — directional gradient, canvas on left where text lives */
.section-type-anchor__overlay {
  position: absolute;
  inset: 0;
  background: var(--color-overlay-light);
}

@media (max-width: 767px) {
  .section-type-anchor__overlay {
    background: var(--color-overlay-mobile);
  }
}

.section-type-anchor__content {
  position: relative;
  z-index: 1;
  max-width: 640px;
}

/* Cascade reveal — same pattern as C-06 */
.section-type-anchor__heading,
.section-type-anchor__body,
.section-type-anchor__cta {
  opacity: 0;
  transform: translateY(16px);
}

.section-type-anchor--revealed .section-type-anchor__heading {
  animation: entry-rise var(--duration-enter) var(--ease-out) 0ms forwards;
}
.section-type-anchor--revealed .section-type-anchor__body {
  animation: entry-rise var(--duration-enter) var(--ease-out) 60ms forwards;
}
.section-type-anchor--revealed .section-type-anchor__cta {
  animation: entry-rise var(--duration-enter) var(--ease-out) 120ms forwards;
}

.section-type-anchor__heading {
  font-family: var(--font-serif);
  font-size: var(--text-section-heading);
  font-weight: 400;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
}

.section-type-anchor__body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

@media (max-width: 767px) {
  .section-type-anchor {
    padding: var(--section-padding-v-mobile) var(--container-padding-mobile);
    justify-content: flex-end;
  }
  /* BTB and About: shorter gradient since content is bottom-aligned —
     solid canvas only covers the text block, more image shows above */
  #section-btb .section-type-anchor__overlay,
  #section-about .section-type-anchor__overlay {
    background: linear-gradient(to top, #F5F3EF 25%, rgba(245, 243, 239, 0) 60%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-type-anchor__heading,
  .section-type-anchor__body,
  .section-type-anchor__cta {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
}


/* ── C-08 · Home section — Contact/CV (dark) ─────────────────
   Section 7. Dark canvas, ren photograph background.
   ──────────────────────────────────────────────────────────── */

.section-contact {
  height: var(--section-height);
  min-height: 100svh; /* absorb sub-pixel gaps at viewport edges */
  background-color: var(--color-canvas-dark);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex-shrink: 0;
  overflow: hidden;
}

.section-contact__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.section-contact__overlay {
  position: absolute;
  inset: 0;
  background-color: var(--color-overlay-dark);
}

.section-contact__content {
  position: relative;
  z-index: 1;
  padding: var(--section-padding-v-desktop) var(--container-padding-desktop);
  color: var(--color-text-reversed);
}

/* Cascade reveal */
.section-contact__framing,
.section-contact__link,
.section-contact__sep {
  opacity: 0;
  transform: translateY(16px);
}

.section-contact--revealed .section-contact__framing {
  animation: entry-rise var(--duration-enter) var(--ease-out) 0ms forwards;
}

/* Individual stagger — each link and separator reveals in turn */
.section-contact--revealed .section-contact__links > *:nth-child(1) {
  animation: entry-rise var(--duration-enter) var(--ease-out) 80ms forwards;
}
.section-contact--revealed .section-contact__links > *:nth-child(2) {
  animation: entry-rise var(--duration-enter) var(--ease-out) 140ms forwards;
}
.section-contact--revealed .section-contact__links > *:nth-child(3) {
  animation: entry-rise var(--duration-enter) var(--ease-out) 180ms forwards;
}
.section-contact--revealed .section-contact__links > *:nth-child(4) {
  animation: entry-rise var(--duration-enter) var(--ease-out) 240ms forwards;
}
.section-contact--revealed .section-contact__links > *:nth-child(5) {
  animation: entry-rise var(--duration-enter) var(--ease-out) 280ms forwards;
}

.section-contact__framing {
  font-family: var(--font-serif);
  font-size: var(--text-section-heading);
  font-weight: 400;
  font-style: italic;
  text-wrap: balance;
  line-height: var(--leading-heading);
  color: var(--color-text-reversed);
  max-width: 600px;
  margin-bottom: var(--space-8);
}

/* Contact links row — [icon] Label | [icon] Label | [icon] Label */
.section-contact__links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-3) var(--space-5);
}

.section-contact__link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 500;
  color: var(--color-text-reversed);
  text-decoration: none;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.section-contact__link:hover {
  opacity: 0.75;
}

.section-contact__link svg {
  flex-shrink: 0;
}

/* Faint vertical separator between links */
.section-contact__sep {
  color: rgba(245, 243, 239, 0.30);
  font-weight: 300;
  line-height: 1;
  user-select: none;
}

@media (prefers-reduced-motion: reduce) {
  .section-contact__framing,
  .section-contact__link,
  .section-contact__sep {
    opacity: 1;
    transform: none;
    animation: none !important;
  }
}


/* ── Image protection ─────────────────────────────────────────
   Atmospheric/decorative background images: full pointer block.
   Interactive case study images: touch-callout + select only
   (pointer-events must remain for lightbox/carousel clicks).
   Right-click contextmenu is suppressed in JS for all images.
   ──────────────────────────────────────────────────────────── */

.section-case-anchor__img,
.section-type-anchor__img,
.section-contact__img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

/* Overlays sit above images; remove their pointer-events so
   right-clicks reach the section element for JS interception */
.section-case-anchor__overlay,
.section-type-anchor__overlay,
.section-contact__overlay {
  pointer-events: none;
}

/* Case study images — protect without blocking lightbox clicks */
.case-image img,
.carousel__slides img,
.btb-image img,
.about-image img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}


/* ── Work page ────────────────────────────────────────────────
   Work page header and C-09 case study cards.
   ──────────────────────────────────────────────────────────── */

.work-header {
  padding-top: var(--space-10);
  padding-bottom: var(--space-5);
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  /* Same effective column width as the centred 680px cards so left edges align */
  max-width: calc(680px + 2 * var(--container-padding-desktop));
  margin: 0 auto;
}

.work-header__title {
  font-family: var(--font-serif);
  font-size: var(--text-case-title);
  font-weight: 400;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
}

.work-cards {
  padding-bottom: var(--space-10);
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-7);
}

/* C-09 · Work page case study card — tinted container, matches C-15 callout-tinted */
.card-case {
  border-radius: var(--radius-md);
  background-color: var(--color-tint-callout);
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
  text-decoration: none;
  display: block;
  padding-top: var(--card-padding-desktop);
}

.card-case__img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
}

/* Placeholder for card images not yet supplied */
.card-case__img-placeholder {
  width: 100%;
  height: 320px;
  background-color: var(--color-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  border-bottom: 1px solid var(--color-border);
}

.card-case__body {
  padding: var(--card-padding-desktop);
}

.card-case__meta {
  font-family: var(--font-sans);
  font-size: var(--text-label-caps);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-3);
}

.card-case__title {
  font-family: var(--font-serif);
  font-size: var(--text-section-subhead);
  font-weight: 400;
  line-height: var(--leading-subhead);
  letter-spacing: var(--tracking-subhead);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.card-case__desc {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

/* Bold phrases — stepped down from near-black for softer emphasis contrast */
.card-case__desc strong {
  font-weight: 600;
  color: #3D3B38;
}

@media (max-width: 767px) {
  .work-header {
    padding-top: var(--space-9);
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .work-cards {
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .card-case {
    padding-top: var(--card-padding-mobile);
  }

  .card-case__body {
    padding: var(--card-padding-mobile);
  }
}


/* ── Case study pages ─────────────────────────────────────────
   C-10 through C-18.
   ──────────────────────────────────────────────────────────── */

/* Shared case study content wrapper */
.case-study {
  max-width: calc(680px + 2 * var(--container-padding-desktop));
  margin: 0 auto;
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  padding-bottom: var(--space-10);
}

/* C-10 · Case study page header */
.case-header {
  padding-top: var(--space-10);
  padding-bottom: 0;
}

.case-header__back {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-metadata);
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  margin-bottom: var(--space-7);
  transition: color var(--duration-fast) var(--ease-out);
}

.case-header__back:hover {
  color: var(--color-text-primary);
}

.case-header__title {
  font-family: var(--font-serif);
  font-size: var(--text-case-title);
  font-weight: 400;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-primary);
  max-width: 720px;
  margin-bottom: var(--space-7);
}

/* C-11 · At a Glance block */
.at-a-glance {
  max-width: 680px;
  border-collapse: collapse;
  width: 100%;
  margin-bottom: var(--space-7);
}

.at-a-glance td {
  padding: var(--space-4) 0;
  vertical-align: top;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
}

.at-a-glance tr:last-child td {
  border-bottom: none;
}

.at-a-glance__label {
  font-weight: 600;
  color: var(--color-text-primary);
  width: 160px;
  padding-right: var(--space-6);
}

.at-a-glance__value {
  font-weight: 400;
  color: var(--color-text-secondary);
}

.at-a-glance__value--outcome {
  font-weight: 400;
  color: var(--color-text-secondary);
}

@media (max-width: 767px) {
  .at-a-glance td {
    display: block;
    width: 100%;
    padding: var(--space-3) 0;
  }

  .at-a-glance tr {
    display: block;
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-3) 0;
  }

  .at-a-glance tr:last-child {
    border-bottom: none;
  }

  .at-a-glance td {
    border-bottom: none;
    padding: var(--space-2) 0;
  }

  .at-a-glance__label {
    width: 100%;
    padding-right: 0;
    padding-bottom: var(--space-1);
  }
}

/* C-12 · Case study section heading */
.case-section-heading {
  font-family: var(--font-serif);
  font-size: var(--text-section-subhead);
  font-weight: 400;
  line-height: var(--leading-subhead);
  letter-spacing: var(--tracking-subhead);
  color: var(--color-text-primary);
  margin-top: var(--stack-gap-section);
  margin-bottom: var(--space-5);
}

/* First section heading follows At a Glance with a narrower gap */
.case-section-heading--first {
  margin-top: var(--space-7);
}

@media (max-width: 767px) {
  .case-section-heading {
    margin-top: var(--stack-gap-section-mobile);
  }
  .case-section-heading--first {
    margin-top: var(--space-9);
  }

  .case-study {
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .case-header {
    padding-top: var(--space-9);
  }
}

/* C-13 · Case study body copy block */
.case-body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  max-width: 680px;
}

.case-body p {
  margin-bottom: var(--stack-gap-body);
}

.case-body p:last-child {
  margin-bottom: 0;
}

.case-body a {
  color: var(--color-text-secondary);
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.case-body a:hover {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.case-body strong {
  font-weight: 600;
  color: #3D3B38;
}

.case-body ul,
.case-body ol {
  padding-left: var(--space-6);
  margin-bottom: var(--stack-gap-body);
}

.case-body li {
  margin-bottom: var(--space-3);
  line-height: var(--leading-body);
}

.case-body li:last-child {
  margin-bottom: 0;
}

/* C-14 · Case study image slate */
.case-image {
  max-width: 680px;
  margin-top: 32px;
  margin-bottom: 24px;
}

.case-image figure {
  margin: 0;
}

.case-image img {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  display: block;
}

.case-image figcaption {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-top: var(--space-3);
  text-align: center;
}

/* Carousel */
.case-image--carousel {
  position: relative;
}

.carousel__track {
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.carousel__slides {
  display: flex;
  transition: transform var(--duration-base) var(--ease-in-out);
  will-change: transform;
}

.carousel__slides img {
  flex-shrink: 0;
  width: 100%;
  border-radius: 0;
  border: none;
}

.carousel__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-top: 2px;
}

.carousel__arrow {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  padding: 6px;
  box-sizing: content-box;
  transition: color var(--duration-fast) var(--ease-out);
}

.carousel__arrow:hover {
  color: var(--color-text-primary);
}

.carousel__dots {
  display: flex;
  gap: var(--space-2);
  list-style: none;
  margin: 0;
  padding: 0;
}

.carousel__dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-dot);
  background-color: var(--color-text-secondary);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.carousel__dot[aria-current="true"] {
  background-color: var(--color-text-primary);
}

.carousel__caption {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: 400;
  color: var(--color-text-secondary);
  margin-top: var(--space-3);
  text-align: center;
}

@media (max-width: 767px) {
  .case-image {
    margin-top: 32px;
    margin-bottom: 24px;
  }
}

/* C-15 · Callout container (outlined) */
.callout-outlined {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--card-padding-desktop);
  background-color: var(--color-canvas);
  max-width: 680px;
}

.callout-outlined__heading {
  font-family: var(--font-sans);
  font-size: var(--text-subhead-sans);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.callout-outlined__body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  color: var(--color-text-secondary);
  line-height: var(--leading-body);
}

@media (max-width: 767px) {
  .callout-outlined {
    padding: var(--card-padding-mobile);
  }
}

/* C-16 · Callout container (tinted) */
.callout-tinted {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--card-padding-desktop);
  background-color: var(--color-tint-callout);
  max-width: 680px;
  margin-top: 32px;
  margin-bottom: 32px;
}

/* Research question — tinted callout with icon, label, and serif italic text */
.callout-tinted--research-question {
  border: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.callout-tinted__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--color-accent);
}

.callout-tinted__rq-label {
  font-family: var(--font-sans);
  font-size: var(--text-label-caps);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.callout-tinted__rq-text {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: clamp(18px, 1.9vw, 24px);
  line-height: var(--leading-subhead);
  color: var(--color-text-primary);
  margin: 0;
}

.callout-tinted-stack {
  display: flex;
  flex-direction: column;
  gap: 32px;
  margin-top: 32px;
  margin-bottom: 32px;
}

.callout-tinted-stack .callout-tinted {
  padding: 24px;
  margin-top: 0;
  margin-bottom: 0;
  border: none;
}

.callout-tinted__body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  color: var(--color-text-secondary);
  line-height: var(--leading-body);
}

.callout-tinted__body strong {
  font-weight: 600;
  color: #3D3B38;
}

@media (max-width: 767px) {
  .callout-tinted {
    padding: var(--card-padding-mobile);
  }
}

/* C-17 · Sticky reading progress pill */
.progress-backdrop {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 96px;
  z-index: 89;
  background: linear-gradient(to top, var(--color-canvas) 40%, transparent 100%);
  pointer-events: none;
}

.progress-pill {
  position: fixed;
  bottom: max(24px, calc(env(safe-area-inset-bottom, 0px) + 8px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background-color: var(--color-text-primary);
  border-radius: var(--radius-cta);
  overflow: hidden;
  cursor: pointer;
  min-width: 0;
}

/* Collapsed state */
.progress-pill__collapsed {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px 16px;
  white-space: nowrap;
}

.progress-pill__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-reversed);
}

.pill-icon--collapse {
  display: none;
}

.progress-pill--expanded .pill-icon--expand {
  display: none;
}

.progress-pill--expanded .pill-icon--collapse {
  display: block;
}

.progress-pill__label {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-reversed);
  flex: 1;
}

/* CSS-only width pinning — ghost text forces min-content = longest section label */
.progress-pill__label::after {
  content: 'The research challenge';
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  white-space: nowrap;
  pointer-events: none;
}

.progress-pill__pct {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-accent);
}

/* Expanded state — max-height transition */
.progress-pill__list {
  display: flex;
  flex-direction: column;
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--duration-base) var(--ease-out);
}

@keyframes pill-item-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.progress-pill--expanded .progress-pill__list-item {
  animation: pill-item-rise 200ms var(--ease-out) both;
}

.progress-pill__list-item {
  display: block;
  padding: var(--space-3) 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-reversed);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  width: 100%;
  white-space: nowrap;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.progress-pill__list-item:hover {
  opacity: 0.75;
}

.progress-pill__list-item[aria-current="true"] {
  font-weight: 600;
}

/* Overflow fade hint */
.progress-pill__overflow-hint {
  position: sticky;
  bottom: 0;
  height: 32px;
  background: linear-gradient(to top, rgba(26, 24, 20, 0.85) 0%, transparent 40%);
  pointer-events: none;
}


/* ── C-18 · End-of-page navigation block ─────────────────────
   Bottom of case study pages, BTB, About.
   Two-column flex row (desktop) / stacked (mobile).
   ──────────────────────────────────────────────────────────── */

.end-nav {
  padding-top: var(--stack-gap-section);
  max-width: 680px;
}

.end-nav__grid {
  display: flex;
  gap: var(--space-6);
  align-items: stretch;
}

.end-nav__card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--card-padding-desktop);
  background-color: var(--color-canvas);
}

.end-nav__next-label {
  font-family: var(--font-sans);
  font-size: var(--text-label-caps);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  display: block;
  margin-bottom: var(--space-2);
}

.end-nav__next-title {
  font-family: var(--font-serif);
  font-size: var(--text-section-subhead);
  font-weight: 400;
  line-height: var(--leading-subhead);
  color: var(--color-text-primary);
}

.end-nav__desc {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  margin-top: var(--space-3);
  margin-bottom: var(--space-6);
}

.end-nav__contact-body {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

@media (max-width: 767px) {
  .end-nav__grid {
    flex-direction: column;
    gap: var(--space-5);
  }

  .end-nav__card {
    padding: var(--card-padding-mobile);
  }
}

/* Tinted container variant — used on BTB and About end-nav (not case study pages) */
.end-nav--tinted .end-nav__card {
  background-color: var(--color-tint-callout);
  border: none;
}

/* Stacked layout variant — case study end-navs only */
.end-nav--stacked .end-nav__grid {
  flex-direction: column;
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .end-nav--stacked .end-nav__card .btn-primary {
    align-self: flex-start;
  }
}

/* Email icon in the contact card — line-box height matches end-nav__next-title */
.end-nav__contact-icon {
  display: block;
  width: calc(var(--text-section-subhead) * var(--leading-subhead) * 0.85);
  height: calc(var(--text-section-subhead) * var(--leading-subhead) * 0.85);
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
}


/* ── BTB page ─────────────────────────────────────────────────
   C-19 header and C-20 contribution entries.
   ──────────────────────────────────────────────────────────── */

.btb-header {
  padding-top: var(--space-10);
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  max-width: calc(680px + 2 * var(--container-padding-desktop));
  margin: 0 auto;
}

.btb-header__title {
  font-family: var(--font-serif);
  font-size: var(--text-case-title);
  font-weight: 400;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-primary);
  margin-bottom: var(--space-7);
}

.btb-body {
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  padding-bottom: var(--space-10);
  max-width: calc(680px + 2 * var(--container-padding-desktop));
  margin: 0 auto;
}

/* Framing intro — C-13 body spec + gap before BTB image */
.btb-intro {
  max-width: 680px;
  margin-bottom: var(--stack-gap-body);
}

/* BTB inline image — no lightbox, no caption */
.btb-image {
  max-width: 680px;
  margin-top: var(--space-6);
  margin-bottom: var(--stack-gap-section);
}

.btb-image img {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.btb-entry {
  max-width: 680px;
}

/* Spacing between entries only — not before the first one */
.btb-entry + .btb-entry {
  margin-top: var(--stack-gap-section);
}

.btb-entry__heading {
  font-family: var(--font-serif);
  font-size: var(--text-section-subhead);
  font-weight: 400;
  line-height: var(--leading-subhead);
  letter-spacing: var(--tracking-subhead);
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
}

@media (max-width: 767px) {
  .btb-header {
    padding-top: var(--space-9);
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .btb-body {
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .btb-entry {
    margin-top: var(--stack-gap-section-mobile);
  }
}


/* ── About page ───────────────────────────────────────────────
   C-21 header, C-22 sections, C-23 testimonials, C-24 ren card.
   ──────────────────────────────────────────────────────────── */

.about-header {
  padding-top: var(--space-10);
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  max-width: calc(680px + 2 * var(--container-padding-desktop));
  margin: 0 auto;
}

.about-header__title {
  font-family: var(--font-serif);
  font-size: var(--text-case-title);
  font-weight: 400;
  line-height: var(--leading-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--color-text-primary);
  margin-bottom: var(--space-7);
}

.about-body {
  padding-left: var(--container-padding-desktop);
  padding-right: var(--container-padding-desktop);
  padding-bottom: var(--space-10);
  max-width: calc(680px + 2 * var(--container-padding-desktop));
  margin: 0 auto;
}

/* C-22 · About section block */
.about-section {
  max-width: 680px;
  margin-top: var(--stack-gap-section);
}

.about-section:first-child {
  margin-top: 0;
}

.about-section__heading {
  font-family: var(--font-serif);
  font-size: var(--text-section-subhead);
  font-weight: 400;
  line-height: var(--leading-subhead);
  letter-spacing: var(--tracking-subhead);
  color: var(--color-text-primary);
  margin-bottom: var(--space-5);
}

/* C-23 · Testimonial quote block — tinted card with avatar header */
.testimonial {
  background-color: var(--color-tint-callout);
  border-radius: var(--radius-md);
  padding: var(--card-padding-desktop);
  max-width: 680px;
  margin-top: var(--space-6);
}

.testimonial + .testimonial {
  margin-top: var(--space-6);
}

.testimonial__header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.testimonial__avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.testimonial__byline {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 500;
  color: var(--color-text-primary);
}

.testimonial__quote {
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--color-text-secondary);
}

/* About inline images — prose images in "How I got here" and "Outside of work" */
.about-image {
  margin-top: var(--space-6);
  margin-bottom: var(--space-6);
}

.about-image img {
  width: 100%;
  display: block;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

@media (max-width: 767px) {
  .about-header {
    padding-top: var(--space-9);
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .about-body {
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }

  .about-section {
    margin-top: var(--stack-gap-section-mobile);
  }

  .testimonial {
    padding: var(--card-padding-mobile);
  }
}


/* ── C-26 · Image lightbox overlay ───────────────────────────
   Triggered by clicking any C-14 image.
   Implemented as a native <dialog> via showModal().
   ⚠️ Pinch-to-zoom is NOT implemented (deferred — see specs).
   ──────────────────────────────────────────────────────────── */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(26, 24, 20, 0.92);
  border: none;
  padding: 0;
  margin: 0;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Override default <dialog> backdrop — we handle background ourselves */
.lightbox::backdrop {
  display: none;
}

/* Open animation */
.lightbox[open] {
  animation: lightbox-open var(--duration-base) var(--ease-out) forwards;
}

@keyframes lightbox-open {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.lightbox__img {
  max-width: 90vw;
  max-height: 85vh;
  object-fit: contain;
  display: block;
}

/* Close button */
.lightbox__close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-reversed);
  font-family: var(--font-sans);
  font-size: 20px;
  transition: opacity var(--duration-fast) var(--ease-out);
  z-index: 201;
}

.lightbox__close:hover {
  opacity: 0.7;
}

/* Navigation arrows (carousel only) */
.lightbox__arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-reversed);
  opacity: 0.7;
  transition: opacity var(--duration-fast) var(--ease-out);
}

.lightbox__arrow:hover {
  opacity: 1;
}

.lightbox__arrow--prev { left: 20px;  }
.lightbox__arrow--next { right: 20px; }

/* Caption and counter */
.lightbox__caption-area {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.lightbox__caption {
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: 400;
  color: var(--color-text-reversed);
}

.lightbox__counter {
  font-family: var(--font-sans);
  font-size: var(--text-metadata);
  font-weight: 500;
  color: var(--color-text-reversed);
}

/* Live region for screen reader announcements */
.lightbox__live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

@media (max-width: 767px) {
  .lightbox__img {
    width: 100%;
    height: auto;
    max-height: none;
    max-width: 100%;
  }
}
