/* ============================================
   Custom Properties
   ============================================ */

:root {
  --font-display: 'Instrument Serif', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Space Mono', 'SF Mono', 'Fira Code', monospace;

  --card-max-width: 900px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --radius: 14px;
  --radius-sm: 8px;
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-warm: #f0f1f5;
  --bg-card: rgba(100, 100, 120, 0.04);
  --bg-elevated: rgba(100, 100, 120, 0.06);
  --bg-glass: rgba(247, 248, 250, 0.85);
  --bg-overlay: rgba(247, 248, 250, 0.97);
  --card-shine: rgba(255, 255, 255, 0.5);
  --hint-bg: rgba(26, 26, 46, 0.85);
  --hint-text: #f7f8fa;

  --text: #1a1a2e;
  --text-dim: #555566;
  --text-faint: #888899;

  --accent: #2244cc;
  --accent-dim: rgba(34, 68, 204, 0.10);
  --accent-glow: rgba(34, 68, 204, 0.25);

  --signal: #cc2233;
  --signal-dim: rgba(204, 34, 51, 0.10);
  --signal-glow: rgba(204, 34, 51, 0.25);

  --rule: rgba(100, 100, 120, 0.12);
  --gerber-canvas-bg: #f2f3f7;
  --trace-top: #cc2222;
  --trace-bottom: #2222cc;
}

[data-theme="dark"] {
  --bg: #121218;
  --bg-warm: #1a1a22;
  --bg-card: rgba(150, 150, 180, 0.04);
  --bg-elevated: rgba(150, 150, 180, 0.07);
  --bg-glass: rgba(18, 18, 24, 0.85);
  --bg-overlay: rgba(18, 18, 24, 0.97);
  --card-shine: rgba(255, 255, 255, 0.03);
  --hint-bg: rgba(226, 226, 234, 0.85);
  --hint-text: #121218;

  --text: #e2e2ea;
  --text-dim: #9090a0;
  --text-faint: #606070;

  --accent: #4488ee;
  --accent-dim: rgba(68, 136, 238, 0.12);
  --accent-glow: rgba(68, 136, 238, 0.30);

  --signal: #ee4455;
  --signal-dim: rgba(238, 68, 85, 0.12);
  --signal-glow: rgba(238, 68, 85, 0.30);

  --rule: rgba(150, 150, 180, 0.12);
  --gerber-canvas-bg: #16161e;
  --trace-top: #ee4444;
  --trace-bottom: #4444ee;
}

/* ============================================
   Reset & Base
   ============================================ */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

/* ---- Theme toggle ---- */

.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
  backdrop-filter: blur(8px);
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* Show sun in dark mode (click → light), moon in light mode (click → dark) */
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.3s var(--ease);
}
a:hover { color: var(--signal); }

/* ---- Background Traces — giant PCB layer silhouettes ---- */

.bg-traces {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-collage {
  position: absolute;
  will-change: transform;
}

.bg-collage-animate {
  animation: meander var(--meander-dur, 120s) ease-in-out infinite;
}

@keyframes meander {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(var(--drift-x, 300px), calc(var(--drift-y, 200px) * 0.6)); }
  50%  { transform: translate(calc(var(--drift-x, 300px) * -0.5), var(--drift-y, 200px)); }
  75%  { transform: translate(calc(var(--drift-x, 300px) * -1), calc(var(--drift-y, 200px) * 0.3)); }
  100% { transform: translate(0, 0); }
}

.bg-trace-group {
  position: absolute;
}

.bg-trace {
  position: absolute;
  inset: 0;
}

[data-theme="dark"] .bg-trace {
  opacity: 0.12 !important;
}

.bg-trace svg {
  display: block;
  width: 100%;
  height: 100%;
}

.bg-trace svg path,
.bg-trace svg rect,
.bg-trace svg circle,
.bg-trace svg ellipse,
.bg-trace svg polygon {
  transition: filter 1s ease, fill 1s ease, opacity 1s ease;
}

