@font-face {
  font-family: 'Fredoka'; font-style: normal; font-weight: 300 700; font-display: swap;
  src: url('../vendor/fonts/fredoka.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito'; font-style: normal; font-weight: 200 1000; font-display: swap;
  src: url('../vendor/fonts/nunito.woff2') format('woff2');
}
@font-face {
  font-family: 'Nunito'; font-style: italic; font-weight: 200 1000; font-display: swap;
  src: url('../vendor/fonts/nunito-italic.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --surface-1: #fcf8ef;      /* paper */
  --surface-2: #f3ecdc;      /* oat */
  --card: #fffdf8;
  --rule: #e6dcc6;
  --text-primary: #2b2722;
  --text-secondary: #5a5248;
  --text-muted: #857b6e;
  --heather: #8a4f8f;
  --heather-soft: #f1e3ef;
  --moss: #4f7a34;
  --moss-soft: #e5efd9;
  --loch: #2c6a88;
  --link: #2c6a88;
  --accent: #8a4f8f;

  /* species, fixed order (validated with the dataviz palette script) */
  --sp-common_frog: #2a78d6;
  --sp-common_toad: #eb6834;
  --sp-palmate_newt: #1baf7a;
  --sp-smooth_newt: #eda100;
  --sp-great_crested_newt: #e87ba4;
  --sp-natterjack_toad: #008300;

  --story-width: 460px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --radius: 18px;
  --shadow: 0 6px 22px rgba(80, 60, 30, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface-1);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 17.5px;
  line-height: 1.6;
}
a { color: var(--link); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--heather); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--heather); outline-offset: 2px; border-radius: 4px; }

.layout {
  display: grid;
  grid-template-columns: var(--story-width) 1fr;
  min-height: 100vh;
}
.story {
  padding: 0 30px 40vh;
  background:
    radial-gradient(circle at 15% 8%, rgba(138, 79, 143, 0.07), transparent 40%),
    radial-gradient(circle at 90% 60%, rgba(79, 122, 52, 0.06), transparent 45%),
    var(--surface-1);
  border-right: 1px solid var(--rule);
  position: relative;
  z-index: 2;
}
.mapwrap { position: sticky; top: 0; height: 100vh; }
#map { position: absolute; inset: 0; }

.loading, .noscript { color: var(--text-muted); padding: 3rem 0; text-align: center; font-family: var(--font-head); font-size: 1.1rem; }
.loading img { display: block; height: 180px; width: auto; margin: 0 auto 0.5rem; animation: bob 3s ease-in-out infinite; }

/* steps */
.step {
  min-height: 85vh;
  padding: 16vh 0 4vh;
  opacity: 0.4;
  transition: opacity 300ms ease;
}
.step.is-active { opacity: 1; }
.step:first-child { padding-top: 6vh; }
.step h1, .step h2 { font-family: var(--font-head); font-weight: 600; color: var(--text-primary); }
.step h1 { font-size: 2.45rem; line-height: 1.08; margin: 0 0 1rem; letter-spacing: -0.005em; }
.step h1 .frog-word { color: var(--moss); }
.step h2 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 0.8rem; }
.step p { margin: 0 0 0.95rem; }

.sticker {
  float: right;
  height: 150px; width: auto;
  margin: -8px 0 6px 14px;
  filter: drop-shadow(0 6px 10px rgba(70, 50, 20, 0.18));
  transform: rotate(4deg);
  animation: bob 4s ease-in-out infinite;
}
.step:nth-child(even) .sticker { transform: rotate(-4deg); animation-delay: -2s; }
.sticker.hero {
  float: none; display: block;
  height: 230px; width: auto;
  margin: 0 auto 0.6rem;
  transform: rotate(-2deg);
}
@keyframes bob {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 -6px; }
}

