/* Fonts are served from this site (SIL Open Font License), never from a third party. */
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/atkinson-hyperlegible-400.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/atkinson-hyperlegible-700.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/barlow-400.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/barlow-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/barlow-600.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 500; font-display: swap; src: url('../fonts/barlow-condensed-500.woff2') format('woff2'); }
@font-face { font-family: 'Barlow Condensed'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/barlow-condensed-600.woff2') format('woff2'); }
@font-face { font-family: 'Bricolage Grotesque'; font-style: normal; font-weight: 600 800; font-display: swap; src: url('../fonts/bricolage-grotesque-600-800.woff2') format('woff2'); }
/* Inside You — design tokens
   Mood: an X-ray lightbox in a dim room. Petrol-blue film, bone-coloured ink,
   and one colour per kind of signal so the animation is readable at a glance. */
:root {
  --bg: #0c242e;
  --bg-2: #113039;
  --panel: #143843;
  --line: #2b5562;
  --ink: #f1eadb;
  --muted: #9fb8bc;
  --lamp: #ffc163;
  --danger: #ff6b6b;

  --sig-mechanical: #ffb14a;
  --sig-fluid: #56d0e8;
  --sig-electrical: #fff06a;
  --sig-chemical: #c9a0ff;
  --sig-gas: #cfeaff;
  --sig-thermal: #ff7d5c;
  --blood-oxy: #f0464f;
  --blood-deoxy: #5a82e6;

  /* shared tissue colours for scenes */
  --skin: #e9b89a; --skin-dark: #b98466;
  --tissue: #e39a8d; --tissue-dark: #a85d55;
  --bone: #efe6d2; --bone-dark: #b9ad92;
  --nerve: #f3d76b; --cartilage: #cfe3df;
  --muscle: #c9544f; --fat: #f2d79a;

  /* Classic medical-publishing fonts, installed on every system (no web fonts): Arial/Helvetica for text and labels,
     Times New Roman for the main headings. */
  --display: Arial, Helvetica, "Liberation Sans", sans-serif;
  --body: Arial, Helvetica, "Liberation Sans", sans-serif;
  --serif: "Times New Roman", Times, "Liberation Serif", serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); font: 17px/1.5 var(--body); }
body { margin: 0; min-height: 100vh; }
a { color: var(--lamp); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.1; margin: 0; }
.skip { position: absolute; left: -999px; } .skip:focus { left: 8px; top: 8px; background: var(--ink); color: var(--bg); padding: 4px 8px; z-index: 9; }
.fine, .fineprint { color: var(--muted); font-size: .86rem; }
.loading, .missing { padding: 20vh 8vw; }


