/* ─── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #FBFBFD;
  --surface: #FFFFFF;
  --surface-2: #F5F5F7;
  --border: rgba(0,0,0,0.08);
  --border-strong: rgba(0,0,0,0.14);
  --border-hover: rgba(0,0,0,0.12);
  --text-primary: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #AEAEB2;
  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-light: #E8F4FD;
  --accent-dark: #005BBB;
  --green: #34C759;
  --green-light: #E8F8EE;
  --red: #FF3B30;
  --red-light: #FFF0EF;
  --warn-bg: #FFF5E6;
  --warn-text: #E08000;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --nav-h: 52px;
  --nav-bg: rgba(251, 251, 253, 0.85);
  --hero-from: #F0F4FF;
}

[data-theme="dark"] {
  --bg: #000000;
  --surface: #1C1C1E;
  --surface-2: #2C2C2E;
  --border: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.16);
  --border-hover: rgba(255,255,255,0.2);
  --text-primary: #F5F5F7;
  --text-secondary: #A1A1A6;
  --text-tertiary: #6E6E73;
  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --accent-light: rgba(10,132,255,0.15);
  --accent-dark: #0071E3;
  --green: #32D74B;
  --green-light: rgba(50,215,75,0.15);
  --red: #FF453A;
  --red-light: rgba(255,69,58,0.15);
  --warn-bg: rgba(224,128,0,0.15);
  --warn-text: #FF9F0A;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.7), 0 4px 12px rgba(0,0,0,0.4);
  --nav-bg: rgba(0,0,0,0.85);
  --hero-from: #070710;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1C1C1E;
    --surface-2: #2C2C2E;
    --border: rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.16);
    --border-hover: rgba(255,255,255,0.2);
    --text-primary: #F5F5F7;
    --text-secondary: #A1A1A6;
    --text-tertiary: #6E6E73;
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-light: rgba(10,132,255,0.15);
    --accent-dark: #0071E3;
    --green: #32D74B;
    --green-light: rgba(50,215,75,0.15);
    --red: #FF453A;
    --red-light: rgba(255,69,58,0.15);
    --warn-bg: rgba(224,128,0,0.15);
    --warn-text: #FF9F0A;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.4), 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.7), 0 4px 12px rgba(0,0,0,0.4);
    --nav-bg: rgba(0,0,0,0.85);
    --hero-from: #070710;
  }
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* ─── Nav ────────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--nav-h);
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.nav-bird-icon {
  width: 22px; height: 22px;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 24px;
}

.nav-links a {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color .2s;
}

.nav-links a:hover { color: var(--text-primary); }

/* ─── Mobile nav toggle (hamburger) ──────────────────────────────────── */
.nav-mobile-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0;
  margin-right: 6px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.nav-mobile-toggle:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}
.nav-mobile-toggle .nav-ham-close { display: none; }
.nav.nav-mobile-open .nav-mobile-toggle .nav-ham-open  { display: none; }
.nav.nav-mobile-open .nav-mobile-toggle .nav-ham-close { display: block; }

/* Prevents layout shift when menu opens on iOS */
body.nav-mobile-locked { overflow: hidden; }

/* ─── Hero ───────────────────────────────────────────────────────────── */
.hero {
  padding: calc(var(--nav-h) + 72px) 24px 56px;
  text-align: center;
  background: linear-gradient(180deg, var(--hero-from) 0%, var(--bg) 100%);
}

.hero-content {
  max-width: 680px;
  margin: 0 auto;
}


