/* ============================================================================
   Put the Story in Order (studies/story-order.html, story-order.js). On top of
   lamp.css (tokens, buttons, light and dark) and kids-trivia.css (the setup
   tiles, menu, roster, scoreboard and standings it shares with Bible Trivia).
   This file adds the board: numbered cards to drag or tap into order, marked
   right or wrong after a check, and the printouts (answer key, cut-out cards).
   Spec: docs/superpowers/specs/2026-10-21-children-story-order-design.md
   ============================================================================ */

.lamp .so-set-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; min-height: 44px; }
.lamp .so-set-row label { font-weight: 500; }
.lamp .so-set-row small { color: var(--muted); font-weight: 400; }
.lamp .so-set-row select, .lamp .so-review select {
  min-height: 40px; padding: 0 10px; border-radius: 10px; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); font: 600 16px/1 var(--f-ui); color: var(--ink);
}
.lamp .so-set-note { margin: 6px 0 0; font-size: 14px; color: var(--muted); max-width: 70ch; }
.lamp .so-title { font-weight: 600; color: var(--muted); }
.lamp .so-from { margin-left: 10px; font-size: 14px; color: var(--muted); }

/* ---- Play: whose turn, and the help line -------------------------------------- */
.lamp .so-turn {
  display: inline-flex; align-items: center; gap: 12px; margin: 0 0 6px; padding: 8px 20px 8px 14px;
  background: var(--card); border: 2px solid var(--team); border-radius: 999px;
  font: 500 clamp(20px, 2.6vw, 28px)/1.2 var(--f-display);
}
.lamp .so-turn .kt-dot { width: 18px; height: 18px; }
.lamp .so-help { margin: 4px 0 14px; min-height: 1.4em; font: 17px/1.5 var(--f-read); color: var(--muted); }

/* ---- The board ------------------------------------------------------------------ */
.lamp .so-board {
  --so-text: 19px;
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}
.lamp .so-board[data-n="2"], .lamp .so-board[data-n="3"], .lamp .so-board[data-n="4"],
.lamp .so-board[data-n="5"], .lamp .so-board[data-n="6"] { --so-text: clamp(21px, 2.4vw, 27px); grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); }
.lamp .so-slot { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lamp .so-card {
  position: relative; flex: 1; display: grid; grid-template-columns: 34px auto 1fr; align-items: start; gap: 4px 12px;
  min-height: 104px; padding: 14px 18px 14px 0; text-align: left; color: var(--ink);
  background: var(--card); border: 2px solid var(--rule); border-radius: var(--kt-radius, 18px);
  box-shadow: 0 2px 6px rgba(27, 31, 42, .06);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none;
  cursor: grab; transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.lamp .so-card:hover { border-color: var(--accent-bright); }
.lamp .so-card:focus-visible { outline: 3px solid var(--accent-bright); outline-offset: 3px; }
.lamp .so-grip {
  align-self: stretch; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  margin: -14px 0; border-right: 1px dashed var(--rule); border-radius: 16px 0 0 16px; touch-action: none;
}
.lamp .so-grip i { display: block; width: 14px; height: 3px; border-radius: 2px; background: var(--border); }
.lamp .so-num {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  background: var(--soft); font: 600 17px/1 var(--f-ui); font-variant-numeric: tabular-nums;
}
.lamp .so-text { align-self: center; font: 500 var(--so-text)/1.35 var(--f-read); text-wrap: pretty; }
.lamp .so-mark {
  position: absolute; top: -12px; right: -10px; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 700 19px/1 var(--f-ui); border: 2px solid currentColor; background: var(--card);
}
.lamp .so-card.is-right { border-color: var(--kt-yes); background: var(--kt-yes-bg); }
.lamp .so-card.is-right .so-mark { color: var(--kt-yes); }
.lamp .so-card.is-right .so-num { background: var(--kt-yes); color: var(--kt-yes-bg); }
.lamp .so-card.is-wrong { border-color: var(--kt-no); background: var(--kt-no-bg); }
.lamp .so-card.is-wrong .so-mark { color: var(--kt-no); }
.lamp .so-card.is-wrong .so-num { background: var(--kt-no); color: var(--kt-no-bg); }
.lamp .so-card.is-held {
  border-color: var(--accent-bright); box-shadow: 0 0 0 3px var(--accent-bright), 0 12px 26px rgba(27, 31, 42, .18);
}
.lamp .so-card.is-held .so-num { background: var(--accent-bright); color: var(--on-ink); }
.lamp .so-board.is-holding .so-card:not(.is-held) { border-style: dashed; }
.lamp .so-board.is-shown .so-card { cursor: default; }
.lamp .so-board.is-shown .so-card:hover { border-color: var(--kt-yes); }

.lamp .so-ref-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 34px; padding: 0 4px; }
.lamp .so-ref { font: 600 14px/1.3 var(--f-ui); color: var(--accent); }
.lamp .so-ref-btn {
  min-height: 34px; padding: 0 14px; border-radius: 999px; background: transparent;
  border: 1px solid var(--border); font: 600 13px/1 var(--f-ui); color: var(--muted);
}
.lamp .so-ref-btn:hover { border-color: var(--ink); color: var(--ink); }

/* Dragging: the card's place stays as a dashed gap; a copy follows the pointer. */
.lamp .so-slot.is-placeholder .so-card { border-style: dashed; border-color: var(--accent-bright); background: var(--soft); box-shadow: none; }
.lamp .so-slot.is-placeholder .so-card > *, .lamp .so-slot.is-placeholder .so-ref-row { visibility: hidden; }
.lamp .so-ghost {
  position: fixed; top: 0; left: 0; z-index: 1000; margin: 0; list-style: none; pointer-events: none;
  display: flex; flex-direction: column;
}
.lamp .so-ghost .so-card { cursor: grabbing; border-color: var(--accent-bright); box-shadow: 0 18px 40px rgba(27, 31, 42, .28); }
.lamp .so-ghost .so-ref-row { display: none; }
.lamp.so-dragging, .lamp.so-dragging * { cursor: grabbing !important; }

/* ---- Under the board: the result and what's next -------------------------------- */
.lamp .so-status { margin: 22px 0 0; text-align: center; }
.lamp .so-status > p { margin: 0 0 12px; font: 500 clamp(20px, 2.4vw, 26px)/1.35 var(--f-read); }
.lamp .so-status b { font-family: var(--f-display); font-weight: 600; }
.lamp .so-check { min-width: 220px; }
.lamp .so-show { background: var(--card); color: var(--ink); }
.lamp .kt-team.is-up { box-shadow: 0 0 0 2px var(--team); }

/* ---- Review --------------------------------------------------------------------- */
.lamp .so-tool-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-right: 6px; cursor: pointer; font-weight: 500; }
.lamp .so-rv-ref { font: 600 13px/1.3 var(--f-ui); color: var(--accent); }
.lamp .so-verses { margin-top: 4px; padding: 10px 14px; border-left: 3px solid var(--rule); font: 16px/1.6 var(--f-read); color: var(--muted); }
.lamp .so-verses[hidden] { display: none; }
.lamp .so-verses sup { font: 600 11px/1 var(--f-ui); color: var(--accent); }
.lamp .so-print { margin: 26px 0 0; padding: 14px 18px; max-width: 880px; border: 1px solid var(--rule); border-radius: var(--radius); }
.lamp .so-print h3 { margin: 0 0 8px; font: 600 12px/1.3 var(--f-ui); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lamp .so-print-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.lamp .so-cutouts { display: none; }

/* ---- Full screen: the board alone ------------------------------------------------- */
.lamp.kt-full .so-board { --so-text: clamp(19px, 1.5vw, 28px); grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); }
.lamp.kt-full .so-board[data-n="2"], .lamp.kt-full .so-board[data-n="3"], .lamp.kt-full .so-board[data-n="4"],
.lamp.kt-full .so-board[data-n="5"], .lamp.kt-full .so-board[data-n="6"] { --so-text: clamp(22px, 2vw, 34px); grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); }
.lamp.kt-full .so-card { min-height: 128px; }
.lamp.kt-full .so-help { display: none; }

