/* Palette drawn from two natural-product pigments: indigo and saffron. */
:root {
  --paper: #eef0ea;
  --paper-2: #e3e6dd;
  --paper-3: #d8dcd1;
  --ink: #1b1e36;
  --ink-2: #555970;
  --indigo: #2f3c9e;
  --indigo-soft: rgba(47, 60, 158, 0.1);
  --saffron: #d99a0b;
  --saffron-soft: rgba(217, 154, 11, 0.18);
  --rule: #c9cdc1;
  --bad: #a83a2a;
  --atom-o: #b0402c;
  --atom-n: #2f3c9e;
  --atom-s: #9a6c04;
  --atom-hal: #2f7a5a;
  --atom-p: #8a4fb0;

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Public Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.625rem;
  --step-3: 2.25rem;
  --step-4: clamp(2.5rem, 5.5vw, 4.25rem);
  --radius: 6px;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121428;
    --paper-2: #1a1d36;
    --paper-3: #242847;
    --ink: #e6e7ef;
    --ink-2: #a0a3ba;
    --indigo: #a3adf5;
    --indigo-soft: rgba(163, 173, 245, 0.12);
    --saffron: #f0b634;
    --saffron-soft: rgba(240, 182, 52, 0.16);
    --rule: #2e3252;
    --bad: #f08a76;
    --atom-o: #f08a76;
    --atom-n: #a3adf5;
    --atom-s: #f0c75a;
    --atom-hal: #7fd0a8;
    --atom-p: #cfa0ef;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.55 var(--sans);
  font-feature-settings: "tnum" 1;
}

a { color: var(--indigo); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.12; margin: 0; }
h2 { font-size: var(--step-2); letter-spacing: -0.01em; }
h3 { font-size: var(--step-1); }

/* Species binomials are italic by convention; this is the only italic use. */
.sp { font-family: var(--serif); font-style: italic; }

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

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

/* ---------- Header ---------- */
.site-head { border-bottom: 1px solid var(--rule); }
.site-head .wrap { display: flex; align-items: center; gap: 24px; min-height: 64px; flex-wrap: wrap; padding-block: 10px; }
.wordmark {
  font-family: var(--serif); font-size: 1.375rem; font-weight: 600; color: var(--ink);
  text-decoration: none; letter-spacing: -0.01em; display: inline-flex; align-items: center; gap: 10px;
}
.wordmark svg { width: 26px; height: 26px; }
.site-head .search { flex: 1 1 320px; max-width: 520px; margin-left: auto; }

/* ---------- Search ---------- */
.search { position: relative; }
.search-row {
  display: flex; align-items: stretch; background: var(--paper); border: 1.5px solid var(--ink);
  border-radius: var(--radius); overflow: hidden;
}
.search-row:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px var(--indigo-soft); }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink);
  font: inherit; padding: 12px 14px; outline: none;
}
.search input::placeholder { color: var(--ink-2); }
.search .mode { display: flex; border-left: 1px solid var(--rule); }
.search .mode button {
  border: 0; background: transparent; color: var(--ink-2); font: 500 var(--step--1) var(--sans);
  padding: 0 12px; cursor: pointer;
}
.search .mode button[aria-pressed="true"] { color: var(--paper); background: var(--ink); }
.search.big .search-row { border-width: 2px; }
.search.big input { font-size: 1.1875rem; padding: 16px 18px; }
.search.big .mode button { padding: 0 16px; font-size: var(--step-0); }

.results {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 12px 32px -12px rgba(20, 22, 50, 0.35);
  list-style: none; margin: 0; padding: 6px; max-height: 420px; overflow-y: auto;
}
.results li { padding: 9px 10px; border-radius: 4px; cursor: pointer; display: flex; gap: 12px; align-items: baseline; justify-content: space-between; }
.results li[aria-selected="true"] { background: var(--indigo-soft); }
.results .r-main { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.results .r-alt { color: var(--ink-2); font-size: var(--step--1); }
.results .r-side { color: var(--ink-2); font-size: var(--step--1); flex: none; }
.results .r-note { cursor: default; color: var(--ink-2); font-size: var(--step--1); }
.results .r-all { color: var(--indigo); font-weight: 500; font-size: var(--step--1); }

/* ---------- Landing ---------- */
.hero { padding-block: clamp(32px, 7vw, 88px) clamp(40px, 6vw, 72px); }
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 72px); align-items: center; }
.hero h1 { font-size: var(--step-4); letter-spacing: -0.025em; font-weight: 400; max-width: 12ch; }
.hero .lede { font-size: 1.1875rem; color: var(--ink-2); max-width: 36em; margin: 20px 0 28px; }
.hero .hint { margin-top: 12px; font-size: var(--step--1); color: var(--ink-2); }
.hero .hint button {
  font: inherit; color: var(--indigo); background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-underline-offset: 0.18em; text-decoration-thickness: 1px;
}

