/* ============================================================================
   Components: the field-guide UI kit. Reads only from tokens.css.
   ============================================================================ */

/* ---------------------------------------------------------------- Masthead */
.masthead {
  background: linear-gradient(180deg, var(--card) 0%, var(--paper-2) 100%);
  border-bottom: 1px solid var(--line);
}
.masthead__inner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-6) 0 var(--s-5);
  flex-wrap: wrap;
}
.wordmark { display: block; }
.wordmark__name {
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  font-weight: 580;
  font-optical-sizing: auto;
  color: var(--ink);
  letter-spacing: -0.015em;
  line-height: 1.05;
}
.wordmark__name a { color: inherit; }
.wordmark__name a:hover { color: var(--sage-700); text-decoration: none; }
.wordmark__tag {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: var(--t-md);
  color: var(--ink-muted);
  margin-top: 2px;
}

/* small bird-track motif divider */
.wordmark__rule {
  width: 64px; height: 0; margin-top: var(--s-2);
  border-top: 2px solid var(--clay-500);
}

/* ----------------------------------------------------------- Hotspot picker */
.hotspot {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--t-sm);
}
.hotspot__label {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--ink-muted);
}
.hotspot select {
  appearance: none;
  background: var(--card-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%23556a3a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 0.7rem center;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 0.5rem 2rem 0.5rem 0.8rem;
  color: var(--ink);
  font-size: var(--t-sm);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.hotspot select:hover { border-color: var(--sage-500); }
.hotspot select:focus {
  outline: none; border-color: var(--sage-600);
  box-shadow: 0 0 0 3px var(--sage-50);
}

/* ---------------------------------------------------------------- Nav bar */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(251, 248, 240, 0.92);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav__inner { display: flex; align-items: center; gap: var(--s-2); }
.nav__links {
  display: flex; align-items: center; gap: 2px;
  list-style: none; padding: 0; margin: 0;
  flex-wrap: wrap; flex: 1;
}
.nav__links li { margin: 0; }
.nav a.nav__link {
  display: inline-block;
  font-size: var(--t-sm);
  color: var(--ink-soft);
  padding: 0.85rem 0.7rem;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav a.nav__link:hover { color: var(--sage-700); text-decoration: none; border-bottom-color: var(--sage-300); }
.nav a.nav__link.is-active { color: var(--sage-700); border-bottom-color: var(--clay-500); font-weight: 600; }
.nav__more { position: relative; }

.btn-ghost-link {
  font-size: var(--t-sm);
  color: var(--ink-soft);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 0.4rem 0.8rem;
  white-space: nowrap;
}
.btn-ghost-link:hover { border-color: var(--sage-500); color: var(--sage-700); text-decoration: none; }

/* Hamburger (mobile) */
.nav__toggle { display: none; background: none; border: none; padding: 0.7rem; }
.nav__toggle span { display: block; width: 24px; height: 2px; background: var(--sage-700); border-radius: 2px; margin: 4px 0; transition: all 0.25s; }
.nav__toggle.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav__toggle.is-open span:nth-child(2) { opacity: 0; }
.nav__toggle.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ---------------------------------------------------------------- Main / hero */
main { padding: var(--s-6) 0 var(--s-8); }

.page-head { margin-bottom: var(--s-5); }
.page-head h1 { font-size: var(--t-2xl); }
.page-head .lede {
  font-family: var(--font-serif);
  font-size: var(--t-md);
  color: var(--ink-muted);
  margin-top: var(--s-1);
  max-width: 62ch;
}
.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 650;
  color: var(--clay-700);
  margin-bottom: var(--s-1);
}

/* ---------------------------------------------------------------- Card */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--s-5); }
.card__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s-3); margin-bottom: var(--s-4);
  padding-bottom: var(--s-3);
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}
.card__head h2, .card__head h3 { margin: 0; }
.card__title { font-size: var(--t-lg); }
.card__sub { font-family: var(--font-serif); font-style: italic; color: var(--ink-muted); font-size: var(--t-sm); }