/* ---- A phone: one column; a touch drags from the grip, the rest scrolls ------------ */
@media (max-width: 700px) {
  .lamp .so-card { touch-action: pan-y; min-height: 84px; }
  .lamp .so-grip { touch-action: none; width: 34px; }
  .lamp .so-board { --so-text: 18px; gap: 10px; }
  .lamp .so-board[data-n="2"], .lamp .so-board[data-n="3"], .lamp .so-board[data-n="4"],
  .lamp .so-board[data-n="5"], .lamp .so-board[data-n="6"] { --so-text: 20px; }
  .lamp .so-status .kt-big { flex: 1 1 100%; }
  .lamp .so-from { display: block; margin: 6px 0 0; }
}
@media (hover: none) { .lamp .so-help-drag::after { content: " On a phone, drag by the handle at the left."; } }
@media (hover: none) and (min-width: 701px) { .lamp .so-help-drag::after { content: ""; } }
@media (prefers-reduced-motion: reduce) { .lamp .so-card { transition: none; } }

/* ---- Print: the answer key (the review list), or cut-out cards ------------------------ */
@media print {
  .lamp .so-rv input, .lamp .so-rv.is-off, .lamp .so-print { display: none !important; }
  .lamp .so-rv { break-inside: avoid; }
  .lamp .so-verses { border-left-color: #999; color: #222; }
  html.so-print-cards body > *:not(main), html.so-print-cards main > *:not(#so), html.so-print-cards #so > *:not(.so-cutouts) { display: none !important; }
  html.so-print-cards .so-cutouts { display: block; }
  /* Inline blocks, not a grid: a row of cards then breaks between pages cleanly. */
  .lamp .so-cut-grid { display: block; font-size: 0; }
  .lamp .so-cut {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 10pt; vertical-align: top;
    width: 50%; height: 2.3in; padding: 14pt 18pt; box-sizing: border-box;
    border: 1.5pt dashed #777; margin: 0 0 -1.5pt; break-inside: avoid; text-align: center;
  }
  .lamp .so-cut:nth-child(even) { margin-left: -1.5pt; width: calc(50% + 1.5pt); }
  .lamp .so-cut-text { font: 500 19pt/1.3 var(--f-read); }
  .lamp .so-cut-foot { font: 600 8.5pt/1.2 var(--f-ui); color: #555; letter-spacing: .04em; }
  .lamp .so-cut-key { break-before: page; }
  .lamp .so-cut-key h2 { font: 600 16pt/1.2 var(--f-display); margin: 0 0 10pt; }
  .lamp .so-cut-key li { margin: 0 0 6pt; font: 12pt/1.4 var(--f-read); }
  .lamp .so-cut-key span { font: 600 10pt/1 var(--f-ui); color: #444; margin-left: 6pt; }
}