.hero-title {
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 700;
  letter-spacing: -1.5px;
  line-height: 1.05;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.hero-title-accent {
  background: linear-gradient(135deg, #0071E3 0%, #34C759 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 18px;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 500px;
  margin: 0 auto;
}

/* ─── Search Card ────────────────────────────────────────────────────── */
.search-section {
  padding: 0 24px 56px;
  display: flex;
  justify-content: center;
}

.search-card {
  width: 100%;
  max-width: 760px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

/* Fields */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.input-icon-wrap {
  position: relative;
}

.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.field-input {
  width: 100%;
  height: 46px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0 14px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: border-color .18s, box-shadow .18s, background .18s;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.input-icon-wrap .field-input {
  padding-left: 36px;
}

.field-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.12);
}

.field-input::placeholder { color: var(--text-tertiary); }

.field-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%236E6E73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.field-row {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

#searchForm .field-group:first-child {
  margin-bottom: 0;
}

/* Search button */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 52px;
  margin-top: 24px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
  cursor: pointer;
  transition: background .18s, transform .1s, box-shadow .18s;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.3);
}

.search-btn:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 16px rgba(0, 113, 227, 0.35);
}

.search-btn:active { transform: scale(0.985); }

.search-btn.loading {
  opacity: 0.7;
  pointer-events: none;
}

.btn-icon { width: 18px; height: 18px; }

/* ─── Loading ────────────────────────────────────────────────────────── */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 16px;
}

.loading-spinner {
  width: 40px; height: 40px;
  position: relative;
}

.spinner-ring {
  width: 40px; height: 40px;
  border: 3px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ─── Error ──────────────────────────────────────────────────────────── */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
  gap: 12px;
}

.error-icon svg {
  width: 40px; height: 40px;
  color: var(--red);
}

.error-message {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: center;
  max-width: 400px;
}

/* ─── Stats Bar ──────────────────────────────────────────────────────── */
.stats-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.stats-inner {
  max-width: 1100px;
  margin: 0 auto;
  height: 72px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 32px;
  gap: 2px;
  white-space: nowrap;
}

.stat-item.stat-location {
  flex-direction: row;
  gap: 6px;
  align-items: center;
}

.stat-number {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.stat-date {
  font-size: 13px;
  font-weight: 600;
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-location-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-pin {
  width: 14px; height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.stat-divider {
  width: 1px;
  height: 32px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── Filter Bar ─────────────────────────────────────────────────────── */
.filter-bar {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.filter-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-mini-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}

.search-mini-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-tertiary);
  pointer-events: none;
}

.search-mini {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 32px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color .18s;
}

.search-mini:focus { border-color: var(--accent); }
.search-mini::placeholder { color: var(--text-tertiary); }

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sort-select {
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M6 9l6 6 6-6' stroke='%236E6E73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color .18s;
}

.sort-select:focus { border-color: var(--accent); }

/* ─── Cards Grid ─────────────────────────────────────────────────────── */
.cards-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.bird-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* Bird Card */
.bird-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: default;
  transition: transform .2s, box-shadow .2s, border-color .2s;
  animation: cardIn .3s ease both;
}

.bird-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-bird-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-bird-icon svg {
  width: 24px; height: 24px;
  color: var(--accent);
}

.card-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-light);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

.card-names { flex: 1; min-width: 0; }

.card-common-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-sci-name {
  font-size: 12px;
  font-style: italic;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.card-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.card-meta-row svg {
  width: 13px; height: 13px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.card-meta-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ebird-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  transition: opacity .15s;
}

.ebird-link:hover { opacity: 0.75; }

.ebird-link svg { width: 10px; height: 10px; }

/* ─── No Filter ──────────────────────────────────────────────────────── */
.no-filter {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 64px 24px;
  gap: 12px;
  color: var(--text-tertiary);
  font-size: 15px;
}

.no-filter-icon {
  width: 32px; height: 32px;
  color: var(--text-tertiary);
}

/* ─── Empty State ────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 72px 24px;
  gap: 12px;
  text-align: center;
}

.empty-icon {
  width: 80px; height: 80px;
  margin-bottom: 4px;
}

.empty-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-sub {
  font-size: 15px;
  color: var(--text-secondary);
  max-width: 360px;
  line-height: 1.5;
}

/* ─── About Section ──────────────────────────────────────────────────── */
.about-section {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 80px 24px;
}

.about-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.about-icon {
  width: 52px; height: 52px;
  margin-bottom: 16px;
}

.about-icon svg {
  width: 52px; height: 52px;
}

.about-card h4 {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}

.about-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── Footer ─────────────────────────────────────────────────────────── */
.footer {
  background: #1D1D1F;
  padding: 32px 24px;
}

.footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.footer-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: white;
}

