/* ==========================================================================
   Daniel Chirigiu — Portfolio
   Plain CSS, no frameworks. Design tokens per design spec §I.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */

:root {
  /* Background hierarchy — dark theme (default) */
  --bg-primary:   #0a0a0c;
  --bg-elevated:  #1a1a1e;
  --bg-overlay:   #252529;
  --bg-subtle:    #14141a;

  /* Text hierarchy */
  --text-primary:   #e8e6e3;
  --text-secondary: #a8a29e;
  --text-tertiary:  #6e6a66;
  /* Small meta text: needs 4.5:1 on --bg-primary in BOTH themes,
     so it maps to a AA-safe shade (tertiary fails contrast audits) */
  --text-meta:      #a8a29e;

  /* Accent & interactive */
  --accent-primary: #ffffff;
  --accent-hover:   #f0f0f0;
  --accent-focus:   #4a9eff;

  /* Semantic */
  --border-subtle: #2a2a2e;
  --border-strong: #3a3a3e;
  --success:       #6abf69;
  --error:         #e85c5c;

  /* Shadows (elevation) */
  --shadow-card:  0 8px 24px rgb(0 0 0 / 0.35);
  --shadow-cta:   0 4px 16px rgb(0 0 0 / 0.4);

  /* Type — system fonts only (spec §3.6: zero network cost) */
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo,
               "Consolas", "Liberation Mono", monospace;

  /* Fluid type scale, 1.25 ratio (spec §1.2) */
  --text-xs:  clamp(0.75rem,  0.7rem + 0.25vw,  0.875rem);
  --text-sm:  clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --text-base: clamp(1rem,    0.95rem + 0.5vw,  1.125rem);
  --text-lg:  clamp(1.125rem, 1rem + 0.625vw,   1.25rem);
  --text-xl:  clamp(1.25rem,  1.1rem + 0.75vw,  1.5rem);
  --text-2xl: clamp(1.5rem,   1.3rem + 1vw,     2rem);
  --text-3xl: clamp(2rem,     1.7rem + 1.5vw,   2.5rem);
  --text-4xl: clamp(2.5rem,   2rem + 2.5vw,     3.5rem);

  /* Line heights */
  --leading-tight: 1.1;
  --leading-body:  1.6;
  --leading-ui:    1.4;

  /* Spacing — 8px base grid (spec §1.3) */
  --space-0:  0;
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.5rem;
  --space-6:  2rem;
  --space-8:  3rem;
  --space-10: 4rem;
  --space-12: 6rem;
  --space-16: 8rem;

  /* Container widths */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;

  /* Page padding: 24px mobile → 48px desktop */
  --padding-page: clamp(1.5rem, 5vw, 3rem);

  /* Motion tokens — derived from hero sequence (spec §2.1):
     ease-spring for the bowtie reveal, ease-out for text slides,
     100ms stat stagger (spec §2.1 Quick Stats). Not tabulated in
     spec §I, so values are inferred from the sequence timings. */
  --dur-fast:   200ms;
  --dur-base:   300ms;
  --dur-slow:   500ms;
  --dur-reveal: 800ms;
  --ease-out:   cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --stagger:    100ms;

  color-scheme: dark;
}

/* Light theme — calm off-white (spec §1.1) */
[data-theme="light"] {
  --bg-primary:   #faf9f7;
  --bg-elevated:  #ffffff;
  --bg-overlay:   #f5f4f2;
  --bg-subtle:    #efeee8;

  --text-primary:   #1a1a1e;
  --text-secondary: #5a5a5e;
  --text-tertiary:  #8a8a8e;
  --text-meta:      #5a5a5e;

  --accent-primary: #0a0a0c;
  --accent-hover:   #2a2a2e;
  --accent-focus:   #2563eb;

  --border-subtle: #e5e4e0;
  --border-strong: #d5d4d0;
  --success:       #16a34a;
  --error:         #dc2626;

  --shadow-card: 0 8px 24px rgb(0 0 0 / 0.08);
  --shadow-cta:  0 4px 16px rgb(0 0 0 / 0.12);

  color-scheme: light;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */

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

* {
  margin: 0;
}

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

body {
  min-height: 100svh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  font-weight: 400;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

a {
  color: inherit;
}

ul[role="list"],
ol[role="list"] {
  list-style: none;
  padding: 0;
}

h1, h2, h3, h4, h5, h6 {
  line-height: var(--leading-tight);
  font-weight: 600;
  overflow-wrap: break-word;
}

code, pre, kbd, samp {
  font-family: var(--font-mono);
}

/* Fixed-header anchor offset without JS */
[id] {
  scroll-margin-top: 5rem;
}

/* --------------------------------------------------------------------------
   3. Accessibility helpers
   -------------------------------------------------------------------------- */

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

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

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: 100;
  padding: var(--space-2) var(--space-4);
  background: var(--accent-primary);
  color: var(--bg-primary);
  border-radius: 6px;
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-200%);
}

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