/* ---- Background annotation — hand-drawn project labels ---- */

.bg-annotation {
  position: absolute;
  pointer-events: none;
  color: var(--accent);
  opacity: 0.3;
}

[data-theme="dark"] .bg-annotation {
  opacity: 0.45;
}

.bg-annotation svg {
  overflow: visible;
}

/* ============================================
   Hero
   ============================================ */

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 5rem 3rem 4rem;
}

.hero-photo {
  flex-shrink: 0;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 2px solid var(--rule);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-photo.has-photo {
  position: relative;
  border-color: var(--accent-dim);
  transition: border-color 0.4s 0.15s var(--ease), box-shadow 0.4s 0.15s var(--ease);
}

/* Dual-tone color overlay (blue → red copper gradient) */
.hero-photo.has-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: 50%;
  pointer-events: none;
  background: linear-gradient(135deg, var(--trace-bottom), var(--trace-top));
  mix-blend-mode: color;
  opacity: 0;
  transition: opacity 0.4s 0.08s var(--ease);
}

/* PCB grid overlay */
.hero-photo.has-photo::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 50%;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 19px, var(--accent) 19px, var(--accent) 20px),
    repeating-linear-gradient(90deg, transparent, transparent 19px, var(--accent) 19px, var(--accent) 20px);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}

.hero-photo-img {
  --crop-scale: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.75;
  transform: scale(var(--crop-scale));
  transition: filter 0.5s 0.15s var(--ease);
}

/* Placeholder icon when no photo */
.hero-photo:not(.has-photo)::after {
  content: '';
  width: 60px;
  height: 60px;
  background: var(--rule);
  border-radius: 50%;
}

.hero-content {
  flex: 1;
  max-width: 600px;
}

.hero-eyebrow {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 1rem;
  position: relative;
  padding-left: 2rem;
}

.hero-eyebrow::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.25rem;
  height: 1px;
  background: var(--accent);
}

.hero-name {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 400;
  font-style: normal;
  color: var(--text);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
}

.hero-bio {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text-dim);
  max-width: 550px;
  line-height: 1.7;
  margin-bottom: 1.75rem;
}

.social-links {
  display: flex;
  gap: 1.75rem;
  align-items: center;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  transition: color 0.3s var(--ease);
}

.social-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.social-link:hover {
  color: var(--accent);
}

/* ============================================
   Portfolio — master-detail layout
   ============================================ */

.portfolio {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  gap: 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 3rem 4rem;
}

/* ============================================
   Vertical Timeline — 3-column grid
   [context cards | line | project cards]
   ============================================ */

.timeline {
  flex: 0 0 500px;
  position: relative;
}

/* Vertical line — continuous across all groups */
.timeline::before {
  content: '';
  position: absolute;
  left: 210px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--rule);
}

/* Arrow at top of line */
.timeline::after {
  content: '';
  position: absolute;
  left: 205px;
  top: -6px;
  width: 12px;
  height: 12px;
  border-left: 2px solid var(--rule);
  border-top: 2px solid var(--rule);
  transform: rotate(45deg);
}

/* ---- Group wrapper ---- */

.timeline-group {
  display: flex;
}

/* ---- Context cards (left column) ---- */

.context-card {
  flex: 0 0 200px;
  position: sticky;
  top: 1rem;
  align-self: flex-start;
  padding: 0.75rem 0.75rem 1rem 0;
  text-align: right;
}

/* ---- Entries column (right of line) ---- */

.timeline-group-entries {
  flex: 1;
  margin-left: 20px;
}

.context-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 0.15rem;
}

.context-dates {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}

.context-text {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ---- Year marker ---- */

.timeline-year {
  position: relative;
  padding: 0.75rem 0 0.4rem 0.5rem;
}

.timeline-year-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--signal);
  letter-spacing: 0.08em;
  display: inline-block;
}

/* ---- Dot on the line ---- */

.timeline-dot {
  position: absolute;
  left: -16px;
  top: 1.1rem;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--text-faint);
  transition: all 0.3s var(--ease);
  z-index: 2;
}

