/* Biology: illustrations with code-drawn labels, and the diagrams of the practice topics.
   Every colour, space and radius comes from the Visual_Token_Set in styles.css; tints are
   the core palette at a lower opacity. A figure's size is its height budget times its
   aspect ratio (--ar, set inline from the manifest), so the labels stay on their parts. */

/* ---------------------------------------------------------------- illustrations */
.bio-figure { margin: 0; display: grid; justify-items: center; gap: var(--space-2); width: 100%; min-width: 0; container-type: inline-size; }
.bio-art { position: relative; width: min(100%, calc(min(46vh, 400px) * var(--ar))); aspect-ratio: var(--ar); }
.is-compact .bio-art { width: min(100%, calc(min(34vh, 300px) * var(--ar))); }
.bio-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; border-radius: var(--radius-md); user-select: none; }
.bio-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.bio-leaders line { stroke: var(--ink); stroke-width: 1.6; vector-effect: non-scaling-stroke; opacity: .85; }
.bio-leaders line.is-hi { stroke: var(--coral-strong); stroke-width: 2.6; opacity: 1; }
.bio-dot { position: absolute; width: 10px; height: 10px; transform: translate(-50%, -50%); background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-round); pointer-events: none; }
.bio-dot.is-hi { border-color: var(--coral-strong); background: var(--yellow); }
.bio-label { position: absolute; width: max-content; max-width: 36%; padding: 0 var(--space-2); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); font-size: 12.5px; font-weight: 700; line-height: 1.5; pointer-events: none; }
.bio-label.to-left { transform: translate(-100%, -50%); text-align: right; }
.bio-label.to-right { transform: translate(0, -50%); text-align: left; }
.bio-label.to-center { transform: translate(-50%, -50%); text-align: center; }
.bio-label.is-hi { background: var(--cream); border-color: var(--coral-strong); }
.bio-badge { position: absolute; min-width: 30px; height: 30px; padding: 0 var(--space-1); display: grid; place-items: center; transform: translate(-50%, -50%); background: var(--blue-strong); border: 3px solid var(--paper); border-radius: var(--radius-lg); color: var(--paper); font-weight: 800; font-size: 15px; pointer-events: none; }
.bio-figure figcaption { color: var(--muted); font-size: var(--text-small); text-align: center; }
.is-compact .bio-label { font-size: 12.5px; }
.bio-key { display: none; }

/* When the name chips do not fit beside the picture (a phone, a narrow column), each labelled dot
   shows its number and a key under the picture names the parts. figure-fit.js sets .is-keyed after
   measuring; the container query covers very narrow figures before it runs. */
.bio-figure.is-keyed .bio-leaders, .bio-figure.is-keyed .bio-label { display: none; }
.bio-figure.is-keyed .bio-dot { width: 20px; height: 20px; display: grid; place-items: center; background: var(--ink); border-color: var(--paper); color: var(--paper); font-size: 12px; font-weight: 800; line-height: 1; }
.bio-figure.is-keyed .bio-dot::after { content: attr(data-n); }
.bio-figure.is-keyed .bio-dot.is-hi { background: var(--coral-strong); border-color: var(--yellow); }
.bio-figure.is-keyed .bio-key { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-3); margin: 0; padding: 0; list-style: none; color: var(--ink); font-size: var(--text-small); font-weight: 700; }
.bio-figure.is-keyed .bio-key li { display: flex; align-items: center; gap: var(--space-1); }
/* Drawn pictures whose words would be too small get a numbered key under them (svg-text-fit.js). */
.bv-svg-key { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-3); margin: var(--space-1) 0 0; padding: 0; list-style: none; color: var(--ink); font-size: var(--text-small); font-weight: 700; }
.bv-svg-key li { display: flex; align-items: center; gap: var(--space-1); }
.bv-svg-key b { display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 var(--space-1); border-radius: var(--radius-round); background: var(--ink); color: var(--paper); font-size: 12px; }
.bio-figure.is-keyed .bio-key b { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: var(--radius-round); background: var(--ink); color: var(--paper); font-size: 12px; }
.bio-figure.is-keyed .bio-key li.is-hi b { background: var(--coral-strong); }
@container (max-width: 440px) {
  .bio-leaders, .bio-label { display: none; }
  .bio-dot { width: 20px; height: 20px; display: grid; place-items: center; background: var(--ink); border-color: var(--paper); color: var(--paper); font-size: 12px; font-weight: 800; line-height: 1; }
  .bio-dot::after { content: attr(data-n); }
  .bio-dot.is-hi { background: var(--coral-strong); border-color: var(--yellow); }
  .bio-key { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-1) var(--space-3); margin: 0; padding: 0; list-style: none; color: var(--ink); font-size: var(--text-small); font-weight: 700; }
  .bio-key li { display: flex; align-items: center; gap: var(--space-1); }
  .bio-key b { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: var(--radius-round); background: var(--ink); color: var(--paper); font-size: 12px; }
  .bio-key li.is-hi b { background: var(--coral-strong); }
}