/* ───── Shared controls ───── */
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.viewer { position: absolute; inset: 0; transition: opacity .8s ease-in, transform .8s ease-in; }
.viewer.diving { opacity: 0; }
.viewer canvas { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.viewer .loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 0; color: #9fb8bc; }
.viewer .body { height: 94%; margin: 2% auto; display: block; }
.body-line { fill: none; stroke: #7fb3bd; stroke-width: 1.6; opacity: .8; }
.bones path { fill: none; stroke: #cfe6e6; stroke-width: 3; opacity: .12; stroke-linecap: round; }
.organ { cursor: pointer; }
.organ-view { transition: opacity .5s, transform .6s cubic-bezier(.2,.7,.2,1); }
.organ-view.entering { opacity: 0; transform: scale(1.03); }
.failure-banner[hidden], [hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { .organ-view, .viewer { transition: none; } }

/* ───── Stage: shared scene styling ───── */
.stage [data-part] { cursor: pointer; transition: opacity .6s, filter .6s; }
.stage.has-focus [data-part]:not(.is-active) { filter: saturate(.45) brightness(.62); }
.stage.has-focus [data-part] [data-part] { filter: none; }
.stage [data-part]:hover { filter: brightness(1.25) !important; }
.stage [data-part].is-failed { filter: grayscale(1) brightness(.6) drop-shadow(0 0 6px var(--danger)) !important; }
.stage [data-step], .stage [data-failure] { opacity: 0; transition: opacity .6s; pointer-events: none; }
.stage [data-step].is-shown, .stage [data-failure].is-shown { opacity: 1; pointer-events: auto; }
.stage .flow-guide { stroke: none; }
.stage .fx { pointer-events: none; }
.stage .labels { pointer-events: none; }
.label line { stroke: var(--ink); opacity: .55; }
.label circle { fill: var(--ink); }
.label text { fill: var(--ink); font-family: var(--display); font-weight: 500; paint-order: stroke; stroke: var(--bg); stroke-linejoin: round; }
.label-failed text { fill: var(--danger); } .label-failed circle { fill: var(--danger); }
.stage .note { fill: var(--muted); font-family: var(--body); font-style: italic; }
.stage .zone-title { fill: var(--muted); font-family: var(--display); font-weight: 500; }
.stage.paused *, .stage.paused { animation-play-state: paused !important; }

/* Reusable motions: add with { anim: 'name', on: 'selector' } */
.stage [class*="a-"] { transform-box: fill-box; transform-origin: center; }
.a-vibrate { animation: vibrate .14s linear infinite; }
.a-pulse { animation: pulse 1.1s ease-in-out infinite; }
.a-beat { animation: beat .9s ease-in-out infinite; }
.a-glow { animation: glow 1.2s ease-in-out infinite; }
.a-swing { animation: swing .5s ease-in-out infinite alternate; }
.a-squeeze { animation: squeeze 1.4s ease-in-out infinite; }
.a-blink { animation: blink 1s steps(2) infinite; }
.a-sway { animation: sway 1.2s ease-in-out infinite alternate; }
.a-breathe { animation: breathe 4s ease-in-out infinite; }
.a-drift { animation: drift 3s linear infinite; }
.a-dash { stroke-dasharray: 10 12; animation: dash 1s linear infinite; }
@keyframes vibrate { 0%,100% { transform: translateX(-1.6px); } 50% { transform: translateX(1.6px); } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes beat { 0%,60%,100% { transform: scale(1); } 20% { transform: scale(.9); } 35% { transform: scale(1.02); } }
@keyframes glow { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.7) drop-shadow(0 0 8px currentColor); } }
@keyframes swing { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes squeeze { 0%,100% { transform: scale(1,1); } 50% { transform: scale(.88,1.04); } }
@keyframes blink { 50% { opacity: .25; } }
@keyframes sway { from { transform: skewX(-9deg); } to { transform: skewX(9deg); } }
@keyframes breathe { 0%,100% { transform: scale(.94); } 45% { transform: scale(1.05); } }
@keyframes drift { to { transform: translateX(30px); opacity: 0; } }
@keyframes dash { to { stroke-dashoffset: -22; } }

/* ───── 3D stage ───── */
.stage3d { position: relative; overflow: hidden; }
.stage3d canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.labels3d { position: absolute; inset: 0; pointer-events: none; }
.label3d { position: absolute; left: 0; top: 0; margin: -0.7em 0 0 10px; padding: .05rem .5rem; pointer-events: auto; white-space: nowrap;
  font-family: var(--display); font-weight: 500; font-size: .92rem; color: var(--ink); background: rgba(12,36,46,.72); border: 1px solid var(--line); border-radius: 99px; }
.label3d::before { content: ""; position: absolute; left: -14px; top: 50%; width: 7px; height: 7px; margin-top: -4px; border-radius: 50%; background: var(--lamp); box-shadow: 0 0 0 3px rgba(255,193,99,.25); }
.label3d:hover { border-color: var(--lamp); color: var(--lamp); }
.label3d.flip { margin-left: -10px; }
.label3d.flip::before { left: auto; right: -14px; }
.label3d.failed { color: var(--danger); border-color: var(--danger); } .label3d.failed::before { background: var(--danger); }
.label3d[hidden] { display: none; }
.note3d { position: absolute; left: 0; top: 0; margin: -0.6em 0 0 6px; max-width: 60%; white-space: normal; font-style: italic; font-size: .86rem; color: var(--muted); text-shadow: 0 0 4px var(--bg), 0 0 4px var(--bg); }
.note3d[hidden] { display: none; }
.note3d.flip { margin-left: -6px; }

/* Credits page and organ-panel note */
.credits { display: block; }
.credits-page { max-width: 44rem; margin: 0 auto; padding: 2rem 1rem 4rem; color: var(--ink); line-height: 1.55; }
.credits-page h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin: 1rem 0 1.2rem; }
.credits-page h2 { font-size: 1.15rem; margin: 1.6rem 0 .4rem; }
.credits-page a { color: inherit; text-decoration: underline; }
.credits-page .back { display: inline-block; text-decoration: none; opacity: .8; }
.panel-note { margin: .8rem 0 0; }
.panel-note a, .fineprint a { color: inherit; text-decoration: underline; }
