/* ============================================
   PROJECTS PAGE STYLES
   Theme tokens, reset, base, and nav are in global.css.
   ============================================ */
:root {
  --section-padding: 4rem 1.5rem;
  /* Shared content-area max-width — used by both .projects-container
     and .hero-timeline-inner so they track the same responsive cap. */
  --content-max-width: 1100px;
}

/* Navigation is handled by global.css */



/* ============================================
   HERO TIMELINE
   ============================================ */
.hero-timeline {
  padding: 1rem 0 0;
  min-height: 0;
  max-height: calc(100vh - 130px);  /* fallback: Safari < 15.4 */
  max-height: calc(100svh - 130px); /* leave room for nav (~62px) + filter legend (~68px) */
  display: flex;
  align-items: flex-start;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: transparent;
}

/* Fixed fullscreen star background — content scrolls over it (parallax) */

.hero-timeline-inner {
  max-width: 1400px;
  width: 100%;
  padding: 0 1.5rem;
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-self: stretch;
}


.hero-timeline-header {
  text-align: center;
  margin-bottom: 0.75rem;
}

.hero-timeline-title {
  font-family: var(--font-poetry, 'Cormorant Garamond', serif);
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.05em;
  margin: 0.5rem 0;
}

.hero-timeline-subtitle {
  font-family: var(--font-poetry, 'Cormorant Garamond', serif);
  font-size: clamp(1.1rem, 2vw, 1.4rem);
  line-height: 1.6;
  color: var(--color-text-secondary);
  max-width: 520px;
  margin: 0 auto;
}

.hero-timeline-svg-wrap {
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  margin: auto 1rem 1rem;
  /* Extra bottom padding so first timeline bubble + drop-shadow are not clipped (MDPI / short heroes) */
  padding: 1.5rem 1.5rem 2.25rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.hero-timeline-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* Let timeline boxes grow beyond their foreignObject clip area
   when text is larger on laptops/desktops */
.hero-timeline-svg foreignObject {
  overflow: visible;
}

/* dotted path — uses accent for theme-awareness */
.hero-timeline-path {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 0.6;
  stroke-linecap: round;
  stroke-dasharray: 6 8;
  /* Start hidden (full offset = total path length ~1077).
     drawIn runs first (0→2.5s), then heroPathPulse takes over and pulses forever. */
  stroke-dashoffset: 1077;
  animation:
    heroTrailDraw  2.5s cubic-bezier(0.4, 0, 0.2, 1) forwards,
    heroPathPulse  10s  2.5s linear infinite alternate;
}

/* Draw the dotted trail from left to right on page load */
@keyframes heroTrailDraw {
  from { stroke-dashoffset: 1077; opacity: 0.5; }
  to   { stroke-dashoffset: 0;    opacity: 0.9; }
}

@keyframes heroPathPulse {
  0% {
    stroke-dashoffset: 0;
    opacity: 0.9;
  }
  100% {
    stroke-dashoffset: -40;
    opacity: 0.7;
  }
}

.hero-timeline-marker {
  cursor: pointer;
  transition: transform 0.25s ease;
}

.hero-timeline-marker:hover {
  transform: translateY(-4px);
}

.hero-timeline-dot {
  fill: var(--color-bg-base);
  stroke: var(--color-accent);
  stroke-width: 3;
  opacity: 0.8;
  filter: drop-shadow(0 0 6px var(--color-accent-glow));
}

.hero-timeline-stem {
  stroke: var(--color-border-strong);
  stroke-width: 2;
  stroke-linecap: round;
}

.hero-timeline-box {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  background: var(--color-bg-card-solid);
  border-radius: 14px;
  padding: 0.4rem 0.55rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--color-cell-border);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  pointer-events: auto;
}

/* Font sizes are intentionally small in CSS because the SVG viewBox-to-
   rendered-width ratio scales all foreignObject content up ~1.1–1.6×.
   Target visual sizes: year ≈ 12-14px, label ≈ 14-16px. */
