/* ============================================
   COMPUTATIONAL MORPHOGENESIS
   Design system matched to hermanity.dev
   ============================================ */

:root {
  /* backgrounds */
  --bg-0:        #06080b;
  --surface-1:  #0b0e13;
  --surface-2:  #0d1117;
  --surface-3:  #12161d;

  /* borders */
  --border-1:      #232a34;
  --border-2:      #1b212a;
  --border:        #1e2632;

  /* text */
  --text-1:   #f2f4f7;
  --text-2:   #e8ebf0;
  --text-3:   #c7ced8;
  --text-4:   #8b95a3;
  --text-5:   #5b6675;

  /* accents */
  --green:    #3ddc97;
  --accent-dim: #1a5c3f;
  --accent-glow: rgba(61, 220, 151, 0.08);
  --green-bg:     #0d1a14;
  --green-border: #1c3a2e;
  --amber:    #f0b84f;
  --red:      #ef6b6b;

  /* fonts */
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --serif:  'Newsreader', Georgia, 'Times New Roman', serif;

  /* radius */
  --radius:   4px;
  --radius-sm: 2px;

  /* shadows */
  --accent-subtle: rgba(61, 220, 151, 0.06);
  --accent-line: rgba(61, 220, 151, 0.14);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.22);
  --shadow-card-lg: 0 12px 32px rgba(0, 0, 0, 0.28);

  --max-width: 1100px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-0);
  color: var(--text-3);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* === Top glow rule === */
.page-glow-rule {
  position: relative;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--green), transparent);
  opacity: 0.5;
  margin-bottom: -1px;
}

/* === Skip link === */
.skip-link {
  position: fixed;
  top: 8px; left: 8px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--surface-2);
  color: var(--green);
  border: 1px solid var(--green);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  text-decoration: none;
  transform: translateY(-150%);
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* === Header === */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 0;
  margin-bottom: 48px;
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--text-2);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 2px;
}

.logo-bracket { color: var(--green); }

.nav {
  display: flex;
  gap: 28px;
}

.nav-link {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-4);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.15s;
  position: relative;
  padding: 5px 11px;
  border-radius: 100px;
}

.nav-link:hover { color: var(--text-2); }
.nav-link.active { color: var(--green); background: var(--accent-glow); }

@media (max-width: 600px) {
  .header-inner { flex-direction: column; gap: 16px; }
  .nav { flex-wrap: wrap; justify-content: center; gap: 16px; }
}

/* === Main === */
.main {
  flex: 1;
  padding-bottom: 64px;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-2);
  line-height: 1.3;
  font-weight: 600;
  text-wrap: pretty;
}

h1 {
  font-family: var(--display);
  font-size: clamp(30px, 4.4vw, 52px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

h2 {
  font-size: 24px;
  margin: 48px 0 16px;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 18px;
  margin: 32px 0 12px;
}

p { margin-bottom: 16px; }

a {
  color: var(--green);
  text-decoration: none;
  transition: opacity 0.15s, color 0.2s;
}

a:hover { opacity: 0.8; }

strong { color: var(--text-2); font-weight: 600; }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--green);
}

pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  margin: 24px 0;
}

pre code { background: none; padding: 0; color: inherit; }

/* === Selection === */
::selection { background: var(--green); color: var(--bg-0); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--border-1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* === Kicker / eyebrow === */
.kicker, .eyebrow {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--green);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.kicker::after, .eyebrow::after {
  content: '';
  height: 1px;
  width: 44px;
  background: linear-gradient(to right, var(--accent-dim), transparent);
}

/* === Hero === */
.hero {
  margin-bottom: 64px;
  text-align: center;
  position: relative;
  overflow: hidden;
  padding: 40px 0;
}

.hero-bg {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 800px; height: 800px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  opacity: 0.4;
  z-index: -1;
}

.hero .subtitle {
  font-family: var(--serif);
  font-size: clamp(1rem, 2.5vw, 1.35rem);
  color: var(--text-4);
  max-width: 640px;
  margin: 0 auto 40px;
  font-style: italic;
}

.hero-meta {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-4);
}

.hero-meta span { display: flex; align-items: center; gap: 6px; }
.hero-meta strong { color: var(--green); font-weight: 600; }

/* === Stats grid === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 48px 0;
}

.stat-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-dim);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.stat-card::before {
  content: '//';
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-5);
  letter-spacing: 0.5px;
}

.stat-card:hover {
  border-color: var(--border-1);
  box-shadow: 0 6px 20px var(--accent-glow);
}

@media (prefers-reduced-motion: no-preference) {
  .stat-card:hover { transform: translateY(-2px); }
}

.stat-label {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text-4);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 700;
  color: var(--green);
  line-height: 1.2;
}

/* === Section headers === */
.section-header { margin-bottom: 44px; }
.section-kicker {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--green);
  margin-bottom: 8px;
}
.section-title {
  font-family: var(--display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 12px;
}
.section-description {
  color: var(--text-4);
  font-size: 16px;
  max-width: 600px;
}

/* === Paper / prose content === */
.paper-content {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text-3);
  max-width: 780px;
  margin: 0 auto;
}

