@font-face {
  font-family: "Syne";
  src: url("./Syne.79bc839264c4.woff2") format("woff2");
  font-display: swap;
  font-weight: 700 800;
}

@font-face {
  font-family: "Manrope";
  src: url("./Manrope.ce093b341d9c.woff2") format("woff2");
  font-display: swap;
  font-weight: 400 600 800;
}

:root {
  --bg-canvas: #f6f8fb;
  --bg-surface: #ffffff;
  --bg-elevated: #edf2f7;
  --text-primary: #090d16;
  --text-secondary: #1e293b;
  --text-muted: #475569;
  --border-subtle: #cbd5e1;
  --border-strong: #090d16;
  --accent-gold: #b45309;
  --plate-body: #d97706;
  --plate-rim: #78350f;
  --plate-glow: rgba(217, 119, 6, 0.2);
  --pin-user: #2563eb;
  --pin-true: #dc2626;
  --vector-line: #d97706;
  --success-tint: #ecfdf5;
  --success-text: #166534;
  --success-border: #22c55e;
  --fail-tint: #fef2f2;
  --fail-text: #991b1b;
  --fail-border: #ef4444;
  --grid-color: rgba(9, 13, 22, 0.05);
  --focus-ring: #2563eb;
  color-scheme: light;
  font-family: "Manrope", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
}

[data-theme="dark"] {
  --bg-canvas: #0a0e17;
  --bg-surface: #111827;
  --bg-elevated: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #94a3b8;
  --border-subtle: #334155;
  --border-strong: #f8fafc;
  --accent-gold: #f59e0b;
  --plate-body: #f59e0b;
  --plate-rim: #fbbf24;
  --plate-glow: rgba(245, 158, 11, 0.25);
  --pin-user: #60a5fa;
  --pin-true: #ef4444;
  --vector-line: #fbbf24;
  --success-tint: #064e3b;
  --success-text: #6ee7b7;
  --success-border: #10b981;
  --fail-tint: #450a0a;
  --fail-text: #fca5a5;
  --fail-border: #f87171;
  --grid-color: rgba(248, 250, 252, 0.06);
  --focus-ring: #60a5fa;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text-secondary);
  background-color: var(--bg-canvas);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 32px 32px;
  font-size: clamp(1rem, 0.94rem + 0.25vw, 1.15rem);
  line-height: 1.6;
}

button, a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.1em;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  inset: 0 auto auto 0;
  padding: 0.75rem 1.25rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 2px solid var(--border-strong);
  transform: translateY(-140%);
  transition: transform 0.2s ease;
  font-weight: 700;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem clamp(1rem, 4vw, 3rem);
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(8px);
}

.brand-link {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-decoration: none;
  text-transform: uppercase;
  color: var(--text-primary);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pill-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: 9999px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.pill-button:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
}

.main-container {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(1.2rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem);
}

.hero-section {
  text-align: center;
  margin-bottom: 1.5rem;
}

.eyebrow-tag {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-gold);
  margin-bottom: 0.5rem;
}

h1 {
  font-family: "Syne", system-ui, sans-serif;
  font-size: clamp(1.75rem, 4.5vw, 3rem);
  font-weight: 800;
  line-height: 1.15;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}

.hero-deck {
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto;
  line-height: 1.45;
}

/* Interactive Workbench */
.instrument-stage {
  position: relative;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  margin-bottom: 2rem;
}

.stage-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  font-size: 0.88rem;
}

.round-tracker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.round-pips {
  display: flex;
  gap: 6px;
}

.round-pip {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--border-subtle);
  background: transparent;
  transition: all 0.2s ease;
}

.round-pip.active {
  border-color: var(--text-primary);
  background: var(--accent-gold);
  transform: scale(1.2);
}

.round-pip.completed {
  border-color: var(--success-border);
  background: var(--success-border);
}

.specimen-info {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* 3D Workbench Viewport */
.board-viewport {
  position: relative;
  width: 100%;
  height: clamp(340px, 52vw, 460px);
  perspective: 1000px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}

.plate-gimbal {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  will-change: transform;
}

.plate-svg {
  width: 100%;
  height: 100%;
  max-width: 480px;
  max-height: 480px;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.15));
}

.plate-polygon {
  fill: var(--plate-body);
  stroke: var(--plate-rim);
  stroke-width: 3px;
  stroke-linejoin: round;
  transition: fill 0.3s ease, filter 0.3s ease;
}

.plate-polygon:hover {
  filter: brightness(1.05);
}

/* Needle and Plumb markers */
.needle-pivot {
  pointer-events: none;
}

.user-tap-marker {
  fill: var(--pin-user);
  stroke: var(--bg-surface);
  stroke-width: 2px;
}

.true-centroid-marker {
  fill: var(--pin-true);
  stroke: var(--bg-surface);
  stroke-width: 2px;
}

.torque-vector-line {
  stroke: var(--vector-line);
  stroke-width: 2.5px;
  stroke-dasharray: 4 4;
}

/* Feedback Overlay Banner */
.stage-feedback {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
}

.feedback-prose {
  flex: 1 1 280px;
}

.feedback-headline {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.feedback-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.feedback-metric {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
}

.metric-unit {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.action-btn {
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  border: 2px solid var(--border-strong);
  background: var(--text-primary);
  color: var(--bg-surface);
  font-weight: 800;
  font-size: 0.92rem;
  transition: all 0.15s ease;
}

.action-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Balance Docket (Summary View) */
.docket-container {
  display: none;
  padding: clamp(1.2rem, 3vw, 2rem);
  background: var(--bg-surface);
}

.docket-container.visible {
  display: block;
}

.docket-header {
  border-bottom: 2px solid var(--border-strong);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.docket-title {
  font-family: "Syne", sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.docket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.docket-stat-card {
  padding: 1.25rem;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: var(--bg-elevated);
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, monospace;
  margin-bottom: 0.25rem;
}

.stat-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* 5 Shapes Preview Strip */
.specimen-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.gallery-card {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.5rem;
  background: var(--bg-canvas);
  text-align: center;
}

.gallery-card svg {
  width: 100%;
  height: 80px;
}

.gallery-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.gallery-error {
  font-size: 0.8rem;
  font-weight: 800;
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--text-primary);
}

.docket-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Editorial Story Section */
.editorial-section {
  max-width: 680px;
  margin: 3rem auto 0;
  border-top: 2px solid var(--border-strong);
  padding-top: 2rem;
}

.editorial-section h2 {
  font-family: "Syne", sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 1.8rem 0 0.8rem;
}

.editorial-section p {
  margin: 0 0 1.25rem;
  line-height: 1.7;
}

.formula-card {
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--accent-gold);
  background: var(--bg-surface);
  border-radius: 0 8px 8px 0;
  margin: 1.5rem 0;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.92rem;
  color: var(--text-primary);
  overflow-x: auto;
}

/* Site Footer */
.site-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4rem;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .plate-gimbal {
    transform: none !important;
  }
}

@media (max-width: 600px) {
  .stage-statusbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .stage-feedback {
    flex-direction: column;
    align-items: stretch;
  }
  .action-btn {
    width: 100%;
    text-align: center;
  }
}