.footer-bird {
  width: 20px; height: 20px;
  color: var(--accent);
}

.footer-copy {
  font-size: 13px;
  color: #6E6E73;
}

.footer-copy a {
  color: var(--accent);
  text-decoration: none;
}

/* ─── Filter Tabs ────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.filter-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

.filter-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

.filter-tab:not(.active):hover { color: var(--text-primary); }

/* ─── Birdhouse Stat ──────────────────────────────────────────────────── */
.stat-birdhouse { color: var(--accent); }

.stat-item-clickable {
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .15s;
  padding: 6px 32px;
}

.stat-item-clickable:hover { background: var(--surface-2); }

.stat-item-clickable.active {
  background: var(--accent-light);
}

.stat-item-clickable.active .stat-label { color: var(--accent); }

/* ─── Birdhouse Badge on Card ────────────────────────────────────────── */
.card-birdhouse-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 999px;
  padding: 3px 8px;
  margin-top: 10px;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: background .15s;
}

.card-birdhouse-badge:hover { background: var(--accent-light); filter: brightness(1.15); }

.card-birdhouse-badge svg { width: 11px; height: 11px; }

/* ─── Birdhouse Spec Panel ────────────────────────────────────────────── */
.birdhouse-panel {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  display: none;
}

.birdhouse-panel.open { display: block; }

.birdhouse-panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}

.spec-item {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.spec-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.spec-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.2px;
}

.spec-value.accent { color: var(--accent); }

.spec-full {
  grid-column: 1 / -1;
}

.spec-note {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 8px;
}

.spec-print-note {
  font-size: 11.5px;
  color: var(--accent);
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.spec-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.spec-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
}

.spec-badge.yes { background: var(--green-light); color: var(--green); }
.spec-badge.warn { background: var(--warn-bg); color: var(--warn-text); }

/* ─── Theme Toggle ───────────────────────────────────────────────────── */
.theme-toggle {
  width: 34px;
  height: 34px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
  padding: 0;
}

.theme-toggle:hover {
  background: var(--surface);
  color: var(--text-primary);
}

/* Light mode shows moon (click → go dark) */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

/* Dark mode shows sun (click → go light) */
[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ─── Utilities ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Hero bird animation ────────────────────────────────────────────── */

.hero-content { position: relative; }

/* Tight bounding box on the "h" so its top-edge ≈ visual cap top */
#earthH {
  display: inline-block;
  line-height: 1;
  vertical-align: baseline;
}

/* Zero-size anchor — JS positions this at the visual top of the "h" cap */
.hero-bird {
  position: absolute;
  width: 0;
  height: 0;
  pointer-events: none;
  color: var(--accent);
  z-index: 10;
}

/* Hide the bird animation on phones — its 88px sprite and pixel-based
   flight path were tuned for the desktop hero (~70px title). On a 36px
   mobile title the bird covers the "h" of "Earth" and overlaps the "S"
   of "birds" mid-flight. The hero text reads cleaner without it. */
@media (max-width: 768px) {
  .hero-bird { display: none; }
}

/* ── Unified bird SVG (warbler) ───────────────────────────────────────── */
.hb-svg {
  display: block;
  width: 88px;
  height: 42px;
  position: absolute;
  /* Pivot for landing translateY is the bottom-centre (the perch line) */
  transform-box: fill-box;
  transform-origin: 50% 100%;
  /*
    Anchor maps to the warbler's body-bottom line (viewBox-y 28 of 38 = 74%).
    During flight the body's underside tracks the path. At path end (0,0)
    the body bottom rests at the visual top of the "h". On landing,
    .is-landed translates the SVG up by the leg length so the legs+claws
    (viewBox-y 26–37) extend down and the claws end at (0,0).

    Path: two G1-continuous cubic-bezier segments, slightly above the
    title baseline at start, peaking high above the title, descending
    with a horizontal flare at the landing point.
  */
  offset-path: path("M -900,16 C -660,16 -460,-110 -230,-110 C -120,-110 -42,0 0,0");
  offset-rotate: auto;
  offset-anchor: 50% 74%;
  opacity: 0;
  will-change: offset-distance, transform, opacity;
}

