:root {
  --ink: #1a1a1a;
  --paper: #f6f4f0;
  --accent: #c44b2b;
  --accent-dim: #d4856f;
  --smoke: #8a8580;
  --rule: #d5d0ca;
  --highlight: #fdf0dc;
  --code-bg: #eae6e0;
}

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
}

/* --- GRAIN TEXTURE OVERLAY --- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* --- LAYOUT --- */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 clamp(1.25rem, 5vw, 2.75rem);
}

@media (min-width: 768px) {
  .container {
    max-width: 840px;
  }
}

/* --- HEADER / MASTHEAD --- */
header {
  padding: clamp(3.5rem, 10vw, 6.5rem) 0 clamp(2.75rem, 5vw, 4rem);
  border-bottom: 1px solid var(--rule);
}

.masthead {
  display: flex;
  flex-direction: column;
  gap: clamp(1.35rem, 3vw, 2rem);
}

.site-title {
  font-family: 'Instrument Serif', serif;
  font-size: 3.6rem;
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.site-title em {
  font-style: italic;
  color: var(--accent);
}

.site-subtitle {
  font-size: 1.1rem;
  color: var(--smoke);
  font-weight: 400;
  max-width: min(38rem, 100%);
  line-height: 1.58;
  text-wrap: balance;
}

/* --- NAV PILLS --- */
nav {
  display: flex;
  gap: 0.75rem;
  margin-top: clamp(0.35rem, 1.5vw, 0.85rem);
  flex-wrap: wrap;
}

nav a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--ink);
  padding: 0.5rem 1rem;
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition: all 0.2s ease;
}

nav a:hover {
  border-color: var(--accent);
  color: var(--accent);
}

nav a.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

nav a.primary:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* --- MAIN SECTIONS --- */
section {
  padding: clamp(3rem, 6vw, 4.75rem) 0;
  border-bottom: 1px solid var(--rule);
}

section:last-of-type {
  border-bottom: none;
}

.section-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--smoke);
  margin-bottom: clamp(1.35rem, 2.5vw, 1.85rem);
}

h2 {
  font-family: 'Instrument Serif', serif;
  font-size: 2rem;
  font-weight: 400;
  line-height: 1.2;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

p {
  margin-bottom: 1rem;
  color: var(--ink);
}

p.muted {
  color: var(--smoke);
  font-size: 0.9rem;
}

.experiments-section {
  scroll-margin-top: 1.5rem;
}

.section-lead {
  max-width: min(40rem, 100%);
  line-height: 1.65;
  margin-bottom: 0.85rem;
}

.section-note {
  font-size: 0.95rem;
  color: var(--smoke);
  line-height: 1.6;
  max-width: min(40rem, 100%);
  margin-bottom: 0;
}

/* --- ABOUT --- */
.about-text {
  max-width: min(42rem, 100%);
}

.about-text p {
  line-height: 1.72;
  margin-bottom: 1.15rem;
}

.about-text p:last-child {
  margin-bottom: 0;
}

/* Inline text links (editorial, not default blue) */
.inline-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.2s ease, border-color 0.2s ease;
}

.inline-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent-dim);
}

.inline-link:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

/* --- EXPERIMENTS --- */
.experiments-frame {
  margin-top: clamp(1.75rem, 4vw, 2.35rem);
  padding: clamp(1.5rem, 4vw, 2.25rem);
  border: 1px solid var(--rule);
  border-radius: 3px;
  background: linear-gradient(165deg, rgba(253, 240, 220, 0.45) 0%, transparent 42%);
  display: flex;
  flex-direction: column;
  gap: clamp(1.35rem, 3vw, 1.85rem);
}

.experiment-card {
  position: relative;
  border-radius: 3px;
  padding: 2.25rem 2.5rem;
  overflow: hidden;
}

.experiment-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent);
}

.experiment-card__label {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 1rem;
}

.experiment-card__title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.65rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.experiment-card__tagline {
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

.experiment-card__body {
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: 1rem;
}

.experiment-card__support {
  font-size: 0.9rem;
  line-height: 1.62;
  margin-bottom: 1rem;
}

.experiment-points {
  list-style: none;
  margin: 0 0 1.35rem;
  padding: 0;
}

.experiment-points li {
  position: relative;
  padding-left: 1rem;
  margin-bottom: 0.55rem;
  font-size: 0.88rem;
  line-height: 1.5;
}

.experiment-points li:last-child {
  margin-bottom: 0;
}

.experiment-points li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.52em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}

