/* Adaptation Detective: the Field Evidence Desk inside the practice shell's stage (about 1066 x 628 at 1366 x 768).
 * Foundations: every word in the play area is 18 px or more; every tap target is 48 px or more.
 * Pictures sit on a lit cream slide that stays the same in light and dark (the art is drawn for it). */
.ad { position: absolute; inset: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 14px; padding: 10px 14px; color: #2a2116; font-size: 18px; line-height: 1.3;
  background: linear-gradient(#f4eedf, #e6dcc4);
  --ad-panel: rgba(255, 252, 244, .96); --ad-line: #c4ab82; --ad-soft: #5a4a33; --ad-accent: #7a4a1e; --ad-accent-bg: #f3e4cc;
  --ad-slide: #fffdf6; --ad-ink: #2a2116; }
html[data-theme="dark"] .ad { color: #f1ebe0; background: linear-gradient(#211c16, #17140f);
  --ad-panel: rgba(38, 33, 26, .97); --ad-line: #6e5c42; --ad-soft: #ddd0bb; --ad-accent: #e7b877; --ad-accent-bg: #3a2d1c; }
.ad *, .ad *::before, .ad *::after { box-sizing: border-box; }
.ad p, .ad figure, .ad figcaption { margin: 0; padding: 0; }
.ad button { font: inherit; color: inherit; }
.ad svg { display: block; }
.ad :focus-visible { outline: 4px solid #ffb000; outline-offset: 2px; }

/* ── picture (left) ── */
.ad .ad-scenebox { container: adscene / inline-size; min-height: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: 14px; background: var(--ad-panel); border: 1.5px solid var(--ad-line); }
.ad-scene-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--ad-slide); color: var(--ad-ink); box-shadow: inset 0 0 0 1px rgba(80, 60, 30, .22); overflow: hidden; }
.ad p.ad-cap { flex: none; font-weight: 600; }
.ad p.ad-model { flex: none; color: var(--ad-soft); font-style: italic; }
.ad.is-revealed .ad-scenebox { border-color: var(--ad-accent); box-shadow: 0 0 0 3px var(--ad-accent-bg); }

/* one living thing (match) */
.ad-solo { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ad-solopic { display: block; width: 330px; height: 264px; background: #f6f1e4; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(80, 60, 30, .18); }
.ad-solopic svg { width: 100%; height: 100%; }
.ad-trait { padding: 6px 14px; border-radius: 10px; background: #f3e4cc; border: 2px solid #b98a4a; }

/* habitats */
.ad-big { width: 100%; display: flex; justify-content: center; }
.ad-habcard { display: block; width: 100%; max-width: 480px; border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 2px #b9a27a; }
.ad-habpic { display: block; aspect-ratio: 3 / 2; }
.ad-habpic svg { width: 100%; height: 100%; }
.ad p.ad-where { font-weight: 700; text-align: center; }
.ad-pair { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; }
.ad-habcard.is-small { max-width: 170px; }
.ad p.ad-change { line-height: 1.3; }

/* groups of 10 */
.ad-strip { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.ad-strip--two { gap: 12px; align-items: stretch; }
.ad-arrow { flex: none; display: block; width: 40px; height: 22px; }
.ad-arrow svg { width: 100%; height: 100%; }
.ad-gcard { flex: 1 1 0; min-width: 0; max-width: 230px; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border-radius: 12px; background: #fbf6ea; border: 2px solid #cdb68e; }
.ad-gcard.is-answer { border-color: #2f9a5c; box-shadow: 0 0 0 3px #2f9a5c; }
.ad-ghead { font-weight: 700; text-align: center; line-height: 1.15; }
.ad p.ad-gcount { text-align: center; line-height: 1.2; }
.ad-group { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; width: 100%; }
.ad-ind { display: block; aspect-ratio: 5 / 4; }
.ad-ind svg { width: 100%; height: 100%; }
.ad-gcard--q { align-self: stretch; justify-content: center; border-style: dashed; }
.ad-qbox { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: #f3e4cc; border: 3px dashed #b98a4a; font-size: 36px; font-weight: 800; color: #7a4a1e; }
.ad-strip--three .ad-gcard { max-width: none; }
.ad-gcol { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.ad-gcol .ad-gcard { max-width: none; }
.ad-gA { border-color: #5d8fb3; background: #eef4f9; }
.ad-gB { border-color: #b0688c; background: #f9eef3; }
.ad-famcard { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ad-fampic { display: block; width: 100%; max-width: 260px; aspect-ratio: 24 / 13; }
.ad-fampic svg { width: 100%; height: 100%; }
.ad--why .ad-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ad--why .ad-pair .ad-habcard.is-small { max-width: none; }

/* ── task (right) ── */
.ad-task { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 8px; container-type: inline-size; }
.ad-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: none; min-height: 48px; flex-wrap: wrap; }
.ad p.ad-title { min-width: 0; padding: 6px 14px; border-radius: 12px; background: var(--ad-panel); border: 1.5px solid var(--ad-line); }
.ad-title b { font-size: 20px; }
html .ad-say { flex: none; min-height: 48px; padding: 8px 14px; border-radius: 999px; border: 2px solid var(--ad-line); background: var(--ad-panel); font-weight: 700; cursor: pointer; white-space: nowrap; }
.ad-say[aria-pressed="true"] { border-color: var(--ad-accent); }
.ad-say:hover { background: var(--ad-accent-bg); }
.ad-k { flex: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.ad-k span { color: var(--ad-soft); }
.ad-msg { font-weight: 700; flex: none; }
.ad-msg:empty { display: none; }
.ad button:disabled { opacity: 1; cursor: default; }

.ad-choices { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
html .ad-choice { position: relative; display: flex; align-items: center; gap: 14px; min-height: 48px; padding: 8px 12px 8px 8px; border-radius: 14px; border: 2.5px solid var(--ad-line); background: var(--ad-panel); text-align: left; cursor: pointer; }
.ad-cpic { flex: none; display: grid; place-items: center; width: 150px; height: 100px; background: var(--ad-slide); border-radius: 10px; box-shadow: inset 0 0 0 1px rgba(80, 60, 30, .22); overflow: hidden; }
.ad-cpic > svg { width: 100%; height: 100%; }
.ad-cpic .ad-group { padding: 4px; gap: 1px; }
.ad-choice-t { flex: 1 1 auto; min-width: 0; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
html .ad-choice:hover:not(:disabled) { border-color: var(--ad-accent); background: var(--ad-accent-bg); }
html .ad-choice.is-chosen { border-color: var(--ad-accent); box-shadow: 0 0 0 3px var(--ad-accent); }

/* ✓ / ✗ after Check: at the end of the choice, never on a picture */
.ad-mark { display: none; }
.ad.is-revealed .ad-mark:not(:empty) { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; font-size: 20px; font-weight: 800; color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
html .ad.is-revealed .ad-choice.is-right { border-color: #2f9a5c; box-shadow: 0 0 0 3px #2f9a5c; }
html .ad.is-revealed .ad-choice.is-wrong { border-color: #c4473d; box-shadow: 0 0 0 3px #c4473d; }
.ad.is-revealed .is-right .ad-mark { background: #17663a; }
.ad.is-revealed .is-wrong .ad-mark { background: #a3241f; }

/* ── Briefing example and Start art ── */
.ad-example { position: static; display: grid; grid-template-columns: 1fr 1fr 1.1fr; gap: 14px; align-items: start; padding: 0; background: none; overflow: visible; color: inherit; }
.ad-example figure { display: flex; flex-direction: column; gap: 6px; }
.ad-example figcaption { line-height: 1.3; }
.ad-ex-pic { display: block; aspect-ratio: 3 / 2; border-radius: 10px; overflow: hidden; box-shadow: 0 0 0 1px rgba(80, 60, 30, .3); }
.ad-ex-pic svg { width: 100%; height: 100%; }
.ad-ex-groups { display: flex; gap: 8px; padding: 6px; background: #fffdf6; border-radius: 10px; color: #2a2116; box-shadow: inset 0 0 0 1px rgba(80, 60, 30, .22); }
.ad-ex-g { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.ps-brief--drawer .ad-example { grid-template-columns: 1fr; }
.ad-start { width: 100%; height: 100%; display: grid; place-items: center; background: #eef3e6; border-radius: 12px; overflow: hidden; }
.ad-start svg { width: 100%; height: 100%; }

/* ── Foundations: 18 px for the shell's words beside the play area too ── */
body[data-activity="adaptation-detective"] .ps-bubble, body[data-activity="adaptation-detective"] .ps-cust-detail, body[data-activity="adaptation-detective"] .ps-feedback,
body[data-activity="adaptation-detective"] .ps-hint, body[data-activity="adaptation-detective"] .ps-gloss, body[data-activity="adaptation-detective"] .ps-cust-who,
body[data-activity="adaptation-detective"] .ps-nudge { font-size: 18px; line-height: 1.3; }
body[data-activity="adaptation-detective"] .ps-cust-detail { color: var(--tlg-text); }
body[data-activity="adaptation-detective"] .ps-say { width: 48px; height: 48px; font-size: 22px; margin: -2px -4px 4px 8px; }
body[data-activity="adaptation-detective"] .ps-hint-btn { min-height: 48px; }
body[data-activity="adaptation-detective"] .ps-hint .ps-hint-note { font-size: 16px; }
body[data-activity="adaptation-detective"] .ps-side:has(.ps-feedback:not([hidden])) .ps-cust-detail,
body[data-activity="adaptation-detective"] .ps-side:has(.ps-feedback:not([hidden])) .ps-hint { display: none; }

/* a narrower right column: smaller pictures */
@container (max-width: 440px) {
  .ad-cpic { width: 120px; height: 84px; }
  html .ad-choice { gap: 10px; }
}
/* a narrow picture panel: stack the change row, shrink the habitat */
@container adscene (max-width: 520px) {
  .ad-pair { grid-template-columns: 120px minmax(0, 1fr); gap: 8px; }
  .ad-habcard.is-small { max-width: 120px; }
  .ad--why .ad-pair { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ad-solopic { width: 260px; height: 208px; }
  .ad-strip--three .ad-arrow { width: 22px; }
  .ad-strip--three { gap: 4px; }
}
/* very narrow (1024 x 768 two-column, phones): the group cards stack so each living thing stays big enough to see */
@container adscene (max-width: 400px) {
  .ad-strip, .ad-strip--three { flex-direction: column; align-items: stretch; gap: 4px; }
  .ad-strip .ad-arrow, .ad-strip--three .ad-arrow { display: block; align-self: center; width: 22px; height: 30px; transform: rotate(90deg); }
  .ad-gcard, .ad-strip--three .ad-gcard { flex: none; max-width: none; width: 100%; }
  .ad-group { max-width: 300px; }
  .ad-gcol { gap: 4px; }
  .ad--why .ad-pair { grid-template-columns: minmax(0, 1fr); }
  .ad-fampic { max-width: 220px; }
}
@media (max-width: 1180px) and (min-width: 901px) {
  .ad { overflow-y: auto; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .ad-scene-body { flex: none; overflow: visible; }
}
@media (max-width: 900px) {
  .ad { position: relative; inset: auto; overflow: visible; grid-template-columns: minmax(0, 1fr); padding: 10px 10px 16px; }
  .ad-scene-body { overflow: visible; }
  .ad-example { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .ad-pair { grid-template-columns: minmax(0, 1fr); }
  .ad-habcard.is-small { max-width: 220px; margin: 0 auto; }
  .ad--why .ad-pair { grid-template-columns: minmax(0, 1fr); }
  .ad-solopic { width: 220px; height: 176px; }
  .ad-cpic { width: 104px; height: 74px; }
  .ad-strip { gap: 4px; }
  .ad-arrow { width: 26px; }
}
@media (prefers-reduced-motion: no-preference) {
  .ad-choice { transition: border-color .12s, background-color .12s, box-shadow .12s; }
  .ad.is-revealed .ad-scenebox { animation: ad-pop .35s ease-out; }
  @keyframes ad-pop { 0% { transform: scale(.98); opacity: .6; } 100% { transform: scale(1); opacity: 1; } }
}