.hero-timeline-year {
  font-size: 0.625rem;     /* 10px CSS → ~11-16px visual after SVG scale */
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.hero-timeline-label {
  font-size: 0.6875rem;    /* 11px CSS → ~12-18px visual after SVG scale */
  font-weight: 500;
  color: var(--color-text-primary);
}

.hero-timeline-box--dance {
  border-left: 3px solid var(--color-accent);
}

.hero-timeline-box--music {
  border-left: 3px solid var(--color-text-muted);
}

.hero-timeline-box--writing {
  border-left: 3px solid var(--color-accent-dark);
}

.hero-timeline-box--art {
  border-left: 3px solid #7CB342;
}

/* ============================================
   TIMELINE LEGEND (“The Journey”)
   ============================================ */
.timeline-section {
  padding: 0 1.5rem 0;
}


.timeline-legend {
  max-width: 1000px;
  margin: 0 auto 1.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: 999px;
  background: var(--color-bg-card-solid);
  border: 1px solid var(--color-cell-border);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: nowrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.legend-item:hover {
  background: rgba(0, 0, 0, 0.04);
  transform: translateY(-1px);
}

.legend-item.active {
  background: rgba(255, 111, 97, 0.08);
  color: var(--color-text-primary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ============================================
   PROJECTS SECTION
   ============================================ */
.projects-section {
  padding: var(--section-padding);
}

.projects-header {
  text-align: center;
  margin-bottom: 3rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  margin-bottom: 0.5rem;
}

.section-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.projects-container {
  max-width: var(--content-max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(3.5rem, 3rem + 2vw, 5rem);  /* raised from 2.5rem — lets background stars show through */
}

.project-card {
  /* Semi-transparent so shapes show through (color-mix below).
     SCROLL-002: NO backdrop-filter here — blur(12px) over the fixed parallax
     background forced a per-card GPU backdrop re-blur on every scroll frame.
     Apple devices already shipped without it; all platforms now match. */
  background: var(--color-bg-card-solid);
  border: 1px solid var(--color-border-subtle);
  border-radius: 20px;
  padding: 1.75rem 1.75rem 1.5rem;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.22),
    0 4px 12px rgba(0, 0, 0, 0.14);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  position: relative;
  overflow: hidden;
  transition:
    border-color 0.42s ease,
    box-shadow    0.42s ease,
    background    0.42s ease,
    transform     0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@supports (color: color-mix(in srgb, red, blue)) {
  .project-card {
    background: color-mix(in srgb, var(--color-bg-card-solid) 50%, transparent);
  }
}

/* (SCROLL-002: the former .ua-webkit-apple .project-card backdrop-filter
   override was removed — the base rule no longer sets one anywhere.) */

/* ::before kept as empty placeholder — no overlay on hover */
.project-card::before {
  display: none;
}

/* Inner border glow — traces the card outline with the accent colour */
.project-card::after {
  content: "";
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0; /* Safari 14.0 — no inset shorthand */
  border-radius: inherit;
  border: 1px solid var(--color-border-strong);
  box-shadow: inset 0 0 28px var(--color-accent-glow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.42s ease;
}

.project-card:hover {
  background: var(--color-bg-card-solid);
  border-color: var(--color-border-medium);
  box-shadow:
    0 36px 90px rgba(0, 0, 0, 0.48),
    0 10px 28px rgba(0, 0, 0, 0.30),
    0 0 56px var(--color-accent-glow);
  transform: translateY(-4px);
}

.project-card:hover::after {
  opacity: 1;
}

.project-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.project-title {
  font-family: var(--font-body);
  font-size: clamp(1.3rem, 1.1rem + 0.6vw, 1.6rem);  /* was clamp(1.8rem,3vw,2.6rem) — scaled down to ~1.2–1.3× body */
  font-weight: 500;
  font-style: italic;
  margin-bottom: 0.25rem;
}

.project-subtitle {
  font-family: var(--font-body);
  font-size: clamp(1.1rem, 1.5vw, 1.25rem);
  color: var(--color-text-secondary);
}

.project-content {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.3fr);
  gap: 2rem;
  align-items: flex-start;
}

.project-description p {
  margin: 0 0 0.8rem;
  line-height: 1.8;
  font-family: var(--font-body);
  font-size: clamp(1.125rem, 1rem + 0.25vw, 1.25rem);  /* 18px mobile → 20px desktop */
}

.project-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: var(--text-sm);
}

.detail-group h4 {
  margin: 0 0 0.4rem;
  font-size: var(--text-sm);
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: var(--text-xs);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ============================================
   MOSAIC GALLERY
   ============================================ */
.project-gallery {
  margin-top: 1.4rem;
}

/* Higher specificity to override gallery-viewer.css's .gallery-title
   which is styled for the fullscreen overlay, not inline project cards */
.project-gallery .gallery-title {
  font-family: var(--font-body);
  font-size: var(--text-sm);   /* 16–18px — always smaller than .project-title */
  font-weight: 400;
  letter-spacing: 0.05em;
  margin-bottom: 0.65rem;
}

.mosaic-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: 120px;
  gap: 0.75rem;
}

.mosaic-item {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: var(--color-bg-elevated);
}

.mosaic-item.large {
  grid-column: span 2;
  grid-row: span 2;
}

.mosaic-item.wide {
  grid-column: span 2;
}

.mosaic-item.tall {
  grid-row: span 2;
}

.mosaic-item img,
.mosaic-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mosaic-item.decorative {
  cursor: default;
}

.mosaic-overlay {
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0; /* Safari 14.0 */
  background: linear-gradient(to top, rgba(9, 4, 30, 0.6), transparent 60%);
  opacity: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding: 0.6rem;
  transition: opacity 0.25s ease;
  color: white;
}

.mosaic-icon {
  width: 22px;
  height: 22px;
}

.mosaic-item:hover .mosaic-overlay {
  opacity: 1;
}

/* A11Y-003: keyboard parity. Tiles are made focusable + role=button + Enter/Space-
   activated in gallery-viewer.js; give the focused tile a clear ring AND reveal the
   same zoom-icon overlay that mouse users get on hover. */
.mosaic-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.mosaic-item:focus-visible .mosaic-overlay {
  opacity: 1;
}

/* decorative inline SVG */
.decorative-svg {
  width: 100%;
  height: 100%;
}

/* ============================================
   CONSTELLATION MIND MAP
   ============================================ */
.mindmap-section {
  padding: var(--section-padding);
  min-height: 80vh;
  display: flex;
  flex-direction: column;
}

.mindmap-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.mindmap-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  background: radial-gradient(circle at top left, var(--color-bg-elevated), var(--color-bg-base) 55%, var(--color-bg-overlay));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.4);
}

.mindmap-svg {
  width: 100%;
  height: 100%;
  min-height: 450px;
}

/* tiny stars */
.mind-stars circle {
  fill: rgba(255, 255, 255, 0.8);
  opacity: 0.4;
}

/* connections — theme-aware */
.mind-connection {
  stroke: var(--color-border-strong);
  stroke-width: 2;
  stroke-linecap: round;
  transition: opacity 0.3s ease, stroke 0.3s ease, stroke-width 0.3s ease;
}

.mind-connection--soft {
  stroke-dasharray: 4 6;
  opacity: 0.5;
}

/* domain nodes */
.mindmap-node {
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.mind-node-orbit {
  fill: rgba(255, 255, 255, 0.05);
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 2;
}

.mind-node-core {
  fill: var(--color-text-muted);
  stroke-width: 3;
}

.mind-node-core--dance {
  stroke: var(--color-accent);
}

.mind-node-core--music {
  stroke: var(--color-text-muted);
}

.mind-node-core--writing {
  stroke: var(--color-accent-dark);
}

.mind-node-core--art {
  stroke: #7CB342;
}

.mind-node-label {
  fill: var(--color-text-primary);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  letter-spacing: 0.28em;
}

.mind-node-count {
  fill: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* project nodes */
.mind-project-node {
  cursor: pointer;
  transition: opacity 0.25s ease, filter 0.25s ease;
}

.mind-project-node:hover .mind-project-dot {
  filter: drop-shadow(0 0 6px var(--color-accent-glow));
  stroke-width: 2.5;
}

.mind-project-dot {
  fill: var(--color-bg-base);
  stroke: var(--color-border-strong);
  stroke-width: 2;
}

.mind-project-text {
  fill: var(--color-text-secondary);
  font-size: var(--text-xs);
}

/* instruction */
.mindmap-instruction {
  text-align: center;
  margin-top: 1.8rem;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  font-style: italic;
}

/* ============================================
   ARCHIVE SECTION (text-only)
   ============================================ */
.archive-section {
  padding: var(--section-padding);
}

.archive-header {
  text-align: center;
  margin-bottom: 3rem;
}

.filter-bar {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 3rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.625rem 1.25rem;
  background: transparent;
  border: 2px solid var(--color-border-subtle);
  border-radius: 30px;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s;
}

.filter-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.filter-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-on-accent, #0d0d0f);
}

.archive-list {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.archive-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-cell-border);
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.3s, box-shadow 0.3s;
}

.archive-item:hover {
  transform: translateX(10px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.archive-item.hidden {
  display: none;
}

.archive-title {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.25rem;
}

.archive-meta {
  display: flex;
  gap: 1rem;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: 0.5rem;
}

.archive-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.archive-tag {
  font-size: var(--text-xs);
  padding: 0.25rem 0.625rem;
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text-secondary);
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.archive-arrow {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: color 0.3s, transform 0.3s;
}

.archive-item:hover .archive-arrow {
  color: var(--color-accent);
  transform: translateX(5px);
}

.archive-arrow svg {
  width: 24px;
  height: 24px;
}

/* Copyright badges on gallery tiles handled by UGV (.gv-credit-badge)
   — only shown when data-copyright is present, no duplicate symbol needed */

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .project-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .mosaic-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}


/* ── Laptop / small desktop (1025–1599px): viewport-height hero + horizontal SVG pan.
   “Contain” mode squeezed the whole 1140×560 diagram into a tiny box — foreignObject
   labels overlapped. Same idea as tablet/mobile: min width + overflow-x auto so the
   vector graphic stays legible; user scrolls sideways if needed.
   ─────────────────────────────────────────────────────────────────── */
@media (min-width: 1025px) and (max-width: 1599px) {
  /* Let the hero size itself from its content instead of forcing viewport
     height.  This keeps the SVG **width-constrained** (fills edge-to-edge)
     at every DPI / Windows-scale combination (100 %, 125 %, 150 %).
     max-height caps it so it never exceeds the viewport on low-DPI screens. */
  .hero-timeline {
    height: auto;
    min-height: 260px;
    max-height: calc(100vh - 130px);
    max-height: calc(100svh - 130px);
    padding: 0;
    display: flex;
    align-items: flex-start;
  }

  .hero-timeline-inner {
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: 98vw;           /* near edge-to-edge */
    padding: 0 0.5rem;
  }

  .hero-timeline-header {
    flex-shrink: 0;
    padding: 0.6rem 1rem 0.15rem;
    margin-bottom: 0;
  }

  .hero-timeline-title {
    font-size: clamp(1.8rem, 3.5vw, 3.2rem);
    margin: 0.2rem 0;
  }

  .hero-timeline-subtitle {
    font-size: clamp(0.95rem, 1.5vw, 1.2rem);
  }

  .hero-timeline-svg-wrap {
    flex: none;               /* natural height from SVG — no stretching */
    margin: 0 0.25rem 0.35rem;
    padding: 0.35rem 0.5rem 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.4) transparent;
  }

  .hero-timeline-svg-wrap::-webkit-scrollbar {
    height: 6px;
  }

  .hero-timeline-svg-wrap::-webkit-scrollbar-track {
    background: transparent;
  }

  .hero-timeline-svg-wrap::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.45);
    border-radius: 3px;
  }

  .hero-timeline-svg {
    display: block;
    /* width:100% + height:auto → SVG is ALWAYS width-constrained.
       The height follows from width × (viewBox-h / viewBox-w).
       This guarantees edge-to-edge rendering at any DPI scaling. */
    width: 100%;
    height: auto;
    min-width: 700px;   /* readability floor; triggers h-scroll below this */
    flex: none;
  }

  /* ── Timeline-box text for laptops ── */
  .hero-timeline-box {
    padding: 0.4rem 0.55rem;
    gap: 0.1rem;
  }

  .hero-timeline-year {
    font-size: 0.6875rem;  /* 11px */
  }

  .hero-timeline-label {
    font-size: 0.8125rem;  /* 13px */
  }
}