/* --------------------------------------------------------------------------
   4. Layout primitives
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container-md);
  margin-inline: auto;
  padding-inline: var(--padding-page);
}

.container-lg {
  max-width: var(--container-lg);
}

.container-xl {
  max-width: var(--container-xl);
}

.section {
  padding-block: var(--space-12);
}

.section > .container > h2,
.section-head h2 {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-8);
}

/* --------------------------------------------------------------------------
   5. Hero
   -------------------------------------------------------------------------- */

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--padding-page);
  gap: var(--space-5);
}

.hero-mark {
  width: 48px;
  height: auto;
  color: var(--accent-primary);
}

.hero-title {
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero-subtitle {
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: var(--leading-ui);
}

.hero-tagline {
  font-size: var(--text-xl);
  font-weight: 400;
  max-width: 24em;
  color: var(--text-primary);
  text-wrap: balance;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

/* --------------------------------------------------------------------------
   6. Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-6);
  border-radius: 10px;
  text-decoration: none;
  font-weight: 500;
  line-height: var(--leading-ui);
  transition:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--bg-primary);
  font-size: var(--text-lg);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
  box-shadow: var(--shadow-cta);
}

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

.btn-ghost {
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: var(--text-base);
  background: transparent;
}

.btn-ghost:hover {
  border-color: var(--text-tertiary);
  background: var(--bg-elevated);
}

/* --------------------------------------------------------------------------
   7. Header & navigation
   -------------------------------------------------------------------------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: var(--container-xl);
  margin-inline: auto;
  padding-inline: var(--padding-page);
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.brand {
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--text-primary);
}

.nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

.nav-list a {
  text-decoration: none;
  color: var(--text-secondary);
  padding-block: var(--space-2);
  transition: color var(--dur-fast) var(--ease-out);
}

.nav-list a:hover {
  color: var(--text-primary);
}

.nav-list a[aria-current="page"] {
  color: var(--accent-focus);
  text-decoration: underline;
  text-underline-offset: 6px;
  text-decoration-thickness: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: var(--text-secondary);
  transition: color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* Sun shows in dark mode (click → light); moon in light mode */
.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.menu-toggle {
  display: none;
}

/* Mobile: nav list becomes a slide-in overlay (spec §2.6) */
.nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30; /* below .site-header (40): menu + toggle stay above the backdrop */
  background: rgb(0 0 0 / 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-base) var(--ease-out),
              visibility var(--dur-base);
}

@media (max-width: 899px) {
  .menu-toggle {
    display: inline-flex;
  }

  .nav-list {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 60;
    height: 100vh;
    height: 100dvh;
    width: min(320px, 85vw);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-5);
    padding: var(--space-12) var(--space-6) var(--space-6);
    background: var(--bg-overlay);
    border-left: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
    transform: translateX(105%);
    transition: transform var(--dur-base) var(--ease-out);
    font-size: var(--text-xl);
  }

  .nav-list a {
    color: var(--text-primary);
  }

  body.menu-open .nav-list {
    transform: none;
  }

  body.menu-open .nav-backdrop {
    opacity: 1;
    visibility: visible;
  }
}

/* No-JS fallback: hamburger hidden, nav links render inline */
html:not(.js) .menu-toggle,
html:not(.js) .nav-backdrop {
  display: none;
}

@media (max-width: 899px) {
  html:not(.js) .nav-list {
    position: static;
    transform: none;
    flex-direction: row;
    flex-wrap: wrap;
    height: auto;
    width: auto;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    font-size: var(--text-sm);
    gap: var(--space-4);
  }
}

/* --------------------------------------------------------------------------
   8. Projects slider (structure now; interaction JS in Phase 3)
   -------------------------------------------------------------------------- */

.slider-region {
  position: relative;
}

