/* Mobile-first: base rules target small screens; min-width media queries at
   the bottom enhance for tablet/desktop, on the same 640/768/1024/1280 scale
   as agrimarkets/agriwiki. Palette, font and dark-mode mechanism are shared
   with those sibling projects (agrimarkets' public/css/style.css holds the
   canonical token set). No inline styles anywhere: the CSP has style-src
   'self' without 'unsafe-inline', so charts are sized via SVG attributes and
   colored via the classes below. */
:root {
  color-scheme: light;
  --bg: #f4f6f0;
  --surface: #ffffff;
  --surface-2: #fafbf7;
  --text: #1a2416;
  --text-secondary: #5c6656;
  --border: #e3e8db;
  --accent: #43803a;
  --accent-dark: #2c5d25;
  --accent-soft: #e4efdc;
  --up: #2c6e25;
  --down: #9a4a1c;
  --radius: 10px;
  --shadow-1: 0 1px 2px rgba(26, 36, 22, .05), 0 2px 8px rgba(26, 36, 22, .06);
  --shadow-2: 0 4px 16px rgba(26, 36, 22, .10);
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --maxw: 1280px;
  --wrap-pad: var(--space-4);
  --hero-pad: var(--space-6);
  --h1-size: clamp(1.6rem, 1.25rem + 1.6vw, 2.5rem);
  font-family: "Noto Sans", "Noto Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #12150f;
  --surface: #1a1e16;
  --surface-2: #1f241b;
  --text: #e8ecdf;
  --text-secondary: #a3ab94;
  --border: #2f3829;
  --accent: #6fb961;
  --accent-dark: #9ed692;
  --accent-soft: #24301d;
  --up: #9ed692;
  --down: #e6a27a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .30), 0 2px 8px rgba(0, 0, 0, .32);
  --shadow-2: 0 4px 16px rgba(0, 0, 0, .40);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12150f;
    --surface: #1a1e16;
    --surface-2: #1f241b;
    --text: #e8ecdf;
    --text-secondary: #a3ab94;
    --border: #2f3829;
    --accent: #6fb961;
    --accent-dark: #9ed692;
    --accent-soft: #24301d;
    --up: #9ed692;
    --down: #e6a27a;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .30), 0 2px 8px rgba(0, 0, 0, .32);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, .40);
    color-scheme: dark;
  }
}

/* Self-hosted Noto Sans (SIL OFL 1.1, see fonts/OFL-NotoSans.txt) - same file
   as agrimarkets/agriwiki. "Noto Fallback" is local Arial with Noto's
   metrics, so the swap to the webfont barely shifts layout. */
@font-face {
  font-family: "Noto Sans";
  src: url("/fonts/notosans-var.woff2") format("woff2-variations"), url("/fonts/notosans-var.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Noto Fallback";
  src: local("Arial");
  ascent-override: 106.9%;
  descent-override: 29.3%;
  line-gap-override: 0%;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--wrap-pad); }
.wrap-narrow { max-width: 820px; margin: 0 auto; padding: 0 var(--wrap-pad); }

a { color: var(--accent-dark); }
h1, h2, h3 { line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 0 0 var(--space-2); }

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -60px;
  z-index: 20;
  background: var(--surface);
  color: var(--text);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  box-shadow: var(--shadow-2);
}
.skip-link:focus { top: var(--space-2); }

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

