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

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* Cross-document page transitions (opted in via <meta name="view-transition">
   on every page) — a quick, subtle cross-fade instead of the browser's
   default ~300ms, using the site's own base duration/easing tokens so it
   reads as one motion language with everything else. No-op in browsers
   without support; navigation just happens instantly as before.
   Duration is base + 125ms (not a bare value) so it stays pinned to
   --duration-base if that token ever changes. */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: calc(var(--duration-base) + 125ms);
  animation-timing-function: var(--ease-standard);
}

/* Every h1 on the site (hero heading, case-study modal title) gets a
   drop shadow — set here rather than per-selector so it stays in sync
   automatically if more h1s are added later. */
h1 {
  text-shadow: var(--shadow-h1);
}

body {
  margin: 0;
  min-width: 375px; /* floor of the mobile-portrait bucket — narrower viewports scroll horizontally rather than squish the layout */
  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; }

/* 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,
.contact-copy h2,
.case-body h3,
.timeline-content h3,
.hero p,
.case-detail .lede,
.section-head p,
.case-body p,
.timeline-content p,
.contact-copy p,
.case-section p,
.case-section li {
  font-family: var(--font-editorial);
}

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

/* ---------- 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 rgba(0, 0, 0, 0.12);
}

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

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  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-xfast) 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: 60px 0 0;
  border-bottom: none;
  position: relative;
  overflow: hidden;
  /* Gradient is always visible; hero-bg div fades the JPG in on top once loaded.
     Colors sampled from the hero image to make the transition seamless. */
  background: linear-gradient(110deg, #c8cbf4 0%, #d8dbf8 30%, #e4e5f8 60%, #eeedf9 100%);
}

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

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

.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 rgba(74, 79, 196, 0.25);
  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 p {
  font-size: 18px;
  color: #484d59;
  max-width: 560px;
  margin: 0 0 36px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 60px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale; /* <button> doesn't inherit font-family from the page like <a> does — without this, .contact-form's submit button (an actual <button>) falls back to the browser's UA font instead of Source Sans 3 */
  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: #1a1c22;
  color: #ffffff;
  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: rgba(255, 255, 255, 0.5);
  color: var(--color-text-primary);
  border-color: #1a1c22;
}

.button-low-contrast:hover { background: #ffffff; border-color: #3d4dff; }

.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: color-mix(in srgb, var(--color-bg-canvas) 25%, transparent);
  padding-bottom: 0;
}

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

.hero-stat {
  padding: 16px 32px;
}

.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-tertiary);
}

/* ---------- 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: 60px 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);
  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);
}

/* ---------- Approach ---------- */
/* Divider lives on the inner .wrap (content-width, matching the About
   page's timeline dividers) rather than the full-bleed section, so both
   read as the same width. The section's own bottom padding moves onto
   .wrap so total spacing before Selected work is unchanged. */
#approach {
  padding-top: 96px;
  padding-bottom: 0;
}

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

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

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

#selected-work {
  padding-top: 96px;
  padding-bottom: 0;
}

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

/* Contact section — same rhythm as other home sections. The subtle warm
   gradient behind the panel mirrors the former standalone contact page. */
#contact {
  padding-top: 96px;
  padding-bottom: 96px;
  background: linear-gradient(
    135deg,
    var(--color-bg-canvas),
    color-mix(in srgb, var(--color-bg-canvas) 92%, #e0955c 8%)
  );
}

/* Same divider treatment as Approach: content-width border on the
   inner .wrap, with the section's bottom padding moved onto it. */
#about {
  padding-top: 96px;
  padding-bottom: 0;
}

#about .wrap {
  border-bottom: 1px solid var(--color-border-default);
  padding-bottom: 96px;
}

#about .approach-lede {
  max-width: none;
}

.approach-lede {
  font-family: var(--font-editorial);
  font-size: var(--text-body-lg);
  color: var(--color-text-primary);
  max-width: 640px;
  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,
#about .section-copy {
  margin-bottom: 24px;
}

#about .btn {
  margin-bottom: 0;
}

/* Reuses .case-grid for identical responsive column behavior (3-across
   down to tablet landscape, 1-across below that). Connected by a shared
   1px divider-colored border: the grid's own background shows through
   the 1px gap as the border between cells, and the grid's own border
   matches on the outer edge — so lines never double up where two cards
   meet. Compound selector (not just .module-grid) is needed to out-
   specificity the base .case-grid gap rule, which is declared later in
   this file. Height is intentionally not fixed — it hugs each card's
   content, so cards are only "square" incidentally at 3-up widths. */