/* ── Wing flap during flight ──────────────────────────────────────────── */
.hb-wing {
  transform-box: fill-box;
  transform-origin: 90% 95%;   /* wing root, near where it joins the body */
  /* Wing only visible while flying — keeps the perched silhouette's back
     a single smooth curve (body → head) with no upper-back protrusion. */
  opacity: 0;
  transition: opacity 0.3s ease-out, transform 0.5s cubic-bezier(0.45, 0, 0.15, 1);
}

@keyframes wingBeat {
  0%, 100% { transform: scaleY(1);     }
  50%      { transform: scaleY(-0.55); }
}

/* ── Legs (hidden during flight; scale-extend on landing) ─────────────── */
.hb-legs {
  transform-box: fill-box;
  transform-origin: 50% 0%;     /* grow downward from body attachment */
  transform: scaleY(0);
  opacity: 0;
  /* Same easing for both transforms keeps legs in sync with body lift */
  transition:
    transform 0.55s cubic-bezier(0.34, 1.45, 0.64, 1) 0.06s,
    opacity   0.20s ease-out 0.10s;
}

/* ── Flight ride (offset-path traversal) ──────────────────────────────── */
@keyframes birdRide {
  from { offset-distance: 0%;   opacity: 0; }
  4%   {                        opacity: 1; }
  to   { offset-distance: 100%; opacity: 1; }
}

/* ── Idle sway after landing ──────────────────────────────────────────── */
@keyframes birdSway {
  0%, 100% { transform: translateY(-10px) rotate(0deg);    }
  30%      { transform: translateY(-10px) rotate(2.5deg);  }
  70%      { transform: translateY(-10px) rotate(-2deg);   }
}

/* ── State classes ────────────────────────────────────────────────────── */

/* Flying: ride the path, wing flaps */
.hero-bird.is-flying .hb-svg {
  animation: birdRide 3.2s cubic-bezier(0.42, 0, 0.06, 1) forwards;
}
.hero-bird.is-flying .hb-wing {
  opacity: 1;
  animation: wingBeat 0.42s ease-in-out infinite;
}

/* Landed: bird stays at path end (offset-distance held by `forwards`),
   body lifts ~15 px, legs+claws extend down, wing folds slightly. */
.hero-bird.is-landed .hb-svg {
  /* Keep the bird at the landing position the path animation produced */
  offset-distance: 100%;
  opacity: 1;
  /* Gentle settle bounce in: lift the body to its perched height */
  animation: birdSway 4.5s ease-in-out 0.6s infinite;
  transform: translateY(-10px);
  transition: transform 0.55s cubic-bezier(0.34, 1.45, 0.64, 1);
}

.hero-bird.is-landed .hb-legs {
  transform: scaleY(1);
  opacity: 1;
}

/* Wing folds slightly toward the body — animation off, transform smoothly in */
.hero-bird.is-landed .hb-wing {
  animation: none;
  transform: rotate(-12deg) scale(0.85);
}

/* ── Shockwave burst when bird passes through a letter ────────────────── */
.letter-burst {
  position: absolute;
  width: 0; height: 0;
  pointer-events: none;
  z-index: 9;
}
.letter-burst::before,
.letter-burst::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
}
.letter-burst::before {
  width: 72px; height: 72px;
  background: radial-gradient(circle, rgba(0,113,227,0.22) 0%, transparent 68%);
  animation: burstRing 0.6s ease-out forwards;
}
.letter-burst::after {
  width: 38px; height: 38px;
  background: radial-gradient(circle, rgba(52,199,89,0.28) 0%, transparent 70%);
  animation: burstRing 0.42s ease-out 0.1s forwards;
}
@keyframes burstRing {
  0%   { transform: translate(-50%, -50%) scale(0);   opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}

/* ─── Trust strip (under hero search) ────────────────────────────────── */
.trust-strip {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 18px 24px;
  margin-top: 24px;
}
.trust-strip-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px;
}
.trust-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.trust-item strong {
  color: var(--text-primary);
  font-weight: 600;
}
.trust-flag {
  width: 22px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}
