/* ===========================================================================
   Lab & game surfaces
   ---------------------------------------------------------------------------
   Everything interactive lives on the "night" surface so that specimen
   photography (bone, feather, skull — all shot on white) pops, and so a lab
   reads as a distinct place from the reading pages.
   ========================================================================= */

/* --- Lab shell ----------------------------------------------------------- */
.lab {
  background: var(--night-900);
  color: var(--night-text);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--night-line);
}
.lab--bleed { border-radius: 0; border-inline: 0; }

.lab__bar {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
  padding: 0.85rem var(--sp-4);
  background: var(--night-800);
  border-bottom: 1px solid var(--night-line);
}
.lab__title {
  display: flex; align-items: center; gap: 0.6rem;
  font-family: var(--display); font-weight: 600;
  font-size: var(--step-1); color: var(--white);
  margin: 0;
}
.lab__title svg { color: var(--amber-400); flex: none; }
.lab__spacer { margin-left: auto; }
.lab__body { padding: var(--sp-4); }
.lab__body--flush { padding: 0; }

.lab__hint {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.8rem 1rem;
  background: color-mix(in srgb, var(--amber-400) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--amber-400) 28%, transparent);
  border-radius: var(--r-md);
  color: var(--amber-200);
  font-size: 0.94rem;
}
.lab__hint svg { flex: none; margin-top: 2px; color: var(--amber-400); }
.lab__hint strong { color: var(--white); }