.case-grid.module-grid {
  margin-top: 24px;
  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: #ddddf4; }
.module-card:nth-child(2) { background: #dae4ec; }
.module-card:nth-child(3) { background: #e8e4e4; }

.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(3, 1fr);
  gap: 24px;
}

.case-card {
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-lg);
  /* overflow:hidden moved to .case-thumb so the ::after hit-area bridge
     can extend below the card without being clipped — prevents the
     translateY hover jitter caused by the bottom edge overtaking the cursor. */
  text-align: left;
  cursor: pointer;
  padding: 0;
  color: var(--color-text-primary);
  font-family: inherit;
  display: flex;
  flex-direction: column;
  transition: transform var(--duration-xfast) var(--ease-standard), border-color var(--duration-xfast) var(--ease-standard), box-shadow var(--duration-xfast) var(--ease-standard);
  position: relative;
}

/* Transparent 4px extension below the card on hover — keeps the cursor
   inside the hover zone as the card lifts, stopping the jitter loop. */
.case-card::after {
  content: '';
  position: absolute;
  inset: 0 0 -4px;
  pointer-events: none;
}

.case-card:hover::after,
.case-card:focus-visible::after {
  pointer-events: auto;
}

.case-card:hover,
.case-card:focus-visible {
  transform: translateY(-4px);
  border-color: rgba(110, 124, 246, 0.4);
  box-shadow: var(--shadow-card-hover);
  outline: none;
}

.case-card:focus-visible { outline: 2px solid var(--color-accent-primary); outline-offset: 2px; }

.case-thumb {
  aspect-ratio: 2 / 1;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 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: rgba(255,255,255,0.85);
  background: rgba(0,0,0,0.25);
  padding: 4px 9px;
  border-radius: var(--radius-pill);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.case-body {
  padding: 22px 22px 24px;
  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: rgba(13, 124, 114, 0.09);
  border: 1px solid rgba(13, 124, 114, 0.22);
  color: var(--color-accent-secondary);
}

.case-open {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-top: 6px;
}

.case-open svg { transition: transform var(--duration-fast) var(--ease-standard); }
.case-card:hover .case-open svg { transform: translateX(3px); }

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

.timeline-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 28px;
  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 rgba(74, 79, 196, 0.2);
  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: 56px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  position: relative;
  overflow: hidden;
}

.contact-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 100% 0%,   rgba(74,  79,  196, 0.45) 0%, transparent 48%),
    radial-gradient(ellipse at 0%   100%, rgba(13,  124, 114, 0.40) 0%, transparent 48%),
    radial-gradient(ellipse at 55%  110%, rgba(137, 107, 0,   0.35) 0%, transparent 45%);
}

.contact-copy h2 { font-size: var(--text-heading-lg); margin: 0 0 12px; letter-spacing: var(--tracking-tight); }
.contact-copy p { font-family: var(--font-editorial); font-size: var(--text-body-lg); color: var(--color-text-primary); margin: 0 0 28px; max-width: 420px; }

.contact-methods { display: flex; flex-direction: column; gap: 14px; }

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

.contact-methods a svg { color: var(--color-accent-secondary); flex-shrink: 0; }

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--color-text-tertiary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field input,
.field textarea {
  width: 100%;
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border-default);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--color-accent-primary);
  outline-offset: 1px;
  border-color: var(--color-accent-primary);
}

.field input.is-invalid {
  border-color: #c0392b;
  outline: 2px solid rgba(192, 57, 43, 0.25);
  outline-offset: 1px;
}

.field-error {
  font-size: 12px;
  color: #c0392b;
  font-family: var(--font-mono);
  margin-top: -2px;
  display: none;
}

.field-error.is-visible {
  display: block;
}

.contact-form .btn { align-self: flex-start; margin-top: 4px; }

/* Contact page only — the page background behind .contact-panel gets a
   slightly warmer, lighter wash than the standard --color-bg-canvas used
   everywhere else, as a 135deg gradient (the site's established gradient
   angle — same as the case-study card fills) between plain canvas and a
   color-mix of canvas + a touch of the site's existing warm amber accent
   (reused from the Microsoft UWP gradient) rather than a new hand-picked
   hex, so it stays visibly related to the rest of the palette instead of
   introducing an unrelated color. */
#contact-page {
  background: linear-gradient(
    135deg,
    var(--color-bg-canvas),
    color-mix(in srgb, var(--color-bg-canvas) 92%, #e0955c 8%)
  );
}

