/* Hirudinea.org — shared stylesheet. Palette and components carried over from the
   original hand-built site (index.html / morphology.html). */

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

:root {
  --ink: #1a1c18;
  --ink-mid: #4a4d44;
  --ink-soft: #8a8d82;
  --cream: #f7f5f0;
  --cream-dark: #ede9e1;
  --rust: #8b3a2a;
  --rust-light: #c4614d;
  --border: rgba(0,0,0,0.1);
  --shadow: 0 2px 12px rgba(0,0,0,0.07);
  --radius: 10px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Source Sans 3', system-ui, sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--rust); text-decoration: none; }
a:hover { text-decoration: underline; }
i, em { font-style: italic; }

/* ── SITE HEADER ── */
header {
  background: var(--ink);
  color: var(--cream);
  padding: 0 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-shrink: 0;
  border-bottom: 3px solid var(--rust);
}
.header-left { padding: 1.25rem 0; }
.header-left .site-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  line-height: 1.2;
  text-decoration: none;
}
.header-left p {
  font-size: 13px;
  color: rgba(255,255,255,0.45);
  margin-top: 3px;
  font-style: italic;
}
.header-right { display: flex; align-items: center; gap: 1.5rem; flex-shrink: 0; }
.stat {
  text-align: center;
  padding: 1rem 0 1rem 1.5rem;
  border-left: 1px solid rgba(255,255,255,0.1);
}
.stat-num { font-family: var(--font-display); font-size: 22px; color: var(--rust-light); line-height: 1; }
.stat-label {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 3px;
}

/* ── SITE NAV ── */
nav.site-nav {
  background: var(--ink);
  display: flex;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0 2.5rem;
  flex-shrink: 0;
}
.nav-link {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  font-weight: 500;
}
.nav-link:hover { color: rgba(255,255,255,0.85); text-decoration: none; }
.nav-link.active { color: #fff; border-bottom-color: var(--rust-light); }

/* ── BANNERS ── */
.banner { padding: 0.7rem 2.5rem; font-size: 13.5px; flex-shrink: 0; }
.banner-identify { background: var(--rust); color: #fff; font-style: italic; }
.banner-identify a { color: #fff; font-weight: 600; }

/* ── PAGE CONTENT ── */
main {
  flex: 1;
  padding: 2rem 2.5rem 3rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
main.wide { max-width: 1400px; }

.crumbs { font-size: 13px; color: var(--ink-soft); margin-bottom: 0.6rem; }
.crumbs a { color: var(--ink-mid); }

.page-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.4rem;
}
.page-subtitle { font-size: 14px; color: var(--ink-soft); margin-bottom: 2rem; }
.page-subtitle .authority { color: var(--ink-mid); font-size: 16px; }

/* ── CHECKLIST TABLE ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  margin-bottom: 1rem;
}
.toolbar input, .toolbar select {
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
.toolbar input[type=search] { flex: 1 1 220px; min-width: 0; }
.toolbar select { flex: 0 1 auto; max-width: 100%; }
.toolbar .count { font-size: 13px; color: var(--ink-soft); margin-left: auto; }
.btn {
  font-size: 13px;
  color: #fff;
  background: var(--ink-mid);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover { background: var(--ink); text-decoration: none; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
table.checklist { width: 100%; min-width: 760px; border-collapse: collapse; font-size: 14px; }
.checklist th, .checklist td { text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.checklist thead th {
  position: sticky;
  top: 0;
  background: var(--cream-dark);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-mid);
  font-weight: 600;
  white-space: nowrap;
}
.checklist th button {
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
.checklist th button::after { content: " \2195"; opacity: 0.35; }
.checklist th[aria-sort=ascending] button::after { content: " \2191"; opacity: 1; }
.checklist th[aria-sort=descending] button::after { content: " \2193"; opacity: 1; }
.checklist tbody tr:hover { background: var(--cream); }
.checklist td.sp { white-space: nowrap; }
.checklist .muted { color: var(--ink-soft); }
.empty-msg { padding: 1.5rem; text-align: center; color: var(--ink-soft); }

/* ── SECTION CARDS (species pages, morphology) ── */
.sections { display: flex; flex-direction: column; gap: 18px; }
.section-card {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.section-stripe { height: 3px; background: linear-gradient(90deg, var(--rust), rgba(139,58,42,0.05)); }
.section-inner { display: grid; grid-template-columns: 1fr 260px; }
.section-text { padding: 22px 24px 24px; border-right: 1px solid var(--border); }
.section-text:only-child { border-right: 0; }
.section-text h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
  scroll-margin-top: 80px;
}
.section-text h2::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rust);
  opacity: 0.7;
  flex-shrink: 0;
}
.section-text p, .section-text li, .section-text dd {
  font-size: 14px;
  color: var(--ink-mid);
  line-height: 1.75;
}
.section-text p { margin: 0 0 12px; }
.section-text p:last-child { margin-bottom: 0; }
.section-text em { color: var(--ink); }
.section-text ul { margin-left: 1.2rem; }
.section-text h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin: 16px 0 4px; }
.section-text h3:first-of-type { margin-top: 0; }
.section-text a { overflow-wrap: anywhere; }

.section-photo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--cream-dark);
  gap: 10px;
  min-height: 200px;
}
.photo-slot {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--cream);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.photo-slot img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; display: block; }
.section-photo p { font-size: 11px; color: var(--ink-soft); text-align: center; }

/* Species page: main column + sidebar */
.species-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.species-photo { background: #fff; padding: 12px; }
.species-photo img { width: 100%; height: auto; max-height: 75vh; object-fit: contain; display: block; border-radius: 6px; }
.species-photo figcaption { font-size: 12px; color: var(--ink-soft); margin-top: 8px; overflow-wrap: anywhere; }

.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; margin: 0; }
.kv dt { font-size: 13px; color: var(--ink-soft); }
.kv dd { font-size: 14px; color: var(--ink); line-height: 1.5; }

.taxon-list { columns: 2 220px; column-gap: 24px; list-style: none; margin-left: 0 !important; }
.taxon-list li { break-inside: avoid; padding: 2px 0; }
.taxon-list .auth { color: var(--ink-soft); font-size: 13px; }

.family-group + .family-group { margin-top: 18px; }

/* ── FOOTER ── */
footer {
  background: var(--ink);
  color: rgba(255,255,255,0.3);
  font-size: 12px;
  padding: 0.75rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
footer a { color: rgba(255,255,255,0.4); }
footer a:hover { color: rgba(255,255,255,0.7); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .species-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 780px) {
  header { padding: 0 1rem; flex-wrap: wrap; gap: 0 1rem; }
  .header-left { padding: 1rem 0 0.25rem; }
  .stat { padding: 0.25rem 0 0.75rem; border-left: 0; text-align: left; }
  nav.site-nav { padding: 0 0.5rem; }
  .nav-link { padding: 10px 10px; }
  .banner { padding: 0.6rem 1rem; }
  main { padding: 1.5rem 1rem 3rem; }
  .section-inner { grid-template-columns: 1fr; }
  .section-text { border-right: none; border-bottom: 1px solid var(--border); }
  .section-text:only-child { border-bottom: 0; }
  .section-photo { min-height: 180px; }
  .photo-slot { aspect-ratio: 16/9; }
  .toolbar .count { margin-left: 0; width: 100%; }
  footer { padding: 0.75rem 1rem; flex-direction: column; gap: 4px; text-align: center; }
}

.section-text h2 .count-note { font-family: var(--font-body); font-size: 13px; font-weight: 400; color: var(--ink-soft); }