/* feature card with a clay left edge for emphasis */
.card--feature { border-left: 3px solid var(--clay-500); }
.card--quiet { background: var(--card-2); box-shadow: none; }

/* ---------------------------------------------------------------- Grid */
.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--charts { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }

/* ---------------------------------------------------------------- Stat blocks */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-4); }
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--sage-300);
}
.stat--clay::after { background: var(--clay-300); }
.stat__num {
  font-family: var(--font-display);
  font-size: var(--t-2xl);
  font-weight: 580;
  color: var(--sage-700);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat__num small { font-size: 0.5em; color: var(--ink-faint); font-weight: 500; }
.stat__label {
  font-size: var(--t-sm);
  color: var(--ink-muted);
  margin-top: var(--s-2);
}
.stat__sub { font-size: var(--t-xs); color: var(--ink-faint); margin-top: 2px; }

/* ---------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-md); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-sm);
}
table.data th {
  text-align: left;
  font-family: var(--font-sans);
  font-weight: 650;
  font-size: var(--t-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  background: var(--paper-2);
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  position: sticky; top: 0;
}
table.data td {
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
table.data tbody tr { transition: background 0.1s; }
table.data tbody tr:hover { background: var(--sage-50); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .rank { color: var(--ink-faint); font-variant-numeric: tabular-nums; width: 1%; }

a.species { color: var(--sage-700); font-weight: 550; }
a.species:hover { color: var(--clay-700); }
.sci { font-family: var(--font-serif); font-style: italic; color: var(--ink-muted); font-size: 0.92em; }
.code-tag {
  font-family: var(--font-mono); font-size: var(--t-xs);
  color: var(--clay-700); background: var(--clay-100);
  padding: 1px 5px; border-radius: var(--r-sm); letter-spacing: 0.03em;
}

/* ---------------------------------------------------------------- Badges / pills */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-xs); font-weight: 600;
  padding: 2px 9px; border-radius: var(--r-pill);
  background: var(--sage-100); color: var(--sage-900);
  white-space: nowrap;
}
.badge--clay   { background: var(--clay-100);  color: var(--clay-700); }
.badge--rare   { background: #f1d9d2;          color: var(--rare); }
.badge--spring { background: var(--sage-100);  color: var(--sage-700); }
.badge--summer { background: #d6e6ee;          color: #2e6c8c; }
.badge--fall   { background: var(--clay-100);  color: var(--clay-700); }
.badge--winter { background: #dfe3e8;          color: #51606f; }
.badge--resident { background: #e7e2d6;        color: var(--ink-soft); }
.badge--outline { background: transparent; border: 1px solid var(--line-strong); color: var(--ink-muted); }

/* a colored dot for legends */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }

/* ---------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: var(--t-sm); font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}
.btn--primary { background: var(--sage-600); color: #fff; }
.btn--primary:hover { background: var(--sage-700); color: #fff; text-decoration: none; }
.btn--ghost { background: var(--card-2); color: var(--ink-soft); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--sage-500); color: var(--sage-700); text-decoration: none; }
.btn--sm { padding: 0.35rem 0.7rem; font-size: var(--t-xs); }

/* ---------------------------------------------------------------- Filter pills */
.pills { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-bottom: var(--s-4); }
.pill {
  font-size: var(--t-sm);
  padding: 0.35rem 0.85rem;
  border-radius: var(--r-pill);
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  color: var(--ink-soft);
  transition: all 0.15s;
}
.pill:hover { border-color: var(--sage-500); color: var(--sage-700); text-decoration: none; }
.pill.is-active { background: var(--sage-600); border-color: var(--sage-600); color: #fff; }

/* ---------------------------------------------------------------- Search input */
.field {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 0.7rem 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus { outline: none; border-color: var(--sage-600); box-shadow: 0 0 0 3px var(--sage-50); }
.field-label { display: block; font-size: var(--t-sm); font-weight: 600; color: var(--ink-soft); margin-bottom: var(--s-2); }

/* ---------------------------------------------------------------- Charts */
.chart-box { position: relative; height: 360px; margin: var(--s-2) 0; }
.chart-box--tall { height: 460px; }
.chart-box--short { height: 240px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s-3); font-size: var(--t-sm); color: var(--ink-muted); margin-top: var(--s-3); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- Methods drawer */
.drawer {
  border: 1px solid var(--sage-300);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin: var(--s-5) 0;
  background: var(--sage-50);
}
.drawer__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3);
  padding: 0.8rem 1.1rem;
  cursor: pointer; user-select: none;
  background: var(--sage-50);
}
.drawer__head:hover { background: var(--sage-100); }
.drawer__head h3, .drawer__head h4 {
  margin: 0; font-size: var(--t-base); color: var(--sage-700);
  font-family: var(--font-sans); font-weight: 650;
  display: flex; align-items: center; gap: var(--s-2);
}
.drawer__chev { color: var(--sage-600); transition: transform 0.25s; font-size: 0.9em; }
.drawer.is-open .drawer__chev { transform: rotate(180deg); }
.drawer__body {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--card-2);
}
.drawer.is-open .drawer__body { max-height: 2400px; }
.drawer__inner { padding: var(--s-4) 1.1rem; line-height: var(--leading-normal); font-size: var(--t-sm); }
.drawer__inner h4 { color: var(--sage-700); margin: var(--s-3) 0 var(--s-2); }
.drawer__inner ul { margin: var(--s-2) 0; }

/* ---------------------------------------------------------------- Callouts */
.callout {
  border-left: 3px solid var(--clay-500);
  background: var(--clay-100);
  padding: var(--s-3) var(--s-4);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  font-size: var(--t-sm);
}
.callout--info { border-color: var(--info); background: #dceaf0; }
.callout--warn { border-color: var(--warn); background: #f4e6cd; }
.callout strong { color: var(--ink); }

/* data-health strip */
.health {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--s-4);
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.health__item .label { font-size: var(--t-xs); color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.health__item .value { font-size: var(--t-md); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- Empty / error states */
.empty {
  text-align: center; padding: var(--s-7) var(--s-4);
  color: var(--ink-muted);
}
.empty__mark { font-size: 2.5rem; color: var(--sage-300); margin-bottom: var(--s-3); }

/* ---------------------------------------------------------------- Footer */
.site-foot {
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  margin-top: var(--s-8);
  padding: var(--s-6) 0;
  font-size: var(--t-sm);
  color: var(--ink-muted);
}
.site-foot a { color: var(--sage-700); }
.site-foot__meta { margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); font-size: var(--t-xs); color: var(--ink-faint); }

/* ---------------------------------------------------------------- Utility spacing */
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }

/* ============================================================ Responsive */
@media (max-width: 820px) {
  .grid--2, .grid--3, .grid--charts { grid-template-columns: 1fr; }
  .masthead__inner { padding: var(--s-5) 0 var(--s-4); }

  .nav__toggle { display: block; order: -1; }
  .nav__inner { flex-wrap: wrap; }
  .nav__links {
    display: none; flex-direction: column; align-items: stretch;
    width: 100%; gap: 0;
    border-top: 1px solid var(--line); margin-top: var(--s-2);
    max-height: 70vh; overflow-y: auto;
  }
  .nav__links.is-open { display: flex; }
  .nav a.nav__link { padding: 0.9rem 0.4rem; border-bottom: 1px solid var(--line-soft); border-left: 2px solid transparent; }
  .nav a.nav__link.is-active { border-bottom-color: var(--line-soft); border-left-color: var(--clay-500); }
  .chart-box { height: 300px; }
}

@media (max-width: 520px) {
  .container { padding: 0 var(--s-4); }
  .stats { grid-template-columns: 1fr 1fr; }
  .wordmark__name { font-size: var(--t-xl); }
  .card { padding: var(--s-4); }
}

@media print {
  .nav, .site-foot, .hotspot, .btn, .drawer__head { display: none !important; }
  body { background: #fff; }
  .card, .stat { box-shadow: none; border-color: #ccc; }
}
