/* Design tokens live in design-system/tokens.css, linked before this
   file in index.html. This file consumes them only —
   see design-system/DESIGN-SYSTEM.md for the full reference. */

* { box-sizing: border-box; }

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

/* Cross-document page transitions (opted in via <meta name="view-transition">
   on every page) — a quick, subtle cross-fade using the same motion language
   as the rest of the site. No-op in browsers without support. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--duration-page);
  animation-timing-function: var(--ease-standard);
}

/* The homepage heading retains a subtle shadow; modal heading contrast is
   strengthened below because those titles render over richer visual surfaces. */
h1 {
  text-shadow: var(--shadow-h1);
}

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

a { color: inherit; text-decoration: none; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-weight: 600;
  transform: translateY(calc(-100% - 16px));
}

.skip-link:focus {
  transform: translateY(0);
}

:where(a, button, input, textarea, select, iframe, [tabindex]):focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

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

/* Editorial face for display/heading-lg/heading-sm/body-lg/body roles.
   Everything else (nav, buttons, tags, mono labels, form fields) stays
   on --font-sans / --font-mono — see design-system/tokens.css. */
.hero h1,
.section-head h2,
.case-body h3,
.timeline-content h3,
.case-detail .lede,
.section-head p,
.case-body p,
.timeline-content p,
.case-section p,
.case-section li {
  font-family: var(--font-editorial);
}

.wrap {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 var(--content-gutter-fluid);
}

/* ---------- Nav ---------- */
/* position: fixed (not sticky) so opening the portrait drawer — which
   grows .nav's own height to stay one shared blurred surface with the
   links — overlays on top of the page instead of pushing it down. Fixed
   elements never affect document flow, at any height. #nav-spacer
   (a plain block right after </nav>, height set by script.js) reserves
   the equivalent space so page content still starts in the right place
   underneath the closed header. */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--color-nav-scrim);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border-chrome);
}

.nav-spacer {
  height: 68px; /* fallback until script.js measures the real value */
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-nav-y-fluid) var(--content-gutter-fluid);
  max-width: var(--content-max-width);
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
}

.brand-mark {
  display: block;
  height: 32px;
  width: auto;
}

.brand-mark path {
  fill: var(--color-brand-mark);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* No-op at desktop/landscape — the links render as if this wrapper
   weren't there. Only the portrait drawer (below) turns it into a real
   flex column, since that's what the max-height open/close animation
   needs to clip against. */
.nav-links-inner {
  display: contents;
}

/* Hamburger toggle — hidden by default (landscape/desktop show the
   inline nav-links directly); shown only in the portrait media query
   below, where it controls the collapsed drawer. */
.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  cursor: pointer;
}

/* Hamburger ⇄ close morph — three bars that rotate/fade into an X via
   transform + opacity, rather than swapping between two separate icons.
   One rule set drives both directions, so opening and closing morph
   with identical timing. */
.nav-toggle-icon {
  position: relative;
  width: 18px;
  height: 14px;
  flex-shrink: 0;
}

.nav-toggle-icon .bar {
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transition: transform var(--duration-base) var(--ease-standard),
    opacity var(--duration-base) var(--ease-standard),
    top var(--duration-base) var(--ease-standard);
}

.nav-toggle-icon .bar:nth-child(1) { top: 0; }
.nav-toggle-icon .bar:nth-child(2) { top: 6px; }
.nav-toggle-icon .bar:nth-child(3) { top: 12px; }

.nav-toggle.open .nav-toggle-icon .bar:nth-child(1) {
  top: 6px;
  transform: rotate(45deg);
}

.nav-toggle.open .nav-toggle-icon .bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle.open .nav-toggle-icon .bar:nth-child(3) {
  top: 6px;
  transform: rotate(-45deg);
}

.nav-links a {
  padding: 4px 7px;
  font-size: 14px;
  color: var(--color-text-secondary);
  transition: color var(--duration-fast) var(--ease-standard);
}

/* Underline lives on the label span, not the padded link box, so it
   hugs the word width instead of the full clickable hit area. */
.nav-links a .nav-label {
  display: inline-block;
  position: relative;
  padding-bottom: 4px;
  box-shadow: inset 0 -2px 0 0 transparent;
  transition: box-shadow var(--duration-fast) var(--ease-standard);
}

/* Hover underline for non-active links: a separate layer from the
   active state's box-shadow underline (left alone below) so the two
   never conflict. Scales in from the left via transform, not width, so
   it animates on the compositor instead of triggering layout. */