/* ── Large desktop / 4K / wide windows (≥1600px)
   Same width-first strategy as the laptop breakpoint: SVG uses
   width:100% + height:auto so it's always width-constrained.
   max-height on .hero-timeline prevents the section from exceeding
   the viewport on standard-DPI monitors.
   ─────────────────────────────────────────────────────────────────── */
@media (min-width: 1600px) {
  .hero-timeline {
    height: auto;
    min-height: 260px;
    max-height: calc(100vh - 130px);
    max-height: calc(100svh - 130px);
    padding: 0;
    display: flex;
    align-items: flex-start;
  }

  .hero-timeline-inner {
    width: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    max-width: min(98vw, 2400px);  /* near edge-to-edge, cap for ultra-wide */
    padding: 0 0.5rem;
  }

  .hero-timeline-header {
    flex-shrink: 0;
    padding: 0.6rem 1rem 0.15rem;
    margin-bottom: 0;
    text-align: center;
  }

  .hero-timeline-svg-wrap {
    flex: none;                    /* natural height from SVG */
    margin: 0 0.25rem 0.35rem;
    padding: 0.35rem 0.5rem 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.4) transparent;
  }

  .hero-timeline-svg-wrap::-webkit-scrollbar { height: 6px; }
  .hero-timeline-svg-wrap::-webkit-scrollbar-track { background: transparent; }
  .hero-timeline-svg-wrap::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.45);
    border-radius: 3px;
  }

  .hero-timeline-svg {
    display: block;
    width: 100%;
    height: auto;               /* width-first: always edge-to-edge */
    min-width: 700px;
    flex: none;
  }

  /* ── Timeline-box text for large desktop ── */
  .hero-timeline-box {
    padding: 0.45rem 0.6rem;
    gap: 0.12rem;
  }

  .hero-timeline-year {
    font-size: 0.75rem;    /* 12px */
  }

  .hero-timeline-label {
    font-size: 0.875rem;   /* 14px */
  }
}