/* ---- Project entry card (right column) ---- */

.timeline-entry {
  position: relative;
  padding: 0.75rem 1rem 0.75rem 0.5rem;
  margin-bottom: 0.5rem;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.25s var(--ease);
  outline: none;
}

.timeline-entry:hover {
  background: var(--bg-card);
  border-left-color: var(--text-faint);
}

.timeline-entry:focus-visible {
  background: var(--bg-card);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.timeline-entry.active {
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.timeline-entry.active .timeline-dot {
  background: var(--signal);
  border-color: var(--signal);
  box-shadow: 0 0 8px var(--signal-glow);
}

.timeline-entry:hover .timeline-dot {
  border-color: var(--signal);
}

/* ---- Card text ---- */

.timeline-date {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  margin-bottom: 0.15rem;
}

.timeline-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 0.2rem;
}

.timeline-nda-icon {
  display: inline-flex;
  align-items: center;
  margin-left: 0.4rem;
  vertical-align: middle;
}

.timeline-nda-icon svg {
  width: 14px;
  height: 14px;
  stroke: var(--text-faint);
  flex-shrink: 0;
}

.timeline-client {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-bottom: 0.3rem;
}

.timeline-blurb {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.55;
  margin-bottom: 0.4rem;
}

.timeline-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.timeline-tag {
  font-family: var(--font-body);
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  background: var(--bg-elevated);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
}

/* ============================================
   Detail Panel
   ============================================ */

.detail-panel {
  flex: 1 1 0;
  min-width: 0;
  align-self: flex-start;
}

.detail-panel:empty {
  display: none;
}

/* Inline detail card (mobile accordion) */
.timeline-inline-card {
  margin-bottom: 0.5rem;
}

.detail-card {
  position: relative;
  padding: 2rem 2.5rem 2.5rem 2.25rem;
  background: linear-gradient(135deg, var(--card-shine) 0%, transparent 60%);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  animation: card-enter 0.4s var(--ease) both;
}

.detail-card.exiting {
  animation: card-exit 0.25s var(--ease) both;
}

@keyframes card-enter {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes card-exit {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(8px); }
}

.detail-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--rule);
  border-radius: 50%;
  color: var(--text-faint);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.detail-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.detail-header {
  margin-bottom: 0.4rem;
}

.detail-meta {
  display: flex;
  align-items: baseline;
  gap: 1rem;
}

.detail-date {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
}

.detail-client {
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-faint);
}

.detail-title {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  font-weight: 400;
  color: var(--text);
  line-height: 1.25;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.detail-blurb {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.75;
  margin-bottom: 1rem;
}

/* Tags — editorial inline style */
.project-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  margin-bottom: 1.5rem;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.03em;
  color: var(--text-faint);
}

.tag {
  display: inline;
  color: var(--accent);
  transition: color 0.2s;
  background: none;
  border: none;
  padding: 0;
  border-radius: 0;
}

.tag:hover {
  color: var(--signal);
  background: none;
  border: none;
}

.tag-sep {
  display: inline;
  margin: 0 0.5rem;
  color: var(--text-faint);
  opacity: 0.35;
  user-select: none;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.project-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 100px;
  border: 1px solid var(--rule);
  background: var(--bg-elevated);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.project-link-chip:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

.link-chip-icon {
  font-size: 0.85em;
}

.link-chip-label {
  letter-spacing: 0.02em;
}

.link-chip-arrow {
  font-size: 0.7em;
  opacity: 0.4;
  transition: opacity 0.2s;
}

.project-link-chip:hover .link-chip-arrow {
  opacity: 1;
}

/* ============================================
   Section Headings
   ============================================ */

.section-heading {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  padding-bottom: 0;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.8s cubic-bezier(0.25, 0.1, 0.25, 1) 0.15s;
}

.section-heading.rule-visible::after {
  transform: scaleX(1);
}

/* ============================================
   3D Model Viewers
   ============================================ */

.models-section {
  margin-top: 1.75rem;
}

.models-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

/* Single model: don't stretch to full width */
.models-grid:has(> :only-child) {
  max-width: 520px;
}

.model-viewer-container {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
}

.model-viewer-container:active { cursor: grabbing; }

/* Active state — click-to-zoom indicator */
.model-viewer-container.model-viewer-active {
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 3px rgba(0,0,0,0.08),
    0 0 0 1px var(--accent),
    0 0 10px var(--accent-glow),
    0 0 20px var(--accent-dim);
}

/* Zoom hint — fades in on hover, auto-hides after 3s */
.model-viewer-zoom-hint {
  position: absolute;
  bottom: 2.5rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--hint-text);
  background: var(--hint-bg);
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s var(--ease);
  z-index: 6;
  letter-spacing: 0.03em;
}