.nav-links a .nav-label::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--color-text-primary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--duration-interactive) var(--ease-emphasized);
}

.nav-links a:hover:not(.active) .nav-label::after {
  transform: scaleX(1);
}

/* Active state: current section — desaturated-yellow text, 2px white
   underline. This is what's always visible at rest; hover does not
   control it. Set on page load (Home) and kept in sync with scroll
   position / click by script.js. Resume never receives this class,
   since it isn't an in-page section. */
.nav-links a.active {
  color: var(--color-accent-tertiary);
}

.nav-links a.active .nav-label {
  box-shadow: inset 0 -2px 0 0 var(--color-text-primary);
}

/* Hover on a non-active link only — text-only, no fill/rounded-button
   treatment, no underline. Excludes .active so hovering the current
   section's link has no effect; it stays exactly as above. */
.nav-links a:hover:not(.active) {
  color: var(--color-text-primary);
}

/* ---------- Hero ---------- */
.hero {
  padding: var(--space-hero-fluid) 0 0;
  border-bottom: none;
  position: relative;
  overflow: hidden;
  transition: padding-top var(--duration-slow) var(--ease-emphasized);
  /* Gradient is always visible. The light-theme hero image layer fades in on
     top once loaded; Midnight Signal intentionally keeps the gradient only. */
  background: var(--gradient-hero-fallback);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: url('assets/hero/hero-1440x680.webp') center / cover no-repeat;
  opacity: 0;
  transition: opacity var(--duration-hero) var(--ease-standard);
  z-index: 0;
}

.hero-bg.loaded {
  opacity: 1;
}

html[data-theme="midnight"] .hero-bg {
  display: none;
}

.hero .wrap {
  position: relative;
  z-index: 1;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent-secondary);
  background: var(--color-accent-primary-tint);
  border: 1px solid var(--color-border-accent);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 24px;
}

.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-circle);
  background: var(--color-accent-secondary);
}

.hero h1 {
  font-size: var(--text-display);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tighter);
  margin: 0 0 22px;
  max-width: 820px;
}

.hero h1 span {
  background: linear-gradient(90deg, var(--color-accent-primary), var(--color-accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-lede {
  font-family: var(--font-editorial);
  font-size: var(--text-body-lg);
  color: var(--color-text-primary);
  width: 100%;
  max-width: var(--content-measure);
  margin: 0 0 36px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 60px;
  transition: padding-bottom var(--duration-slow) var(--ease-emphasized);
}

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-action);
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; /* Keep native buttons aligned with the site's font rendering. */
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--color-border-default);
  cursor: pointer;
  transition: transform var(--duration-base) var(--ease-emphasized),
    border-color var(--duration-base) var(--ease-emphasized),
    background var(--duration-base) var(--ease-emphasized);
}

/* Filled, high-contrast fill against the canvas — primary calls to action
   (e.g. "View selected works", "Send message"). */
.button-high-contrast {
  background: var(--color-control-high-bg);
  color: var(--color-control-high-text);
  border-color: var(--color-text-primary);
}

.button-high-contrast:hover { background: var(--color-accent-secondary); border-color: var(--color-accent-secondary); }

/* Transparent, outline-only — secondary actions (e.g. "View resume"). */
.button-low-contrast {
  background: var(--color-control-low-bg);
  color: var(--color-text-primary);
  border-color: var(--color-text-primary);
}

.button-low-contrast:hover {
  background: var(--color-control-low-hover-bg);
  border-color: var(--color-control-low-hover-border);
}

.view-resume-btn {
  border-width: 2px;
}

/* Stats row sits below the hero, separated by a border.
   Content is constrained to .wrap (1056px); border spans full width. */
.hero-stats-row {
  border-top: 1px solid var(--color-border-default);
  border-bottom: 1px solid var(--color-border-default);
  position: relative;
  z-index: 1;
  background: var(--color-hero-stats-scrim);
  padding-bottom: 0;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding-bottom: 0;
}

.hero-stat {
  padding: 16px var(--content-gutter-fluid);
}

.hero-stat:first-child { padding-left: 0; }
.hero-stat:last-child  { padding-right: 0; }

.hero-stat:not(:last-child) {
  border-right: 1px solid var(--color-border-default);
}

