/* Game 2: Parental Testing. Loaded after zora.css and clinic.css; colours come from clinic.css. */

body { padding: 8px; min-height: 100vh; }
.parentage-page { max-width: none; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.parentage-page [tabindex="-1"]:focus, .feedback:focus { outline: none; }

/* Frames: the art's border is 24px wide but its decoration sits in the outer part, so the content
   may start closer to the edge than the full border width. */
.parentage-page .panel { border-width: 16px; padding: 0 2px; margin: 0; min-width: 0; }
.parentage-page h2 { font-size: 1rem; margin: 0 0 4px; }
.parentage-page h3, .px-popup h3 { font-size: 0.95rem; margin: 0; }
/* Cells that scroll inside themselves show a scroll bar whenever there is more to see. */
.cell-scroll::-webkit-scrollbar, #task::-webkit-scrollbar, .candidate-body::-webkit-scrollbar, .feedback::-webkit-scrollbar,
.reveal::-webkit-scrollbar, dialog.px-popup::-webkit-scrollbar { width: 12px; height: 12px; }
.cell-scroll::-webkit-scrollbar-track, #task::-webkit-scrollbar-track, .candidate-body::-webkit-scrollbar-track, .feedback::-webkit-scrollbar-track,
.reveal::-webkit-scrollbar-track, dialog.px-popup::-webkit-scrollbar-track { background: var(--ink); }
.cell-scroll::-webkit-scrollbar-thumb, #task::-webkit-scrollbar-thumb, .candidate-body::-webkit-scrollbar-thumb, .feedback::-webkit-scrollbar-thumb,
.reveal::-webkit-scrollbar-thumb, dialog.px-popup::-webkit-scrollbar-thumb { background: var(--mint-bright); border: 3px solid var(--ink); }
@supports not selector(::-webkit-scrollbar) {
  .cell-scroll, #task, .candidate-body, .feedback, .reveal, dialog.px-popup { scrollbar-width: thin; scrollbar-color: var(--mint-bright) var(--ink); }
}

/* ---- Top bar ---- */
.parentage-page .topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; border-width: 12px; padding: 0 8px; }
.topbar h1 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.2rem; text-align: left; }
.topbar h1, .levels button, .progress, .top-link { white-space: nowrap; }
.levels { display: flex; flex-wrap: wrap; gap: 6px; }
.levels button { min-height: 40px; }
/* The level being played: pressed in, with gold lettering (also while the mouse is over it). */
.levels button[aria-pressed="true"], .levels button[aria-pressed="true"]:hover:not(:disabled) {
  border-image-source: url(clinic/btn2_down.png); color: var(--gold); text-shadow: 1px 1px 0 var(--ink); }