/* ── Tablet range (769–1024 px): portrait iPad, Surface Pro, large tabs
   Viewport-fill layout so "Featured Projects" is never visible on load.
   Title positioned at top (matching books/poems), SVG fills remaining.
   Filter docked as a compact 80px strip at screen bottom.
   ─────────────────────────────────────────────────────────────────── */
@media (min-width: 769px) and (max-width: 1024px) {
  /* Hero fills viewport minus nav(52px) + filter(80px) */
  .hero-timeline {
    height: calc(100vh - 132px);   /* Safari < 16 fallback */
    height: calc(100svh - 132px);
    min-height: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
  }

  .hero-timeline-inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 1.5rem;
  }

  /* Title at top with generous padding — same visual as books/poems */
  .hero-timeline-header {
    flex-shrink: 0;
    text-align: center;
    padding: 6rem 1rem 2rem;
  }

  .hero-timeline-title {
    font-family: var(--font-poetry, 'Cormorant Garamond', serif);
    font-size: clamp(2.4rem, 4vw, 4.5rem);
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
  }

  .hero-timeline-subtitle {
    font-size: clamp(0.9rem, 1.5vw, 1.1rem);
  }

  /* SVG fills remaining hero space — horizontally scrollable */
  .hero-timeline-svg-wrap {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0.5rem 1.35rem;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.35) transparent;
  }

  .hero-timeline-svg-wrap::-webkit-scrollbar { height: 4px; }
  .hero-timeline-svg-wrap::-webkit-scrollbar-track { background: transparent; }
  .hero-timeline-svg-wrap::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.35);
    border-radius: 2px;
  }

  .hero-timeline-svg {
    height: 100%;
    width: auto;
    min-width: 800px;
    display: block;
    overflow: visible;
  }

  /* Filter: compact 80px strip — 2 rows of legend items */
  .timeline-section {
    height: 80px;
    overflow: hidden;
    padding: 0.4rem 1.5rem;
  }

  .timeline-legend {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
    flex-wrap: unset;
    overflow: visible;
    border-radius: 10px;
    padding: 0.3rem 0.5rem;
    max-width: 100%;
    margin: 0;
  }

  .legend-item {
    font-size: 0.875rem;
    padding: 0.28rem 0.35rem;
    gap: 0.25rem;
    border-radius: 7px;
    justify-content: center;
    text-align: center;
    flex-shrink: unset;
  }

  .legend-dot { width: 7px; height: 7px; }
}

