/* ============================================
   NoptiK Design System
   Editorial-scientific aesthetic
   Stripe Press × Bayesian methods paper
   ============================================ */

:root {
  /* Colors */
  --paper: #F4F1EA;
  --paper-soft: #EDE7D8;
  --paper-deep: #E5DDC8;
  --ink: #15110D;
  --ink-soft: #4A4338;
  --ink-faint: #8B7F6E;
  --rule: #D6CEBE;
  --accent: #8B1F1F;
  --accent-soft: #C77878;
  --accent-fill: rgba(139, 31, 31, 0.09);

  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* Layout */
  --content-width: 68ch;
  --wide-width: 1180px;
  --page-padding: 40px;

  /* Animation */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Paper grain */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgba(21,17,13,0.045) 1px, transparent 0);
  background-size: 3px 3px;
  z-index: 0;
  mix-blend-mode: multiply;
}

main, header, footer { position: relative; z-index: 1; }

::selection { background: var(--accent); color: var(--paper); }

a { color: inherit; text-decoration: none; }

/* Layout */
.wrap {
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}
.narrow { max-width: var(--content-width); }

/* ============================================
   Header
   ============================================ */
header.site-header {
  padding: 24px 0;
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  background: rgba(244, 241, 234, 0.92);
}
header.site-header .wrap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
}
.wordmark {
  font-family: var(--font-display);
  font-weight: 500;
  font-style: italic;
  font-size: 24px;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}
.wordmark::after {
  content: '.';
  color: var(--accent);
}
.site-nav {
  display: flex;
  align-items: baseline;
  gap: 28px;
}
.site-nav a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: color 0.2s var(--ease);
}
.site-nav a:hover, .site-nav a.active { color: var(--accent); }
.site-nav .nav-apply {
  background: var(--accent);
  color: var(--paper);
  padding: 10px 18px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.2s var(--ease);
}
.site-nav .nav-apply:hover { background: #6f1818; color: var(--paper); }

.menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--accent);
  margin: 4px 0;
  transition: 0.3s var(--ease);
}

/* ============================================
   Typography scale
   ============================================ */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.02em;
  font-variation-settings: "opsz" 100, "SOFT" 50;
}
h1 {
  font-size: clamp(40px, 5.6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.025em;
  font-variation-settings: "opsz" 144, "SOFT" 30;
}
h2 {
  font-size: clamp(32px, 4.2vw, 48px);
  line-height: 1.1;
  margin-bottom: 32px;
  max-width: 22ch;
}
h3 {
  font-size: 24px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  font-weight: 500;
}
h1 em, h2 em {
  font-style: italic;
  font-variation-settings: "opsz" 100, "SOFT" 100;
  color: var(--accent);
}

p { margin-bottom: 1.2em; max-width: var(--content-width); }
p:last-child { margin-bottom: 0; }

.lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 56ch;
}

/* ============================================
   Eyebrows, section labels
   ============================================ */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 28px;
}
.section-label {
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rule);
  max-width: 200px;
}

/* ============================================
   Sections
   ============================================ */
section.section {
  padding: 112px 0;
  border-bottom: 1px solid var(--rule);
}
section.hero {
  padding: 112px 0 96px;
  border-bottom: 1px solid var(--rule);
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: var(--paper);
  padding: 14px 28px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: none;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s var(--ease);
  margin-right: 16px;
}
.btn-primary:hover { background: #6f1818; }
.btn-secondary {
  display: inline-block;
  color: var(--accent);
  font-family: var(--font-body);
  font-size: 15px;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 2px;
  transition: border-color 0.2s var(--ease);
}
.btn-secondary:hover { border-bottom-color: var(--accent); }

/* ============================================
   Cards & blocks
   ============================================ */
.card {
  border-top: 1px solid var(--ink);
  padding-top: 24px;
}
.card-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.14em;
  margin-bottom: 16px;
}
.card h3 {
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 12px;
  letter-spacing: -0.005em;
}
.card p {
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.55;
  max-width: none;
}

