/* Orderly: the sortable card list. Everything else is in shared/core.css. */
:root { --brand: var(--sun); --brand-text: var(--sun-text); --on-brand: var(--on-sun); }

/* home logo: three bars, short to long */
#logo { display: flex; flex-direction: column; gap: 8px; width: 112px; margin-bottom: 8px; }
#logo i { height: 22px; border-radius: 6px; background: var(--speck), var(--brand); box-shadow: 2px 2px 0 var(--reg); animation: fan .4s var(--ease) both; }
#logo i:nth-child(1) { width: 50%; background: var(--grain), var(--stock); box-shadow: inset 0 0 0 1px var(--hair), var(--lift); }
#logo i:nth-child(2) { width: 75%; animation-delay: 80ms; }
#logo i:nth-child(3) { width: 100%; background: var(--speck), var(--ink); animation-delay: 160ms; box-shadow: 2px 2px 0 var(--brand); }
@keyframes fan { from { transform: translateX(-16px); opacity: 0; } }

#btn-random b { font-size: 17px; }

/* new puzzle: a quiet row of difficulties, pips above the name */

/* topic picker */
.t-all { margin-bottom: 12px; }
.t-all .chip { justify-content: center; }
.topics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; text-align: start; }
.topics label {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line); font-weight: 550; font-size: 14.5px; line-height: 1.15;
  transition: background-color .15s, box-shadow .15s;
}
.topics label:has(input:checked) { background: var(--grain), var(--hl); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 70%, transparent); }
.topics input { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--ink); }
#dlg-topics .give-up { margin-top: 8px; }

