/* Animal Kingdom: chapter-wide scene styles (the kit is assets/xp/xp.css).
   Content palette: the germ layers in the embryology convention, plus the sea. Used for strokes, glows, fills and
   swatches only; type is never coloured (KIT §13.6). */
html.xp {
  --xp-ecto: #5794ff;   /* ectoderm: skin and nerves */
  --xp-meso: #ff5a3c;   /* mesoderm: muscle, blood, the notochord's layer */
  --xp-endo: #ffbd45;   /* endoderm: the gut lining */
  --xp-noto: #66f2cc;   /* the notochord, a glassy rod */
  --xp-sea: #4cc9e6;    /* sea water, a cnidarian's glow */
}

/* ---------- the key: five questions that sort every phylum (built from tools/experience/bio-11-04/key.html) ---------- */
.b4-key { width: 100%; max-width: 760px; }
.b4k { list-style: none; margin: 0; padding: 0; position: relative; }
.b4k > li { position: relative; display: grid; grid-template-columns: 28px 1fr; column-gap: 14px; padding: 0 0 18px; margin: 0; }
.b4k > li::before { content: ""; position: absolute; left: 13.5px; top: 30px; bottom: -2px; width: 1px; background: var(--hairline-strong); }
.b4k > li:last-child::before { display: none; }
.b4k > li.lit::before { background: var(--xp-accent); opacity: .85; }
.b4k > li.end::before { background: var(--hairline-strong); opacity: 1; }
.b4k .b4k-n { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--hairline-strong); display: grid; place-items: center; font-size: var(--text-xs); color: var(--mix-4); font-variant-numeric: tabular-nums; }
.b4k li.lit .b4k-n { box-shadow: inset 0 0 0 1.5px var(--xp-accent); color: var(--bone); }
.b4k .b4k-ask { margin: 2px 0 8px; font-size: var(--text-md); line-height: 1.3; color: var(--mix-3); font-weight: 500; }
.b4k li.lit .b4k-ask { color: var(--bone); }
.b4k .b4k-out { grid-column: 2; margin: 0 0 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: var(--text-sm); line-height: 1.3; }
.b4k .b4k-a { color: var(--mix-4); min-width: 0; }
.b4k .b4k-a::after { content: " →"; color: var(--mix-5); }
.b4k .b4k-p { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--hairline); color: var(--mix-4); }
.b4k .b4k-p.on { box-shadow: inset 0 0 0 1px var(--bone); color: var(--bone); background: color-mix(in srgb, var(--xp-accent) 16%, transparent); }
.b4k .b4k-go { grid-column: 2; margin: 0; font-size: var(--text-sm); color: var(--mix-5); }
.b4k .b4k-go::before { content: "↓ "; }
.b4k li.lit .b4k-go { color: var(--mix-3); }
.b4-keywrap { display: grid; gap: 22px; }
@media (min-width: 900px) {
  .b4-keywrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; column-gap: 56px; }
}
.b4-nw { white-space: nowrap; }

/* ---------- a pinned photo stack: one photo at a time with its labels; head, ladder and photo in one column ---------- */
.b4-levels .b4-col { position: absolute; z-index: 2; left: var(--xp-g); right: var(--xp-g); top: calc(var(--xp-bar) + 14px); display: grid; gap: 14px; align-content: start; }
.b4-levels .b4-col .xs-stagehead { position: relative; top: auto; left: auto; right: auto; }
.b4-levels .b4-ladder { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 0; padding: 0; list-style: none; }
.b4-levels .b4-ladder3 { grid-template-columns: repeat(3, 1fr); }
.b4-levels .b4-ladder li { margin: 0; padding: 6px 0 0; border-top: 2px solid var(--hairline-strong); font-size: 13px; line-height: 1.2; color: var(--mix-5); transition: color .4s var(--xp-out), border-color .4s var(--xp-out); }
.b4-levels .b4-ladder li b { display: block; font-weight: 500; }
.b4-levels .b4-ladder li span { display: none; }
.b4-levels .b4-ladder li.on { color: var(--bone); border-top-color: var(--xp-accent); }
.b4-levels .b4-lv-photo { display: grid; }
.b4-levels .b4-lv { grid-area: 1 / 1; align-self: start; width: 100%; opacity: 0; transform: translateY(10px); transition: opacity .55s var(--xp-out), transform .8s var(--xp-out); }
.b4-levels .b4-lv.on { opacity: 1; transform: none; }
.b4-levels .b4-lv img { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }
@media (max-width: 899px) and (max-height: 700px) { .b4-levels .b4-lv { width: min(100%, calc(34svh * var(--r, 1.33))); justify-self: center; } }
@media (min-width: 900px) {
  .b4-levels .b4-col { top: 14svh; grid-template-columns: minmax(0, .72fr) minmax(0, 1.28fr); grid-template-rows: auto 1fr; column-gap: 56px; row-gap: 32px; }
  .b4-levels .b4-col .xs-stagehead { grid-column: 1; grid-row: 1; }
  .b4-levels .b4-ladder { grid-column: 1; grid-row: 2; align-self: start; grid-template-columns: 1fr; gap: 0; }
  .b4-levels .b4-ladder li { display: grid; grid-template-columns: 1fr auto; padding: 12px 0; border-top-width: 1px; font-size: var(--text-md); }
  .b4-levels .b4-ladder li span { display: block; font-size: var(--text-sm); color: inherit; opacity: .8; }
  .b4-levels .b4-lv-photo { grid-column: 2; grid-row: 1 / 3; }
  .b4-levels .b4-lv { width: min(100%, calc(68svh * var(--r, 1.33))); }
  .b4-levels .xp-cap { max-width: 26rem; }
}
html.xp-reduced .b4-levels .b4-ladder, html:not(.xp-js) .b4-levels .b4-ladder { display: none; }
html.xp-reduced .b4-levels .b4-col, html:not(.xp-js) .b4-levels .b4-col { position: relative; top: auto; left: auto; right: auto; margin: 0 var(--xp-g); }
html.xp-reduced .b4-levels .b4-lv-photo, html:not(.xp-js) .b4-levels .b4-lv-photo { gap: 14px; }
html.xp-reduced .b4-levels .b4-lv, html:not(.xp-js) .b4-levels .b4-lv { grid-area: auto; opacity: 1; transform: none; }