.specimen { margin: 0; }
.specimen .plate {
  aspect-ratio: 4 / 3; display: grid; place-items: center; position: relative;
  border-bottom: 1px solid var(--rule);
}
.specimen .plate svg { width: 100%; height: 100%; }
.specimen figcaption { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding-top: 14px; }
.specimen .s-name { font-family: var(--serif); font-size: var(--step-2); line-height: 1.15; }
.specimen .s-src { color: var(--ink-2); }
.specimen .s-meta { color: var(--ink-2); font-size: var(--step--1); text-align: right; }
.specimen .s-actions { grid-column: 1 / -1; display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: var(--radius);
  font: 500 var(--step--1) var(--sans); padding: 9px 14px; cursor: pointer; text-decoration: none;
  border: 1.5px solid var(--ink); background: var(--ink); color: var(--paper);
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn:hover { background: var(--indigo); border-color: var(--indigo); color: var(--paper); text-decoration: none; }

/* Draw-in for the hero structure: bonds are stroked on, then labels appear. */
.drawing line, .drawing path, .drawing polygon { stroke-dasharray: var(--len, 200); stroke-dashoffset: var(--len, 200); animation: stroke 0.9s ease-out forwards; animation-delay: var(--d, 0s); }
.drawing text, .drawing g > circle, .drawing tspan { opacity: 0; animation: appear 0.4s ease-out forwards; animation-delay: var(--d, 0.8s); }
@keyframes stroke { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }

.section { padding-block: clamp(36px, 5vw, 64px); border-top: 1px solid var(--rule); }
.section-head { margin-bottom: 24px; }
.section-head p { margin: 8px 0 0; color: var(--ink-2); max-width: 40em; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tile {
  display: flex; flex-direction: column; text-decoration: none; color: var(--ink);
  background: var(--paper-2); border-radius: var(--radius); padding: 10px 14px 14px;
  border: 1px solid transparent;
}
.tile:hover { border-color: var(--indigo); }
.tile .mol { aspect-ratio: 4 / 3; display: grid; place-items: center; }
.tile .mol svg { width: 100%; height: 100%; }
.tile .t-name { font-family: var(--serif); font-size: 1.125rem; line-height: 1.2; overflow-wrap: anywhere; }
.tile .t-meta { font-size: var(--step--1); color: var(--ink-2); margin-top: 2px; }

.species-list { list-style: none; margin: 0; padding: 0; columns: 2 320px; column-gap: 48px; }
.species-list li { break-inside: avoid; border-bottom: 1px solid var(--rule); }
.species-list a { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; text-decoration: none; color: var(--ink); }
.species-list a:hover .sp { color: var(--indigo); }
.species-list .sp { font-size: 1.1875rem; }
.species-list .count { color: var(--ink-2); font-size: var(--step--1); align-self: center; white-space: nowrap; }

.site-foot { border-top: 1px solid var(--rule); padding-block: 28px 40px; color: var(--ink-2); font-size: var(--step--1); }
.site-foot p { margin: 0; max-width: 60em; }

/* ---------- Compound page ---------- */
.c-head { padding-block: clamp(28px, 5vw, 56px) 24px; }
.c-head h1 { font-size: clamp(2rem, 4.5vw, 3.25rem); letter-spacing: -0.02em; font-weight: 400; overflow-wrap: anywhere; max-width: 24ch; }
.c-head .sub { font-size: 1.0625rem; display: flex; flex-wrap: wrap; gap: 6px 22px; margin-top: 14px; color: var(--ink-2); }
.c-head .sub strong { color: var(--ink); font-weight: 500; }
.formula sub { font-size: 0.72em; }

.c-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: clamp(28px, 4vw, 56px); padding-bottom: 64px; align-items: start; }
.c-struct { position: sticky; top: 16px; }
.c-struct .plate { aspect-ratio: 1 / 1; background: var(--paper-2); border-radius: var(--radius); display: grid; place-items: center; padding: 12px; }
.c-struct .plate svg { width: 100%; height: 100%; }
.c-struct .links { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: var(--step--1); }

.block { padding-block: 26px; border-top: 1px solid var(--rule); }
.block:first-child { border-top: 0; padding-top: 0; }
.block h2 { margin-bottom: 16px; }
.block h3 { font-family: var(--sans); font-size: var(--step--1); font-weight: 600; color: var(--ink-2); margin: 18px 0 6px; }
.block h3:first-of-type { margin-top: 0; }

.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0 24px; margin: 0; }
.props div { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.props dt { font-size: var(--step--1); color: var(--ink-2); }
.props dd { margin: 2px 0 0; font-size: 1.125rem; }
.props dd .unit { font-size: var(--step--1); color: var(--ink-2); margin-left: 3px; }

.rules { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.rules li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--paper-2); font-size: var(--step--1); }
.rules .mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 12px; }
.rules .ok .mark { background: var(--indigo); color: var(--paper); }
.rules .no .mark { background: var(--bad); color: var(--paper); }
.rules .val { margin-left: auto; color: var(--ink-2); }