/* ---------- header ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}

/* Shared "agri." wordmark: fixed family colors, not the --accent tokens, so
   the mark reads identically across agri.markets / agri.wiki / agri.science.
   Inline-block ::before + margin (never flex/gap - that splits the text runs
   around the dot into separate flex items and spaces them apart). Values
   match agrimarkets' live style.css. */
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: #365c2c;
  text-decoration: none;
  white-space: nowrap;
  flex: 0 0 auto;
}
.logo::before {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-right: .35em;
  vertical-align: -0.15em;
  background: #4a7c3c;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.05 8.05c-2.73 2.73-2.73 7.15-.02 9.88 1.47-3.4 4.09-6.24 7.36-7.93-2.77 2.34-4.71 5.61-5.39 9.32 2.6 1.23 5.8.78 7.95-1.37C19.43 14.47 20 4 20 4S9.53 4.57 6.05 8.05z"/></svg>') center / contain no-repeat;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.05 8.05c-2.73 2.73-2.73 7.15-.02 9.88 1.47-3.4 4.09-6.24 7.36-7.93-2.77 2.34-4.71 5.61-5.39 9.32 2.6 1.23 5.8.78 7.95-1.37C19.43 14.47 20 4 20 4S9.53 4.57 6.05 8.05z"/></svg>') center / contain no-repeat;
}
.logo span { color: #c98a2c; }
/* Dark-mode exception for the family mark (approved for agrimarkets
   2026-09-28): the brand greens only reach ~2.2:1 on the dark header. */
:root[data-theme="dark"] .logo { color: #8fbf7a; }
:root[data-theme="dark"] .logo::before { background: #7cb668; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo { color: #8fbf7a; }
  :root:not([data-theme="light"]) .logo::before { background: #7cb668; }
}

.header-actions { display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto; }

.site-nav { display: none; align-items: center; gap: var(--space-6); flex: 1 1 auto; margin-left: var(--space-6); }
.site-nav a { text-decoration: none; color: var(--text-secondary); font-weight: 500; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent-dark); }
.site-nav a[aria-current="page"] { text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }

.mobile-nav { position: relative; }
.menu-toggle {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  color: var(--text);
}
.menu-toggle::-webkit-details-marker { display: none; }
.menu-toggle:hover, .mobile-nav[open] .menu-toggle { background: var(--surface-2); }
.mobile-nav nav {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: var(--space-2);
}
.mobile-nav nav a { text-decoration: none; color: var(--text); padding: var(--space-3); border-radius: 8px; }
.mobile-nav nav a:hover { background: var(--surface-2); }
.mobile-nav nav a[aria-current="page"] { color: var(--accent-dark); font-weight: 600; }

/* ---------- page furniture ---------- */
.hero {
  background: linear-gradient(180deg, var(--surface-2), var(--bg));
  padding: var(--hero-pad) 0;
  text-align: center;
}
.hero h1 { font-size: var(--h1-size); max-width: 760px; margin: 0 auto var(--space-3); }
.hero p { max-width: 680px; margin: 0 auto; color: var(--text-secondary); font-size: 1.05rem; }

main { padding-bottom: var(--space-8); }
main > section { margin: var(--space-6) 0; }

.crumbs { margin: var(--space-6) 0 var(--space-2); font-size: .9rem; color: var(--text-secondary); }
.crumbs a { text-decoration: none; }
.page-head { margin: var(--space-6) 0; }
.crumbs + .page-head { margin-top: var(--space-2); }
.page-head h1 { font-size: var(--h1-size); margin: 0 0 var(--space-2); }
.lead { color: var(--text-secondary); font-size: 1.05rem; margin: 0; max-width: 760px; }
.hint { font-size: .85rem; color: var(--text-secondary); margin: 0 0 var(--space-3); }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-3); }
.section-head h2 { margin: 0; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-4);
  margin: 0 0 var(--space-4);
}

.prose { max-width: 72ch; }
.prose h2 { margin-top: var(--space-6); }
.prose ul { padding-left: 1.2rem; }
.prose li { margin: var(--space-2) 0; }
.field-main > .prose { margin-bottom: var(--space-6); }

.kw { display: block; font-size: .8rem; color: var(--text-secondary); font-weight: 400; margin-top: 2px; }
.kw a { color: inherit; }
.up { color: var(--up); font-weight: 600; }
.down { color: var(--down); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--text);
  transition: box-shadow .15s ease, transform .15s ease;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card h3 { margin: 0 0 var(--space-2); font-size: 1.05rem; color: var(--accent-dark); }
.card p { margin: 0 0 var(--space-3); color: var(--text-secondary); font-size: .9rem; flex: 1 1 auto; }
.card-stats { display: flex; align-items: center; gap: var(--space-3); font-size: .82rem; color: var(--text-secondary); }
.card-stats strong { color: var(--text); }

.sparkline { flex: 0 0 auto; }
.sparkline polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }

/* ---------- charts ---------- */
.chart { display: block; width: 100%; height: auto; }
.chart-bar { fill: var(--accent); }
.chart-bar:hover { fill: var(--accent-dark); }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--text-secondary); font-size: 11px; }

/* ---------- ranked lists with bars ---------- */
.ranked { list-style: none; margin: 0; padding: 0; counter-reset: rank; }
.ranked li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border);
}
.ranked li:last-child { border-bottom: none; }
.ranked-label { min-width: 0; overflow-wrap: anywhere; }
.ranked-value { font-variant-numeric: tabular-nums; font-weight: 600; }
.hbar { grid-column: 1 / -1; width: 100%; height: 6px; display: block; border-radius: 3px; overflow: hidden; }
.hbar-track { fill: var(--surface-2); }
.hbar-fill { fill: var(--accent); }

.front-list { list-style: none; margin: 0; padding: 0; }
.front-list li { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.front-list li:last-child { border-bottom: none; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.data-table th, .data-table td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--text-secondary); font-weight: 600; }
.data-table tbody th { font-weight: 500; }
.data-table th.num, .data-table td.num { text-align: right; }
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- papers, programs, misc ---------- */
.paper-list { margin: 0; padding-left: 1.2rem; }
.paper-list li { margin: 0 0 var(--space-3); }
.paper-list a { font-weight: 600; }
.paper-meta { display: block; font-size: .82rem; color: var(--text-secondary); margin-top: 2px; }
.oa { color: var(--up); font-weight: 600; }

.program-list { list-style: none; margin: 0; padding: 0; }
.program-list li { padding: var(--space-3) 0; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--space-2); }
.program-list li:last-child { border-bottom: none; }
.program-name { font-weight: 600; }
.degree {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
}
.program-inst, .program-lang { flex-basis: 100%; font-size: .85rem; color: var(--text-secondary); }
.program-lang { margin-top: -2px; }

/* Phones: one horizontally scrolling row (13 field chips would otherwise fill
   a whole screen before the first result); wraps normally from 768px. The
   padding keeps the chips' shadows from being clipped by overflow. */
.jump {
  display: flex;
  gap: var(--space-2);
  margin: 0 calc(-1 * var(--wrap-pad)) var(--space-4);
  padding: 4px var(--wrap-pad) 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.jump::-webkit-scrollbar { display: none; }
.jump a {
  flex: 0 0 auto;
  white-space: nowrap;
  text-decoration: none;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .9rem;
  color: var(--text);
}
.jump a span { color: var(--text-secondary); font-size: .8rem; margin-left: 2px; }
.jump a:hover { color: var(--accent-dark); }

.stat-panel .stat { margin: 0 0 var(--space-2); color: var(--text-secondary); font-size: .92rem; }
.stat-panel .stat:last-child { margin-bottom: 0; }
.stat-panel strong { display: block; font-size: 1.5rem; color: var(--text); line-height: 1.2; }
.stat-panel strong.up { color: var(--up); }
.stat-panel strong.down { color: var(--down); }

.id-list { list-style: none; margin: 0; padding: 0; font-size: .9rem; }
.id-list li { margin: 4px 0; overflow-wrap: anywhere; }

.site-footer { padding: var(--space-6) 0 var(--space-8); color: var(--text-secondary); font-size: .82rem; border-top: 1px solid var(--border); }
.site-footer p { max-width: 760px; margin: 0 0 var(--space-2); }

/* University table: location/field get their own columns only where there's
   room; on phones they're repeated under the name instead (.kw-narrow). */
.col-wide { display: none; }

/* ---------- breakpoints ---------- */
@media (min-width: 640px) {
  :root { --wrap-pad: var(--space-6); --hero-pad: var(--space-8); }
  .logo { font-size: 1.25rem; }
  .panel { padding: var(--space-6); }
}

@media (min-width: 768px) {
  .col-wide { display: table-cell; }
  .kw-narrow { display: none; }
  .jump { flex-wrap: wrap; overflow-x: visible; margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
}

@media (min-width: 900px) {
  .site-nav { display: flex; }
  .mobile-nav { display: none; }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); align-items: start; }
}

@media (min-width: 1024px) {
  .field-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-6); align-items: start; }
}