/* ---------- 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 { background: var(--color-bg-raised); }
#back-to-top:not(.is-disabled):active { color: var(--color-text-primary); 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-base) var(--ease-standard);
}

.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-slow) var(--ease-emphasized), opacity var(--duration-slow) 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;
  height: var(--nav-height, 68px);
  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-body {
  flex: 1;
  overflow-y: auto;
  position: relative;
}

/* 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-xfast) 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) { color: var(--color-text-primary); background: var(--color-bg-raised); }
.modal-footer-btn:active:not(:disabled) { color: var(--color-text-primary); 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; }
.modal-footer-btn svg { flex-shrink: 0; }

.case-hero {
  height: 320px;
  position: relative;
  display: flex;
  align-items: flex-end;
  padding: 40px;
  overflow: hidden;
}

.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;
  max-width: var(--content-max-width);
  margin: 0 auto;
  width: 100%;
}

.case-hero-inner .case-kicker { color: rgba(255,255,255,0.85); margin-bottom: 10px; }
.case-hero-inner h1 { font-size: 38px; margin: 0; color: #fff; letter-spacing: -0.02em; }

.case-detail {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 0 32px 48px;
}

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

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

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

.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;
}

.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-secondary);
  margin: 0 0 32px;
}

.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-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);
}

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

.resume-contact {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-text-tertiary);
  line-height: 1.8;
}

/* 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 h4 {
  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);
}

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

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


/* ---------- Responsive ----------
   Four device/orientation buckets, mutually exclusive by width so
   exactly one applies at a time (widest → narrowest below). Desktop
   (>1366px, or any width above the tablet-landscape ceiling) gets no
   override and uses the base styles above as-is.
     Mobile portrait   : <=767px  & orientation: portrait
     Tablet portrait    : 768–1024px & orientation: portrait
     Mobile landscape   : <=1024px & orientation: landscape
     Tablet landscape    : 1025–1366px & orientation: landscape
   See design-system/DESIGN-SYSTEM.md, "Breakpoints". */

/* ----- Tablet landscape: 1025–1366px, landscape (e.g. iPad landscape) -----
   Case grid stays 3-across here, same as desktop — there's enough width
   for it, and only the other three (narrower) buckets drop to 1 card
   per row. */
@media (min-width: 1025px) and (max-width: 1366px) and (orientation: landscape) {
  .wrap, .nav-inner { padding-left: 28px; padding-right: 28px; }
}

/* ----- Home page section rhythm: tablet + mobile -----
   Desktop keeps the base 96px top/bottom on #about / #approach /
   #selected-work; every tablet and mobile bucket (tablet landscape
   1025–1366, and anything <=1024px) drops to 48px. ID selectors are
   needed here to out-specify the base ID rules above. */
@media (min-width: 1025px) and (max-width: 1366px) and (orientation: landscape), (max-width: 1024px) {
  .hero { padding: 32px 0 0; }
  #about, #approach, #selected-work, #contact { padding-top: 48px; }
  #about .wrap, #approach .wrap, #selected-work .wrap { padding-bottom: 48px; }
  #contact { padding-bottom: 48px; }
}

/* Switch stats to 2-col at ≤1024px regardless of orientation.
   Kept as a standalone block (not merged with the combined landscape rule above)
   so the 4-col desktop grid is preserved at 1025–1366px landscape screens. */
@media (max-width: 1024px) {
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stat { padding: 16px 0; }
  .hero-stat:not(:last-child) { border-right: none; }
  .hero-stat:nth-child(odd)  { padding-right: 20px; border-right: 1px solid var(--color-border-default); }
  .hero-stat:nth-child(even) { padding-left: 20px; border-right: none; }
  .hero-stat:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }
}

/* ----- Tablet portrait: 768–1024px, portrait (e.g. iPad portrait) ----- */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
  .wrap, .nav-inner { padding-left: 24px; padding-right: 24px; }
  .case-grid { grid-template-columns: 1fr; }
  .case-meta-grid { grid-template-columns: repeat(2, 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; border-right: none; }
  .case-meta-grid > div:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }
  .case-gallery { grid-template-columns: 1fr; }
  .contact-panel { grid-template-columns: 1fr; padding: 40px; }
  .resume-skills-grid { grid-template-columns: 1fr; }
}

