/* Scaleval Science — science.scaleval.org */

:root {
  --ink: #0D1B2A;
  --parchment: #F7F4EE;
  --teal: #1D9E75;
  --teal-dark: #167A5B;
  --gold: #C9A84C;
  --gold-text: #8A6D1F;
  --gold-pale: #FBF4E0;
  --slate: #4A5568;
  --border: #E2DDD5;
  --panel-bg: #FFFFFF;
  --tag-bg: #EDF7F2;
  --mark: #F6E7B5;

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

  --max: 1200px;
  --nav-h: 64px;
}

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }

body {
  margin: 0;
  background: var(--parchment);
  color: var(--ink);
  font: 400 16px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--teal-dark); }
a:hover { color: var(--teal); }

:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 3px; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 24px; }

h1, h2 { font-family: var(--serif); color: var(--ink); margin: 0; }
h1 { font-size: 48px; font-weight: 700; line-height: 1.15; }
h2 { font-size: 32px; font-weight: 600; line-height: 1.25; }
h3 { font: 600 22px/1.35 var(--sans); margin: 0; }

.label {
  font: 500 12px/1.4 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
}

.mono { font-family: var(--mono); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ─── Navigation ─────────────────────────────────────────── */

.nav {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  height: var(--nav-h);
  background: rgba(247, 244, 238, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { height: 100%; display: flex; align-items: center; gap: 32px; }

.wordmark {
  font: 700 21px/1 var(--serif);
  color: var(--teal);
  text-decoration: none;
  white-space: nowrap;
}
.wordmark span { color: var(--ink); font-weight: 600; }
.wordmark:hover { color: var(--teal); }

.nav-links { display: flex; gap: 28px; margin: 0 auto; padding: 0; list-style: none; }
.nav-links a {
  color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 500;
  padding: 6px 0; border-bottom: 2px solid transparent;
}
.nav-links a:hover { border-bottom-color: var(--teal); color: var(--ink); }

.nav-ext {
  font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap;
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  background: var(--panel-bg);
}
.nav-ext small { color: var(--slate); font-weight: 400; }

.nav-toggle {
  display: none; margin-left: auto;
  background: none; border: 1px solid var(--border); border-radius: 6px;
  width: 40px; height: 40px; cursor: pointer; color: var(--ink);
}
.nav-toggle svg { display: block; margin: auto; }

@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .nav-links, .nav-ext { display: none; }
  .nav.open .nav-links {
    display: flex; flex-direction: column; gap: 0;
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    background: var(--parchment); border-bottom: 1px solid var(--border);
    padding: 8px 16px 16px;
  }
  .nav.open .nav-links a { display: block; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .nav.open .nav-links .mobile-only { display: block; }
}
.nav-links .mobile-only { display: none; }

/* ─── Hero ───────────────────────────────────────────────── */

.hero { padding: calc(var(--nav-h) + 72px) 0 56px; }
.hero .eyebrow { margin-bottom: 20px; }
.hero h1 { font-size: 56px; max-width: 760px; letter-spacing: -0.01em; }
.hero .lede {
  font-size: 20px; line-height: 1.6; color: var(--slate);
  max-width: 720px; margin: 24px 0 20px;
}
.oneliner {
  display: inline-block; color: var(--teal-dark); font-weight: 500;
  border-bottom: 2px solid var(--teal); padding-bottom: 2px; margin: 0;
}
.disambig {
  margin: 32px 0 0; max-width: 720px;
  background: var(--gold-pale); border-left: 4px solid var(--gold);
  padding: 16px 20px; border-radius: 0 6px 6px 0;
  color: var(--ink); font-size: 15px;
}
.disambig strong { font-weight: 600; }

/* Search */
.search-block { margin: 56px auto 0; max-width: 600px; position: relative; }
.search-field { position: relative; }
.search-field svg {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  color: var(--slate); pointer-events: none;
}
#search {
  width: 100%; height: 56px;
  padding: 0 48px 0 50px;
  font: 400 16px var(--sans); color: var(--ink);
  background: var(--panel-bg);
  border: 1px solid var(--border); border-radius: 28px;
  box-shadow: 0 2px 10px rgba(13, 27, 42, 0.06);
}
#search:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15); }
#search::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: transparent; color: var(--slate);
  font-size: 20px; cursor: pointer; display: none;
}
.search-clear:hover { background: var(--tag-bg); }
.search-block.has-value .search-clear { display: block; }

.suggest {
  position: absolute; left: 0; right: 0; top: 62px; z-index: 20;
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(13, 27, 42, 0.12);
  list-style: none; margin: 0; padding: 6px; max-height: 360px; overflow-y: auto;
}
.suggest[hidden] { display: none; }
.suggest li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 9px 12px; border-radius: 8px; cursor: pointer;
}
.suggest li[aria-selected="true"], .suggest li:hover { background: var(--tag-bg); }
.suggest .s-term { font-weight: 500; }
.suggest .s-kind { font: 500 11px var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--slate); white-space: nowrap; }
.suggest mark { background: var(--mark); color: inherit; border-radius: 2px; }