@media (max-width: 768px) {

  /* ═══════════════════════════════════════════════════════════════
     ABOVE-THE-FOLD LAYOUT — MOBILE
     Goal: title centred (books-page style) + timeline + filter all
     visible on page load.  Nothing from "Featured Projects" visible.

     Nav sticky ~52px.  Filter legend ~90px.
     Hero = calc(100svh - 142px) fills the remaining viewport.
     Inside hero: title header flex:1 so it pushes SVG to bottom
     and centres its own content vertically — same feel as books.
     ═══════════════════════════════════════════════════════════════ */

  /* ── Hero: exact viewport fill minus nav + filter ───────────── */
  .hero-timeline {
    height: calc(100vh - 142px);   /* Safari < 16 fallback */
    height: calc(100svh - 142px);
    min-height: 0;
    padding: 0;
    display: flex;
    align-items: stretch;
  }

  .hero-timeline-inner {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 0 0.75rem;
  }

  /* Title at top, same padding as books/poems hero (4.5rem top)  */
  .hero-timeline-header {
    flex-shrink: 0;
    text-align: center;
    padding: 4.5rem 0.5rem 1.5rem;
  }

  /* Match poems-hero-title style exactly */
  .hero-timeline-title {
    font-family: var(--font-poetry, 'Cormorant Garamond', serif);
    font-size: clamp(2.4rem, 6.5vw, 4.5rem);
    font-weight: 400;
    font-style: italic;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
  }

  .hero-timeline-subtitle {
    font-size: var(--text-sm);
    text-align: center;
  }

  /* ── SVG: fills remaining hero space after title ─────────────── */
  .hero-timeline-svg-wrap {
    flex: 1;
    min-height: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.4rem 0.5rem 1rem;
    margin: 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(212, 175, 55, 0.35) transparent;
  }

  .hero-timeline-svg-wrap::-webkit-scrollbar { height: 4px; }
  .hero-timeline-svg-wrap::-webkit-scrollbar-track { background: transparent; }
  .hero-timeline-svg-wrap::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.35);
    border-radius: 2px;
  }

  .hero-timeline-svg {
    height: 100%;
    width: auto;
    min-width: 700px;
    display: block;
    overflow: visible;
  }

  /* Smaller fonts inside timeline boxes */
  .hero-timeline-box {
    font-size: 0.875rem;
    padding: 0.4rem 0.5rem;
    gap: 0.1rem;
    border-radius: 10px;
  }

  .hero-timeline-year {
    font-size: 0.875rem;
    letter-spacing: 0.12em;
  }

  .hero-timeline-label {
    font-size: 0.875rem;
  }

  /* ── Filter legend: compact, two rows, no scrolling ─────────── */
  .timeline-section {
    height: 90px;
    padding: 0.35rem 0.75rem 0.4rem;
    overflow: hidden;
  }

  .timeline-legend {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.28rem;
    flex-wrap: unset;
    overflow: visible;
    border-radius: 10px;
    padding: 0.3rem 0.4rem;
    max-width: 100%;
    margin: 0;
  }

  .legend-item {
    font-size: 0.875rem;
    padding: 0.25rem 0.3rem;
    gap: 0.22rem;
    border-radius: 7px;
    justify-content: center;
    text-align: center;
    flex-shrink: unset;
  }

  .legend-dot { width: 7px; height: 7px; }

  /* ── Filter bar (projects section) ──────────────────────────── */
  .filter-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding: 0 1rem 0.4rem;
    gap: 0.5rem;
    margin-bottom: 2rem;
    scrollbar-width: none;
  }

  .filter-bar::-webkit-scrollbar { display: none; }

  .filter-btn {
    flex-shrink: 0;
    padding: 0.48rem 1rem;
    font-size: var(--text-xs);
  }

  /* ── Section margins: match the 0.75rem used by hero & filter ── */
  /* All content sections share the same edge spacing             */
  :root { --section-padding: 2rem 0.75rem; }

  .projects-section,
  .mindmap-section,
  .archive-section {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .projects-header { margin-bottom: 1.5rem; }
  .projects-container { gap: clamp(2.5rem, 2rem + 1.5vw, 3.5rem); }

  /* Reduce card internal horizontal padding to match tight layout */
  .project-card { padding: 1.25rem 1rem 1.1rem; }

  /* Filter bar: remove extra internal horizontal padding          */
  .filter-bar { padding: 0 0.25rem 0.4rem; }

  /* ── Rest ─────────────────────────────────────────────────────── */
  .mosaic-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 130px;
  }

  .archive-item { grid-template-columns: 1fr; }
  .archive-arrow { display: none; }
  .mindmap-svg { min-height: 420px; }
  .mind-project-text { font-size: var(--text-xs); }
}