.slider-track {
  display: flex;
  gap: var(--space-5);
  list-style: none;
  padding: var(--space-2) var(--padding-page) var(--space-6);
  margin-inline: calc(var(--padding-page) * -1);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.slider-track::-webkit-scrollbar {
  display: none;
}

.slider-card {
  flex: 0 0 86%;
  scroll-snap-align: center;
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  overflow: hidden;
  opacity: 0.6;
  transition: opacity var(--dur-base) var(--ease-out),
              transform var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.slider-card.centered {
  opacity: 1;
  border-color: var(--border-strong);
}

@media (min-width: 1024px) {
  .slider-card {
    flex-basis: 38%;
  }

  .slider-card.centered {
    transform: scale(1.05);
  }
}

.card-media img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: var(--bg-subtle);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  flex: 1;
}

.card-title {
  font-size: var(--text-2xl);
}

.card-desc {
  color: var(--text-secondary);
}

.card-metrics {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-meta);
  line-height: var(--leading-ui);
}

.card-metrics li::before {
  content: "•";
  margin-inline-end: var(--space-2);
  color: var(--text-meta);
}

.card-link {
  margin-top: auto;
  padding-top: var(--space-2);
  color: var(--accent-focus);
  font-weight: 500;
  text-decoration: none;
}

.card-link:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.slider-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.slider-arrow {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
  transition: color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}

.slider-arrow:hover {
  color: var(--text-primary);
  border-color: var(--text-tertiary);
  background: var(--bg-elevated);
}

@media (min-width: 768px) {
  .slider-arrow {
    display: inline-flex;
  }
}

.slider-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: 0;
}

.slider-dot {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.slider-dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.slider-dot[aria-current="true"]::before {
  background: var(--accent-primary);
  transform: scale(1.25);
}

@media (min-width: 768px) {
  .slider-dots,
  .slider-hint {
    display: none;
  }
}

.slider-hint {
  margin-top: var(--space-2);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-meta);
}

/* --------------------------------------------------------------------------
   9. Quick stats
   -------------------------------------------------------------------------- */

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

.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: var(--space-5);
  text-align: center;
  display: grid;
  gap: var(--space-1);
  align-content: center;
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.stat-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-ui);
}

@media (min-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

/* Scroll reveal — hidden state only when JS is present */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--dur-slow) var(--ease-out),
              transform var(--dur-slow) var(--ease-out);
}

html.js [data-reveal].in-view {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   10. Footer
   -------------------------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding-block: var(--space-10);
}

.footer-cta {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-5);
}

.footer-social {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.footer-social a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--dur-fast) var(--ease-out);
}

.footer-social a:hover {
  color: var(--accent-focus);
}

.footer-social svg {
  width: 24px;
  height: 24px;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-meta);
}

.footer-meta .footer-mark {
  width: 32px;
  height: auto;
  color: var(--text-meta);
  margin-inline-start: auto;
}

/* --------------------------------------------------------------------------
   10b. Hero intro sequence (spec §2.1 timeline, §3.2 skip logic)
        Plays only when <html> has .intro-play (first visit of the
        session, motion allowed). Without JS: static, always visible.
   -------------------------------------------------------------------------- */

@keyframes hero-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

html.intro-play .hero-mark {
  opacity: 0;
  animation: hero-fade var(--dur-reveal) var(--ease-spring) 300ms both;
}

html.intro-play .hero-title {
  animation: hero-rise var(--dur-slow) var(--ease-out) 500ms both;
}

html.intro-play .hero-subtitle {
  animation: hero-fade var(--dur-base) var(--ease-out) 700ms both;
}

html.intro-play .hero-tagline {
  animation: hero-fade var(--dur-base) var(--ease-out) 900ms both;
}

html.intro-play .hero-actions {
  animation: hero-fade var(--dur-fast) var(--ease-out) 1100ms both;
}

/* --------------------------------------------------------------------------
   10c. Case study & content pages (spec §2.2–2.5)
   -------------------------------------------------------------------------- */

.breadcrumb {
  padding-top: calc(64px + var(--space-5));
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
}

.breadcrumb a:hover {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.page-hero {
  padding-block: var(--space-6) 0;
}

.page-hero h1 {
  font-size: var(--text-4xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-lede {
  margin-top: var(--space-3);
  font-size: var(--text-xl);
  color: var(--text-secondary);
  max-width: 36em;
}

.prose {
  display: grid;
  gap: var(--space-4);
  max-width: 46em;
}

.prose ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.prose ul li::before {
  content: "•";
  color: var(--text-meta);
  margin-inline-end: var(--space-2);
}

.prose strong {
  font-weight: 600;
}

/* Video player */
.video-frame {
  margin: var(--space-6) 0 0;
}

.video-frame video {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
}

.video-frame figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-meta);
}

/* Metrics grid (Impact) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.metric {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: var(--space-5);
  display: grid;
  gap: var(--space-1);
  align-content: center;
  text-align: center;
}

.metric-value {
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: var(--leading-tight);
}

.metric-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-ui);
}

@media (min-width: 768px) {
  .metrics-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Features + screenshots */
.feature-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
  max-width: 46em;
}