.progress-box { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.progress { color: var(--cream); font-weight: 600; }
.stars { display: inline-flex; gap: 2px; }
.stars .star { width: 24px; height: 24px; }
.stars .star.off { filter: grayscale(1) brightness(0.55); opacity: 0.7; }
.top-links { display: flex; align-items: center; gap: 16px; }
.top-link, button.link.top-link { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; color: var(--ice);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.top-link .px-icon { width: 24px; height: 24px; }

/* ---- The known parent and the baby on one stage ---- */
.bento { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.scene { display: flex; min-width: 0; min-height: 0; }
.scene .stage { flex: 1 1 auto; height: min(62vw, 60vh); min-height: 200px; }
.stage .plate { font-size: 0.85rem; }
/* A pedestal is a square that fits both the stage's width and its height, so the platform stays
   under the zora's feet whatever shape the stage has. */
@supports (width: 1cqw) {
  .stage { container-type: size; }
  .stage .pedestal { flex: none; width: min(46cqw, 86cqh); height: auto; max-width: none; }
  .reveal .stage .pedestal { width: min(80cqw, 86cqh); }   /* one zora on its own may be wider */
}

/* ---- Known parent's alleles, baby's features ---- */
.info { display: flex; flex-direction: column; min-height: 0; }
.cell-scroll { overflow: auto; min-height: 0; }
.gtable { font-size: 0.85rem; }
.gtable th, .gtable td { padding: 2px 6px; vertical-align: top; }
.gtable td { color: var(--cream); }
.gtable .col-head, .gtable tbody th { color: var(--mint); }
.gtable .col-head { border-bottom: 2px solid var(--edge); white-space: nowrap; }
/* The two copies get equal columns wide enough for their words; a long gene name wraps first. */
.gtable .col-head { width: 32%; }
.gtable .col-head:first-child { width: 36%; }
.gtable .chr-head { color: var(--mint); font: 700 0.72rem var(--heading-font); text-transform: uppercase; letter-spacing: 0.04em;
  padding-top: 5px; opacity: 0.85; }
.feature-list { font-size: 0.9rem; color: var(--cream); }
.feature-list li { padding: 3px 0; }

/* ---- The task ---- */
.task-cell { display: flex; flex-direction: column; min-height: 0; }
#task { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: auto; }
.instruction { margin: 0 0 6px; font-size: 1rem; font-weight: 600; color: var(--cream); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
.pending { flex: 1 1 8rem; min-width: 0; color: var(--dim); font-size: 0.9rem; }
.actions [hidden] { display: none; }

/* Level 1: one row per gene */
.tick-list { display: grid; grid-auto-rows: minmax(min-content, 1fr); flex: 1 1 auto; }
.tick-gene { display: grid; grid-template-columns: minmax(0, 1fr); align-items: center; gap: 2px 14px; padding: 6px 8px;
  border-top: 2px solid var(--wall-3); border-left: 4px solid transparent; }
.tick-gene:nth-child(even) { background: var(--wall-2); }
.tick-gene.good { border-left-color: var(--mint-bright); }
.tick-gene.bad { border-left-color: var(--pink); }
.tick-head { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
.tick-name { font-weight: 700; font-size: 1rem; }
.tick-given { display: flex; flex-direction: column; min-width: 0; }
.given { color: var(--cream); font-size: 0.85rem; line-height: 1.3; overflow-wrap: anywhere; }
.given.possible { font-weight: 700; }
.tick-boxes { display: flex; flex-wrap: wrap; gap: 6px; }
/* An allele choice: a chip with a real checkbox inside. */
.tick-chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; min-width: 6.4rem; padding: 0 6px 0 2px;
  color: var(--cream); font-size: 0.95rem; cursor: pointer; user-select: none;
  border: solid transparent; border-width: 6px 12px;
  border-image: url(clinic/chip.png) 4 fill / 12px stretch; image-rendering: pixelated; }
.tick-chip input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--mint-bright); cursor: inherit; }
.tick-chip:hover:not(.locked) { color: var(--gold); }
.tick-chip.ticked { outline: 3px solid var(--mint-bright); outline-offset: -3px; font-weight: 700; }
.tick-chip.locked { cursor: default; }

/* Marks: right and wrong */
.tag { display: inline-block; padding: 1px 6px; font: 700 0.75rem var(--heading-font); color: var(--ink); white-space: nowrap; }
.tag.good { background: var(--mint-bright); }
.tag.bad { background: var(--pink); }
.verdict { font: 700 1.15rem var(--heading-font); margin-bottom: 8px; }
.verdict.good, .gene-result.good .mark { color: var(--mint-bright); }
.verdict.bad, .gene-result.bad .mark { color: var(--pink); }
.gene-result { list-style: none; padding: 5px 0; overflow-wrap: anywhere; }
.gene-result .mark { font-weight: 700; margin-right: 6px; }
.gene-result .why { color: var(--dim); font-size: 0.85rem; display: block; margin-top: 2px; }
.reasons { list-style: none; margin-top: 4px; }
.reasons li { color: var(--dim); font-size: 0.8rem; padding: 2px 0 2px 10px; border-left: 2px solid var(--edge); overflow-wrap: anywhere; }
.summary { list-style: none; margin-bottom: 4px; }
.complete { margin-top: 8px; font-weight: 700; color: var(--gold); }
.popup-note { margin-top: 8px; color: var(--dim); font-size: 0.9rem; }

/* Level 2: a row of candidate cards */
.lineup { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.candidate { display: flex; flex-direction: column; gap: 6px; min-width: 0; min-height: 0; border-width: 12px; padding: 2px 2px 4px; }
.candidate-head { display: flex; flex-direction: column; gap: 2px; }
.candidate-head h3 { color: var(--gold); font-size: 1rem; }
.candidate-head .zora-box { flex: none; align-self: center; width: min(100%, 180px); }
.candidate-body { flex: 1 1 auto; min-height: 0; overflow: hidden auto; }
/* A slim scroll bar, so the allele table still fits beside it once the reasons are added after Check. */
.candidate-body::-webkit-scrollbar { width: 6px; }
.candidate-body::-webkit-scrollbar-thumb { border-width: 1px; }
.candidate .gtable { font-size: 0.8rem; }
.candidate .gtable th, .candidate .gtable td { padding: 1px 4px; }
.candidate .gtable .col-head { letter-spacing: 0; font-size: 0.66rem; white-space: nowrap; width: 35%; }
.candidate .gtable .col-head:first-child { width: 30%; }
.candidate-result { padding: 0 0 6px; margin-bottom: 4px; border-bottom: 2px solid var(--edge); }
.candidate-result .why { color: var(--cream); }
.mark-buttons { display: grid; gap: 6px; }
/* The chosen mark turns mint and stays mint after Check, when the buttons are switched off. */
.mark-button { min-height: 40px; padding: 0 0 3px; font-size: 0.78rem; white-space: normal; }
.mark-button[aria-pressed="true"], .mark-button[aria-pressed="true"]:disabled, .mark-button[aria-pressed="true"]:hover:not(:disabled) {
  border-image-source: url(clinic/btn.png); color: var(--ink); text-shadow: none; padding: 0 0 3px; }
.badge { margin: 0 2px; padding: 2px 6px; text-align: center; font: 700 0.75rem var(--heading-font); background: var(--gold); color: var(--ink);
  box-shadow: 0 0 0 2px var(--ink); }

/* ---- Pop-ups ---- */
dialog.px-popup { border-width: 18px; padding: 2px 6px 4px; }
.px-popup .popup-head h2 { font-size: 1.1rem; }
.px-popup .close { min-width: 44px; min-height: 40px; padding: 0 4px 3px; }
.px-popup .close .px-icon { width: 24px; height: 24px; }
.how-popup { width: min(640px, 94vw); }
.how-popup .intro { color: var(--cream); font-size: 1rem; line-height: 1.5; text-align: left; margin: 0 0 10px; max-width: none; }
.result-popup { width: min(520px, 94vw); }
.result-popup[data-level="1"] { width: min(1100px, 94vw); }
.result-popup .feedback { min-width: 0; }
.result-popup .feedback ul { margin: 0; padding: 0; }
.reveal:empty { display: none; }
.reveal h2 { font-size: 1.05rem; margin: 0 0 4px; }
.reveal-note { color: var(--dim); font-size: 0.85rem; line-height: 1.35; margin: 0 0 8px; }
.reveal .stage { height: min(60vw, 240px); margin-bottom: 8px; }
.reveal .gtable { font-size: 0.85rem; }
.popup-actions { margin-top: 10px; }
.popup-actions .progress { font-size: 0.9rem; }

/* Trait-name hints (zora-widgets.js), in the clinic's colours */
.hint:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 0; }
.hint-tip { background: var(--ink); color: var(--cream); border: 2px solid var(--gold); border-radius: 0;
  box-shadow: 4px 4px 0 var(--ink); z-index: 50; }
.hint-sample { color: var(--mint); }

/* ---- Middle widths: the stage on top, the two information cells side by side ---- */
@media (min-width: 620px) {
  .bento { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .scene, .task-cell { grid-column: 1 / -1; }
  .scene .stage { height: min(46vw, 56vh); }
  .tick-gene { grid-template-columns: 8.5rem minmax(0, 1fr) auto; }
  .tick-head { flex-direction: column; align-items: flex-start; }
  .lineup { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .result-popup[data-level="1"] .reveal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; align-items: start; }
  .result-popup[data-level="1"] .reveal h2, .result-popup[data-level="1"] .reveal-note { grid-column: 1 / -1; }
  .result-popup[data-level="1"] .reveal .stage { height: clamp(220px, 38vh, 400px); margin: 0; }
}

/* ---- Bento: the page fills the window and does not scroll; cells scroll inside themselves ---- */
@media (min-width: 1240px) and (min-height: 620px) {
  .parentage-page { height: calc(100vh - 16px); }
  .parentage-page .topbar { flex: none; }
  .parentage-page h2 { font-size: 0.88rem; }
  .bento { flex: 1 1 auto; min-height: 0;
    grid-template-columns: minmax(0, 19fr) minmax(0, 16fr) minmax(0, 64fr);
    grid-template-rows: minmax(170px, 1fr) minmax(0, auto);
    grid-template-areas: "scene scene task" "known baby task"; }
  .scene { grid-area: scene; }
  .scene .stage { height: auto; min-height: 0; }
  .known-cell { grid-area: known; }
  .baby-cell { grid-area: baby; }
  .task-cell { grid-area: task; }
  .info .gtable { font-size: 0.78rem; line-height: 1.15; }
  .info .gtable th, .info .gtable td { padding: 1px 5px 0; }
  .info .gtable .chr-head { padding-top: 2px; font-size: 0.66rem; }
  .info .gtable .col-head { font-size: 0.68rem; letter-spacing: 0.5px; }
  .feature-list { font-size: 0.82rem; }
  .tick-gene { padding: 2px 8px; }
  .given { line-height: 1.2; }
  .lineup { flex: 1 1 0; min-height: 0; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-rows: minmax(0, 1fr); }
  .candidate { overflow: hidden; }
  /* The picture is sized from the window's height so the allele table fits under it. */
  .candidate-head .zora-box { width: min(100%, 13vh); }
  .candidate .gtable { font-size: 0.7rem; }
  .candidate .gtable th, .candidate .gtable td { padding: 1px 2px; }
  .candidate .gtable .chr-head { font-size: 0.64rem; padding-top: 2px; }
  .mark-button { font-size: 0.7rem; }

  /* The feedback pop-up: the list of reasons scrolls inside its own column. */
  .result-popup[open] { display: flex; flex-direction: column; overflow: hidden; }
  .result-popup .popup-head, .result-popup .popup-actions { flex: none; }
  .result-body { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); gap: 16px; }
  .result-popup[data-level="1"] .result-body { grid-template-columns: minmax(0, 10fr) minmax(0, 11fr); }
  .result-popup .feedback, .result-popup .reveal { overflow: auto; min-height: 0; }
  .result-popup .feedback { padding-right: 6px; }
  .result-popup[data-level="1"] .reveal { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); align-content: start; }
}
/* Short windows: the candidate's picture sits beside its name, to leave the table more room. */
@media (min-width: 1240px) and (min-height: 620px) and (max-height: 699px) {
  .candidate { gap: 4px; }
  .candidate-head { flex-direction: row-reverse; align-items: center; justify-content: space-between; }
  .candidate-head .zora-box { align-self: auto; width: min(60%, 12vh); }
}
@media (min-width: 1240px) and (max-width: 1420px) {
  .parentage-page .topbar { gap: 4px 12px; padding: 0 4px; }
  .topbar h1 { font-size: 1.02rem; gap: 6px; }
  .topbar h1 .px-icon { width: 24px; height: 24px; }
  .levels button { font-size: 0.8rem; padding-left: 8px; padding-right: 8px; }
  .progress { font-size: 0.9rem; }
  .instruction { font-size: 0.92rem; }
  .stars .star { width: 20px; height: 20px; }
  .top-links { gap: 10px; }
  .top-link { font-size: 0.9rem; }
}
@media (min-width: 1240px) and (min-height: 820px) {
  .parentage-page h2 { font-size: 1rem; }
  .info .gtable { font-size: 0.88rem; line-height: 1.25; }
  .info .gtable th, .info .gtable td { padding: 2px 6px; }
  .info .gtable .chr-head { padding-top: 4px; font-size: 0.72rem; }
  .feature-list { font-size: 0.9rem; }
  .tick-gene { padding: 6px 8px; }
  .given { line-height: 1.3; }
  .candidate .gtable { font-size: 0.78rem; }
  .candidate .gtable th, .candidate .gtable td { padding: 2px 3px; }
  .candidate .gtable .chr-head { font-size: 0.68rem; padding-top: 4px; }
  /* Tall windows have room for a bigger picture; after Check it shrinks to leave room for the reasons. */
  .candidate-head .zora-box { width: min(100%, 20vh); }
  .candidate.good .candidate-head .zora-box, .candidate.bad .candidate-head .zora-box { width: min(100%, 12vh); }
  .mark-button { font-size: 0.8rem; }
  .tick-chip { min-height: 44px; }
  .given { font-size: 0.95rem; }
}
@media (max-width: 619px) {
  .topbar h1 { font-size: 1rem; }
  .progress-box { margin-left: 0; }
  .levels button { font-size: 0.8rem; }
}
/* Very large windows: the candidates' tables can use the spare room. */
@media (min-width: 1700px) and (min-height: 980px) {
  .candidate .gtable { font-size: 0.92rem; }
  .candidate .gtable th, .candidate .gtable td { padding: 3px 4px; }
  .candidate .gtable .col-head { font-size: 0.72rem; }
  .candidate .gtable .chr-head { font-size: 0.74rem; }
}