@media (max-width: 480px) {
  /* Small phones: same viewport-filling approach */
  .hero-timeline {
    height: calc(100vh - 142px);   /* Safari < 16 fallback */
    height: calc(100svh - 142px);
  }

  /* Tighter top padding for small screens but still generous */
  .hero-timeline-header {
    padding: 3.5rem 0.5rem 1.2rem;
  }

  .hero-timeline-title {
    font-size: clamp(2.4rem, 10vw, 3.5rem);
  }

  /* SVG inherits flex:1 from 768px rule — just adjust min-width */
  .hero-timeline-svg-wrap {
    padding: 0.3rem 0.4rem 0.75rem;
  }

  .hero-timeline-svg {
    min-width: 620px;
  }

  .hero-timeline-box {
    font-size: 0.875rem;
    padding: 0.32rem 0.42rem;
  }

  .hero-timeline-year { font-size: 0.875rem; }
  .hero-timeline-label { font-size: 0.875rem; }

  .timeline-section {
    height: 90px;
    padding: 0.3rem 0.6rem 0.35rem;
  }

  .legend-item {
    font-size: 0.875rem;
    padding: 0.22rem 0.25rem;
  }

  /* Even tighter on very small phones */
  :root { --section-padding: 1.5rem 0.5rem; }

  .projects-section,
  .mindmap-section,
  .archive-section {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  .project-card { padding: 1rem 0.85rem 0.9rem; }
  .filter-bar { padding: 0 0.2rem 0.4rem; }

  .mosaic-grid {
    grid-auto-rows: 120px;
    gap: 0.5rem;
  }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .gv-modal,
  .filter-bar,
  .site-nav {
    display: none !important;
  }

  body {
    background: white;
  }

  .hero-timeline,
  .projects-section,
  .mindmap-section,
  .archive-section {
    page-break-inside: avoid;
  }

  .project-card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================================
   SCROLL-008 — render cost containment (audit P1-3, 2026-06-13)
   Skip style/layout/paint for project cards outside the viewport
   (~3,000-node page stops re-laying-out everything on each change).
   Older browsers ignore both properties (progressive perf only).
   ============================================================ */
.project-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 640px;
}