.verdict { margin: 0 0 14px; }
.verdict strong { font-weight: 600; }

.gauge { margin-top: 18px; }
.gauge .g-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.gauge .g-val { font-size: 1.125rem; }
.gauge .track { position: relative; height: 8px; border-radius: 4px; background: var(--paper-3); margin: 8px 0 4px; }
.gauge .fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--indigo); }
.gauge .pin { position: absolute; top: -4px; width: 4px; height: 16px; margin-left: -2px; border-radius: 2px; background: var(--saffron); box-shadow: 0 0 0 2px var(--paper); }
.gauge .g-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--ink-2); }

.path { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
.path li { display: flex; align-items: center; gap: 6px; }
.path li + li::before { content: ""; width: 10px; height: 1.5px; background: var(--ink-2); }
.path span { background: var(--paper-2); padding: 4px 10px; border-radius: 999px; font-size: var(--step--1); }
.path li:last-child span { background: var(--saffron-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tags span { font-size: var(--step--1); border: 1px solid var(--rule); border-radius: 999px; padding: 3px 10px; }

.ids { margin: 0; }
.ids div { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.ids dt { color: var(--ink-2); font-size: var(--step--1); padding-top: 2px; }
.ids dd { margin: 0; overflow-wrap: anywhere; font-size: 0.9375rem; }
.ids .code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.875rem; }
.copy {
  font: 500 0.75rem var(--sans); color: var(--indigo); background: none; border: 1px solid var(--rule);
  border-radius: 4px; padding: 3px 8px; cursor: pointer;
}
.copy:hover { border-color: var(--indigo); }

.organisms { list-style: none; margin: 0; padding: 0; columns: 2 220px; column-gap: 32px; }
.organisms li { padding: 4px 0; break-inside: avoid; }
.organisms a { font-size: 1.0625rem; }
.more { font: 500 var(--step--1) var(--sans); color: var(--indigo); background: none; border: 0; padding: 8px 0 0; cursor: pointer; }

.refs { list-style: none; margin: 0; padding: 0; font-size: var(--step--1); }
.refs li { padding: 3px 0; overflow-wrap: anywhere; }

details.syn summary { cursor: pointer; color: var(--indigo); font-weight: 500; font-size: var(--step--1); }
details.syn ul { list-style: none; padding: 0; margin: 12px 0 0; columns: 2 240px; column-gap: 28px; font-size: var(--step--1); }
details.syn li { padding: 2px 0; overflow-wrap: anywhere; break-inside: avoid; }

/* ---------- Species + search pages ---------- */
.list-head { padding-block: clamp(28px, 5vw, 56px) 28px; }
.list-head h1 { font-size: clamp(2rem, 4.5vw, 3.25rem); font-weight: 400; letter-spacing: -0.02em; }
.list-head p { margin: 10px 0 0; color: var(--ink-2); }
.list-tools { display: flex; gap: 12px; margin: 22px 0 0; flex-wrap: wrap; align-items: center; }
.list-tools input {
  font: inherit; color: var(--ink); background: var(--paper); border: 1.5px solid var(--rule);
  border-radius: var(--radius); padding: 9px 12px; width: min(100%, 340px);
}
.list-tools input:focus { border-color: var(--indigo); outline: none; box-shadow: 0 0 0 3px var(--indigo-soft); }
.pager { display: flex; justify-content: center; padding: 28px 0 64px; }

.hits { list-style: none; margin: 0 0 64px; padding: 0; }
.hits li { border-bottom: 1px solid var(--rule); }
.hits a { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; text-decoration: none; color: var(--ink); }
.hits a:hover .h-name { color: var(--indigo); }
.hits .h-name { font-family: var(--serif); font-size: 1.25rem; }
.hits .h-alt { color: var(--ink-2); font-size: var(--step--1); }
.hits .h-side { color: var(--ink-2); font-size: var(--step--1); align-self: center; white-space: nowrap; }

.empty { padding: 48px 0 80px; max-width: 40em; }
.empty h2 { margin-bottom: 10px; }

.unavailable { color: var(--ink-2); font-size: var(--step--1); }

@media (max-width: 860px) {
  .hero .wrap, .c-grid { grid-template-columns: minmax(0, 1fr); }
  .c-struct { position: static; max-width: 460px; }
  .ids div { grid-template-columns: minmax(0, 1fr) auto; }
  .ids dt { grid-column: 1 / -1; }
}

@media (max-width: 520px) {
  .site-head .search { min-width: 0; flex-basis: 100%; }
  .search-row { flex-wrap: wrap; }
  .search input { flex: 1 1 100%; }
  .search .mode { flex: 1 1 100%; border-left: 0; border-top: 1px solid var(--rule); }
  .search .mode button, .search.big .mode button { flex: 1; padding: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawing line, .drawing path, .drawing polygon, .drawing text, .drawing g > circle, .drawing tspan { animation: none; stroke-dashoffset: 0; opacity: 1; }
}