.model-viewer-container:hover .model-viewer-zoom-hint {
  animation: hint-flash 4s var(--ease) forwards;
}

@keyframes hint-flash {
  0%   { opacity: 0; }
  15%  { opacity: 1; }
  75%  { opacity: 1; }
  100% { opacity: 0; }
}

.model-viewer-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.model-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(transparent, var(--bg-glass));
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  text-align: center;
  letter-spacing: 0.03em;
  pointer-events: none;
  z-index: 5;
}

.model-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.75rem;
  gap: 0.5rem;
}

.model-fallback svg { opacity: 0.25; }

/* ============================================
   Cutaway Control
   ============================================ */

.cutaway-control {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--hint-bg);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  z-index: 6;
  pointer-events: auto;
}

.cutaway-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--hint-text);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.cutaway-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  background: rgba(128, 128, 128, 0.4);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.cutaway-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--hint-text);
}

.cutaway-flip-btn {
  background: none;
  border: 1px solid rgba(128, 128, 128, 0.4);
  border-radius: var(--radius-sm);
  color: var(--hint-text);
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

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

.cutaway-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--hint-text);
}

@media (max-width: 640px) {
  .cutaway-slider {
    width: 80px;
  }
}

/* ============================================
   Callouts
   ============================================ */

.callout-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.callout-marker {
  width: 12px;
  height: 12px;
  background: var(--signal);
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  opacity: 0.65;
  transition: opacity 0.2s, transform 0.2s;
}

.callout-marker:hover {
  opacity: 1;
  transform: scale(1.2);
}

.callout-marker .callout-pulse {
  position: absolute;
  inset: -5px;
  border: 1px solid var(--signal);
  border-radius: 50%;
  animation: callout-pulse 3s ease-out infinite;
}

@keyframes callout-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(2); opacity: 0; }
}

.callout-tooltip {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-overlay);
  border: 1px solid var(--accent-glow);
  border-left: 2px solid var(--signal);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 0.8rem;
  min-width: 190px;
  max-width: 260px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  backdrop-filter: blur(12px);
  z-index: 20;
}

.callout-marker:hover .callout-tooltip,
.callout-marker.active .callout-tooltip {
  opacity: 1;
  pointer-events: auto;
}

.callout-leader {
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 1px;
  background: var(--signal);
  opacity: 0.5;
}

.callout-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--signal);
  margin-bottom: 0.2rem;
  letter-spacing: 0.02em;
}

.callout-desc {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.55;
}

/* ============================================
   Size Reference
   ============================================ */

.size-ref-label {
  position: absolute;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.02em;
}

/* ============================================
   Protected Project
   ============================================ */

.protected-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding: 2.5rem 1.5rem;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}

.protected-icon {
  color: var(--text-faint);
  opacity: 0.5;
}

.protected-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.protected-unlock-btn {
  padding: 0.35rem 1.1rem;
  background: transparent;
  border: 1px solid var(--text-faint);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.protected-unlock-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.protected-error {
  font-size: 0.8rem;
  color: var(--signal);
}

/* ── Password Modal ── */

.pw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  animation: pw-fade-in 0.2s ease;
}
.pw-modal-backdrop.pw-modal-out {
  animation: pw-fade-out 0.15s ease forwards;
}