.hero-stat strong {
  display: block;
  font-size: 26px;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--color-accent-primary), var(--color-accent-secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-stat span {
  font-size: 13px;
  line-height: var(--leading-compact);
  color: var(--color-text-primary);
}

/* ---------- Scroll reveal ---------- */
.reveal {
  opacity: 0;
  transition: opacity var(--duration-reveal) var(--ease-standard);
}
.reveal.no-transition {
  transition: none !important;
}
.reveal.in-view {
  opacity: 1;
}

/* ---------- Section shell ---------- */
section { padding: var(--space-section-fluid) 0; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 44px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: var(--text-heading-lg);
  letter-spacing: var(--tracking-tight);
  margin: 0 0 8px;
}

.section-head p {
  color: var(--color-text-secondary);
}

.section-head p {
  margin: 0;
  max-width: 480px;
}

.section-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-tertiary);
}

/* ---------- About ---------- */
/* The legacy #approach anchor is retained for stable links. Its divider lives
   on the inner .wrap so the section aligns with the Selected work divider. */
#approach {
  padding-top: var(--space-section-fluid);
  padding-bottom: 0;
}

#approach .wrap {
  border-bottom: 1px solid var(--color-border-default);
  padding-bottom: var(--space-section-fluid);
}

#approach .section-head {
  margin-bottom: 0;
}

#selected-work .section-head,
#contact .section-head {
  margin-bottom: 0;
}

#selected-work {
  padding-top: var(--space-section-fluid);
  padding-bottom: 0;
}

#selected-work .wrap {
  border-bottom: 1px solid var(--color-border-default);
  padding-bottom: var(--space-section-fluid);
}

/* Contact section — the original card treatment, with the established warm
   background treatment retained for visual separation. */
#contact {
  padding-top: var(--space-section-fluid);
  padding-bottom: 296px;
  background: var(--gradient-contact-section);
}

.approach-lede {
  font-family: var(--font-editorial);
  font-size: var(--text-body-lg);
  color: var(--color-text-primary);
  width: 100%;
  max-width: none;
  margin: 0 0 16px;
}

.section-copy {
  font-family: var(--font-editorial);
  font-size: var(--text-body);
  color: var(--color-text-secondary);
  max-width: 1056px;
  margin: 0;
}

.section-copy + .section-copy {
  margin-top: 16px;
}

#selected-work .section-copy {
  margin-bottom: 24px;
}

#approach .view-resume-btn {
  margin-top: 24px;
}

/* About principles stay three columns on desktop and tablet, then become one
   stacked column at the mobile breakpoint. Connected by a shared 1px
   divider-colored border: the grid's own background shows through the 1px
   gap as the border between cells. Compound selector (not just
   .module-grid) is needed to out-specificity the base .case-grid gap rule,
   which is declared later in this file. */
.case-grid.module-grid {
  margin-top: 24px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--color-border-default);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.module-card {
  background: var(--color-bg-canvas);
  padding: 24px;
}

/* Three subtly-tinted surfaces — each pulls from one of the site's three
   accent hues (indigo / teal / gold) at low opacity so the grid reads as
   intentionally colorful without competing with body text. */
.module-card:nth-child(1) { background: var(--color-bg-module-indigo); }
.module-card:nth-child(2) { background: var(--color-bg-module-teal); }
.module-card:nth-child(3) { background: var(--color-bg-module-gold); }

.module-card p {
  font-family: var(--font-editorial);
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.module-card p + p {
  margin-top: 16px;
}

/* Label line matches .resume-skills-grid h4's treatment. */
.module-card p strong {
  display: block;
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  font-weight: 400;
  font-size: 13px;
  margin-bottom: 8px;
}

/* ---------- Case study cards ---------- */
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: var(--space-grid-fluid);
}

/* Selected work is intentionally two-up on larger screens. Explicitly set
   both axes so every line uses the same gutter, including the second row. */
#selected-work .case-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: var(--space-grid-fluid);
}

/* Keep the selected-work grid tied to its page-level hook so the shared
   three-column case-grid default cannot affect this section. */
#selected-work #case-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
}

.case-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-case-study);
  overflow: hidden;
  /* The card shell owns the outer clipping so darker media cannot reveal the
     light card surface through its rounded corners. */
  text-align: left;
  cursor: pointer;
  padding: 0;
  color: var(--color-text-primary);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  transition:
    box-shadow var(--duration-slow) var(--ease-standard),
    border-color var(--duration-base) var(--ease-emphasized);
  position: relative;
  text-decoration: none;
}

