/* SAGE benchmark website — palette lifted from the paper's figure code
   (src/visualizations/property_space.py, species_map.py, delta_heatmap.py). */

:root {
  --paper:      #F9F4F3;  /* warm figure background */
  --paper-2:    #F2EBE8;
  --card:       #FFFDFC;
  --ink:        #2D3A4A;  /* navy — also the sampling-effort axis colour */
  --ink-soft:   #5B6875;
  --accent:     #D4603A;  /* terracotta — the relative-prevalence axis colour */
  --presence:   #E07A5F;
  --absence:    #3D405B;  /* evaluation plots: a small mark, keeps its weight */
  --cell-absence: #C3C9D5;  /* surveyed-not-recorded cells: a large-area fill */
  --border:     #DDD3CE;
  --border-2:   #c0bdb6;
  --ocean:      #d4e4f7;

  /* delta heatmap, palette "H" in delta_heatmap.py: violet -> green,
     green = the model on the left is better */
  --dh-neg-2:   #5C3578;
  --dh-neg-1:   #A87BC0;
  --dh-mid:     #F5F2EC;
  --dh-pos-1:   #4E9448;
  --dh-pos-2:   #1E5020;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --maxw: 1400px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; }
h1 { font-size: 2.4rem; margin: 0 0 .4em; letter-spacing: -0.01em; }
h2 { font-size: 1.6rem; margin: 2.6rem 0 .6rem; scroll-margin-top: 86px; }
h3 { font-size: 1.15rem; margin: 1.8rem 0 .4rem; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px solid rgba(212,96,58,.3); }
a:hover { border-bottom-color: var(--accent); }

code, .mono { font-family: var(--mono); font-size: .88em; }
code { background: var(--paper-2); padding: .1em .35em; border-radius: 3px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.lede { font-size: 1.08rem; color: var(--ink-soft); text-wrap: pretty; }
.muted { color: var(--ink-soft); }
.metric-highlight { color: var(--ink); font-weight: 700; }
h2 .metric-highlight {
  display: inline-block; margin-left: .35em; padding: .08em .35em;
  border-radius: 4px; background: var(--paper-2); font-size: .72em;
  letter-spacing: .04em; vertical-align: .12em;
}
.small { font-size: .86rem; }

/* ── header / nav ─────────────────────────────────────────────────────── */

header.site {
  border-bottom: 1px solid var(--border);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(140%) blur(6px);
}
header.site .wrap {
  display: flex; align-items: center; gap: 28px;
  height: 80px;
}
header.site .brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--serif); font-weight: 700; font-size: 1.35rem;
  color: var(--ink); border: 0; letter-spacing: .02em;
}
header.site .brand-mark {
  position: relative; display: inline-block; flex: none;
  width: 54px; height: 54px;
}
header.site .brand-mark img {
  position: absolute; inset: 0; width: 54px; height: 54px;
  display: block; object-fit: contain;
}
header.site nav { display: flex; gap: 20px; margin-left: auto; }
header.site nav a {
  color: var(--ink-soft); border: 0; font-size: .95rem;
  padding-bottom: 2px; border-bottom: 2px solid transparent;
}
header.site nav a:hover { color: var(--ink); }
header.site nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ── hero ─────────────────────────────────────────────────────────────── */

.hero { padding: 64px 0 28px; }
.hero h1 { font-size: 2.5rem; line-height: 1.15; margin-bottom: .5em;
           text-wrap: wrap; }
.hero .sub { font-size: 1.15rem; color: var(--ink-soft); text-wrap: pretty; }
.axis-effort { color: var(--ink); }
.axis-prevalence { color: var(--accent); }
.author-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 18px 14px; margin: 4px 0 18px;
}
.author-card {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  min-width: 0; text-align: center; font-size: .84rem; line-height: 1.2;
  color: var(--ink); border: 0;
}
.author-card:hover { color: var(--accent); }
.author-card img, .author-photo-placeholder {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 1px solid var(--border-2); background: var(--paper-2);
}
.author-card sup { color: var(--accent); font-size: .7em; }
.affiliation-row {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; margin-top: 16px;
}
.affiliation-logos {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  width: max-content; max-width: 100%; gap: 8px 10px; margin: 0 auto;
}
.affiliation-logo {
  display: flex; align-items: flex-start; justify-content: center; gap: 1px;
  width: max-content; max-width: 100%; min-width: 0;
  color: var(--ink-soft);
}
.affiliation-logo sup {
  margin-right: 3px;
  font-size: .72rem; line-height: 1; font-weight: 600; color: var(--accent);
}
.affiliation-logo img {
  width: auto; max-width: 115px; height: 28px; object-fit: contain;
}
.affiliation-note { margin: 0; white-space: nowrap; font-size: .78rem; }

