/* Home page. Tokens in tokens.css. */

/* ---------------------------------------------------------------- nav: quiet, floats over the photo */
.nav { position: fixed; inset: 0 0 auto; z-index: 30; display: flex; align-items: center; gap: var(--s6);
  padding: max(var(--s4), env(safe-area-inset-top)) clamp(var(--s4), 4vw, var(--s7)) var(--s4);
  transition: background-color 300ms, -webkit-backdrop-filter 300ms, backdrop-filter 300ms; }
.nav.solid { background: rgb(11 20 16 / .72); -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 0 var(--line); }
.brand { display: flex; align-items: center; gap: var(--s2); text-decoration: none; font: 600 1.2rem/1 var(--display); }
.nav nav { display: flex; gap: var(--s5); margin-left: auto; }
.nav nav a { font: 500 var(--t-small)/1 var(--ui); text-decoration: none; color: var(--mist-80); padding: var(--s2) 0; }
.nav nav a:hover { color: var(--mist-100); }
@media (max-width: 40rem) { .nav nav a:not(:first-child) { display: none; } }

/* ---------------------------------------------------------------- hero */
.hero { position: relative; z-index: 2; min-height: 100svh; display: grid; grid-template-rows: 1fr auto; isolation: isolate; }
.slides, .scrim { position: absolute; inset: 0; z-index: -1; }
.slides { overflow: clip; }  /* clip the drifting photos here, not on .hero, so the search results can hang below it */
.slide { position: absolute; inset: 0; opacity: 0; transition: opacity 1600ms var(--ease-out); }
.slide.on { opacity: 1; }
.slide img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.04); transform-origin: var(--focus, 50% 50%); }
/* Slow drift while a slide shows: transform only, so it stays on the compositor. */
.slide.on img { animation: drift 9s linear forwards; }
@keyframes drift { to { transform: scale(1.12) translate3d(var(--dx, -1.5%), 0, 0); } }
.hero.paused .slide.on img { animation-play-state: paused; }
/* Legibility: a left and bottom scrim, not a full dark overlay, so the bird keeps its colour. */
.scrim { background:
  linear-gradient(90deg, rgb(8 15 12 / .85) 0%, rgb(8 15 12 / .5) 38%, transparent 66%),
  linear-gradient(0deg, rgb(8 15 12 / .85) 0%, transparent 32%),
  linear-gradient(180deg, rgb(8 15 12 / .55) 0%, transparent 18%); }

.hero-copy { position: relative; z-index: 2; align-self: center; padding: 7rem clamp(var(--s4), 6vw, var(--s8)) var(--s6); max-width: 54rem; }
.hero h1 { margin: var(--s3) 0 var(--s4); font: 400 var(--t-hero)/.92 var(--display); letter-spacing: var(--track-hero);
  font-variation-settings: "opsz" 144; text-wrap: balance; }
.hero h1 em { font-style: italic; color: var(--sun-200); }
.hero-lead { margin: 0 0 var(--s6); max-width: 32rem; font-size: var(--t-lead); line-height: 1.45; color: var(--mist-80); text-wrap: pretty; }
.hero-copy > * { animation: rise var(--d-hero) var(--spring) both; }
.hero-copy > :nth-child(2) { animation-delay: 80ms; } .hero-copy > :nth-child(3) { animation-delay: 160ms; }
.hero-copy > :nth-child(4) { animation-delay: 240ms; } .hero-copy > :nth-child(5) { animation-delay: 320ms; }
@keyframes rise { from { opacity: 0; transform: translate3d(0, 1.5rem, 0); } }

/* Search: the primary action, so it is the biggest control on the page.
   z-index lifts it (and its results list) above the later hero lines and the hero foot: each hero line animates
   in with a transform and the glass has a backdrop-filter, so each is its own layer and would otherwise paint on top. */
.hero-search { position: relative; z-index: 10; display: flex; align-items: center; gap: var(--s3); max-width: 34rem;
  padding: 0 var(--s4); border-radius: var(--r-card); }
.hero-search svg { width: 1.25rem; flex: none; fill: none; stroke: var(--mist-80); stroke-width: 2; stroke-linecap: round; }
.hero-search input { flex: 1; min-width: 0; height: 3.6rem; border: 0; background: none; font-size: 1.05rem; }
.hero-search input:focus { outline: none; }
.hero-search:focus-within { border-color: var(--sun-400); box-shadow: 0 0 0 4px rgb(232 176 75 / .18); }
.hero-search input::placeholder { color: var(--mist-60); }
.hero-or { margin: var(--s4) 0 0 var(--s1); color: var(--mist-60); font-size: var(--t-small); }
.hero-or a { color: var(--mist-100); text-underline-offset: 3px; }