.trust-icon {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex-shrink: 0;
}
.trust-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
}

/* ─── Mission Section ────────────────────────────────────────────────── */
.mission-section {
  background: linear-gradient(180deg, var(--bg) 0%, var(--surface-2) 100%);
  border-top: 1px solid var(--border);
  padding: 96px 24px;
}
.mission-inner {
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}
.mission-eyebrow,
.system-eyebrow,
.drops-eyebrow,
.about-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}
.mission-headline {
  font-size: 56px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1.2px;
  color: var(--text-primary);
  margin-bottom: 20px;
}
.mission-headline-accent {
  background: linear-gradient(135deg, #34C759 0%, #0071E3 50%, #5856D6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mission-lede {
  font-size: 19px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 680px;
  margin: 0 auto 64px;
}
.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 56px;
  text-align: left;
}
.mission-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.mission-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}
.mission-card-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mission-card-icon svg {
  width: 100%;
  height: 100%;
}
.mission-card h3 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.mission-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}
.mission-pledge {
  font-size: 22px;
  line-height: 1.5;
  color: var(--text-primary);
  font-weight: 400;
  letter-spacing: -0.3px;
  max-width: 720px;
  margin: 0 auto;
}
.mission-pledge strong {
  font-weight: 600;
  color: var(--accent);
}