.linkrow { display: flex; flex-wrap: wrap; gap: 10px; margin: 26px 0 0; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: 6px;
  border: 1px solid var(--border-2); background: var(--card);
  color: var(--ink); font-size: .92rem; cursor: pointer;
}
.btn:hover { border-color: var(--ink); background: var(--paper-2); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: var(--paper-2); color: var(--ink); }
.btn[disabled] { opacity: .45; cursor: default; }

/* ── stat strip ───────────────────────────────────────────────────────── */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1px;
         background: var(--border); border: 1px solid var(--border); border-radius: 8px;
         overflow: hidden; margin: 34px 0; }
.stats div { background: var(--card); padding: 16px 18px; }
.stats .v { font-family: var(--serif); font-size: 1.55rem; display: block; line-height: 1.15; }
.stats .k { font-size: .8rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.part-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin: 18px 0;
}
.part-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  min-height: 116px; padding: 18px; background: var(--card); color: var(--ink);
  border: 0;
}
.part-icon { width: 32px; height: 32px; margin-bottom: 3px; object-fit: contain; }
.part-card strong { font-family: var(--serif); font-size: 1.2rem; }
.part-card span { color: var(--ink-soft); font-size: .9rem; line-height: 1.4; }
.part-card b { margin-top: auto; color: var(--accent); font-size: 1.1rem; }
.part-card:hover { background: var(--paper-2); }
.predictor-table details summary { cursor: pointer; color: var(--ink); }
.predictor-table details summary::marker { color: var(--accent); }
.predictor-list { display: block; margin-top: 7px; color: var(--ink-soft); font-size: .84rem;
  line-height: 1.5; max-width: 34rem; }

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

.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px 22px; margin: 18px 0;
}
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
select, input[type="search"], input[type="text"] {
  font: inherit; font-size: .93rem; padding: 6px 9px;
  border: 1px solid var(--border-2); border-radius: 5px;
  background: var(--card); color: var(--ink);
}
textarea, input[type="email"], input[type="url"] {
  font: inherit; font-size: .93rem; padding: 6px 9px; border: 1px solid var(--border-2);
  border-radius: 5px; background: var(--card); color: var(--ink);
}
.submission-form { display: flex; flex-direction: column; gap: 14px; }
.submission-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
textarea { resize: vertical; min-height: 90px; }
#heat-a { border-color: var(--dh-pos-1); background: #eef5ec; }
#heat-b { border-color: var(--dh-neg-2); background: #f3edf5; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: 5px; overflow: hidden; }
.seg button {
  font: inherit; font-size: .9rem; padding: 6px 13px; border: 0;
  background: var(--card); color: var(--ink-soft); cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border-2); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }

/* --switch: a labelled on/off control, for settings that are a single choice
   rather than a set of alternatives. */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 21px; border-radius: 11px; flex: none;
  background: #d8d0cb; border: 1px solid var(--border-2);
  transition: background .15s; position: relative;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s;
}
.switch input:checked + .track { background: var(--ink); border-color: var(--ink); }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch .label { font-size: .93rem; }

/* ── tables ───────────────────────────────────────────────────────────── */