/* Inside practice questions and steps */
.mp-q-visual .bio-art { width: min(100%, calc(min(38vh, 320px) * var(--ar))); }
.mp-step-visual .bio-art { width: min(100%, calc(min(34vh, 290px) * var(--ar))); }

/* Inside a mission */
.body-figure-card { padding: var(--space-3); }
.body-figure-card .bio-art { width: min(100%, calc(min(48vh, 420px) * var(--ar))); }
.body-system-preview:has(.bio-figure) { padding: var(--space-3); border-radius: var(--radius-lg); }
.body-system-preview .bio-art { width: min(100%, calc(min(38vh, 300px) * var(--ar))); }
.body-quiz-card.has-figure { width: min(1120px, 100%); }
.body-quiz-layout { display: block; min-height: 0; }
.has-figure .body-quiz-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: var(--space-4); align-items: center; }
.has-figure .body-quiz-main h1 { text-align: left; font-size: clamp(19px, 2.2vw, 25px); margin: 0 0 var(--space-3); line-height: 1.22; }
.body-quiz-main > h1 { max-width: 720px; margin: 0 auto var(--space-3); font-size: clamp(20px, 2.6vw, 28px); line-height: 1.22; text-align: center; }
.has-figure .body-answer-grid { grid-template-columns: 1fr; }
.body-quiz-figure { display: grid; place-items: center; padding: var(--space-2); background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius-md); }
.body-quiz-figure .bio-art { width: min(100%, calc(min(46vh, 380px) * var(--ar))); }
.body-quiz-figure .body-picture { width: 100%; max-height: min(40vh, 330px); }
.body-review-nav { display: flex; gap: var(--space-2); }
.body-review-nav .button[disabled] { opacity: .45; cursor: default; }

/* ---------------------------------------------------------------- practice diagrams */
.bv-facts { margin: 0; width: 100%; }
.bv-facts dl { display: grid; gap: var(--space-1); margin: 0; }
.bv-facts dl > div { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: var(--space-3); padding: var(--space-1) var(--space-3); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.bv-facts dl > div.is-hi { border-color: var(--blue-strong); background: var(--cream); }
.bv-facts dt { font-weight: 700; color: var(--ink); }
.bv-facts dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 480px) { .bv-facts dl > div { grid-template-columns: minmax(0, 1fr); gap: 0; } }

.bv-compare { margin: 0; width: 100%; }
.bv-sides { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
.bv-side { padding: var(--space-3); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md); }
.bv-side strong { display: block; margin-bottom: var(--space-2); color: var(--blue-dark); }
.bv-side ul { margin: 0; padding-left: var(--space-4); color: var(--ink); }
.bv-side li + li { margin-top: var(--space-1); }

