/* Everyday Science Sort: the Sorting Room inside the practice shell's stage (about 1066 x 628 at 1366 x 768).
 * Track F (Foundations): every word in the play area is 18 px or more; every tap target is 48 px or more. */
.ess { position: absolute; inset: 0; overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding: 10px 14px 10px; color: #1f2933; font-size: 18px; line-height: 1.3;
  background: linear-gradient(#f4ede2, #e7dccb);
  --ess-panel: rgba(255, 253, 248, .96); --ess-line: #b9a98e; --ess-soft: #4f4335; --ess-accent: #2f6b5a; --ess-accent-bg: #e1f1ea;
  --ess-ok: #17663a; --ess-bad: #a3241f; --ess-slide: #fffaf0;
  --ess-b0: #dcedf8; --ess-b0-line: #4f8fbf; --ess-b1: #fde6cf; --ess-b1-line: #c0702c; --ess-b2: #e2f2dc; --ess-b2-line: #4f9a4a; }
html[data-theme="dark"] .ess { color: #eef2f6; background: linear-gradient(#1d232d, #161b23);
  --ess-panel: rgba(30, 36, 46, .96); --ess-line: #56657a; --ess-soft: #c9d3de; --ess-accent: #8fd6bd; --ess-accent-bg: #18352c;
  --ess-ok: #7fdca0; --ess-bad: #ffb4a8;
  --ess-b0: #1c3346; --ess-b0-line: #6fb0e0; --ess-b1: #3d2a1a; --ess-b1-line: #e8a060; --ess-b2: #1f3a22; --ess-b2-line: #7fcf78; }
.ess *, .ess *::before, .ess *::after { box-sizing: border-box; }
.ess p, .ess figure { margin: 0; padding: 0; }
.ess button { font: inherit; color: inherit; }

/* pictures sit on a lit cream slide (the same in light and dark) */
.ess-slide { position: relative; display: block; aspect-ratio: 16 / 10; background: var(--ess-slide); border-radius: 8px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(60, 50, 36, .3), 0 1px 3px rgba(0, 0, 0, .14); flex: none; }
.ess-pic { display: block; width: 100%; height: 100%; }

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

/* ── the tray of picture cards ── */
.ess-tray-box { flex: none; padding: 8px 12px 10px; border-radius: 14px; background: var(--ess-panel); border: 1.5px solid var(--ess-line); }
.ess-tray-box.is-empty .ess-tray { display: none; }
.ess-tray-box.is-empty .ess-k { margin: 0; }
.ess-tray-box.is-empty .ess-tray-note { color: var(--ess-ok); font-weight: 700; }
.ess-tray-box.is-over { outline: 4px dashed var(--ess-accent); outline-offset: 2px; }
.ess-tray { display: flex; justify-content: center; gap: 12px; }
html .ess-card { position: relative; flex: 1 1 0; min-width: 0; max-width: 200px; display: flex; flex-direction: column; gap: 4px; padding: 6px; border-radius: 12px;
  border: 2.5px solid var(--ess-line); background: var(--ess-panel); cursor: grab; text-align: center; min-height: 48px; }
.ess-card .ess-slide { width: 100%; }
.ess-name { display: block; font-weight: 700; line-height: 1.2; overflow-wrap: break-word; }
html .ess-card:hover:not(:disabled) { border-color: var(--ess-accent); }
html .ess-card.is-held { border-color: #e0a21c; box-shadow: 0 0 0 4px rgba(255, 196, 61, .55), 0 6px 14px rgba(0, 0, 0, .22); background: #fff7dc; }
html[data-theme="dark"] .ess-card.is-held { background: #3a3220; }
.ess-card:focus-visible, .ess-chip:focus-visible, .ess-bin-btn:focus-visible, .ess-say:focus-visible { outline: 4px solid #ffb000; outline-offset: 2px; }

/* ── bins ── */
.ess-bins { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ess--b3 .ess-bins { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ess-bin { min-height: 0; display: flex; flex-direction: column; border-radius: 14px; border: 2.5px solid var(--ess-b0-line); background: var(--ess-b0); overflow: hidden; }
.ess-bin--1 { border-color: var(--ess-b1-line); background: var(--ess-b1); }
.ess-bin--2 { border-color: var(--ess-b2-line); background: var(--ess-b2); }
.ess-bin.is-over { box-shadow: 0 0 0 4px #ffc43d; }
html .ess-bin-btn { flex: none; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 64px; padding: 6px 10px; border: 0; border-bottom: 2px solid rgba(0, 0, 0, .12); background: rgba(255, 255, 255, .55); text-align: left; cursor: pointer; }
html[data-theme="dark"] .ess-bin-btn { background: rgba(0, 0, 0, .18); border-bottom-color: rgba(255, 255, 255, .12); }
.ess-icon { flex: none; width: 52px; height: 52px; border-radius: 10px; background: #fffaf0; box-shadow: inset 0 0 0 1px rgba(60, 50, 36, .25); }
.ess-bin-t { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.2; }
.ess-bin-t b { font-size: 20px; }
.ess-bin-t span { color: var(--ess-soft); }
.ess-bin-n { flex: none; min-width: 30px; height: 30px; display: grid; place-items: center; border-radius: 999px; background: rgba(0, 0, 0, .1); font-weight: 800; }
.ess-bin-n:empty { visibility: hidden; }
html .ess-bin-btn.is-ready { background: rgba(255, 214, 90, .4); box-shadow: inset 0 0 0 3px #e0a21c; }
html .ess-bin-btn:hover:not(:disabled) { background: rgba(255, 214, 90, .3); }
.ess-bin-list { flex: 1 1 auto; min-height: 0; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 8px; }
html .ess-chip { width: calc(50% - 4px); max-width: 160px; display: flex; flex-direction: column; gap: 3px; padding: 5px; border-radius: 10px; border: 2px solid var(--ess-line); background: var(--ess-panel); cursor: grab; text-align: center; min-height: 48px; }
.ess--b2 .ess-chip { width: calc(33.3% - 6px); }
.ess-chip .ess-slide { width: 100%; }
.ess-chip .ess-name { font-size: 18px; }
.ess.is-dragging, .ess.is-dragging * { cursor: grabbing; }
.ess-ghost { position: fixed; z-index: 2147483600; width: 150px; transform: translate(-50%, -60%) rotate(-3deg); pointer-events: none; box-shadow: 0 10px 24px rgba(0, 0, 0, .35); border-radius: 8px; }
@media (pointer: fine), (min-width: 901px) { html .ess-card:not(:disabled), html .ess-chip:not(:disabled) { touch-action: none; } }
.ess.is-locked .ess-card, .ess.is-locked .ess-chip, .ess.is-locked .ess-bin-btn { cursor: default; }
.ess button:disabled { opacity: 1; }

/* ── reveal: each card in its right bin, marked, with its reason ── */
.ess.is-revealed .ess-bin-list { flex-direction: column; flex-wrap: nowrap; gap: 6px; }
.ess-why { display: flex; align-items: flex-start; gap: 10px; padding: 6px; border-radius: 10px; background: var(--ess-panel); border: 2px solid var(--ess-line); }
.ess-why .ess-slide { width: 112px; }
.ess-why.is-ok { border-color: #3aa364; }
.ess-why.is-bad { border-color: #d0574c; }
.ess-why-t { min-width: 0; flex: 1 1 auto; line-height: 1.25; }
.ess-moved { color: var(--ess-bad); font-weight: 700; }
/* the ✓ / ✗ sits inline before the card's name, never on the picture */
.ess-mark { display: inline-grid; vertical-align: -6px; margin-right: 6px; width: 28px; height: 28px; place-items: center; border-radius: 50%; font-size: 18px; font-weight: 800; color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.ess-why.is-ok .ess-mark { background: #17663a; }
.ess-why.is-bad .ess-mark { background: #a3241f; }
.ess.is-revealed .ess-bin.is-emptybin .ess-bin-list { display: none; }

/* ── Briefing example ── */
.ess-example { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; }
.ess-example figure { flex: 1 1 220px; max-width: 300px; }
.ess-example .ess-slide { width: 100%; }
.ess-example figcaption { margin-top: 4px; line-height: 1.25; }

/* ── Foundations: 18 px for the shell's words beside the play area too ── */
body[data-activity="everyday-science-sort"] .ps-bubble, body[data-activity="everyday-science-sort"] .ps-cust-detail, body[data-activity="everyday-science-sort"] .ps-feedback,
body[data-activity="everyday-science-sort"] .ps-hint, body[data-activity="everyday-science-sort"] .ps-gloss, body[data-activity="everyday-science-sort"] .ps-cust-who,
body[data-activity="everyday-science-sort"] .ps-nudge { font-size: 18px; line-height: 1.3; }
body[data-activity="everyday-science-sort"] .ps-cust-detail { color: var(--tlg-text); }
body[data-activity="everyday-science-sort"] .ps-say { width: 48px; height: 48px; font-size: 22px; margin: -2px -4px 4px 8px; }
body[data-activity="everyday-science-sort"] .ps-hint-btn { min-height: 48px; }
body[data-activity="everyday-science-sort"] .ps-hint .ps-hint-note { font-size: 16px; }
/* after Check the how-to line and the used hint are no longer needed: give their room to the feedback */
body[data-activity="everyday-science-sort"] .ps-side:has(.ps-feedback:not([hidden])) .ps-cust-detail,
body[data-activity="everyday-science-sort"] .ps-side:has(.ps-feedback:not([hidden])) .ps-hint { display: none; }

/* ── a narrower stage: the play area may scroll inside the stage instead of squeezing the pictures ── */
@media (max-width: 1180px) and (min-width: 901px) {
  .ess { overflow-y: auto; }
  .ess-bins { flex: none; }
  .ess-bin-list { min-height: 90px; }
  .ess--b3 .ess-chip { width: 100%; max-width: 180px; }
  .ess-why { flex-direction: column; }
  .ess-why .ess-slide { width: 100%; max-width: 200px; }
  /* three bins side by side are narrow here: icon and count on the first line, the bin's name and rule full width below */
  html .ess--b3 .ess-bin-btn { position: relative; flex-wrap: wrap; align-items: flex-start; gap: 4px 8px; padding-right: 40px; }
  .ess--b3 .ess-icon { width: 40px; height: 40px; }
  .ess--b3 .ess-bin-t { flex-basis: 100%; }
  .ess--b3 .ess-bin-n { position: absolute; right: 6px; top: 6px; }
}
@media (max-width: 900px) {
  .ess { position: relative; inset: auto; overflow: visible; padding: 10px 10px 16px; }
  .ess-head { flex-wrap: wrap; }
  .ess-tray { flex-wrap: wrap; }
  html .ess-card { flex: 0 0 calc(50% - 6px); max-width: 220px; }
  .ess-bins, .ess--b3 .ess-bins { grid-template-columns: minmax(0, 1fr); }
  .ess-bin-list { min-height: 56px; }
  html .ess-chip, .ess--b2 .ess-chip { width: calc(33.3% - 6px); max-width: 160px; }
}
@media (max-width: 520px) {
  html .ess-chip, .ess--b2 .ess-chip { width: calc(50% - 4px); }
  .ess-why .ess-slide { width: 96px; }
  .ess-icon { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .ess-card, .ess-chip, .ess-bin-btn { transition: border-color .12s, background-color .12s, transform .12s, box-shadow .12s; }
  .ess.is-revealed .ess-why { animation: ess-pop .35s ease-out; }
  @keyframes ess-pop { 0% { transform: scale(.94); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }
}