.tablewrap { overflow-x: auto; }
table.results { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.results th, table.results td { padding: 8px 12px; text-align: right; white-space: nowrap; }
table.results th:first-child, table.results td:first-child { text-align: left; }
table.results th:not(:first-child):not([data-sort="time"]),
table.results td:not(:first-child):not(:last-child):not(:nth-last-child(2)) { text-align: center; }
table.results thead th {
  font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft); font-weight: 600; border-bottom: 1px solid var(--border-2);
  cursor: pointer; user-select: none;
}
table.results thead th.group { text-align: center; border-bottom: 0; padding-bottom: 2px; cursor: default; }
table.results thead th.group span { border-bottom: 1px solid var(--border-2); padding: 0 10px 3px; display: inline-block; }
table.results thead th.axis-sparse,
table.results thead th.axis-dense { color: var(--ink); }
table.results thead th.axis-prevalence { color: var(--accent); }
.quadrant-icon {
  display: inline-grid; grid-template-columns: repeat(2, 5px); gap: 1px;
  width: 11px; height: 11px; margin-right: 5px; vertical-align: -1px;
}
.quadrant-icon i { display: block; background: var(--border-2); border-radius: 1px; }
.quadrant-icon i.active { background: var(--accent); }
table.results tbody tr:hover { background: var(--paper-2); }
table.results tr.grouphead td {
  font-family: var(--serif); font-size: .95rem; padding-top: 16px;
  color: var(--ink-soft); border-bottom: 1px solid var(--border);
}
table.results td.best { font-weight: 700; }
table.results td.second { text-decoration: underline; text-underline-offset: 3px; }
.legend-second { text-decoration: underline; text-underline-offset: 3px; }
table.results .sd { color: var(--ink-soft); font-size: .84em; }
table.results tr.user td { background: rgba(212,96,58,.07); }
table.results tr.user td:first-child::before { content: "★ "; color: var(--accent); }
.mapbtn { border: 0; background: none; cursor: pointer; color: var(--ink-soft); font-size: .84rem; padding: 0 4px; white-space: nowrap; }
.mapbtn:hover { color: var(--accent); }

table.plain { border-collapse: collapse; width: 100%; font-size: .93rem; }
table.plain th, table.plain td { padding: 7px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.plain thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }

/* ── heatmap ──────────────────────────────────────────────────────────── */

.heat-layout { display: grid; grid-template-columns: minmax(320px, 1fr) 260px; gap: 26px; align-items: start; }
.heat { overflow: hidden; border-radius: 8px; }
.heat svg { width: 100%; max-width: 560px; height: auto; display: block; margin: 0 auto; }
.heat text { font-family: var(--sans); }
.heat-title { width: 460px; max-width: calc(100% - 92px); margin: 0 auto -2px; transform: translateX(28px);
  text-align: center; font-family: var(--sans); font-size: 1.2rem; }
.heat-title strong:first-child { color: var(--dh-pos-2); }
.heat-title strong:last-child { color: var(--dh-neg-2); }
.heat-title span { color: var(--ink); font-weight: 400; }
.legend-bar { height: 12px; border-radius: 3px; margin: 8px 0 4px;
  background: linear-gradient(to right, var(--dh-neg-2), var(--dh-neg-1), var(--dh-mid), var(--dh-pos-1), var(--dh-pos-2)); }
.presets { display: flex; flex-direction: column; gap: 6px; }
.presets button { text-align: left; font-size: .88rem; padding: 6px 10px; }

/* ── drop zone ────────────────────────────────────────────────────────── */

