:root {
  --paper: #f3efe6;
  --paper-2: #e9e3d6;
  --ink: #14161b;
  --ink-soft: #555a66;
  --rule: #cfc7b6;
  --flame: #ff6b01;
  --blue: #0a7fc2;
  --green: #1f8a5b;
  --violet: #6a4fd8;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --grid: 28px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0;
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  background-color: var(--paper);
  /* graph paper */
  background-image:
    linear-gradient(to right, rgba(20, 22, 27, .05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20, 22, 27, .05) 1px, transparent 1px);
  background-size: var(--grid) var(--grid);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.02; font-weight: 800; letter-spacing: -.02em; }
h3 { font-size: 1.25rem; font-weight: 600; }
em { font-style: italic; }

.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--flame); outline-offset: 3px; }

.label {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font-family: var(--mono);
  font-size: .85rem;
  font-weight: 700;
  text-decoration: none;
  padding: 14px 22px;
  background: var(--ink);
  color: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--flame);
  transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--flame); }
.btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--flame); }
.btn-ghost { background: var(--paper); color: var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.btn-ghost:hover { box-shadow: 6px 6px 0 var(--ink); }
.btn-ghost:active { box-shadow: 2px 2px 0 var(--ink); }
.btn-small { padding: 8px 16px; box-shadow: 3px 3px 0 var(--flame); }
.btn-invert { background: var(--flame); border-color: var(--flame); color: var(--ink); box-shadow: 4px 4px 0 var(--paper); }
.btn-invert:hover { box-shadow: 6px 6px 0 var(--paper); }

.text-link {
  display: inline-block; margin-top: 16px;
  font-family: var(--mono); font-size: .8rem; font-weight: 700;
  color: var(--flame); text-decoration: none;
  border-bottom: 2px solid currentColor;
}
.text-link:hover { color: inherit; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  padding: 10px clamp(16px, 4vw, 48px);
  background: rgba(243, 239, 230, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-bottom-color: var(--rule); }
.nav nav { display: flex; gap: 22px; margin-left: auto; }
.nav nav a {
  font-family: var(--mono); font-size: .78rem; text-decoration: none;
  padding: 6px 0; border-bottom: 2px solid transparent;
}
.nav nav a:hover { border-bottom-color: var(--flame); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-logo { display: block; height: 46px; width: auto; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: min(calc(100svh - 62px), 920px);
  display: grid; align-items: center;
  padding: 48px clamp(16px, 6vw, 96px) 96px;
  overflow: hidden;
}
#particles { position: absolute; inset: 0; width: 100%; height: 100%; }
.hero-inner { position: relative; max-width: 1100px; margin: 0 auto; text-align: center; }
.equation {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .12em .28em;
  margin: 18px 0 28px;
  font-size: clamp(2.8rem, 10.5vw, 8.5rem);
  font-weight: 800; line-height: .95; letter-spacing: -.04em;
}
.eq-op { color: var(--ink-soft); font-weight: 400; }
.eq-product { color: var(--flame); }
.eq-tile {
  position: relative;
  display: inline-grid; place-items: center;
  width: 1.25em; height: 1.25em;
  border: .04em solid var(--ink);
  background: var(--flame);
  box-shadow: .07em .07em 0 var(--ink);
  font-size: .82em; letter-spacing: -.02em;
  transform: rotate(-4deg);
  animation: wobble 6s ease-in-out infinite;
}
.eq-tile small, .eq-tile em {
  position: absolute; font-family: var(--mono); font-style: normal; font-weight: 500;
  font-size: .11em; letter-spacing: .04em;
}
.eq-tile small { top: .7em; left: .8em; }
.eq-tile em { bottom: .7em; left: 0; right: 0; text-align: center; text-transform: uppercase; }
@keyframes wobble { 50% { transform: rotate(3deg) translateY(-.04em); } }

.lede { max-width: 38em; margin: 0 auto; font-size: clamp(1.05rem, 1.6vw, 1.3rem); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 32px; }

.scroll-cue {
  position: absolute; bottom: 28px; left: 50%; translate: -50% 0;
  width: 24px; height: 40px; border: 2px solid var(--ink); border-radius: 14px;
}
.scroll-cue span {
  position: absolute; left: 50%; top: 7px; width: 4px; height: 8px; margin-left: -2px;
  background: var(--flame); border-radius: 2px; animation: cue 1.6s infinite;
}
@keyframes cue { 60% { transform: translateY(14px); opacity: 0; } 100% { opacity: 0; } }

/* ---------- sections ---------- */
.section { padding: clamp(64px, 10vw, 130px) clamp(16px, 6vw, 96px); max-width: 1400px; margin: 0 auto; }
.section-head { max-width: 760px; margin-bottom: 44px; }
.section-head h2 { margin: 10px 0 16px; }
.section-head p:last-child { color: var(--ink-soft); }

.reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s, transform .7s; }
.reveal.in { opacity: 1; transform: none; }

/* ---------- periodic table ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 20px; font-family: var(--mono); font-size: .75rem; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 14px; border: 2px solid var(--ink); background: var(--c); }

.table-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 1fr); gap: 28px; align-items: stretch; }
.ptable { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-content: start; }
.el {
  position: relative;
  aspect-ratio: 1;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 10px;
  font: inherit; color: var(--ink); text-align: left;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-top: 8px solid var(--c);
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.el:hover { transform: translate(-3px, -3px); box-shadow: 5px 5px 0 var(--ink); }
.el[aria-pressed="true"] { background: var(--c); transform: translate(-3px, -3px); box-shadow: 5px 5px 0 var(--ink); }
.el[aria-pressed="true"], .el[aria-pressed="true"] .el-name { color: #fff; }
.el-num { position: absolute; top: 6px; left: 9px; font-family: var(--mono); font-size: .65rem; }
.el-sym { font-size: clamp(1.5rem, 3.4vw, 2.8rem); font-weight: 800; line-height: 1; letter-spacing: -.03em; }
.el-name { font-family: var(--mono); font-size: clamp(.55rem, .9vw, .72rem); color: var(--ink-soft); margin-top: 4px; overflow-wrap: anywhere; }

.detail {
  position: sticky; top: 90px;
  padding: 28px;
  background: var(--ink); color: var(--paper);
  border-left: 10px solid var(--c, var(--flame));
  min-height: 300px;
}
.detail .label { color: #a9acb5; }
.detail-sym { font-size: 5rem; font-weight: 800; line-height: 1; letter-spacing: -.04em; margin: 8px 0 2px; }
.detail h3 { font-size: 1.6rem; margin-bottom: 12px; }
.detail p { color: #d8d5cc; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 20px 0 0; font-family: var(--mono); font-size: .78rem; }
.detail dt { color: #a9acb5; }
.detail dd { margin: 0; }
.detail .text-link { color: var(--c, var(--flame)); }

/* ---------- grants ---------- */
.section-dark {
  max-width: none;
  background: var(--ink); color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(243, 239, 230, .05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(243, 239, 230, .05) 1px, transparent 1px);
  background-size: var(--grid) var(--grid);
}
.section-dark .label { color: #a9acb5; }
.grant-grid { max-width: 1210px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(32px, 6vw, 90px); align-items: center; }
.grant-grid h2 { margin: 10px 0 20px; font-weight: 600; font-size: clamp(1.6rem, 3vw, 2.4rem); }
.big-num { display: block; font-size: clamp(4.5rem, 13vw, 10rem); font-weight: 800; line-height: .9; color: var(--flame); letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.grant-grid p { color: #d8d5cc; max-width: 32em; }
.grant-grid .btn { margin-top: 28px; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 20px; padding: 20px 0; border-top: 1px solid #3a3d47; }
.steps li:last-child { border-bottom: 1px solid #3a3d47; }
.steps span { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border: 2px solid var(--flame); color: var(--flame); font-family: var(--mono); font-weight: 700; }
.steps p { font-size: .95rem; margin-top: 4px; }

/* ---------- join + footer ---------- */
.join { padding: clamp(80px, 12vw, 160px) clamp(16px, 6vw, 96px); text-align: center; background: var(--flame); border-block: 2px solid var(--ink); }
.join .label { color: var(--ink); }
.join h2 { margin: 12px 0 18px; }
.join .hero-cta { justify-content: center; }
.join .btn { box-shadow: 4px 4px 0 var(--paper); }
.join .btn-ghost { box-shadow: 4px 4px 0 var(--ink); }

.footer { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 28px clamp(16px, 6vw, 96px); font-family: var(--mono); font-size: .75rem; }
.footer-logo { height: 22px; width: auto; }
.footer .muted { margin-left: auto; color: var(--ink-soft); }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .table-wrap, .grant-grid { grid-template-columns: 1fr; }
  .detail { position: static; min-height: 0; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .nav nav { gap: 16px; }
  .nav nav a[href*="#"] { display: none; } /* keep only Dashboard on small screens */
  .ptable { grid-template-columns: repeat(3, 1fr); }
  .footer .muted { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