.results { position: absolute; z-index: 5; top: calc(100% + var(--s2)); left: 0; right: 0; margin: 0; padding: var(--s2);
  list-style: none; border-radius: var(--r-card); max-height: min(26rem, 60vh); overflow: auto;
  background: rgb(12 22 17); border: 1px solid var(--glass-border); box-shadow: 0 18px 48px rgb(0 0 0 / .5); transform-origin: top; animation: pop var(--d-ui) var(--spring); }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(-4px); } }
.results li { display: grid; grid-template-columns: 1fr auto; column-gap: var(--s3); padding: .6rem .8rem;
  border-radius: var(--r-inner); cursor: pointer; }
.results li[aria-selected="true"], .results li:hover { background: rgb(255 255 255 / .09); }
.results .r-name { font-weight: 500; }
.results i { grid-column: 1; color: var(--mist-60); font-size: var(--t-small); }
.results .r-meta { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-size: var(--t-micro); color: var(--mist-60); text-align: right; }
.results .r-meta b { color: var(--fern-300); font-weight: 600; }

.hero-foot { display: grid; grid-template-columns: 1fr auto auto; align-items: end; gap: var(--s4);
  padding: 0 clamp(var(--s4), 6vw, var(--s8)) max(var(--s5), env(safe-area-inset-bottom)); }
.now { display: grid; gap: .15rem; text-decoration: none; justify-self: start; }
.now strong { font: 400 1.35rem/1.1 var(--display); }
.now i { color: var(--mist-60); font-size: var(--t-small); }
.now:hover strong { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.dots { display: flex; gap: var(--s2); }
.dots button { position: relative; width: 2.75rem; height: 2.75rem; border: 0; background: none; padding: 0; cursor: pointer; }
.dots button::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 3px; border-radius: 2px; background: var(--mist-30); }
.dots button::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 3px; border-radius: 2px;
  background: var(--mist-100); transform: scaleX(0); transform-origin: left; }
.dots button[aria-current="true"]::after { animation: fill var(--slide, 7s) linear forwards; }
.hero.paused .dots button[aria-current="true"]::after { animation-play-state: paused; }
@keyframes fill { to { transform: scaleX(1); } }
.pause { width: 2.75rem; height: 2.75rem; border-radius: 50%; border: 1px solid var(--glass-border); background: var(--glass-bg);
  display: grid; place-items: center; cursor: pointer; }