.paper-content p { margin-bottom: 1.2em; }
.paper-content strong { color: var(--text-2); }
.paper-content code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 2px 6px; border-radius: var(--radius-sm); color: var(--green); }

.paper-content .math {
  font-family: var(--serif);
  font-style: italic;
  background: var(--surface-1);
  border-left: 3px solid var(--green);
  padding: 16px 20px;
  margin: 20px 0;
  overflow-x: auto;
  font-size: 1.05em;
  color: var(--text-2);
}

.paper-content blockquote {
  border-left: 2px solid var(--accent-dim);
  padding-left: 20px;
  color: var(--text-4);
  font-style: italic;
}

.paper-content ul, .paper-content ol { margin-left: 24px; margin-bottom: 1.2em; }
.paper-content li { margin-bottom: 0.5em; }

/* Long-form body in serif like hermanity */
.prose p, .prose li, .prose blockquote { font-family: var(--serif); font-size: 19px; }

/* === Figures === */
figure {
  margin: 32px 0;
  text-align: center;
}
figure img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
figcaption {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-4);
  margin-top: 8px;
}

/* === Gallery === */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 32px 0;
}

.gallery-item {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent-dim);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.gallery-item:hover {
  border-color: var(--accent-dim);
  box-shadow: inset 2px 0 0 var(--green), 0 8px 28px var(--accent-glow);
  transform: translateY(-2px);
}

.gallery-item img {
  width: 100%;
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
}

.gallery-item .gallery-info { padding: 12px 14px; }
.gallery-item .gallery-label { font-family: var(--display); font-size: 14px; font-weight: 600; color: var(--text-2); }
.gallery-item .gallery-params { font-family: var(--mono); font-size: 11px; color: var(--text-4); margin-top: 2px; }

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

/* === Tables === */
.data-table, .paper-content table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
  margin: 24px 0;
}

.data-table th, .paper-content th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-4);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

.data-table td, .paper-content td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-3);
}

.data-table tr:hover td, .paper-content tr:hover td { background: var(--surface-1); }

/* === Callout / result banner === */
.callout {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  padding: 20px 24px;
  border-radius: var(--radius);
  margin: 24px 0;
  box-shadow: var(--shadow-card);
}

.callout .callout-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
  margin-bottom: 8px;
}

.result-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 24px 0;
  box-shadow: var(--shadow-card);
}

.result-icon { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; }
.result-text { flex: 1; }
.result-text strong { color: var(--text-2); display: block; margin-bottom: 4px; }
.result-text span { font-size: 14px; color: var(--text-4); }

/* === Key findings === */
.findings-list { list-style: none; margin: 24px 0; }
.findings-list li {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.finding-number { font-family: var(--mono); font-size: 1.2rem; font-weight: 700; color: var(--green); min-width: 32px; }
.finding-content { flex: 1; }
.finding-content strong { color: var(--text-2); display: block; margin-bottom: 4px; }
.finding-content span { color: var(--text-4); font-size: 14px; }

/* === Pill / CTA === */
.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 0;
  border: 1px solid var(--border-1);
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
}
.pill-accent { background: var(--accent-glow); border-color: var(--green-border); color: var(--green); }
.pill-accent:hover { opacity: 0.8; }

/* === Footer === */
.site-footer {
  border-top: 1px solid transparent;
  border-image: linear-gradient(to right, var(--green), transparent 60%) 1;
  padding: 32px 0;
  margin-top: auto;
  position: relative;
}

.site-footer::before {
  content: '';
  position: absolute;
  top: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--accent-line) 20%, var(--accent-line) 80%, transparent);
  pointer-events: none;
}

.footer-inner {
  display: flex;
  gap: 48px;
  flex-wrap: wrap;
  align-items: center;
}

.footer-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.footer-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text-4);
  text-transform: uppercase;
}

.footer-value { font-size: 13px; color: var(--text-3); }
.footer-link { font-size: 13px; color: var(--green); }

.footer-credit {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-4);
}

.footer-credit-note { color: var(--text-4); opacity: 0.7; }
.footer-credit span:first-child { color: var(--text-3); }

.footer-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--green);
}

.footer-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--accent-glow);
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .footer-status-dot { animation: status-pulse 2.4s ease-in-out infinite; }
  .main { animation: page-fade-in 0.3s ease-out both; }
}

@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(61, 220, 151, 0.5); }
  50% { box-shadow: 0 0 0 5px rgba(61, 220, 151, 0); }
}

@keyframes page-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .footer-inner { flex-direction: column; gap: 20px; align-items: flex-start; }
}

/* === Keyboard focus === */
a:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