.stats {
  display: grid; grid-template-columns: repeat(3, 1fr);
  max-width: 720px; margin: 56px auto 0;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.stat { text-align: center; padding: 20px 12px; }
.stat + .stat { border-left: 1px solid var(--border); }
.stat b { display: block; font: 700 32px/1.1 var(--serif); color: var(--ink); }
.stat span { font-size: 14px; color: var(--slate); }

/* ─── Sections ───────────────────────────────────────────── */

section { padding: 80px 0; }
.section-head { margin-bottom: 32px; max-width: 760px; }
.section-head p { color: var(--slate); margin: 10px 0 0; }
.alt { background: var(--panel-bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* Filters */
.filters {
  display: flex; gap: 8px; margin: 0 0 16px; padding: 0 0 4px;
  overflow-x: auto; scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.pill {
  flex: none;
  font: 500 14px var(--sans); color: var(--ink);
  background: var(--panel-bg); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 16px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
}
.pill i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.pill:hover { border-color: var(--slate); }
.pill[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

.result-count { min-height: 1.7em; color: var(--slate); font-size: 14px; margin: 0 0 20px; }
.result-count b { color: var(--ink); }

/* ─── Knowledge panels ───────────────────────────────────── */

.panels {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px; align-items: start;
}
@media (max-width: 1024px) { .panels { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 680px)  { .panels { grid-template-columns: 1fr; } }

.kp {
  --c: var(--teal); --cb: var(--teal);
  background: var(--panel-bg);
  border: 1px solid var(--border); border-top: 3px solid var(--c);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: box-shadow .2s ease, opacity .25s ease, border-color .2s ease;
  display: flex; flex-direction: column;
}
.kp:hover { box-shadow: 0 8px 24px rgba(13, 27, 42, 0.12); border-top-color: var(--cb); }
.kp.dim { opacity: 0.3; }
.kp.dim:hover { opacity: 0.6; }
.kp.hidden { display: none; }
.kp.flash { animation: flash 1.4s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--cb); } 100% { box-shadow: 0 2px 8px rgba(0,0,0,.06); } }

.kp > * { padding-left: 20px; padding-right: 20px; }
.kp-head { display: flex; align-items: flex-start; gap: 12px; padding-top: 18px; padding-bottom: 14px; }
.kp-icon { font-size: 28px; line-height: 32px; width: 32px; text-align: center; flex: none; }
.kp-title { flex: 1; min-width: 0; }
.kp-title h3 { font-size: 19px; line-height: 1.3; }
.kp-eq { font-size: 13px; color: var(--slate); margin-top: 2px; }
.kp-eq em { font-style: normal; color: var(--ink); }
.kp-eq .star { color: var(--gold-text); font-weight: 600; }
.kp-num { font: 600 28px/1 var(--serif); color: var(--gold); flex: none; }

.kp-def { border-top: 1px solid var(--border); padding-top: 14px; padding-bottom: 14px; margin: 0; font-size: 15px; line-height: 1.6; }

.kp-block { border-top: 1px solid var(--border); padding-top: 12px; padding-bottom: 14px; }
.kp-block .label { margin-bottom: 8px; }
.kp-subs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px 14px; font-size: 14px; }
.kp-subs li { position: relative; padding-left: 12px; line-height: 1.5; }
.kp-subs li::before { content: "·"; position: absolute; left: 0; color: var(--c); font-weight: 700; }
.kp-subs li.more { display: none; }
.kp.open .kp-subs li.more { display: list-item; }
.kp-more-note { font-size: 13px; color: var(--slate); margin-top: 6px; }
.kp.open .kp-more-note { display: none; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font: 500 12.5px/1.3 var(--sans); color: var(--teal-dark);
  background: var(--tag-bg); border: 1px solid transparent; border-radius: 4px;
  padding: 4px 8px; cursor: pointer;
}
.tag:hover, .tag[aria-expanded="true"] { border-color: var(--teal); }
.tag.mono-ish { font-family: var(--mono); font-size: 12px; }

.kp-note {
  border-top: 1px solid var(--border); padding-top: 12px; padding-bottom: 12px;
  font-size: 13.5px; color: var(--ink); background: #FDF7F4; margin: 0;
}
.kp-note b { color: #B24A26; }

.kp-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px; padding-bottom: 16px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: auto;
}
.kp-researcher { font-size: 14px; }
.kp-researcher .label { display: block; margin-bottom: 2px; }
.kp-explore {
  font: 500 14px var(--sans); color: var(--teal-dark);
  background: none; border: none; cursor: pointer; padding: 4px 0;
  white-space: nowrap;
}
.kp-explore:hover { color: var(--teal); text-decoration: underline; }

/* Expanded content */
.kp-expanded { display: none; border-top: 1px solid var(--border); padding-top: 14px; padding-bottom: 16px; font-size: 14px; }
.kp.open .kp-expanded { display: block; }
.kp-expanded dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
.kp-expanded dt { color: var(--slate); }
.kp-expanded dd { margin: 0; }
.kp-expanded .related { margin-top: 12px; }
.kp-expanded .related a { margin-right: 10px; }
.kp-expanded .page-link { display: inline-block; margin-top: 12px; font-weight: 500; }

mark.hl { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; box-shadow: 0 1px 0 var(--gold); }

/* Concept tooltip */
.tip {
  position: absolute; z-index: 60; width: 300px; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; border-radius: 8px;
  padding: 14px 16px; font-size: 14px; line-height: 1.55;
  box-shadow: 0 12px 32px rgba(13, 27, 42, 0.3);
}
.tip[hidden] { display: none; }
.tip h4 { margin: 0 0 6px; font: 600 15px var(--sans); color: var(--gold); }
.tip p { margin: 0 0 10px; color: #E8ECF1; }
.tip a { color: #7FE0BF; font-weight: 500; text-decoration: none; }
.tip a:hover { text-decoration: underline; color: #A6F0D5; }
.tip .tip-close {
  position: absolute; top: 6px; right: 8px; background: none; border: none; color: #9AA5B4;
  font-size: 18px; cursor: pointer; line-height: 1;
}
.tip .also { font-size: 12.5px; color: #9AA5B4; margin-top: 8px; }

/* ─── Glossary ───────────────────────────────────────────── */

.glossary { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.gl-letter {
  grid-column: 1 / -1; font: 600 20px var(--serif); color: var(--gold-text);
  border-bottom: 1px solid var(--border); padding-bottom: 4px; margin-top: 8px;
}
.gl {
  background: var(--parchment); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
}
.gl dfn { font: 600 19px/1.25 var(--serif); color: var(--gold-text); font-style: normal; }
.gl p { margin: 0; font-size: 14px; line-height: 1.55; color: var(--slate); flex: 1; }
.gl a {
  align-self: flex-start; font-size: 12px; font-weight: 500; text-decoration: none;
  color: var(--teal-dark); background: var(--tag-bg); border-radius: 4px; padding: 3px 8px;
}
.gl a:hover { text-decoration: underline; }

/* ─── Comparison ─────────────────────────────────────────── */

.cmp-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--panel-bg); }
table.cmp { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 520px; }
.cmp th {
  text-align: left; font: 600 20px var(--serif); padding: 16px 20px;
  border-bottom: 2px solid var(--ink); background: var(--parchment);
}
.cmp th:last-child { color: var(--teal-dark); }
.cmp td { padding: 11px 20px; border-bottom: 1px solid var(--border); vertical-align: top; }
.cmp tr:last-child td { border-bottom: none; }
.cmp td:first-child { color: var(--slate); width: 42%; }
.cmp td a { color: var(--ink); text-decoration: none; font-weight: 500; }
.cmp td a:hover { color: var(--teal-dark); text-decoration: underline; }
.cmp tr.original td { background: #FCF7E8; }
.cmp tr.original td:last-child { box-shadow: inset 3px 0 0 var(--gold); }
.cmp tr.unique td { background: #E6F5EE; }
.cmp tr.unique td:last-child { box-shadow: inset 3px 0 0 var(--teal); }
.cmp tr.unique td a { color: var(--teal-dark); font-weight: 600; }
.cmp tr.na td:last-child { color: var(--slate); font-style: italic; }

.legend { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 14px; font-size: 13.5px; color: var(--slate); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.legend i { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }

/* ─── Founding statement ─────────────────────────────────── */

.founding { background: var(--teal); color: #fff; text-align: center; padding: 96px 0; }
.founding blockquote { margin: 0 auto; max-width: 820px; }
.founding blockquote p { font: 600 36px/1.3 var(--serif); margin: 0; }
.founding .attr { margin-top: 28px; font-size: 16px; }
.founding .attr strong { display: block; font-weight: 600; letter-spacing: 0.02em; }
.founding .attr span { opacity: 0.85; font-size: 15px; }
.founding .doi-link {
  display: inline-block; margin-top: 32px; color: #fff; text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.6); border-radius: 999px; padding: 10px 22px;
  font-weight: 500;
}
.founding .doi-link:hover { background: #fff; color: var(--teal-dark); }
.founding .doi-link .mono { font-size: 14px; }

/* ─── Footer ─────────────────────────────────────────────── */

footer { background: var(--ink); color: #C4CCD6; padding: 64px 0 32px; font-size: 14.5px; }
.foot-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px; }
@media (max-width: 860px) { .foot-grid { grid-template-columns: repeat(2, 1fr); } }
footer h4 { margin: 0 0 14px; font: 600 12px var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
footer ul { list-style: none; margin: 0; padding: 0; }
footer li { margin-bottom: 8px; }
footer a { color: #E5EAF0; text-decoration: none; }
footer a:hover { color: #7FE0BF; text-decoration: underline; }
footer .mono { font-size: 12.5px; }
.foot-bottom {
  margin-top: 48px; padding-top: 24px; border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 13.5px; color: #9AA5B4; line-height: 1.8;
}
.foot-bottom .wm { font-family: var(--serif); color: #fff; }

/* ─── Branch page ────────────────────────────────────────── */

.crumbs { font-size: 14px; color: var(--slate); margin-bottom: 24px; }
.crumbs a { text-decoration: none; }
.branch-hero { padding: calc(var(--nav-h) + 48px) 0 24px; }
.branch-hero .num { font: 600 18px var(--serif); color: var(--gold-text); }
.branch-hero h1 { display: flex; align-items: center; gap: 16px; margin-top: 6px; }
.branch-hero .eq { font-size: 18px; color: var(--slate); margin-top: 10px; }
.branch-hero .def { font-size: 20px; line-height: 1.6; max-width: 760px; margin: 20px 0 0; }
.branch-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 40px; padding-bottom: 80px; align-items: start; }
@media (max-width: 900px) { .branch-layout { grid-template-columns: 1fr; } }
.branch-main h2 { font-size: 26px; margin: 36px 0 14px; }
.branch-main h2:first-child { margin-top: 0; }
.sub-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; list-style: none; padding: 0; margin: 0; }
.sub-list li { background: var(--panel-bg); border: 1px solid var(--border); border-left: 3px solid var(--c, var(--teal)); border-radius: 6px; padding: 12px 14px; }
.sub-list li b { display: block; font-weight: 600; }
.sub-list li small { color: var(--slate); }
.concept-list { margin: 0; }
.concept-list > div { padding: 12px 0; border-bottom: 1px solid var(--border); }
.concept-list dt { font-weight: 600; }
.concept-list dd { margin: 4px 0 0; color: var(--slate); font-size: 15px; }
.concept-list dd a { font-size: 14px; }
.infobox { position: sticky; top: calc(var(--nav-h) + 24px); }
.infobox .kp > * { padding-left: 18px; padding-right: 18px; }
.infobox table { width: 100%; font-size: 14px; border-collapse: collapse; }
.infobox th { text-align: left; color: var(--slate); font-weight: 500; padding: 7px 10px 7px 0; vertical-align: top; width: 42%; }
.infobox td { padding: 7px 0; }
.infobox tr + tr th, .infobox tr + tr td { border-top: 1px solid var(--border); }
.branch-pager { display: flex; justify-content: space-between; gap: 16px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border); }
.branch-pager a { text-decoration: none; font-weight: 500; }
.branch-pager small { display: block; color: var(--slate); font-weight: 400; }

/* ─── Mobile ─────────────────────────────────────────────── */

@media (max-width: 680px) {
  .wrap { padding: 0 16px; }
  h1, .hero h1 { font-size: 38px; }
  h2 { font-size: 27px; }
  .hero { padding-top: calc(var(--nav-h) + 40px); }
  .hero .lede { font-size: 18px; }
  .search-block { margin-top: 40px; }
  .stats { margin-top: 40px; }
  .stat b { font-size: 24px; }
  .stat span { font-size: 12.5px; }
  section { padding: 56px 0; }
  .founding blockquote p { font-size: 27px; }
  .kp-subs { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
}

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