.drop {
  border: 2px dashed var(--border-2); border-radius: 8px;
  padding: 30px; text-align: center; color: var(--ink-soft);
  background: var(--paper-2); transition: border-color .15s, background .15s;
}
.drop.over { border-color: var(--accent); background: #fff; color: var(--ink); }
.drop input[type="file"] { display: none; }

.note { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; margin: 16px 0; color: var(--ink-soft); }
.err { color: #b03a2e; }

/* ── map explorer ─────────────────────────────────────────────────────── */

.explorer-overview { display: grid; grid-template-columns: 290px 1fr; gap: 20px; align-items: start; }
.explorer-map { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 20px; margin-top: 24px; }
#map { height: 480px; border-radius: 8px; border: 1px solid var(--border); background: var(--ocean); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; margin-top: 16px; }
.map-legend > .layerlist { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin: 0 !important; }
.map-legend > .layerlist > div { display: inline-flex !important; }
.explorer-layers { margin-top: 16px; gap: 9px; }
.probability-legend { display: inline-flex; align-items: center; gap: 8px; }
.probability-bar { width: 130px; height: 10px; border-radius: 3px; display: inline-block; }
.maplibregl-ctrl-attrib { font-size: 10px; }
.layerlist { display: flex; flex-direction: column; gap: 9px; }
.layerlist label { display: flex; gap: 9px; align-items: center; font-size: .92rem; cursor: pointer; }
.layer-row { display: flex; align-items: center; gap: 10px; }
.layer-row > label { flex: 1 1 auto; min-width: 0; }
.layer-opacity { flex: none; width: 74px; accent-color: var(--ink-soft); cursor: pointer; }
.layer-opacity:disabled { opacity: .35; cursor: default; }
.swatch { width: 13px; height: 13px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex: none; }
.swatch.square { border-radius: 2px; }
.swatch.circle { border-radius: 50%; }
.swatch.dual { background: linear-gradient(135deg, var(--presence) 0 50%, var(--absence) 50% 100%); }
.swatch.dual-cell { background: linear-gradient(135deg, var(--presence) 0 50%, var(--cell-absence) 50% 100%); }
.swatch.outline { background: transparent !important; border: 2px solid var(--presence); }
.species-summary { display: grid; grid-template-columns: 290px 230px 354px;
  gap: 6px; align-items: start; justify-content: space-between; }
.species-illustration { width: 290px; margin: 0; }
.species-image { width: 290px; height: 290px; display: flex; align-items: center; justify-content: center;
  overflow: hidden; border-radius: 6px; background: var(--paper-2); color: var(--ink-soft); }
.species-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.species-illustration figcaption { margin-top: 4px; }
.species-summary dt { margin-top: 0; }
.species-identity { height: 290px; margin: 0; padding: 10px 14px; display: flex; flex-direction: column;
  justify-content: space-between; border: 1px solid var(--border); border-radius: 6px; background: var(--card);
  line-height: 1.2; }
.species-identity { transform: translateY(0); }
.species-group { transform: none; }
.species-links { margin-top: 0; font-size: .95rem; }
.species-identity dd { max-width: 230px; font-size: 1rem; }
.species-group { padding-top: 0; margin-left: 0; min-width: 0; overflow: hidden; }
.species-group svg { display: block; width: 290px; max-width: 100%; height: auto; }
.effort-percentile { color: var(--ink); }
.prevalence-percentile { color: var(--accent); }
.metric-percentile { font-weight: 700; }
.explorer-controls #species-select { height: 235px; }
.speciescard dt { font-size: .76rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-top: 10px; }
.speciescard dd { margin: 0; font-size: 1.02rem; }
.slider-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.slider-row input[type="range"] { flex: 1; accent-color: var(--accent); }

footer.site { border-top: 1px solid var(--border); margin-top: 70px; padding: 26px 0 50px;
  color: var(--ink-soft); font-size: .88rem; }

@media (max-width: 1300px) {
  .heat-layout, .explorer-overview, .explorer-map { grid-template-columns: 1fr; }
  .species-summary { grid-template-columns: 290px 230px 354px; gap: 6px; }
  .species-group { transform: none; }
  .species-illustration, .species-image { width: 100%; max-width: 324px; }
  .species-image { height: auto; aspect-ratio: 1; }
  .species-identity { width: 230px; height: 290px; }
  .hero h1 { font-size: 2.1rem; }
}
@media (max-width: 900px) {
  .species-summary { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: flex-start; }
  .species-illustration { flex: 0 1 290px; }
  .species-group { flex: 0 0 100%; width: 100%; }
  .species-identity { flex: 0 0 230px; width: 230px; }
  #map { height: 420px; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .species-summary { display: block; }
  .species-group { width: 100%; margin-top: 16px; }
  .species-identity { width: auto; height: auto; }
  .affiliation-logos { gap: 14px 18px; }
  .affiliation-note { white-space: normal; text-align: center; }
  .part-grid { grid-template-columns: 1fr; }
}