/* ─── System (How It Works) ─────────────────────────────────────────── */
.system-section {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 96px 24px;
}
.system-inner {
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}
.system-headline {
  font-size: 44px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1px;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.system-lede {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto 56px;
}
.system-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  text-align: left;
}
.system-step {
  position: relative;
  padding: 32px 24px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.system-step-num {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--accent);
  margin-bottom: 12px;
}
.system-step h4 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.system-step p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* ─── Drops Section ─────────────────────────────────────────────────── */
.drops-section {
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--bg) 100%);
  border-top: 1px solid var(--border);
  padding: 96px 24px;
}
.drops-inner {
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
}
.drops-headline {
  font-size: 44px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1px;
  color: var(--text-primary);
  margin-bottom: 16px;
}
.drops-headline-accent {
  background: linear-gradient(135deg, #FF9500 0%, #FF3B30 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.drops-lede {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto 56px;
}
.drops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-bottom: 64px;
  text-align: left;
}
.drop-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.drop-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.drop-card-tag {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(0,113,227,0.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 100px;
  z-index: 2;
}
.drop-card-art {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}
.drop-card-art svg { width: 60%; height: 80%; }
.drop-art-spring {
  background: linear-gradient(135deg, #E8F8EE 0%, #D4F1FF 100%);
  color: #34C759;
}
.drop-art-halloween {
  background: linear-gradient(135deg, #FFF0E0 0%, #FFE5D4 100%);
  color: #FF9500;
}
.drop-art-conservation {
  background: linear-gradient(135deg, #E8F4FD 0%, #D4E8FF 100%);
  color: #0071E3;
}
[data-theme="dark"] .drop-art-spring {
  background: linear-gradient(135deg, rgba(52,199,89,0.18) 0%, rgba(0,113,227,0.18) 100%);
}
[data-theme="dark"] .drop-art-halloween {
  background: linear-gradient(135deg, rgba(255,149,0,0.18) 0%, rgba(255,69,58,0.18) 100%);
}
[data-theme="dark"] .drop-art-conservation {
  background: linear-gradient(135deg, rgba(0,113,227,0.18) 0%, rgba(88,86,214,0.18) 100%);
}
.drop-card h4 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  margin: 24px 24px 8px;
}
.drop-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 0 24px 16px;
}
.drop-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

/* Drops CTA */
.drops-cta {
  max-width: 540px;
  margin: 0 auto;
  text-align: center;
  padding: 48px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}
.drops-cta h3 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.drops-cta > p {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-secondary);
  margin-bottom: 24px;
}
.drops-form {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.drops-email {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.drops-email:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}
.drops-submit {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.drops-submit:hover { background: var(--accent-hover); }
.drops-submit:active { transform: scale(0.97); }
.drops-fineprint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 4px;
}

/* About refresh */
.about-section .about-eyebrow,
.about-section .about-headline {
  text-align: center;
  display: block;
}
.about-eyebrow {
  margin-bottom: 12px;
}
.about-headline {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.7px;
  color: var(--text-primary);
  margin-bottom: 48px;
}

/* Footer refresh */
.footer-inner {
  flex-direction: column;
  align-items: flex-start;
  gap: 24px;
}
.footer-brand {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer-tagline {
  font-size: 14px;
  color: #A1A1A6;
  line-height: 1.5;
  font-weight: 400;
}
.footer-usa {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 6px 10px 6px 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  color: #D1D1D6;
  letter-spacing: 0.1px;
  width: fit-content;
}
.footer-usa-icon {
  width: 22px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
  display: block;
}
.footer-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-links a {
  font-size: 13px;
  color: #A1A1A6;
  text-decoration: none;
  transition: color 0.15s ease;
}
.footer-links a:hover { color: white; }
.footer-copy {
  font-size: 12px;
  color: #6E6E73;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 20px;
  width: 100%;
}

/* ─── Responsive — tablet/mobile nav (≤880px) ───────────────────────── */
@media (max-width: 880px) {
  /* Hamburger sits next to the theme toggle on the right.
     margin-left:auto pushes it (and everything after it) to the right
     edge instead of letting flex space-between put it in the middle. */
  .nav-mobile-toggle {
    display: inline-flex;
    margin-left: auto;
  }

  /* Drop the horizontal nav-links into an absolutely-positioned dropdown
     panel that hangs below the fixed nav bar. */
  .nav-links {
    position: absolute;
    top: var(--nav-h);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    padding: 8px;
    background: var(--nav-bg);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    visibility: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: visibility 0.18s, opacity 0.18s, transform 0.18s;
    pointer-events: none;
  }
  .nav-links a {
    display: block;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
  }
  .nav-links a:hover,
  .nav-links a.nav-active {
    background: var(--surface-2);
    color: var(--accent);
  }
  .nav.nav-mobile-open .nav-links {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}

/* ─── Responsive — phones (≤640px) ─────────────────────────────────── */
@media (max-width: 640px) {
  .hero { padding-top: calc(var(--nav-h) + 48px); }
  .hero-title { font-size: 36px; }
  .hero-sub { font-size: 16px; }
  .search-card { padding: 20px; border-radius: var(--radius-lg); }
  .field-row { flex-direction: column; gap: 12px; }
  .stats-inner { gap: 0; }
  .stat-item { padding: 0 16px; }
  .stat-location-text { max-width: 140px; }
  .bird-grid { grid-template-columns: 1fr; }
  .filter-inner { flex-direction: column; align-items: stretch; }
  .search-mini-wrap { max-width: 100%; }
  .footer-inner { flex-direction: column; text-align: left; }

  /* Trust strip stacks on small screens */
  .trust-strip-inner { flex-direction: column; gap: 12px; }
  .trust-divider { display: none; }
  .trust-item { font-size: 13px; }

  .mission-section,
  .system-section,
  .drops-section,
  .about-section { padding: 64px 20px; }
  .mission-headline { font-size: 36px; }
  .mission-lede { font-size: 16px; }
  .mission-pledge { font-size: 18px; }
  .system-headline,
  .drops-headline { font-size: 30px; }
  .about-headline { font-size: 26px; }
  .drops-cta { padding: 32px 24px; }
  .drops-cta h3 { font-size: 22px; }
  .drops-form { flex-direction: column; }
  .drops-submit { justify-content: center; }
}