.feature-list li::before {
  content: "•";
  color: var(--text-meta);
  margin-inline-end: var(--space-2);
}

.screenshot-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  margin-top: var(--space-6);
}

.screenshot-grid img {
  width: 100%;
  height: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-subtle);
}

.screenshot-grid figcaption,
.research-figure figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-meta);
}

@media (min-width: 768px) {
  .screenshot-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Architecture diagram + stack */
.arch-wrap {
  position: relative;
  margin-top: var(--space-2);
}

.arch {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: var(--space-5);
  overflow-x: auto;
  font-size: var(--text-sm);
  line-height: 1.45;
}

.arch-wrap .copy-btn {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  background: var(--bg-elevated);
}

.stack-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-top: var(--space-6);
}

.stack-grid h3 {
  font-size: var(--text-base);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

.stack-grid ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
  line-height: var(--leading-ui);
}

@media (min-width: 768px) {
  .stack-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .stack-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Performance bars */
.perf-bars {
  display: grid;
  gap: var(--space-6);
  max-width: 46em;
}

.perf-metric h3 {
  font-size: var(--text-base);
  margin-bottom: var(--space-3);
}

.perf-row {
  display: grid;
  grid-template-columns: 4.5em 1fr 4em;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.perf-label {
  font-size: var(--text-sm);
  color: var(--text-meta);
}

.perf-bar {
  display: block;
  height: 12px;
  border-radius: 6px;
  width: var(--w);
  min-width: 12px;
  background: var(--border-strong);
}

.perf-after {
  background: var(--success);
}

.perf-value {
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.perf-note {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-meta);
}

.next-project {
  margin-top: var(--space-8);
}

/* Research page */
.research-item {
  border-top: 1px solid var(--border-subtle);
}

.research-item h2 {
  font-size: var(--text-2xl);
}

.research-impact {
  margin-top: var(--space-2);
  font-size: var(--text-lg);
  color: var(--text-secondary);
}

.research-figure {
  margin: var(--space-6) 0 0;
}

.research-figure img {
  width: 100%;
  max-width: 720px;
  height: auto;
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  background: var(--bg-subtle);
}

.research-links {
  display: flex;
  gap: var(--space-5);
  margin-top: var(--space-5);
}

/* About page */
.about-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  justify-items: center;
  text-align: left;
}

.headshot {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border-subtle);
}

.about-layout h1 {
  font-size: var(--text-3xl);
  margin-bottom: var(--space-5);
}

.about-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin-block: var(--space-6);
}

.about-columns h2 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

.about-columns ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.about-columns li::before {
  content: "•";
  color: var(--text-meta);
  margin-inline-end: var(--space-2);
}

@media (min-width: 768px) {
  .about-layout {
    grid-template-columns: 240px 1fr;
    justify-items: start;
    align-items: start;
  }

  .headshot {
    width: 240px;
    height: 240px;
  }

  .about-columns {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Contact page */
.contact-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-8);
}

.contact-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: var(--space-6);
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}

.contact-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

.contact-card h2 {
  font-size: var(--text-base);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.contact-value {
  margin-top: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.contact-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

@media (min-width: 768px) {
  .contact-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}

.response-note {
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-meta);
}

/* Toast (copy confirmation) */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-6);
  transform: translateX(-50%);
  z-index: 70;
  background: var(--bg-overlay);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-fast) var(--ease-out),
              visibility var(--dur-fast);
}

.toast.visible {
  opacity: 1;
  visibility: visible;
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

/* Back to top (jarvis page, spec §2.2 mobile behavior) */
.back-to-top {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 45;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  box-shadow: var(--shadow-card);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-fast) var(--ease-out),
              visibility var(--dur-fast),
              color var(--dur-fast) var(--ease-out);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  color: var(--text-primary);
}

@media (min-width: 768px) {
  .back-to-top {
    display: none; /* spec: mobile behavior */
  }
}

/* Skeleton loading state for lazy images (Phase 9): animates until
   script.js marks the image .loaded on load/error */
@keyframes skeleton-pulse {
  from { background-color: var(--bg-subtle); }
  to   { background-color: var(--bg-overlay); }
}

html.js img[loading="lazy"]:not(.loaded) {
  animation: skeleton-pulse 1.1s var(--ease-out) infinite alternate;
}

/* --------------------------------------------------------------------------
   11. Global reduced motion (spec: full support)
   -------------------------------------------------------------------------- */

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

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