.case-card:hover,
.case-card:focus-visible {
  box-shadow: var(--shadow-card-hover);
}

.case-card:focus-visible {
  outline: 3px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.case-thumb {
  height: 168px;
  aspect-ratio: 2 / 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  overflow: hidden;
  border-radius: 0;
  border-bottom: 1px solid var(--color-border-default);
}

.case-thumb .grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  mix-blend-mode: overlay;
}

.case-thumb .index {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-on-dark);
  background: var(--color-image-chip-bg);
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.case-body {
  padding: 22px 22px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.case-kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-accent-secondary);
}

.case-body h3 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.01em;
}

.case-body p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.case-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
}

.case-tags span {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--color-accent-primary-tint);
  border: 1px solid var(--color-border-accent-subtle);
  color: var(--color-accent-primary);
}

.case-open {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-brand-mark);
  background: var(--color-bg-raised);
  width: calc(100% + 44px);
  margin-top: 12px;
  margin-right: -22px;
  margin-left: -22px;
  padding: 12px 22px;
  border-top: 1px solid var(--color-border-default);
  border-radius: 0;
  transition: color var(--duration-base) var(--ease-emphasized);
}

.case-open svg {
  transition: transform var(--duration-fast) var(--ease-standard);
}

.case-card:hover .case-open svg,
.case-card:focus-visible .case-open svg {
  transform: translateX(3px);
}

/* ---------- Experience ---------- */
.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-item {
  display: grid;
  grid-template-columns: minmax(112px, 160px) minmax(0, 1fr);
  gap: var(--space-timeline-gap-fluid);
  padding: 28px 0;
  border-top: 1px solid var(--color-border-default);
}

.timeline-item:last-child { border-bottom: 1px solid var(--color-border-default); }

.timeline-period {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-tertiary);
  padding-top: 2px;
}

.timeline-content h3 {
  margin: 0 0 4px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.timeline-content .company {
  color: var(--color-accent-secondary);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 10px;
  display: block;
}

.timeline-content p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14.5px;
}

.timeline-content ul {
  margin: 0;
  padding-left: 20px;
  color: var(--color-text-secondary);
  font-size: 14.5px;
}

.timeline-content ul li { margin-bottom: 4px; }
.timeline-content ul li:last-child { margin-bottom: 0; }

.timeline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.timeline-tags span {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  background: var(--color-accent-primary-tint);
  border: 1px solid var(--color-border-accent-subtle);
  color: var(--color-accent-primary);
}

/* ---------- Contact ---------- */
.contact-panel {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-panel-fluid);
  position: relative;
  overflow: hidden;
}

.contact-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: var(--gradient-contact-panel);
}

.contact-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-contact-columns);
}

.contact-columns > .approach-lede {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
}

.contact-details {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-contact-details-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.contact-detail {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  color: var(--color-text-primary);
  font-size: 14px;
}

.contact-detail svg {
  display: block;
  flex-shrink: 0;
  color: var(--color-accent-secondary);
}

.contact-methods {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.contact-methods a[href^="mailto:"] { order: 1; }
.contact-methods a[href^="https://linkedin.com/"] { order: 2; }

.contact-methods .btn {
  border-width: 2px;
}

.contact-methods svg {
  display: block;
  flex-shrink: 0;
}

.contact-methods .button-label {
  line-height: 1;
}

@media (max-width: 767px) {
  .contact-columns {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .contact-columns > .contact-details {
    grid-column: 1;
    grid-row: 1;
  }

  .contact-columns > .approach-lede {
    grid-column: 1;
    grid-row: 2;
  }
}

/* ---------- Footer ---------- */
footer {
  position: sticky;
  bottom: 0;
  z-index: 40;
  background: var(--color-nav-scrim);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--color-border-default);
  padding: 24px 0;
  /* So crossing the tablet/mobile breakpoint (padding drops to 12px 0)
     eases between the two values instead of snapping. Transitions still
     fire on media-query-driven changes as long as the element persists
     across the resize, which it does here. */
  transition: padding var(--duration-slow) var(--ease-emphasized);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-tertiary);
  /* gap is the one genuinely-interpolable property here, so it eases on
     its own. The actual row↔column repositioning (flex-direction,
     justify-content, text-align are all discrete — CSS can't tween
     them) is handled as a real slide by the FLIP animation in
     script.js, which measures each child's position immediately before
     and after the breakpoint flips and animates the difference via
     transform. Don't add flex-direction/justify-content/text-align to
     this transition list — a CSS "discrete" transition on those would
     flip layout mid-animation and fight the JS transform. */
  transition: gap var(--duration-slow) var(--ease-emphasized);
}

.footer-inner a { color: var(--color-text-secondary); }
#back-to-top {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-pill, 999px);
  transition: color var(--duration-base) var(--ease-emphasized),
    background var(--duration-base) var(--ease-emphasized);
}