.pause svg { width: 1rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pause .i-play { display: none; fill: currentColor; }
.pause[aria-pressed="true"] .i-play { display: block; } .pause[aria-pressed="true"] .i-pause { display: none; }
.hero-credit { grid-column: 1 / -1; margin: 0; }
@media (max-width: 40rem) {
  .hero-foot { grid-template-columns: 1fr auto; }
  .dots { grid-row: 2; }
}

/* ---------------------------------------------------------------- bands */
.band { padding: var(--s9) clamp(var(--s4), 6vw, var(--s8)); }
.wrap { max-width: var(--wide); margin: 0 auto; }
.band h2 { margin: var(--s3) 0 var(--s4); font: 400 var(--t-h1)/1.02 var(--display); letter-spacing: var(--track-h1); text-wrap: balance; }
.lead { max-width: var(--measure); font-size: var(--t-lead); line-height: 1.5; color: var(--mist-80); margin: 0 0 var(--s6); }

/* Scroll reveals: CSS scroll-driven where supported (Chrome, Safari), IntersectionObserver otherwise. Never scroll-jacked. */
@supports (animation-timeline: view()) {
  [data-reveal] { animation: rise linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }
}
@supports not (animation-timeline: view()) {
  .js [data-reveal] { opacity: 0; transform: translate3d(0, 1.5rem, 0); transition: opacity var(--d-reveal) var(--ease-out), transform var(--d-reveal) var(--spring); }
  .js [data-reveal].in { opacity: 1; transform: none; }
}

.numbers { padding-block: var(--s7); border-block: 1px solid var(--line); background: var(--canopy-900); }
.numbers ul { max-width: var(--wide); margin: 0 auto; padding: 0; list-style: none; display: grid; gap: var(--s5);
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
.numbers li { display: grid; gap: var(--s1); }
.numbers b { font: 400 clamp(2rem, 1.5rem + 2vw, 3.25rem)/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.numbers span { color: var(--mist-60); font-size: var(--t-small); }

/* Bird of the day: one big editorial card. */
.today-card { max-width: var(--wide); margin: 0 auto; display: grid; grid-template-columns: 1.25fr 1fr; gap: 0;
  border-radius: calc(var(--r-card) * 1.6); overflow: hidden; background: var(--canopy-800); border: 1px solid var(--line); }
.today-card figure { margin: 0; position: relative; min-height: 26rem; }
.today-card figure img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.today-card figcaption { position: absolute; left: var(--s4); bottom: var(--s3); right: var(--s4); text-shadow: 0 1px 6px rgb(0 0 0 / .6); }
.today-body { padding: clamp(var(--s5), 4vw, var(--s7)); display: flex; flex-direction: column; gap: var(--s4); }
.today-body h3 { margin: 0; font: 400 var(--t-h1)/1 var(--display); letter-spacing: var(--track-h1); }
.today-body h3 + i { color: var(--mist-60); margin-top: calc(var(--s3) * -1); }
.today-body p { margin: 0; color: var(--mist-80); }
.today-facts { display: flex; flex-wrap: wrap; gap: var(--s2); }
.today-facts .chip { background: rgb(255 255 255 / .04); }
.today-card .button { align-self: start; margin-top: auto; }
@media (max-width: 52rem) { .today-card { grid-template-columns: 1fr; } .today-card figure { min-height: 20rem; } }

.button { display: inline-flex; align-items: center; gap: var(--s2); padding: .9rem 1.4rem; border-radius: var(--r-pill);
  background: var(--sun-400); color: var(--canopy-950); font-weight: 600; text-decoration: none; }
.button::after { content: "→"; transition: transform var(--d-ui) var(--spring); }
.button:hover::after { transform: translateX(4px); }

/* Conservation: one stacked bar, true proportions (lie factor 1), labels on the segments that fit. */
.iucn-bar { display: flex; height: 4.5rem; border-radius: var(--r-inner); overflow: hidden; gap: 2px; margin-bottom: var(--s4); }
.iucn-bar span { flex: var(--n) 1 0; min-width: 3px; display: flex; align-items: flex-end; padding: var(--s2);
  font: 700 var(--t-micro)/1 var(--ui); color: #0B1410; transform-origin: left; }
.iucn-bar span.dark { color: #fff; }
@supports (animation-timeline: view()) {
  .iucn-bar span { animation: grow linear both; animation-timeline: view(); animation-range: entry 10% cover 40%; }
}
@keyframes grow { from { transform: scaleX(0); } }
.iucn-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); padding: 0; margin: 0 0 var(--s4); list-style: none; font-size: var(--t-small); }
.iucn-legend b { font-variant-numeric: tabular-nums; }

/* Families: a horizontal rail with scroll-snap (native momentum; no carousel library). */
.families { padding-inline: 0; }
/* The rail's first card lines up with the heading; later cards bleed to the screen edge. */
.families { --gutter: max(clamp(var(--s4), 6vw, var(--s8)), calc((100% - var(--wide)) / 2)); }
.families .wrap { max-width: none; padding-inline: var(--gutter); }
.rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(15rem, 19rem); gap: var(--s4); margin: 0; list-style: none;
  padding: var(--s5) var(--gutter) var(--s4); overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter); scrollbar-width: thin; }
.rail li { scroll-snap-align: start; }
.fam { display: block; position: relative; aspect-ratio: 3 / 4; border-radius: var(--r-card); overflow: hidden; text-decoration: none;
  background: var(--canopy-800); }
.fam img { width: 100%; height: 100%; object-fit: cover; transition: transform 900ms var(--ease-out); }
.fam:hover img { transform: scale(1.05); }
.fam::after { content: ""; position: absolute; inset: 0; background: linear-gradient(0deg, rgb(8 15 12 / .9), transparent 55%); }
.fam div { position: absolute; z-index: 1; left: var(--s4); right: var(--s4); bottom: var(--s4); display: grid; gap: var(--s1); }
.fam strong { font: 400 1.5rem/1.05 var(--display); }
.fam span { font-size: var(--t-small); color: var(--mist-80); }

.explore-cta { text-align: center; background: radial-gradient(60rem 30rem at 50% 120%, var(--canopy-700), transparent), var(--canopy-950); }
.explore-cta h2 { margin-inline: auto; max-width: 20ch; }

.foot { padding: var(--s7) clamp(var(--s4), 6vw, var(--s8)); border-top: 1px solid var(--line); color: var(--mist-60);
  font-size: var(--t-small); }
.foot p { max-width: 50rem; }

/* Cross-document view transitions (Chrome, Safari): the bird-of-the-day photo morphs into the species hero. */
@view-transition { navigation: auto; }
.today-card figure img { view-transition-name: hero-photo; }
::view-transition-group(hero-photo) { animation-duration: 520ms; animation-timing-function: var(--spring); }
/* Wordmark: "I [heart-bird] Birds"; the heart-bird stands for "Love" (spoken via .sr-only). */
.wordmark { display: inline-flex; align-items: center; gap: .32em; white-space: nowrap; }
.wordmark .mark { width: 1.2em; height: 1.2em; fill: var(--sun-400); flex: none; margin-top: -.14em; }
.wordmark em { font-style: italic; font-weight: 400; color: var(--sun-200, #F6DBA4); }