.pw-modal {
  width: min(340px, 90vw);
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.25);
  animation: pw-slide-up 0.2s ease;
}
.pw-modal-out .pw-modal {
  animation: pw-slide-down 0.15s ease forwards;
}

.pw-modal-label {
  display: block;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.6rem;
}

.pw-modal-input {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
}
.pw-modal-input:focus {
  border-color: var(--accent);
}

.pw-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}

.pw-modal-cancel,
.pw-modal-submit {
  padding: 0.4rem 1rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pw-modal-cancel {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--text-dim);
}
.pw-modal-cancel:hover {
  border-color: var(--text-faint);
  color: var(--text);
}

.pw-modal-submit {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
}
.pw-modal-submit:hover {
  opacity: 0.85;
}

@keyframes pw-fade-in  { from { opacity: 0 } to { opacity: 1 } }
@keyframes pw-fade-out { from { opacity: 1 } to { opacity: 0 } }
@keyframes pw-slide-up {
  from { transform: translateY(12px); opacity: 0 }
  to   { transform: translateY(0);    opacity: 1 }
}
@keyframes pw-slide-down {
  from { transform: translateY(0);    opacity: 1 }
  to   { transform: translateY(12px); opacity: 0 }
}

/* ============================================
   Gerber Layer Explorer
   ============================================ */

.gerber-section { margin-top: 1.75rem; }
.gerber-viewer-container { position: relative; min-height: 380px; }

.gerber-board-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 0.4rem;
}

.gerber-board-tab {
  padding: 0.4rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.75rem;
  cursor: pointer;
  transition: color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.gerber-board-tab:first-child { border-radius: var(--radius) 0 0 0; }
.gerber-board-tab:last-child { border-radius: 0 var(--radius) 0 0; }

.gerber-board-tab:hover { color: var(--text); }

.gerber-board-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.gerber-canvas-wrap {
  position: relative;
  width: 100%;
  height: 380px;
  background: var(--gerber-canvas-bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: grab;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.06);
}

.gerber-canvas-wrap:active { cursor: grabbing; }

.gerber-canvas-wrap svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.gerber-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.6rem;
  padding: 0.6rem 0.75rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.75rem;
  color: var(--text-dim);
  user-select: none;
  transition: color 0.3s var(--ease);
}

.layer-toggle:hover { color: var(--text); }
.layer-toggle input[type="checkbox"] { display: none; }

.layer-toggle .toggle-track {
  width: 26px;
  height: 13px;
  background: var(--rule);
  border-radius: 7px;
  position: relative;
  transition: background 0.3s var(--ease);
  flex-shrink: 0;
}

.layer-toggle .toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 9px;
  height: 9px;
  background: var(--text-faint);
  border-radius: 50%;
  transition: transform 0.3s var(--ease), background 0.3s var(--ease);
}

.layer-toggle input:checked + .toggle-track {
  background: var(--accent-dim);
}

.layer-toggle input:checked + .toggle-track::after {
  transform: translateX(13px);
  background: var(--accent);
}

.color-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gerber-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.75rem;
}

/* ============================================
   State Machine
   ============================================ */

.state-machine-section { margin-top: 1.75rem; }
.state-machine-container { position: relative; }

.state-machine-canvas {
  width: 100%;
  height: auto;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  display: block;
}

.state-machine-canvas .sm-node {
  fill: var(--bg-glass);
  stroke: var(--text-dim);
  stroke-width: 1.5;
  cursor: pointer;
  transition: fill 0.3s, stroke 0.3s;
}

.state-machine-canvas .sm-node:hover {
  stroke: var(--text-dim);
  fill: var(--bg-overlay);
}

.state-machine-canvas .sm-node.sm-active {
  fill: var(--signal-dim);
  stroke: var(--signal);
  filter: drop-shadow(0 0 6px var(--signal-glow)) drop-shadow(0 0 12px var(--signal-dim));
}