#back-to-top:not(.is-disabled):hover,
#back-to-top:not(.is-disabled):focus { background: var(--color-bg-raised); }
#back-to-top:not(.is-disabled):active { color: var(--color-bg-canvas); background: var(--color-border-default); }

/* Disabled until the user scrolls below the fold (home & about). */
#back-to-top.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}
.footer-inner a:hover { color: var(--color-text-primary); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-overlay-scrim);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: stretch;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-modal-overlay) var(--ease-standard);
}

.modal-overlay[hidden] {
  display: none;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-shell {
  position: fixed;
  inset: 0;
  background: var(--color-bg-canvas);
  display: flex;
  flex-direction: column;
  transform: translateY(16px);
  opacity: 0;
  transition: transform var(--duration-modal-shell) var(--ease-emphasized),
    opacity var(--duration-modal-shell) var(--ease-standard);
}

.modal-overlay.open .modal-shell {
  transform: translateY(0);
  opacity: 1;
}

.modal-bar {
  border-bottom: 1px solid var(--color-border-default);
  flex-shrink: 0;
  min-height: var(--nav-height, 68px);
  height: auto;
  padding: 8px 0;
  display: flex;
  align-items: center;
}

.modal-bar-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.resume-download {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-decoration: none;
}

.modal-bar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-tertiary);
  font-family: var(--font-mono);
}

.modal-close {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-circle);
  border: 1px solid var(--color-border-default);
  background: var(--color-bg-raised);
  color: var(--color-text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background var(--duration-base) var(--ease-emphasized),
    transform var(--duration-base) var(--ease-emphasized);
}

.modal-close:hover { background: var(--color-border-default); transform: rotate(90deg); }
.modal-close:active { color: var(--color-bg-canvas); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

#resume-modal-body {
  overflow-anchor: none;
}

/* Crossfade snapshot: a clone of the outgoing case study laid over the
   modal body (script.js sets top/height to match), fading out to reveal
   the new page already rendered beneath it. Opaque background so the
   two pages blend directly with no blank frame. */
.case-ghost {
  position: absolute;
  left: 0;
  right: 0;
  overflow: hidden;
  background: var(--color-bg-canvas);
  pointer-events: none;
  z-index: 5;
  opacity: 1;
  transition: opacity var(--duration-interactive) var(--ease-standard);
}

/* Modal footer — mirrors the sticky site footer's scrim/blur treatment */
.modal-footer {
  flex-shrink: 0;
  padding: 12px 0;
  background: var(--color-nav-scrim);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--color-border-default);
}

/* .wrap gives the footer row the same max-width + side padding as the
   page content at every breakpoint. */
.modal-footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-footer-center .modal-footer-inner { justify-content: center; }

/* Pill-shaped nav buttons: quiet text that gains a raised pill
   background on hover. */
.modal-footer-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color var(--duration-base) var(--ease-emphasized),
    background var(--duration-base) var(--ease-emphasized);
}

.modal-footer-btn:hover:not(:disabled),
.modal-footer-btn:focus:not(:disabled) { color: var(--color-text-primary); background: var(--color-bg-raised); }
.modal-footer-btn:active:not(:disabled) { color: var(--color-bg-canvas); background: var(--color-border-default); }
/* A disabled Prev/Next means no item in that direction — hide it rather
   than graying it out. visibility (not display) keeps the space-between
   row from shifting, and disabled keeps it out of the focus trap. */
.modal-footer-btn.prev:disabled,
.modal-footer-btn.next:disabled { visibility: hidden; }

/* A disabled Back to top just dims (still above the fold). */
.modal-footer-btn.top:disabled { opacity: 0.35; cursor: default; }
.modal-footer-btn.resume-download { gap: 4px; }
.resume-download:hover,
.resume-download:focus { color: var(--color-text-primary); background: var(--color-bg-raised); }
.resume-download:active { color: var(--color-bg-canvas); background: var(--color-border-default); }
.modal-footer-btn svg { flex-shrink: 0; }