.bv-punnett { margin: 0; display: grid; justify-items: center; gap: var(--space-2); }
.bv-punnett table { border-collapse: separate; border-spacing: 5px; }
.bv-punnett th { width: 58px; height: 42px; color: var(--blue-dark); font: 700 24px var(--font-display); text-align: center; }
.bv-punnett td { position: relative; width: 96px; height: 72px; padding: var(--space-1); background: var(--paper); border: 2px solid var(--line); border-radius: var(--radius-md); text-align: center; vertical-align: middle; }
.bv-punnett td::before { content: ''; position: absolute; inset: 0; border-radius: inherit; opacity: 0; pointer-events: none; }
.bv-punnett td.is-dom::before { background: var(--blue); opacity: .14; }
.bv-punnett td.is-rec::before { background: var(--yellow); opacity: .22; }
.bv-punnett td > * { position: relative; }
.bv-punnett td strong { display: block; font: 700 26px var(--font-display); color: var(--ink); }
.bv-punnett td small { display: block; color: var(--muted); font-size: 12px; line-height: 1.15; }
.bv-punnett td.is-hi { border-color: var(--coral-strong); border-width: 3px; }
.bv-punnett td.bv-pq-empty { color: var(--muted); font: 700 22px var(--font-display); border-style: dashed; }

svg.bv-pyramid .bv-pyr { stroke: var(--paper); stroke-width: 2; }
svg.bv-pyramid .bv-pyr-0 { fill: var(--green); fill-opacity: .5; }
svg.bv-pyramid .bv-pyr-1 { fill: var(--green); fill-opacity: .25; }
svg.bv-pyramid .bv-pyr-2 { fill: var(--yellow); fill-opacity: .5; }
svg.bv-pyramid .bv-pyr-3 { fill: var(--coral); fill-opacity: .38; }
svg.bv-pyramid .bv-pyr.is-hi { stroke: var(--coral-strong); stroke-width: 4; }
svg.bv-pyramid .bv-pyr-text { font-size: 16px; font-weight: 700; fill: var(--ink); }

svg.bv-web .bv-web-arrow line { stroke: var(--muted); stroke-width: 2.5; }
svg.bv-web .bv-web-arrow polygon { fill: var(--muted); }
svg.bv-web .bv-web-arrow.is-hi line { stroke: var(--coral-strong); stroke-width: 4; }
svg.bv-web .bv-web-arrow.is-hi polygon { fill: var(--coral-strong); }
svg.bv-web .bv-web-name { font-size: 13px; font-weight: 700; fill: var(--ink); }
svg.bv-web .bv-web-ring { fill: var(--cream); stroke: var(--coral-strong); stroke-width: 3; }
svg.bv-web .bv-web-hidden { fill: var(--cream); stroke: var(--blue-strong); stroke-width: 2; stroke-dasharray: 5 4; }
svg.bv-web .bv-web-q { font: 700 24px var(--font-display); fill: var(--blue-strong); }
svg.bv-web .bv-web-dot { fill: var(--green); fill-opacity: .4; }

/* Short laptop screens (1280×720): a smaller picture keeps the lesson, its note and Next on one screen. */
@media (max-height: 740px) {
  .body-figure-card .bio-art { width: min(100%, calc(min(40vh, 420px) * var(--ar))); }
  .body-quiz-figure .bio-art { width: min(100%, calc(min(40vh, 380px) * var(--ar))); }
  .body-system-preview .bio-art { width: min(100%, calc(min(32vh, 300px) * var(--ar))); }
}

.body-picture-narrow { display: none; }

@media (max-width: 700px) {
  .body-picture:has(+ .body-picture-narrow) { display: none; }
  .body-picture.body-picture-narrow { display: block; max-height: none; width: min(100%, 420px); margin: 0 auto; }
  .has-figure .body-quiz-layout { grid-template-columns: 1fr; }
  .bio-label { font-size: 12px; max-width: 42%; padding: 0 var(--space-1); }
  .bv-punnett td { width: 76px; height: 60px; }
  .bv-sides { grid-template-columns: 1fr; }
}

/* One construction stage, with paginated candidate stops. The path and feedback remain visible. */
.body-builder-choice-nav { display:flex; flex-wrap:wrap; align-items:center; gap:calc(var(--space-1) * 1.5); margin-top:var(--space-2); }
.body-builder-choice-nav span { width:100%; font-size:13px; color:var(--muted); }
.body-builder-choice-nav button { flex:1; min-height:42px; font-size:13px; }