/* ----- Mobile landscape: <=1024px, landscape (phones on their side) -----
   Width can be generous but height is tight, so this trims vertical
   rhythm (hero padding, section padding, nav height) rather than
   collapsing columns as aggressively as portrait mobile. */
@media (max-width: 1024px) and (orientation: landscape) {
  .wrap, .nav-inner { padding-left: 20px; padding-right: 20px; }
  .nav-inner { padding-top: 12px; padding-bottom: 12px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stat { padding: 16px 0; }
  .hero-stat:not(:last-child) { border-right: none; }
  .hero-stat:nth-child(odd)  { padding-right: 20px; border-right: 1px solid var(--color-border-default); }
  .hero-stat:nth-child(even) { padding-left: 20px; border-right: none; }
  .hero-stat:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }
  section { padding: 48px 0; }
  .case-grid { grid-template-columns: 1fr; }
  .contact-panel { grid-template-columns: 1fr; padding: 32px; }
  .timeline-item { grid-template-columns: 1fr; gap: 8px; }
  .case-meta-grid { grid-template-columns: repeat(2, 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; border-right: none; }
  .case-meta-grid > div:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }
  .case-gallery { grid-template-columns: 1fr; }
  .case-swatches { grid-template-columns: repeat(3, 1fr); }
  .resume-skills-grid { grid-template-columns: 1fr; }
}

/* ----- Mobile portrait: <=767px, portrait (phones upright) -----
   Narrowest bucket: everything collapses to one column. Nav is handled
   by the shared hamburger block below, alongside tablet portrait. */
@media (max-width: 767px) and (orientation: portrait) {
  .wrap { padding-left: 20px; padding-right: 20px; }
  .nav-inner { padding: 12px 20px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stat { padding: 16px 0; }
  .hero-stat:not(:last-child) { border-right: none; }
  .hero-stat:nth-child(odd)  { padding-right: 16px; border-right: 1px solid var(--color-border-default); }
  .hero-stat:nth-child(even) { padding-left: 16px; border-right: none; }
  .hero-stat:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }
  section { padding: 48px 0; }
  .case-grid { grid-template-columns: 1fr; }
  .contact-panel { grid-template-columns: 1fr; padding: 28px; }
  .timeline-item { grid-template-columns: 1fr; gap: 8px; }
  .case-meta-grid { grid-template-columns: repeat(2, 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; border-right: none; }
  .case-meta-grid > div:nth-child(n+3) { border-top: 1px solid var(--color-border-default); }
  .case-gallery { grid-template-columns: 1fr; }
  .case-swatches { grid-template-columns: repeat(3, 1fr); }
  .resume-skills-grid { grid-template-columns: 1fr; }
}

/* ----- Hamburger nav: shared by both portrait buckets -----
   Mobile portrait and tablet portrait both collapse .nav-links into a
   toggled drawer instead of shrinking link text to fit — landscape
   buckets (mobile or tablet) never see this; they keep the full inline
   nav since width isn't the constraint there.

   The drawer is NOT a separately-blurred overlay panel — backdrop-filter
   on a floating absolutely-positioned layer was unreliable in practice
   (WebKit in particular). Instead .nav-links wraps onto its own full-width
   row inside .nav-inner via flex-wrap, so it's painted as part of the
   same .nav box that already has a working background + blur. Opening
   the drawer genuinely grows the (fixed) header rather than overlaying
   a separate surface on top of it.

   Height animation uses max-height, not grid-template-rows fr-unit
   interpolation — the fr trick has inconsistent real-browser support for
   this exact "flex item that's also a grid container" combination, which
   was the root cause of the drawer misbehaving in Chrome/Firefox/Safari.
   max-height is the boring, universally-supported option. */
@media (max-width: 1024px) and (orientation: portrait) {
  .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: 320px; }

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

  .nav-links a { padding: 4px 4px; }
  .nav-links a .nav-label { display: inline-block; }
}

/* ----- Footer: reduced vertical padding across every tablet/mobile
   bucket (both orientations) — anything at or below the tablet-landscape
   ceiling, so desktop is the only size that keeps the roomier default. ----- */
@media (max-width: 1366px) {
  footer { padding: 12px 0; }
}

/* ----- Footer: mobile only (not tablet) — copyright and "Back to top"
   no longer fit on one line at these widths, so stack and center them
   instead of the space-between left/right split. "Back to top" leads
   (order swapped from source order), with a tighter 8px gap than the
   12px used everywhere else. */
@media (max-width: 1024px) and (orientation: landscape), (max-width: 767px) and (orientation: portrait) {
  .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; }
}