.case-hero {
  min-height: clamp(240px, 34vh, 320px);
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 40px;
  overflow: hidden;
  transition: padding var(--duration-slow) var(--ease-emphasized);
}

.case-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--gradient-case-hero-scrim);
  pointer-events: none;
}

.case-hero-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity var(--duration-hero) var(--ease-standard);
  z-index: 0;
}

.case-hero-bg.loaded {
  opacity: 1;
}

.case-hero .grid-overlay {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 32px 32px;
  mix-blend-mode: overlay;
}

.case-hero-inner {
  position: relative;
  z-index: 2;
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

.case-hero-inner .case-kicker { color: var(--color-text-on-image); margin-bottom: 10px; }
.case-hero-inner h1 { font-size: 38px; margin: 0; color: var(--color-text-on-dark); letter-spacing: -0.02em; }

.modal-shell h1 {
  text-shadow: var(--shadow-modal-title);
}

.case-detail {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 32px 48px;
  transition: padding-left var(--duration-slow) var(--ease-emphasized),
    padding-right var(--duration-slow) var(--ease-emphasized);
}

.case-detail-image {
  margin: 0 0 32px;
}

.case-detail-image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-case-study);
  opacity: 0;
  transition: opacity var(--duration-image) var(--ease-standard);
}

.case-detail-image img.natural-size {
  width: auto;
  max-width: 100%;
  margin-inline: auto;
}

.case-detail-image img.img-loaded {
  opacity: 1;
}

.case-carousel {
  margin: 0 0 32px;
  border: 1px solid var(--color-border-accent-subtle);
  border-radius: var(--radius-case-study);
  padding: 12px;
  background: var(--color-bg-raised);
  outline: none;
}

.case-carousel-track {
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border-radius: var(--radius-case-study);
  background: var(--color-bg-canvas);
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-y pinch-zoom;
  cursor: grab;
}

.case-carousel-track::-webkit-scrollbar {
  display: none;
}

.case-carousel-track.dragging {
  scroll-behavior: auto;
  scroll-snap-type: none;
  cursor: grabbing;
  user-select: none;
}

.case-carousel-slide {
  flex: 0 0 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.case-carousel-slide img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius-case-study);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-image) var(--ease-standard);
}

.case-carousel-slide img.img-loaded {
  opacity: 1;
}

.case-carousel-thumbnails {
  display: flex;
  justify-content: safe center;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 2px 2px;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}

.case-carousel-thumbnail {
  flex: 0 0 92px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: calc(var(--radius-case-study) / 2);
  padding: 0;
  background: var(--color-bg-canvas);
  opacity: 0.58;
  cursor: pointer;
  scroll-snap-align: start;
  transition:
    border-color var(--duration-fast) var(--ease-standard),
    opacity var(--duration-fast) var(--ease-standard);
}

.case-carousel-thumbnail img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.case-carousel-thumbnail:hover {
  opacity: 0.82;
}

.case-carousel-thumbnail.active {
  border-color: var(--color-text-primary);
  opacity: 1;
}

.case-carousel-thumbnail:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 2px;
  opacity: 1;
}

.case-carousel-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
}

.case-carousel-button {
  width: max-content;
  border: 0;
  padding: 8px 0;
  color: var(--color-text-secondary);
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.case-carousel-button.next {
  justify-self: end;
}

.case-carousel-button:hover,
.case-carousel-button:focus-visible {
  color: var(--color-text-primary);
}

.case-carousel-button:focus-visible,
.case-carousel:focus-visible {
  outline: 2px solid var(--color-border-focus);
  outline-offset: 4px;
}

.case-carousel-status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-text-tertiary);
}

.case-detail-video {
  aspect-ratio: 16 / 9;
  margin: 0 0 32px;
  overflow: hidden;
  border-radius: var(--radius-case-study);
  background: var(--color-bg-canvas);
  isolation: isolate;
  clip-path: inset(0 round var(--radius-case-study));
}

.case-detail-video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: var(--color-bg-canvas);
}

.case-meta-row {
  border-top: 1px solid var(--color-border-default);
  border-bottom: 1px solid var(--color-border-default);
  margin-bottom: 40px;
}

.case-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 32px;
  transition: padding-left var(--duration-slow) var(--ease-emphasized),
    padding-right var(--duration-slow) var(--ease-emphasized);
}