/* --- Score / progress chips --------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  background: var(--night-700); color: var(--night-text);
  border: 1px solid var(--night-line);
  border-radius: var(--r-pill);
  font-size: 0.82rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chip b { color: var(--amber-400); }
.chip--good { border-color: color-mix(in srgb, var(--good) 55%, transparent); }
.chip--good b { color: #6fd6a5; }

.meter {
  flex: 1 1 120px; min-width: 90px; max-width: 260px;
  height: 8px; border-radius: 999px;
  background: var(--night-700); overflow: hidden;
  border: 1px solid var(--night-line);
}
.meter__fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--teal-500), var(--amber-400));
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* --- Stage steps --------------------------------------------------------- */
.steps {
  display: flex; gap: 0.25rem; list-style: none;
  margin: 0; padding: 0; flex-wrap: wrap;
}
.steps li {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.3rem 0.75rem 0.3rem 0.35rem;
  border-radius: var(--r-pill);
  font-size: 0.8rem; font-weight: 600;
  color: var(--night-soft);
  border: 1px solid transparent;
}
.steps li i {
  display: grid; place-items: center;
  width: 1.35rem; height: 1.35rem; border-radius: 999px;
  background: var(--night-700); color: var(--night-soft);
  font-style: normal; font-size: 0.72rem; font-weight: 700;
}
.steps li[data-state="active"] {
  background: var(--night-700); color: var(--white);
  border-color: var(--night-line);
}
.steps li[data-state="active"] i { background: var(--amber-400); color: #3a1c04; }
.steps li[data-state="done"] { color: #6fd6a5; }
.steps li[data-state="done"] i { background: color-mix(in srgb, var(--good) 40%, var(--night-700)); color: #bdf3d8; }

/* =========================================================================
   Pellet Lab — the flagship dissection
   ========================================================================= */
.pellet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 560px;
}
@media (max-width: 940px) {
  .pellet { grid-template-columns: 1fr; }
}

.pellet__stage {
  position: relative;
  background:
    radial-gradient(75% 60% at 50% 42%, #12343b 0%, var(--night-900) 72%);
  display: grid; place-items: center;
  padding: var(--sp-4);
  min-height: 420px;
  overflow: hidden;
}
.pellet__canvas {
  display: block;
  width: 100%; height: auto;
  max-height: 62vh;
  touch-action: none;
  cursor: crosshair;
  border-radius: var(--r-lg);
}
.pellet__canvas[data-tool="tweezers"] { cursor: grab; }
.pellet__canvas[data-tool="tweezers"]:active { cursor: grabbing; }

/* Tool rail */
.pellet__tools {
  position: absolute; left: var(--sp-3); top: 50%;
  transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.45rem;
  background: color-mix(in srgb, var(--night-800) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--night-line);
  border-radius: var(--r-pill);
  z-index: 3;
}
@media (max-width: 640px) {
  .pellet__tools {
    left: 50%; top: auto; bottom: var(--sp-3);
    transform: translateX(-50%);
    flex-direction: row; border-radius: var(--r-pill);
  }
}
.tool {
  display: grid; place-items: center;
  width: 46px; height: 46px; padding: 0;
  background: transparent; color: var(--night-soft);
  border: 1px solid transparent; border-radius: 999px;
  cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.tool:hover { background: var(--night-700); color: var(--white); }
.tool[aria-pressed="true"] {
  background: var(--amber-400); color: #3a1c04;
  border-color: var(--amber-200);
}
.tool svg { width: 22px; height: 22px; }

/* Side panel: findings tray */
.pellet__panel {
  background: var(--night-800);
  border-left: 1px solid var(--night-line);
  display: flex; flex-direction: column;
  max-height: 62vh;
}
@media (max-width: 940px) {
  .pellet__panel { border-left: 0; border-top: 1px solid var(--night-line); max-height: none; }
}
.pellet__panel h3 {
  margin: 0; padding: var(--sp-3) var(--sp-3) 0.6rem;
  font-size: var(--step-0); color: var(--white);
  font-family: var(--sans); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.pellet__panel-scroll { overflow-y: auto; padding: 0 var(--sp-3) var(--sp-3); flex: 1; }

/* Bone chart slots */
.bone-chart { display: grid; gap: 0.4rem; list-style: none; margin: 0; padding: 0; }
.bone-slot {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.65rem;
  background: var(--night-700);
  border: 1px dashed var(--night-line);
  border-radius: var(--r-md);
  font-size: 0.88rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.bone-slot__thumb {
  flex: none; width: 40px; height: 32px;
  display: grid; place-items: center;
  background: var(--night-900); border-radius: var(--r-sm);
  overflow: hidden;
}
.bone-slot__thumb img { width: 100%; height: 100%; object-fit: contain; }
.bone-slot__thumb span { color: var(--night-line); font-size: 1rem; }
.bone-slot b { display: block; color: var(--white); font-weight: 600; }
.bone-slot small { color: var(--night-soft); font-size: 0.76rem; }
.bone-slot__count {
  margin-left: auto; flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--night-soft);
}
.bone-slot[data-found="true"] {
  border-style: solid;
  border-color: color-mix(in srgb, var(--good) 60%, transparent);
  background: color-mix(in srgb, var(--good) 14%, var(--night-700));
}
.bone-slot[data-found="true"] .bone-slot__count { color: #6fd6a5; }
.bone-slot[data-hint="true"] { border-color: var(--amber-400); }

/* Floating "found it" toast */
.lab-toast {
  position: absolute; left: 50%; bottom: var(--sp-4);
  transform: translate(-50%, 1rem);
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.7rem 1.1rem;
  background: var(--white); color: var(--ink);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-lg);
  font-weight: 600; font-size: 0.92rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 5; max-width: min(90%, 30rem);
}
.lab-toast[data-show="true"] { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 640px) {
  /* The tool rail sits along the bottom on a phone; keep the toast clear of it. */
  .lab-toast { bottom: calc(var(--sp-3) + 62px); }
}
.lab-toast__icon {
  display: grid; place-items: center; flex: none;
  width: 1.6rem; height: 1.6rem; border-radius: 999px;
  background: var(--good); color: var(--white); font-size: 0.85rem;
}
.lab-toast[data-kind="miss"] .lab-toast__icon { background: var(--ink-faint); }

/* --- Identify step: prey cards ------------------------------------------ */
.prey-grid { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
.prey-card {
  position: relative;
  display: flex; flex-direction: column; gap: 0.4rem;
  padding: 0.8rem;
  background: var(--night-700);
  border: 2px solid var(--night-line);
  border-radius: var(--r-md);
  color: var(--night-text);
  cursor: pointer; text-align: left;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.prey-card:hover { border-color: var(--teal-300); transform: translateY(-3px); }
.prey-card[aria-pressed="true"] { border-color: var(--amber-400); background: var(--night-600); }
.prey-card img { border-radius: var(--r-sm); background: var(--night-900); aspect-ratio: 4/3; object-fit: contain; }
.prey-card b { font-size: 0.95rem; color: var(--white); }
.prey-card small { color: var(--night-soft); font-size: 0.78rem; line-height: 1.4; }
.prey-card[data-verdict="right"] { border-color: var(--good); }
.prey-card[data-verdict="wrong"] { border-color: var(--bad); opacity: 0.55; }

/* --- Lab report ---------------------------------------------------------- */
.report { display: grid; gap: var(--sp-4); }
.report__head { text-align: center; }
.report__grade {
  display: inline-grid; place-items: center;
  width: 7rem; height: 7rem; border-radius: 999px;
  background: conic-gradient(var(--amber-400) var(--pct, 0%), var(--night-700) 0);
  margin-bottom: var(--sp-2);
}
.report__grade span {
  display: grid; place-items: center;
  width: 5.9rem; height: 5.9rem; border-radius: 999px;
  background: var(--night-800);
  font-family: var(--display); font-size: 1.7rem; font-weight: 700;
  color: var(--white);
}
.report__rows { display: grid; gap: 0.4rem; }
.report__row {
  display: flex; gap: 0.8rem; align-items: center;
  padding: 0.6rem 0.9rem;
  background: var(--night-700); border-radius: var(--r-md);
  font-size: 0.92rem;
}
.report__row b { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--white); }
.report__row svg { flex: none; }

/* =========================================================================
   Skull Lab — multi-view specimen viewer
   ========================================================================= */
.skull-lab { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 540px; }
@media (max-width: 880px) { .skull-lab { grid-template-columns: 1fr; } }

.skull-list {
  background: var(--night-800);
  border-right: 1px solid var(--night-line);
  max-height: 62vh; overflow-y: auto;
  padding: var(--sp-2);
}
@media (max-width: 880px) {
  .skull-list { border-right: 0; border-bottom: 1px solid var(--night-line); max-height: 15rem; }
}
.skull-list__group {
  padding: 0.7rem 0.6rem 0.3rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--amber-400);
}
.skull-list button {
  display: flex; align-items: center; gap: 0.6rem; width: 100%;
  padding: 0.5rem 0.6rem; margin-bottom: 1px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--night-soft); text-align: left;
  font-size: 0.9rem; cursor: pointer;
}
.skull-list button:hover { background: var(--night-700); color: var(--white); }
.skull-list button[aria-current="true"] { background: var(--teal-700); color: var(--white); font-weight: 600; }
.skull-list button img {
  width: 34px; height: 26px; flex: none;
  object-fit: contain; background: var(--night-900); border-radius: 3px;
}

.skull-view { display: flex; flex-direction: column; padding: var(--sp-4); gap: var(--sp-3); }
.skull-view__frame {
  position: relative; flex: 1;
  display: grid; place-items: center;
  min-height: 280px;
  background: radial-gradient(60% 60% at 50% 45%, #13383f, var(--night-900));
  border-radius: var(--r-lg);
  border: 1px solid var(--night-line);
  overflow: hidden;
}
.skull-view__frame img {
  max-height: 46vh; width: auto; max-width: 100%;
  filter: drop-shadow(0 18px 30px rgb(0 0 0 / 0.55));
}
.skull-view h3 { margin: 0; color: var(--white); }
.skull-view__note { color: var(--night-soft); font-size: 0.94rem; margin: 0; max-width: 62ch; }
.view-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.view-tabs button {
  padding: 0.35rem 0.8rem;
  background: var(--night-700); color: var(--night-soft);
  border: 1px solid var(--night-line); border-radius: var(--r-pill);
  font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.view-tabs button:hover { color: var(--white); }
.view-tabs button[aria-pressed="true"] { background: var(--amber-400); color: #3a1c04; border-color: var(--amber-200); }

/* =========================================================================
   Quiz — shared by Beak Match, Skull Detective, Diet Sorter, Feet ID
   ========================================================================= */
.quiz { display: grid; gap: var(--sp-4); }
.quiz__prompt {
  display: grid; gap: var(--sp-3);
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  align-items: center;
}
@media (max-width: 720px) { .quiz__prompt { grid-template-columns: 1fr; } }
.quiz__figure {
  background: var(--white);
  border-radius: var(--r-lg); overflow: hidden;
  border: 1px solid var(--night-line);
  display: grid; place-items: center; padding: var(--sp-3);
  min-height: 190px;
}
.quiz__figure img { max-height: 240px; width: auto; }
.quiz__ask { font-family: var(--display); font-size: var(--step-2); color: var(--white); margin: 0 0 0.4em; }
.quiz__sub { color: var(--night-soft); margin: 0; }

.options { display: grid; gap: 0.6rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.option {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.85rem 1rem;
  background: var(--night-700); color: var(--night-text);
  border: 2px solid var(--night-line); border-radius: var(--r-md);
  font-size: 0.98rem; font-weight: 550;
  text-align: left; cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.option:hover:not([disabled]) { border-color: var(--teal-300); transform: translateY(-2px); }
.option i {
  display: grid; place-items: center; flex: none;
  width: 1.7rem; height: 1.7rem; border-radius: 999px;
  background: var(--night-600); color: var(--night-soft);
  font-style: normal; font-size: 0.8rem; font-weight: 700;
}
.option[data-verdict="right"] {
  border-color: var(--good);
  background: color-mix(in srgb, var(--good) 18%, var(--night-700));
}
.option[data-verdict="right"] i { background: var(--good); color: var(--white); }
.option[data-verdict="wrong"] {
  border-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 16%, var(--night-700));
}
.option[data-verdict="wrong"] i { background: var(--bad); color: var(--white); }
.option[disabled] { cursor: default; }

.quiz__feedback {
  display: none; gap: 0.8rem; align-items: flex-start;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--night-700);
  border-left: 4px solid var(--amber-400);
  font-size: 0.96rem;
}
.quiz__feedback[data-show="true"] { display: flex; }
.quiz__feedback strong { color: var(--white); }
.quiz__feedback p { margin: 0.2em 0 0; color: var(--night-soft); }
.quiz__feedback[data-verdict="right"] { border-left-color: var(--good); }
.quiz__feedback[data-verdict="wrong"] { border-left-color: var(--bad); }

.quiz__foot { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; }

/* =========================================================================
   Topography — interactive bird map
   ========================================================================= */
.topo { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 0; min-height: 520px; }
@media (max-width: 900px) { .topo { grid-template-columns: 1fr; } }
.topo__stage {
  position: relative;
  display: grid; place-items: center;
  padding: var(--sp-4);
  background: radial-gradient(65% 65% at 50% 45%, #133a41, var(--night-900));
}
.topo__img-wrap { position: relative; width: 100%; max-width: 620px; }
.topo__img-wrap img { width: 100%; }
.topo__hot {
  position: absolute; width: 26px; height: 26px;
  transform: translate(-50%, -50%);
  border-radius: 999px; padding: 0; cursor: pointer;
  background: color-mix(in srgb, var(--amber-400) 85%, transparent);
  border: 2px solid var(--white);
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.4);
  transition: transform 0.15s ease;
}
.topo__hot::after {
  content: ""; position: absolute; inset: -8px; border-radius: 999px;
  border: 2px solid var(--amber-400); opacity: 0;
  transition: opacity 0.2s ease;
}
.topo__hot:hover { transform: translate(-50%, -50%) scale(1.25); }
.topo__hot[aria-pressed="true"] { background: var(--white); }
.topo__hot[aria-pressed="true"]::after { opacity: 1; }
.topo__hot[data-done="true"] { background: color-mix(in srgb, var(--good) 85%, transparent); }

.topo__panel {
  background: var(--night-800);
  border-left: 1px solid var(--night-line);
  padding: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-2);
}
@media (max-width: 900px) { .topo__panel { border-left: 0; border-top: 1px solid var(--night-line); } }
.topo__panel h3 { color: var(--white); margin: 0; font-size: var(--step-1); }
.topo__detail-img {
  background: var(--white); border-radius: var(--r-md);
  overflow: hidden; border: 1px solid var(--night-line);
}
.topo__list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.3rem;
  max-height: 12rem; overflow-y: auto;
}
.topo__list button {
  padding: 0.3rem 0.6rem; font-size: 0.78rem;
  background: var(--night-700); color: var(--night-soft);
  border: 1px solid var(--night-line); border-radius: var(--r-pill);
  cursor: pointer;
}
.topo__list button:hover { color: var(--white); }
.topo__list button[aria-current="true"] { background: var(--amber-400); color: #3a1c04; }

/* =========================================================================
   Explorer — card/detail pattern for beaks, feet, feathers, diets, eggs
   ========================================================================= */
.explorer { display: grid; gap: var(--sp-4); }
.explorer__strip {
  display: flex; gap: 0.6rem; overflow-x: auto;
  padding-bottom: 0.5rem;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.explorer__strip button {
  flex: none; width: 110px; scroll-snap-align: start;
  padding: 0.4rem; background: var(--night-700);
  border: 2px solid var(--night-line); border-radius: var(--r-md);
  color: var(--night-soft); cursor: pointer;
  font-size: 0.76rem; font-weight: 600;
}
.explorer__strip button img {
  width: 100%; aspect-ratio: 4/3; object-fit: contain;
  background: var(--white); border-radius: var(--r-sm); margin-bottom: 0.35rem;
}
.explorer__strip button:hover { color: var(--white); border-color: var(--teal-300); }
.explorer__strip button[aria-current="true"] { border-color: var(--amber-400); color: var(--white); }

.explorer__detail {
  display: grid; gap: var(--sp-4);
  grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 760px) { .explorer__detail { grid-template-columns: 1fr; } }
.explorer__figure {
  background: var(--white); border-radius: var(--r-lg);
  padding: var(--sp-3); border: 1px solid var(--night-line);
  display: grid; place-items: center; min-height: 200px;
}
.explorer__figure img { max-height: 320px; width: auto; }
.explorer__text h3 { color: var(--white); margin-bottom: 0.2em; }
.explorer__text .explorer__species {
  color: var(--amber-400); font-size: 0.9rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.9em;
}
.explorer__text p { color: var(--night-soft); }
.explorer__variants { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); margin-top: var(--sp-3); }
.explorer__variant {
  padding: 0.7rem; background: var(--night-700);
  border: 1px solid var(--night-line); border-radius: var(--r-md);
}
.explorer__variant img { background: var(--white); border-radius: var(--r-sm); aspect-ratio: 4/3; object-fit: contain; margin-bottom: 0.4rem; }
.explorer__variant b { color: var(--white); font-size: 0.9rem; display: block; }
.explorer__variant small { color: var(--night-soft); font-size: 0.8rem; line-height: 1.45; }

/* --- Egg comparison ----------------------------------------------------- */
.eggs { display: grid; gap: var(--sp-3); grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.egg {
  background: var(--night-700); border: 1px solid var(--night-line);
  border-radius: var(--r-md); overflow: hidden; text-align: center;
}
.egg__imgs { display: grid; grid-template-columns: 1fr 1fr; background: var(--white); }
.egg__imgs img { aspect-ratio: 1; object-fit: contain; padding: 0.3rem; }
.egg b { display: block; padding: 0.55rem 0.4rem; font-size: 0.85rem; color: var(--white); }

/* --- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .card--link:hover, .option:hover, .prey-card:hover, .topo__hot:hover { transform: none; }
}

/* An explorer entry with no photograph: text takes the full width. */
.explorer__detail[data-noimg="true"] { grid-template-columns: 1fr; }
.explorer__noimg {
  display: block; width: 100%; aspect-ratio: 4/3;
  margin-bottom: 0.35rem; border-radius: var(--r-sm);
  background:
    repeating-linear-gradient(45deg, var(--night-600) 0 6px, var(--night-700) 6px 12px);
  opacity: 0.6;
}