.experiment-card--dark {
  background: var(--ink);
  color: var(--paper);
}

.experiment-card--dark .experiment-card__label {
  background: var(--accent);
  color: var(--paper);
  padding: 0.2rem 0.6rem;
  border-radius: 2px;
}

.experiment-card--dark .experiment-card__title {
  color: var(--paper);
}

.experiment-card--dark .experiment-card__tagline {
  color: #c9c4be;
}

.experiment-card--dark .experiment-card__body {
  color: #b8b3ad;
  margin-bottom: 1.1rem;
}

.experiment-card--dark .experiment-points--on-dark {
  color: #a8a39d;
}

.experiment-card--dark .experiment-points--on-dark li::before {
  background: var(--accent-dim);
  opacity: 0.9;
}

.experiment-card--light {
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(26, 26, 26, 0.04);
}

.experiment-card--light .experiment-card__label {
  color: var(--smoke);
  letter-spacing: 0.09em;
  padding-bottom: 0.15rem;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  margin-bottom: 1.1rem;
}

.experiment-card--light .experiment-card__title {
  color: var(--ink);
}

.experiment-card--light .experiment-card__body {
  color: var(--ink);
}

.experiment-card--light .experiment-card__support {
  color: var(--smoke);
}

.experiment-card--light .experiment-points--on-light {
  color: var(--smoke);
}

.experiment-card__cta {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  border-radius: 2px;
  margin-top: 0.25rem;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.experiment-card__cta--solid {
  color: var(--paper);
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--accent);
  background: var(--accent);
}

.experiment-card__cta--solid:hover {
  background: transparent;
  color: var(--accent);
}

.experiment-card__cta--outline {
  color: var(--ink);
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--ink);
  background: transparent;
}

.experiment-card__cta--outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* --- NEWSLETTER --- */
.newsletter-block {
  background: var(--highlight);
  padding: 2rem 2.5rem;
  border-radius: 3px;
  border-left: 3px solid var(--accent);
  margin-top: 1.5rem;
}

.newsletter-block h3 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.4rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}

.newsletter-block p {
  font-size: 0.9rem;
  color: var(--smoke);
  margin-bottom: 1rem;
}

.newsletter-block a {
  display: inline-block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--paper);
  padding: 0.55rem 1.25rem;
  background: var(--ink);
  border-radius: 2px;
  transition: background 0.2s ease;
}

.newsletter-block a:hover {
  background: var(--accent);
}

/* --- TOPICS --- */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 3px;
  margin-top: 1.5rem;
  overflow: hidden;
}

.topic-item {
  background: var(--paper);
  padding: 1.5rem;
}

.topic-item h4 {
  font-family: 'Instrument Serif', serif;
  font-size: 1.15rem;
  font-weight: 400;
  margin-bottom: 0.35rem;
}

.topic-item p {
  font-size: 0.82rem;
  color: var(--smoke);
  margin-bottom: 0;
  line-height: 1.45;
}

/* --- FOOTER --- */
footer {
  padding: 3rem 0;
  text-align: center;
}

footer p {
  font-size: 0.78rem;
  color: var(--smoke);
  margin-bottom: 0.3rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* --- RESPONSIVE --- */
@media (max-width: 640px) {
  html { font-size: 16px; }
  header { padding: 3rem 0 2.25rem; }
  .masthead { gap: 1.25rem; }
  .site-title { font-size: 2.6rem; }
  .site-subtitle { line-height: 1.55; }
  .topic-grid { grid-template-columns: 1fr; }
  .experiment-card { padding: 1.65rem 1.75rem; }
  .newsletter-block { padding: 1.5rem; }
}

/* --- ENTRANCE ANIMATIONS --- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.masthead, section, footer {
  animation: fadeUp 0.6s ease both;
}

section:nth-child(2) { animation-delay: 0.1s; }
section:nth-child(3) { animation-delay: 0.2s; }
section:nth-child(4) { animation-delay: 0.3s; }
footer { animation-delay: 0.35s; }