.case-meta-grid > div {
  padding: 16px 24px;
}

.case-meta-grid > div:first-child { padding-left: 0; }
.case-meta-grid > div:last-child  { padding-right: 0; }

.case-meta-grid > div:not(:last-child) {
  border-right: 1px solid var(--color-border-default);
}

.case-meta-grid > div span {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
}

.case-meta-grid > div strong {
  font-size: 15px;
  font-weight: 500;
}

.case-detail .lede {
  font-size: 19px;
  color: var(--color-text-primary);
  width: 100%;
  max-width: none;
  margin: 0 0 32px;
}

.case-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 48px;
  overflow: hidden;
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-case-study);
  background: var(--color-border-default);
}

.case-summary > div {
  padding: 18px;
  background: var(--color-bg-raised);
}

.case-summary span {
  display: block;
  margin-bottom: 8px;
  color: var(--color-accent-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.case-summary p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
}

.case-section {
  padding: 0;
  scroll-margin-top: 24px;
}

.case-section { margin-bottom: 32px; }
.case-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: var(--font-mono);
  color: var(--color-accent-secondary);
  margin: 0 0 16px;
}

.case-section p {
  color: var(--color-text-secondary);
  margin: 0 0 14px;
  font-size: 15.5px;
}

.case-section ul {
  margin: 0;
  padding-left: 20px;
  color: var(--color-text-secondary);
  font-size: 15.5px;
}

.case-section li { margin-bottom: 8px; }

/* ---------- Resume modal ---------- */
.resume-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 24px;
  padding-top: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border-default);
}

.resume-header h1 {
  margin: 0 0 6px;
  font-family: var(--font-editorial);
  font-size: var(--text-heading-lg);
  letter-spacing: var(--tracking-tight);
  text-shadow: none;
}

.case-detail .resume-lede {
  width: 100%;
  max-width: none;
}

.resume-role {
  color: var(--color-accent-secondary);
  font-weight: 600;
  font-size: 15px;
}

.resume-contact {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-style: normal;
  font-size: 14px;
}

.resume-contact a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.resume-contact a:hover { color: var(--color-text-primary); }

/* Same connected-boxes treatment as .module-grid / .module-card in the
   Approach section: 1px divider-colored border shared via the grid's own
   background, rounded outer corners only (overflow: hidden clips the
   individual cells), three progressively lighter surfaces per cell. */
.resume-skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--color-border-default);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.resume-skills-grid > div {
  padding: 24px;
  background: var(--color-bg-raised);
}

.resume-skills-grid h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--color-text-primary);
  font-weight: 400;
}

.resume-skills-grid p {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-secondary);
  font-style: normal;
}

.resume-edu-row {
  font-size: 15px;
  color: var(--color-text-secondary);
  margin-bottom: 10px;
}

.resume-edu-row:last-child { margin-bottom: 0; }

@keyframes responsive-reflow-settle {
  from { opacity: 0; }
  to { opacity: 1; }
}

.responsive-reflow-fade {
  animation: responsive-reflow-settle var(--duration-base) var(--ease-standard);
  will-change: opacity;
}

@keyframes resume-timeline-crossfade {
  from { opacity: 1; }
  to { opacity: 0; }
}

.resume-timeline-ghost {
  position: absolute;
  z-index: 2;
  overflow: hidden;
  background: var(--color-bg-canvas);
  pointer-events: none;
  animation: resume-timeline-crossfade var(--duration-slow) var(--ease-standard) forwards;
}


/* ---------- Responsive ----------
   Primary layout reflows from available inline space rather than device or
   orientation buckets. Fluid spacing interpolates with clamp(); the stats
   and approach grids use explicit tracks so their intended composition is
   preserved at each breakpoint. */
@media (min-width: 1025px) {
  .hero {
    padding-top: var(--space-16);
  }

  .hero-actions {
    padding-bottom: var(--space-16);
  }
}

@media (max-width: 720px) {
  .timeline-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .case-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .case-meta-grid > div { padding: 16px 0; }
  .case-meta-grid > div:not(:last-child) { border-right: none; }
  .case-meta-grid > div:nth-child(odd) { padding-right: 16px; border-right: 1px solid var(--color-border-default); }
  .case-meta-grid > div:nth-child(even) { padding-left: 16px; }
  .case-meta-grid > div:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }

}

/* Stats use four columns on desktop and a stable 2x2 arrangement at both
   tablet and mobile widths. The explicit edge rules keep the connected
   dividers correct after the track count changes. */