/* ---------- small sketches (pairs, layers) ---------- */
.b4-pair .xs-vis { min-height: 0; }
.b4-pair .xa-box { max-width: 440px; margin: 0 auto; }
.b4-pair svg { width: 100%; height: auto; display: block; }
.b4-wall { fill: none; stroke: var(--bone); stroke-opacity: .6; stroke-width: 1.6; stroke-linecap: round; }
.b4-food { fill: none; stroke: var(--xp-endo); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 3 9; }
.b4-heart { fill: var(--xp-meso); opacity: .9; }
.b4-cells circle { fill: color-mix(in srgb, var(--xp-ecto) 20%, transparent); stroke: var(--xp-ecto); stroke-opacity: .6; }
.b4-blood circle { fill: var(--xp-meso); }
.b4-pipe { fill: none; stroke: var(--xp-meso); stroke-opacity: .28; stroke-width: 8; stroke-linecap: round; }
.b4-cap { fill: none; stroke: var(--xp-meso); stroke-opacity: .55; stroke-width: 1.2; }
.b4-blood-line { fill: none; stroke: var(--xp-meso); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 10; }
@keyframes b4-flow { to { stroke-dashoffset: -48; } }
@keyframes b4-drift { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(4px, 3px); } }
html.xp-js:not(.xp-reduced) .b4-flow { animation: b4-flow 1.6s linear infinite; }
html.xp-js:not(.xp-reduced) .b4-drift circle { animation: b4-drift 2.4s ease-in-out infinite; }
html.xp-js:not(.xp-reduced) .b4-drift circle:nth-child(2n) { animation-duration: 3.1s; animation-delay: -1s; }
html.xp-js:not(.xp-reduced) .b4-drift circle:nth-child(3n) { animation-duration: 2.7s; animation-delay: -.5s; }
@media (prefers-reduced-motion: reduce) { .b4-flow, .b4-drift circle { animation: none !important; } }

/* a cut line laid over a photo (symmetry) */
.b4-cutbox > svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.b4-cut { fill: none; stroke: var(--bone); stroke-width: 2; stroke-dasharray: 6 6; stroke-linecap: round; opacity: .9; }
.b4-cut.dim { opacity: .45; }
.b4-axis { fill: var(--bone); }
@keyframes b4-spin { to { transform: rotate(180deg); } }
html.xp-js:not(.xp-reduced) .b4-spin { animation: b4-spin 7s cubic-bezier(.62,.05,.01,.99) infinite; }
/* germ-layer sheets */
.b4-sheet { fill: color-mix(in srgb, var(--c) 55%, transparent); stroke: var(--c); stroke-width: 1; }
.b4-jelly { fill: color-mix(in srgb, var(--bone) 6%, transparent); stroke: var(--bone); stroke-opacity: .35; stroke-dasharray: 3 4; }
.b4-meso { fill: color-mix(in srgb, var(--xp-meso) 55%, transparent); stroke: var(--xp-meso); }
.b4-split-gap { fill: none; stroke: var(--bone); stroke-opacity: .35; stroke-dasharray: 3 4; }
@media (prefers-reduced-motion: reduce) { .b4-spin { animation: none !important; } }

/* ---------- desktop: two-column sections come from the kit now (xp.css, kit merge 2026-11-20) ---------- */
@media (min-width: 900px) {
  html.xp .xs.xs-split .xs-vis > .xa-box[style*="--r"] { width: min(100%, calc(70svh * var(--r))); justify-self: center; }
}