.state-machine-canvas .sm-node.sm-idle-pulse {
  animation: sm-idle-pulse 3.5s ease-in-out infinite;
}

@keyframes sm-idle-pulse {
  0%, 100% { filter: drop-shadow(0 0 2px var(--accent-dim)); stroke: var(--text-faint); }
  50% { filter: drop-shadow(0 0 6px var(--accent-glow)); stroke: var(--accent); }
}

.state-machine-canvas .sm-label {
  fill: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  pointer-events: none;
  user-select: none;
}

.state-machine-canvas .sm-edge {
  fill: none;
  stroke: var(--text-dim);
  stroke-width: 1;
  opacity: 0.5;
}

.state-machine-canvas .sm-edge.sm-edge-active {
  stroke: var(--signal);
  opacity: 1;
}

.state-machine-canvas .sm-edge-label-bg {
  fill: var(--bg);
  opacity: 0.85;
}

.state-machine-canvas .sm-edge-label {
  fill: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 10px;
  opacity: 0.85;
  pointer-events: none;
  user-select: none;
}

.state-machine-canvas .sm-travel-dot {
  fill: var(--signal);
  filter: drop-shadow(0 0 5px var(--signal-glow));
}

.sm-tooltip {
  position: absolute;
  background: var(--bg-overlay);
  border: 1px solid var(--accent-glow);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.5rem 0.7rem;
  max-width: 210px;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  backdrop-filter: blur(12px);
}

.sm-tooltip.visible { opacity: 1; }

.sm-tooltip-title {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 0.15rem;
}

.sm-tooltip-desc {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.45;
}

.sm-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.65rem;
  align-items: center;
}

.sm-controls-label {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-right: 0.2rem;
}

.sm-sequence-btn {
  padding: 0.3rem 0.7rem;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 400;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.3s var(--ease);
  letter-spacing: 0.02em;
}

.sm-sequence-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.sm-sequence-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.sm-sequence-btn.sm-playing {
  border-color: var(--signal);
  color: var(--signal);
  background: var(--signal-dim);
}

.sm-sequence-btn.sm-default {
  border-color: var(--accent);
  color: var(--accent);
}

.sm-status {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--signal);
  min-height: 1.2em;
  margin-top: 0.4rem;
  opacity: 0;
  transition: opacity 0.3s;
  letter-spacing: 0.02em;
}

.sm-status.visible { opacity: 1; }

/* ============================================
   Data Exhibits
   ============================================ */

.data-exhibits-section { margin-top: 1.75rem; }
.data-viewer-container { position: relative; }

.data-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.data-stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 1rem;
  text-align: center;
}

.data-stat-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  margin-bottom: 0.3rem;
}

.data-stat-label {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 0.2rem;
}

.data-stat-desc {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 300;
  color: var(--text-dim);
  line-height: 1.4;
}

.data-chart-wrapper {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.75rem;
  margin-bottom: 0.75rem;
}