.kicker {
  display: inline-block;
  background: var(--heather-soft); color: var(--heather);
  font-family: var(--font-head); font-weight: 600; font-size: 0.85rem;
  padding: 3px 12px; border-radius: 999px; margin-bottom: 0.5rem;
}
.big {
  font-family: var(--font-head);
  font-size: 3.1rem;
  font-weight: 600;
  line-height: 1.02;
  margin: 0.3rem 0 0.2rem;
  color: var(--moss);
}
.big-sub { color: var(--text-secondary); margin-bottom: 1rem; font-weight: 600; }
.note { font-size: 0.92rem; color: var(--text-secondary); }
.tip {
  background: var(--moss-soft); border-radius: 12px; padding: 8px 12px;
  font-size: 0.92rem; color: #3b5a27;
}
.source {
  font-size: 0.82rem; color: var(--text-muted);
  border-top: 1px dashed var(--rule); padding-top: 0.5rem; clear: both;
}
.swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 6px; vertical-align: baseline;
}

/* ladder chart */
.ladder {
  clear: both;
  margin: 1rem 0 0.8rem;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 14px 12px 12px; box-shadow: var(--shadow);
}
.ladder svg { display: block; width: 100%; height: auto; overflow: visible; }
.ladder .grid line { stroke: #ece4d2; stroke-width: 1; }
.ladder .ref line { stroke: #c9bda4; stroke-width: 1; }
.ladder text { font-family: var(--font); fill: var(--text-secondary); font-size: 11px; }
.ladder .ref text { fill: var(--text-muted); }
.ladder .col-label { fill: var(--text-primary); font-size: 11.5px; font-weight: 700; }
.ladder .bar { cursor: pointer; }
.ladder .bar rect.hit { fill: transparent; }
.ladder .bar.is-selected rect.mark { stroke: var(--text-primary); stroke-width: 1.5; }
.ladder-controls { display: flex; gap: 12px; align-items: center; font-size: 0.85rem; color: var(--text-secondary); flex-wrap: wrap; margin-top: 0.4rem; }
.ladder-controls button, .pill-button {
  font: inherit; font-size: 0.85rem; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--rule);
  border-radius: 999px; padding: 4px 14px; color: var(--text-primary); cursor: pointer;
}
.ladder-controls button:hover { background: var(--heather-soft); }
.ladder-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.4rem; }
.ladder-legend .key { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.ladder-legend .key.hollow { background: transparent !important; border: 1.5px solid var(--text-secondary); }
.ladder-table { font-size: 0.82rem; max-height: 340px; overflow: auto; border: 1px solid var(--rule); border-radius: 12px; margin-top: 0.5rem; background: var(--card); }
.ladder-table table { width: 100%; border-collapse: collapse; }
.ladder-table th, .ladder-table td { padding: 4px 6px; border-bottom: 1px solid var(--rule); text-align: left; }
.ladder-table tr[data-fid] { cursor: pointer; }
.ladder-table tr[data-fid]:hover { background: var(--heather-soft); }
.ladder-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tooltip {
  position: fixed; pointer-events: none; z-index: 20;
  background: var(--card); border: 1px solid var(--rule); border-radius: 12px;
  padding: 7px 10px; font-size: 0.8rem; line-height: 1.4; box-shadow: var(--shadow);
  max-width: 260px;
}


/* scrolling cues */
.step { scroll-margin-top: 0; }
.scroll-cue {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  margin: 2.2rem auto 0; padding: 12px 22px 10px;
  font: inherit; font-family: var(--font-head); font-weight: 600; font-size: 1.05rem;
  color: #fff; background: var(--moss); border: 0; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 16px rgba(79, 122, 52, 0.35);
  animation: nudge 1.8s ease-in-out infinite;
}
.scroll-cue:hover { background: #426a2a; }
.scroll-cue .chevron {
  width: 14px; height: 14px; border-right: 3px solid #fff; border-bottom: 3px solid #fff;
  transform: rotate(45deg); margin-top: -4px;
}
@keyframes nudge {
  0%, 100% { translate: 0 0; }
  50% { translate: 0 8px; }
}
.next-step {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 1.4rem; padding: 8px 18px;
  font: inherit; font-weight: 700; font-size: 0.95rem;
  color: var(--heather); background: var(--heather-soft);
  border: 1.5px solid #e2c9df; border-radius: 999px; cursor: pointer;
  clear: both;
}
.next-step:hover { background: #e9d3e6; }
.next-step span { font-size: 1.1rem; line-height: 1; }
.the-end { margin-top: 1.4rem; color: var(--text-muted); font-size: 0.92rem; clear: both; }

.progress {
  position: absolute; top: 14px; left: 50%; translate: -50% 0; z-index: 4;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 253, 248, 0.95); border: 1px solid var(--rule); border-radius: 999px;
  padding: 6px 14px 6px 10px; box-shadow: 0 3px 12px rgba(80, 60, 30, 0.12);
  max-width: calc(100% - 24px);
}
.progress .dots { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.progress .dots button {
  display: block; width: 12px; height: 12px; padding: 0; border-radius: 50%; cursor: pointer;
  background: #fff; border: 2px solid #c9bda4; transition: transform 150ms ease;
}
.progress .dots button:hover { transform: scale(1.3); border-color: var(--heather); }
.progress .dots button.is-done { background: #d9c7d8; border-color: #b58fb2; }
.progress .dots button.is-current { background: var(--heather); border-color: var(--heather); transform: scale(1.25); }
.progress-label { font-family: var(--font-head); font-weight: 600; font-size: 0.85rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* map overlays */
.card {
  position: absolute; left: 14px; bottom: 36px; z-index: 5;
  width: min(350px, calc(100% - 28px));
  background: rgba(255, 253, 248, 0.97);
  border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 14px 16px 12px; font-size: 0.86rem; line-height: 1.45;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 4px; font-size: 1.05rem; font-family: var(--font-head); font-weight: 600; }
.card .range { font-family: var(--font-head); font-size: 1.55rem; font-weight: 600; margin: 2px 0 4px; color: var(--moss); }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0; }
.card dt { color: var(--text-muted); }
.card dd { margin: 0; }
.card .close {
  position: absolute; top: 8px; right: 10px; border: 0; background: var(--surface-2);
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 1.1rem; line-height: 1; cursor: pointer; color: var(--text-secondary);
}
.card .close:hover { background: var(--heather-soft); color: var(--heather); }
.legend {
  position: absolute; top: 12px; left: 12px; z-index: 4;
  background: rgba(255, 253, 248, 0.95); border: 1px solid var(--rule); border-radius: 14px;
  padding: 8px 12px; font-size: 0.8rem; color: var(--text-secondary); max-width: 270px;
  box-shadow: 0 3px 12px rgba(80, 60, 30, 0.1);
}
.legend:empty { display: none; }
.legend .row { display: flex; align-items: center; gap: 7px; }
.legend .row + .row { margin-top: 2px; }
.legend .key { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend .key.outline { background: transparent !important; border: 2px solid; }

.maplibregl-ctrl-attrib { font-size: 11px; font-family: var(--font); }
.maplibregl-ctrl-group { border-radius: 12px !important; overflow: hidden; }

@media (max-width: 820px) {
  .layout { display: flex; flex-direction: column; }
  .mapwrap { order: -1; position: sticky; top: 0; height: 46vh; z-index: 3; border-bottom: 1px solid var(--rule); }
  .story { border-right: 0; padding: 0 18px 30vh; }
  .step { min-height: 70vh; padding: 8vh 0 4vh; }
  .step:first-child { padding-top: 3vh; }
  .step h1 { font-size: 2rem; }
  .big { font-size: 2.5rem; }
  .sticker { height: 112px; }
  .sticker.hero { height: 170px; }
  .card { bottom: 8px; left: 8px; font-size: 0.8rem; padding: 10px 12px; }
  .card dl { display: none; }
  .legend { font-size: 0.72rem; padding: 6px 9px; }
  .progress { top: auto; bottom: 8px; padding: 4px 10px 4px 8px; gap: 6px; }
  .progress .dots { gap: 4px; }
  .progress .dots button { width: 10px; height: 10px; }
  .progress-label { font-size: 0.72rem; max-width: 120px; }
  .card { bottom: 44px; }
  .step { scroll-margin-top: 46vh; }
}

@media (prefers-reduced-motion: reduce) {
  .step { transition: none; }
  .sticker, .loading img, .scroll-cue { animation: none; }
}