/* ---------- game ---------- */
#game { gap: 6px; }
.subject { margin: 0 0 4px; text-align: center; max-width: 420px; }
.subject b { font-size: clamp(22px, calc(6 * var(--vw)), 28px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; text-wrap: balance; }
.end-label { font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }

.list {
  --gap: 6px;
  position: relative; list-style: none; margin: 0; padding: 0; row-gap: var(--gap);
  width: min(420px, 100%); flex: 1; min-height: calc(38px * var(--k, 10)); max-height: calc(62px * var(--k, 10)); /* --k: cards, 10 but the tutorial's 4 */
  touch-action: none; user-select: none; -webkit-user-select: none;
}
/* .name clips (overflow: hidden), so it's a scroll container: the list's touch-action stops there and the global
   `* { manipulation }` would let a drag that starts on a card's text pan the page */
.list * { touch-action: none; }
.list.shake { animation: shake .4s; }
.card {
  --pos: 0; --dy: 0px;
  position: absolute; inset-inline: 0; top: 0; height: calc((100% - (var(--k, 10) - 1) * var(--gap)) / var(--k, 10));
  display: flex; align-items: center; gap: 10px; padding-block: 0; padding-inline: 8px 14px;
  border-radius: 12px; background: var(--grain), var(--stock); border: 1px solid var(--hair); box-shadow: var(--lift);
  font-size: clamp(15px, calc(4.2 * var(--vw)), 17px); font-weight: 550; line-height: 1.15;
  transform: translateY(calc(var(--pos) * (100% + var(--gap)) + var(--dy)));
  transition: transform .22s var(--ease), background-color .25s, border-color .25s;
  cursor: grab; outline: none;
}
.card:focus-visible { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.list.hinting .card { transition-duration: .55s; }
.card.held { transition: none; cursor: grabbing; z-index: 2; scale: 1.02; box-shadow: var(--float); }
.grip { flex: none; width: 20px; height: 20px; stroke: var(--line); stroke-width: 2; }
.name { flex: 1; min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
.card .val { display: none; flex: none; max-width: 45%; text-align: end; font: italic 600 .9em var(--display); line-height: 1.05; color: var(--on-fill, var(--teal-text)); font-variant-numeric: tabular-nums; }
/* grouped: overprinted with the teal drum */
.card.ok { background: var(--speck), var(--teal); color: var(--on-teal); border-color: transparent; box-shadow: 2px 2px 0 var(--reg); --on-fill: var(--on-teal); }
/* a group is one framed slab: inner corners squared, the gap filled, a faint rule between cards */
.card.link { border-bottom-width: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; box-shadow: none; }
.card.ok.link { box-shadow: 2px 0 0 var(--reg); }
.card.linked { border-top-width: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.card.link::after {
  content: ''; position: absolute; inset-inline: -2px; top: 100%; height: var(--gap);
  border: 0; box-shadow: 2px 0 0 var(--reg);
  background: linear-gradient(color-mix(in srgb, var(--on-teal) 30%, transparent) 0 0) center / calc(100% - 28px) 1px no-repeat, var(--speck), var(--teal);
}
.card.ok .grip { stroke: currentColor; opacity: .6; }
.card.ok .val { display: block; }
.card.pop .val { animation: enter .3s var(--ease); }
/* joined on Check: the card snaps into its group with a little squash (scale, so it stacks on the --pos transform) */
.card.pop { animation: squash .28s var(--ease); }
@keyframes squash { 35% { scale: 1.03 .9; } 70% { scale: .99 1.03; } }

.play, .result { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 8px; }
.status { margin: 0; color: var(--muted); font-size: 14.5px; text-align: center; min-height: 1.3em; }
.play .btn { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.result .stats { margin: 0 0 6px; }

@media (max-height: 700px) {
  .list { min-height: 330px; --gap: 4px; }
  .card { border-radius: 10px; }
}

@media (pointer: coarse) and (min-width: 700px) and (min-height: 700px) {
  .subject { max-width: 620px; }
  .subject b { font-size: 36px; }
  .end-label { font-size: 12.5px; }
  .list { --gap: 8px; width: min(580px, 100%); max-height: 860px; }
  .card { font-size: 20px; gap: 14px; padding-inline: 12px 18px; border-radius: 14px; }
  .grip { width: 24px; height: 24px; }
  .play, .result { width: min(580px, 100%); }
  .status { font-size: 16.5px; }
}
/* tablet in landscape: the list takes the full height on the left, the subject and buttons sit beside it */
@media (pointer: coarse) and (orientation: landscape) and (min-height: 700px) {
  #game {
    display: grid; height: calc(100 * var(--dvh)); max-width: 1100px; column-gap: 56px; justify-content: center;
    grid-template-columns: minmax(0, 580px) 380px; grid-template-rows: auto auto 1fr auto 1fr auto;
  }
  .bar { grid-column: 1 / -1; }
  #lbl-top { grid-column: 1; grid-row: 2; justify-self: center; }
  .list { grid-column: 1; grid-row: 3 / 6; align-self: stretch; min-height: 0; max-height: none; }
  #lbl-bottom { grid-column: 1; grid-row: 6; justify-self: center; }
  .subject { grid-column: 2; grid-row: 3; align-self: end; margin-bottom: 16px; }
  .play, .result { grid-column: 2; grid-row: 4; width: 100%; }
}

/* ---------- print ---------- */
#print .subject b { font-size: 20pt; }
.p-strips { width: 100%; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3.5mm; }
.p-strips li { position: relative; display: flex; align-items: center; gap: 5mm; min-height: 14mm; padding: 1mm 6mm; border: 1pt dashed #000; font-size: 13pt; font-weight: 600; }
/* scissors on the cut line */
.p-strips li::before { content: '✂'; position: absolute; inset-inline-start: 3mm; top: -.62em; padding: 0 1mm; background: #fff; font-size: 12pt; line-height: 1; font-weight: 400; }
.p-strips.bound li { border-style: solid; }
.p-strips.bound li::before { content: none; }
.p-strips i { flex: none; width: 12mm; height: 7mm; border-bottom: 1.2pt solid #000; }
.p-order { width: 100%; margin: 0; padding-inline-start: 10mm; font-size: 13pt; }
.p-order li { padding: 2.5mm 0; border-bottom: .5pt solid #888; }
.p-order span { font-weight: 400; color: #444; }

/* ---------- play.html: a shared level ---------- */
.broken { margin: auto 0; width: min(380px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.broken .btn { text-decoration: none; }
#res-make { margin-top: 2px; }

/* ---------- editor ---------- */
#editor { max-width: 560px; }
.e-intro { margin: 4px 0 20px; font-size: 15px; }
.e-form { width: 100%; display: flex; flex-direction: column; gap: 22px; }
.e-field { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; border: 0; min-width: 0; }
.e-field > .kicker, .e-field legend { padding: 0; margin-bottom: 2px; }
.e-hint { color: var(--muted); font-size: 13.5px; line-height: 1.35; margin-top: -4px; }
.e-form input {
  width: 100%; min-width: 0; height: 46px; padding: 0 12px; border: 0; border-radius: 10px;
  background: var(--grain), var(--stock); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line);
  font: inherit; font-size: 16px; /* 16px: iOS zooms into anything smaller */ transition: box-shadow .15s;
}
.e-form input::placeholder { color: var(--muted); opacity: .75; }
.e-form input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
.e-form input[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--red); }
#e-subject { height: 52px; font: 600 19px var(--display); letter-spacing: -0.01em; }

.e-presets { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-inline: -16px; padding: 2px 16px; }
.e-presets .chip { flex: none; padding-inline: 14px; font-size: 13.5px; }
.e-presets .chip[aria-pressed="true"] { background: var(--grain), var(--hl); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 70%, transparent); }
.e-ends { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 4px; }
.e-ends label { position: relative; }
.e-ends label > span[aria-hidden] { position: absolute; inset-inline-start: 12px; top: 50%; translate: 0 -50%; font-size: 11px; color: var(--muted); pointer-events: none; }
.e-ends input { padding-inline-start: 28px; }

.e-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; row-gap: 6px; }
.e-row {
  position: relative; display: grid; grid-template-columns: auto auto 1fr auto; align-items: center; gap: 6px;
  padding-block: 6px; padding-inline: 2px 4px; border-radius: 12px; background: var(--grain), var(--stock);
  border: 1px solid var(--hair); box-shadow: var(--lift); transition: translate .18s var(--ease);
}
.e-list.settling .e-row { transition: none; }
.e-row.held { transition: none; z-index: 2; scale: 1.02; box-shadow: var(--float); }
/* the handle alone starts a drag: none on it and everything in it (the #48 lesson), so the rest still scrolls the page */
.e-grip, .e-grip * { touch-action: none; }
.e-grip { display: grid; place-items: center; width: 32px; align-self: stretch; cursor: grab; color: var(--line); }
.e-row.held .e-grip { cursor: grabbing; }
.e-n { min-width: 1.4em; text-align: center; font: italic 600 15px var(--display); color: var(--brand-text); font-variant-numeric: tabular-nums; }
.e-fields { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.e-fields .e-name { flex: 1 1 190px; height: 42px; font-weight: 550; }
.e-fields .e-val { flex: 1 1 110px; height: 42px; font: italic 600 15px var(--display); }
.e-move { display: flex; flex-direction: column; }
.e-move .icon { width: 36px; height: 30px; border-radius: 8px; }
.e-move .icon svg { width: 18px; height: 18px; }
.e-move .icon:disabled { opacity: .25; cursor: default; }
#editor .end-label { text-align: center; }

.e-preview { display: grid; gap: 6px; }
.e-preview .card { position: relative; transform: none; height: 54px; cursor: default; }
.e-preview .name.empty { color: var(--muted); }
.e-preview .card.ok .name.empty { color: inherit; opacity: .7; }

.e-msg { margin: -6px 0 -8px; min-height: 1.4em; text-align: center; font-size: 14.5px; color: var(--muted); }
.e-msg.bad { color: var(--red-text); font-weight: 550; }
.e-msg.shake { animation: shake .4s; }
.e-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.e-actions .row { width: 100%; }


/* How to play: a sample column, Check's group in the middle (not yet in its spot) */
.help-cards { --gap: 5px; list-style: none; margin: 0 auto 4px; padding: 0; width: min(240px, 100%); display: grid; row-gap: var(--gap); text-align: start; }
.help-cards .card { position: relative; height: 34px; transform: none; transition: none; cursor: default; font-size: 14.5px; padding-inline: 14px; }