.data-chart-title {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.data-chart-desc {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 300;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.data-chart-canvas-wrap {
  position: relative;
  height: 260px;
}

.data-chart-canvas-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.data-chart-three-wrap {
  position: relative;
  width: 100%;
  height: 300px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: grab;
}

.data-chart-three-wrap:active { cursor: grabbing; }

.data-chart-three-wrap canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.data-chart-companion-wrap {
  position: relative;
  margin-top: 0.25rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.data-chart-companion-label {
  position: absolute;
  top: 2px;
  right: 6px;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-faint);
  pointer-events: none;
  z-index: 1;
}

.data-chart-companion-wrap canvas {
  display: block;
  width: 100%;
}

/* ============================================
   Footer
   ============================================ */

footer {
  position: relative;
  z-index: 1;
  padding: 0 2rem 3rem;
  max-width: 1100px;
  margin: 0 auto;
}

.footer-rule {
  width: 100%;
  height: 1px;
  background: var(--rule);
  margin-bottom: 3rem;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.6s var(--ease);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-bottom: 3rem;
}

.footer-heading {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
  position: relative;
}

.footer-heading::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 1.25rem;
  height: 1px;
  background: var(--accent);
}

.footer-author-name {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.footer-author-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-bottom: 1.25rem;
}

.footer-social {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.footer-social .social-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

.footer-social .social-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.footer-tech-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
}

.footer-tech-list li {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  line-height: 1.9;
  letter-spacing: 0.02em;
}

.footer-quip {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.8rem;
  color: var(--text-faint);
}

.footer-bottom {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* Footer scroll reveal */
.footer-rule,
.footer-contact,
.footer-colophon,
.footer-bottom {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}

.footer-rule {
  opacity: 0;
  transform: scaleX(0);
  transition: opacity 0.5s var(--ease), transform 0.6s var(--ease);
}

.footer-contact   { transition-delay: 0.1s; }
.footer-colophon  { transition-delay: 0.15s; }
.footer-bottom    { transition-delay: 0.25s; }

footer.footer-visible .footer-rule {
  opacity: 1;
  transform: scaleX(1);
}

footer.footer-visible .footer-contact,
footer.footer-visible .footer-colophon,
footer.footer-visible .footer-bottom {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1000px) {
  .hero {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4rem 2rem 3rem;
    gap: 2rem;
  }

  .hero-eyebrow { padding-left: 0; }
  .hero-eyebrow::before { display: none; }
  .hero-content { max-width: none; }
  .hero-bio { max-width: none; }
  .social-links { justify-content: center; }

  .portfolio {
    flex-direction: column;
    padding: 0 2rem 4rem;
  }

  .timeline {
    flex: none;
    width: 100%;
  }

  .timeline::before {
    left: 7px;
  }

  .timeline::after {
    left: 2px;
  }

  .timeline-group {
    flex-direction: column;
  }

  .context-card {
    flex: none;
    position: static;
    text-align: left;
    padding: 1rem 0 0.5rem;
    border-bottom: 1px solid var(--rule);
    margin-bottom: 0.5rem;
  }

  .timeline-group-entries {
    margin-left: 0;
  }

  .timeline-year { padding-left: 24px; }
  .timeline-entry { padding-left: 24px; }

  .timeline-dot { left: -24px; }

  /* Hide right-column detail panel; cards go inline in timeline */
  .detail-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .bg-traces { display: none; }

  .hero {
    padding: 3.5rem 1.5rem 2rem;
  }

  .hero-photo {
    width: 180px;
    height: 180px;
  }

  .hero-name {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  .portfolio { padding: 0 1.5rem 4rem; }

  .timeline { flex: none; }

  .detail-card {
    padding: 1.5rem 1.5rem 2rem 1.25rem;
  }

  .models-grid { grid-template-columns: 1fr; }
  .gerber-canvas-wrap { height: 260px; }

  .data-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .data-chart-canvas-wrap { height: 200px; }
  .data-chart-three-wrap { height: 240px; }

  .social-links { gap: 1.25rem; }
  .social-link span { display: none; }

  .footer-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .footer-heading {
    padding-left: 0;
    justify-content: center;
  }

  .footer-heading::before {
    display: none;
  }

  .footer-social {
    align-items: center;
  }
}

@media (max-width: 480px) {
  .hero { padding: 2.5rem 1.25rem 1.5rem; }
  .portfolio { padding: 0 1rem 3rem; }

  .detail-card {
    padding: 1.25rem 1rem 1.5rem;
  }

  .timeline { flex: none; }
}

/* ============================================
   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; }

  .detail-card {
    animation: none !important;
  }

  .section-heading::after {
    transform: scaleX(1) !important;
  }

  .model-viewer-zoom-hint {
    transition: none !important;
  }

  .footer-rule,
  .footer-contact,
  .footer-colophon,
  .footer-bottom {
    opacity: 1 !important;
    transform: none !important;
  }

  .bg-trace svg path,
  .bg-trace svg rect,
  .bg-trace svg circle,
  .bg-trace svg ellipse,
  .bg-trace svg polygon {
    transition: none !important;
  }
}