@media (max-width: 1024px) {
  .hero-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-stat:first-child,
  .hero-stat:nth-child(3) {
    padding-left: 0;
  }

  .hero-stat:nth-child(2),
  .hero-stat:last-child {
    padding-right: 0;
  }

  .hero-stat:not(:last-child) {
    border-right: 0;
  }

  .hero-stat:nth-child(odd) {
    border-right: 1px solid var(--color-border-default);
  }

  .hero-stat:nth-child(-n+2) {
    border-bottom: 1px solid var(--color-border-default);
  }
}

/* The approach grid intentionally waits until mobile to stack. */
@media (max-width: 767px) {
  .case-grid.module-grid {
    grid-template-columns: 1fr;
  }

  #selected-work .case-grid {
    gap: 24px;
  }
}

/* The navigation becomes a drawer only once the actual controls no longer
   fit comfortably on one row, regardless of orientation. */
@media (max-width: 680px) {
  .nav-toggle { display: inline-flex; }
  .nav-inner { flex-wrap: wrap; }

  .nav-links {
    order: 3;
    flex-basis: 100%;
    display: block;
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-emphasized);
  }

  .nav-links.open {
    max-height: calc(100vh - var(--nav-height, 68px));
    overflow-y: auto;
  }

  .nav-links-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0 4px;
  }

  .nav-links a { padding: 4px; }
}

@media (max-width: 600px) {
  .footer-inner {
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 8px;
  }

  .footer-inner span:first-child { order: 2; }
  .footer-inner span:last-child { order: 1; }
}

@media (max-width: 480px) {
  .modal-bar-inner {
    gap: 8px;
  }

  .case-hero {
    padding: 28px 20px;
  }

  .case-hero-inner h1 {
    font-size: clamp(28px, 10vw, 38px);
    overflow-wrap: anywhere;
  }

  .case-detail,
  .case-meta-grid {
    padding-right: 20px;
    padding-left: 20px;
  }

  .case-summary {
    grid-template-columns: 1fr;
  }

  .modal-footer-btn.prev,
  .modal-footer-btn.next {
    max-width: 38%;
  }

  .modal-footer-btn.prev span,
  .modal-footer-btn.next span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .modal-shell .case-meta-grid {
    grid-template-columns: 1fr;
  }

  .modal-shell .case-meta-grid > div,
  .modal-shell .case-meta-grid > div:nth-child(odd),
  .modal-shell .case-meta-grid > div:nth-child(even) {
    padding: 14px 0;
    border-right: 0;
  }

  .modal-shell .case-meta-grid > div + div {
    border-top: 1px solid var(--color-border-default);
  }

  .resume-download {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }
}

/* ---------- Case and resume modal preservation ----------
   The selected-work grid uses fluid tracks on the homepage. Case-detail
   and resume modal pages deliberately retain their original fixed desktop
   structure and orientation-specific reflow rules. */
@media (min-width: 1025px) and (max-width: 1366px) and (orientation: landscape) {
  .modal-bar .wrap,
  .modal-footer .wrap {
    padding-right: 28px;
    padding-left: 28px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .modal-bar .wrap,
  .modal-footer .wrap {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait),
  (max-width: 1024px) and (orientation: landscape),
  (max-width: 767px) and (orientation: portrait) {
  .modal-shell .case-meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-shell .case-meta-grid > div {
    padding: 16px 0;
  }

  .modal-shell .case-meta-grid > div:not(:last-child) {
    border-right: none;
  }

  .modal-shell .case-meta-grid > div:nth-child(odd) {
    padding-right: 16px;
    border-right: 1px solid var(--color-border-default);
  }

  .modal-shell .case-meta-grid > div:nth-child(even) {
    padding-left: 16px;
  }

  .modal-shell .case-meta-grid > div:nth-child(n+3) {
    border-top: 1px solid var(--color-border-default);
  }

  .modal-shell .resume-skills-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) and (orientation: landscape),
  (max-width: 767px) and (orientation: portrait) {
  .modal-bar .wrap,
  .modal-footer .wrap {
    padding-right: 20px;
    padding-left: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .modal-close {
    transition-property: background !important;
  }

  .resume-timeline-ghost {
    animation: none !important;
  }

  .modal-close:hover,
  .case-card:hover .case-open svg,
  .case-card:focus-visible .case-open svg {
    transform: none;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
}