/* Math block */
.math {
  background: var(--paper-soft);
  border-left: 2px solid var(--accent);
  padding: 32px 36px;
  margin: 32px 0;
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 2.1;
  color: var(--ink);
  max-width: 64ch;
  overflow-x: auto;
}
.math .annot {
  color: var(--ink-faint);
  font-size: 13px;
  margin-top: 18px;
  line-height: 1.6;
  font-family: var(--font-body);
  border-top: 1px solid var(--rule);
  padding-top: 14px;
}

/* ============================================
   Footer
   ============================================ */
footer.site-footer {
  padding: 80px 0 48px;
  border-top: 1px solid var(--rule);
  background: var(--paper-soft);
}
footer.site-footer .wrap {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 48px;
}
footer.site-footer h4 {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
  margin-bottom: 18px;
  font-weight: 400;
}
footer.site-footer .wordmark { font-size: 22px; margin-bottom: 14px; display: inline-block; }
footer.site-footer p { font-size: 14px; color: var(--ink-soft); max-width: 40ch; margin-bottom: 8px; }
footer.site-footer ul { list-style: none; }
footer.site-footer ul li { margin-bottom: 8px; }
footer.site-footer ul a {
  font-size: 14px;
  color: var(--ink-soft);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}
footer.site-footer ul a:hover { color: var(--accent); }
.footer-meta {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}
.footer-meta a { color: var(--ink-faint); margin-left: 18px; transition: color 0.2s var(--ease); }
.footer-meta a:hover { color: var(--accent); }

/* ============================================
   Animation
   ============================================ */
@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.reveal { animation: reveal 1s var(--ease) both; }
.delay-1 { animation-delay: 0.08s; }
.delay-2 { animation-delay: 0.16s; }
.delay-3 { animation-delay: 0.28s; }
.delay-4 { animation-delay: 0.4s; }

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

/* ============================================
   SVG chart styles
   ============================================ */
.density-prior { fill: none; stroke: var(--ink-faint); stroke-width: 1; stroke-dasharray: 3 4; }
.density-posterior { fill: none; stroke: var(--accent); stroke-width: 2; }
.density-fill { fill: var(--accent); opacity: 0.09; }
.density-fill-light { fill: var(--accent); opacity: 0.05; }
.axis { stroke: var(--ink); stroke-width: 0.5; }
.axis-faint { stroke: var(--ink-faint); stroke-width: 0.5; }
.tick-label { font-family: var(--font-mono); font-size: 9px; fill: var(--ink-faint); letter-spacing: 0.02em; }
.legend-text { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-soft); }
.caption-text { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-faint); letter-spacing: 0.06em; text-transform: uppercase; }

/* ============================================
   Utility
   ============================================ */
.placeholder {
  color: var(--ink-faint);
  font-style: italic;
  background: rgba(139, 127, 110, 0.08);
  padding: 2px 6px;
  border-radius: 2px;
  font-size: 0.95em;
}
.placeholder-block {
  color: var(--ink-faint);
  font-style: italic;
  border: 1px dashed var(--rule);
  padding: 16px 20px;
  background: var(--paper-soft);
  border-radius: 2px;
  font-size: 0.95em;
}

.demo-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  background: var(--paper);
  border: 1px solid var(--accent-soft);
  padding: 4px 10px;
  border-radius: 2px;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  :root { --page-padding: 24px; }
  body { font-size: 16px; }
  .lede { font-size: 17px; }
  section.hero, section.section { padding: 64px 0; }

  .menu-toggle { display: block; }
  .site-nav {
    position: fixed;
    top: 73px;
    left: 0;
    right: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    transform: translateY(-100%);
    transition: transform 0.3s var(--ease);
    z-index: 49;
  }
  .site-nav.open { transform: translateY(0); }
  .site-nav a {
    padding: 18px 24px;
    border-bottom: 1px solid var(--rule);
  }
  .site-nav .nav-apply {
    margin: 16px 24px;
    text-align: center;
  }

  footer.site-footer .wrap { grid-template-columns: 1fr; gap: 32px; }
  .footer-meta { flex-direction: column; gap: 12px; align-items: flex-start; }
  .footer-meta a { margin-left: 0; margin-right: 18px; }
}
