/* Карточки и корзины (sort) и картинки шагов (гейт stepKit.image, slide, choice). Вынесены из
   style.css: слои урока 2 добавляют сюда карточки-картинки и три корзины, не трогая общий файл.
   Подключается там, где рисуются шаги ученика (index.html). Пульт своих миниатюр отсюда не берёт. */
.sort-progress { margin: 12px 4px; font-weight: 700; color: #4a5270; }
.cards-tray { display: flex; flex-wrap: wrap; gap: 10px; }
.card-chip { background: #fff; padding: 14px 18px; font-size: 19px; font-weight: 600;
  border-radius: 14px; box-shadow: 0 2px 8px rgba(28,35,64,.1); touch-action: none; user-select: none; }
.card-chip.selected { outline: 4px solid #f5a623; transform: scale(1.04); }
.card-chip.dragging { position: relative; z-index: 40; box-shadow: 0 10px 26px rgba(28,35,64,.3);
  pointer-events: none; opacity: .95; }
/* любое число корзин: на ширине урока 1 две корзины — те же две колонки, что раньше */
.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 18px; }
.bucket { min-height: 130px; border: 3px dashed #b9c4e8; border-radius: 18px; padding: 12px; background: #fafbff; }
.bucket.target { border-color: #f5a623; background: #fff8ec; }
.bucket h3 { margin: 0 0 8px; font-size: 17px; color: #3450d2; }
.bucket .card-chip { font-size: 16px; padding: 8px 12px; margin: 4px 4px 0 0; display: inline-block; }

/* ---------- гейт картинки (steps/base.js) ---------- */
.img-box { position: relative; overflow: hidden; border-radius: 12px; background: #eef1fa; aspect-ratio: 1 / 1; }
.img-box img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .15s; }
.img-box.ready img { opacity: 1; }
.img-spinner { display: none; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px;
  margin: -15px 0 0 -15px; border: 3px solid #c9d2ee; border-top-color: #3450d2; border-radius: 50%;
  animation: img-spin .8s linear infinite; }
.img-box.loading .img-spinner { display: block; }
.img-retry { display: none; position: absolute; inset: 0; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; padding: 6px; text-align: center; font-size: 13px; font-weight: 700;
  line-height: 1.2; color: #b03a2e; background: #fff4f2; cursor: pointer; }
.img-retry small { font-weight: 400; color: #7a839f; }
.img-retry-icon { font-size: 20px; line-height: 1; }
.slide-thumb .img-retry-text, .slide-thumb .img-retry small,
.bucket-cards .img-retry-text, .bucket-cards .img-retry small { display: none; }
.img-box.failed .img-retry { display: flex; }
.img-box.failed img { visibility: hidden; }
@keyframes img-spin { to { transform: rotate(360deg); } }
.img-wait { cursor: progress; }
.btn-big.img-wait { opacity: .4; }

/* ---------- sort: карточки-картинки (card_display image, блок 8) ---------- */
.hint.hint-top { margin: 0 4px 12px; text-align: left; }
.cards-tray.tray-img { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.card-chip.card-img { display: block; width: 100%; padding: 5px; border-radius: 16px; }
.card-chip.card-img .img-box { border-radius: 11px; }
/* строка корзин липкая снизу: драг не умеет автоскролл, корзины всегда под пальцем */
.buckets-dock { position: sticky; bottom: 0; z-index: 5; margin: 14px -6px 0; padding: 8px 6px 10px;
  background: rgba(240,244,255,.96); border-radius: 18px 18px 0 0; box-shadow: 0 -4px 14px rgba(28,35,64,.08); }
.buckets-dock .buckets { margin-top: 0; }
.buckets-img .bucket { min-height: 110px; max-height: 32vh; overflow-y: auto; padding: 10px; }
.buckets-img .bucket h3 { display: flex; align-items: center; gap: 8px; }
.b-count { display: inline-block; min-width: 26px; padding: 1px 8px; border-radius: 999px; background: #3450d2;
  color: #fff; font-size: 14px; text-align: center; }
.buckets-img .bucket-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.bucket-cards .card-chip.card-img { width: 64px; padding: 3px; margin: 0; border-radius: 10px; }
.bucket-cards .card-chip.card-img .img-box { border-radius: 7px; }
.bucket-panel { display: none; }
/* текстовые карточки + картинка шага (sortchoice.js, dock-text): корзины пониже, растут до 26vh */
.dock-text .bucket { min-height: 90px; max-height: 26vh; overflow-y: auto; }
/* тянем карточку из корзины: прокрутка корзины её бы обрезала */
.dock-text .bucket:has(.dragging) { overflow: visible; }
@media (max-width: 599px) {
  .buckets-dock.dock-text { position: static; margin: 0; padding: 0; background: none; box-shadow: none; }
  .buckets-dock.dock-text .buckets { margin-top: 18px; }
  .dock-text .bucket { min-height: 130px; max-height: none; overflow: visible; }
}

/* узкий экран: три колонки по 150 px не влезают, корзины — чипы со счётчиком в одну строку,
   содержимое раскрытой корзины панелью над строкой; справа место под кнопку руки */
@media (max-width: 599px) {
  .buckets.buckets-img { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    gap: 6px; margin-right: 72px; }
  .buckets-img .bucket { min-height: 0; max-height: none; overflow: visible; padding: 8px 4px;
    border-width: 2px; border-radius: 14px; }
  .buckets-img .bucket h3 { margin: 0; flex-direction: column; gap: 3px; font-size: 13px; line-height: 1.15;
    text-align: center; }
  .buckets-img .bucket-cards { display: none; }
  .buckets-img .bucket.open { border-style: solid; border-color: #3450d2; background: #eef2ff; }
  .bucket-panel { display: block; max-height: 36vh; overflow-y: auto; margin: 0 0 8px; padding: 8px;
    background: #fff; border-radius: 14px; }
  .bucket-panel .bucket-cards { display: flex; flex-wrap: wrap; gap: 6px; }
  .bucket-panel-title { font-weight: 700; color: #3450d2; font-size: 15px; margin-bottom: 6px; }
  .bucket-empty { color: #7a839f; font-size: 14px; }
  .cards-tray.tray-img { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
}

/* ---------- картинка шага над заданием (choice, multi_choice, sort, reflection, 2026-09-29) ----------
   Иллюстрация, декоративная (кнопку ответа не запирает), над первым заданием шага. Низкая,
   чтобы на ноутбуке 1366×768 первый вариант ответа (у sort — корзины) был виден без прокрутки.
   До загрузки — плейсхолдер 16:9 того же размера, что готовая картинка урока 3 (без скачка). */
.step-pic { width: min(100%, 302px); aspect-ratio: 16 / 9; margin: 0 auto 12px; }
.step-pic.ready img { max-height: 170px; }
@media (max-width: 599px) {
  .step-pic { width: min(100%, 213px); margin-bottom: 10px; }
  .step-pic.ready img { max-height: 120px; }
}
/* невысокий экран (ноутбук 1366×768, телефон): картинка ниже, 112 px вместо 170 */
@media (max-height: 820px) {
  .step-pic { width: min(100%, 199px); margin-bottom: 8px; }
  .step-pic.ready img { max-height: 112px; }
  /* задание под картинкой плотнее: у s03 урока 3 (4 варианта) «Готово» влезает в 1366×768 */
  #step-content:has(> .step-pic) .prompt { padding: 14px 20px; }
  #step-content:has(> .step-pic) .prompt > p:first-child { margin-top: 0; }
  #step-content:has(> .step-pic) .prompt > p:last-child { margin-bottom: 0; }
  #step-content:has(> .step-pic) .options { gap: 10px; margin-top: 14px; }
  #step-content:has(> .step-pic) .opt-btn { padding: 12px 16px; }
  #step-content:has(> .step-pic) .choice-progress { margin: 6px 4px; }
  #step-content:has(> .step-pic) .mc-dots { margin-bottom: 8px; }
  #step-content:has(> .step-pic) .hint-top { margin-bottom: 8px; }
}

/* slide-pic и step-pic после загрузки: рамка по пропорции картинки, без пустых полей (квадратный
   кадр img-box давал серые полосы у 16:9). Квадратная картинка (start-rocket) — квадрат, как раньше. */
.slide-pic.ready, .step-pic.ready { aspect-ratio: auto; width: fit-content; max-width: 100%; background: transparent; }
.slide-pic.ready img, .step-pic.ready img { width: auto; height: auto; max-width: 100%; margin: 0 auto; }

/* ---------- choice и slide с картинками ---------- */
.choice-pic { max-width: 320px; margin: 14px auto 0; }
.options.options-img { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.opt-btn .opt-pic { margin-bottom: 8px; }
.opt-btn .opt-text { display: block; }
.slide .slide-pic { max-width: 420px; margin: 16px auto 0; }
.slide .slide-pic img { object-fit: contain; }
.slide .slide-pic.ready { max-width: min(100%, 420px); }
.slide-images { gap: 8px; margin-top: 12px; }
/* лента картинок слайда (вне групп с подписью): по центру и крупнее — таких картинок на слайде
   две-три, и прижатые влево мелкие плитки читались как обрезанный ряд */
.slide-images.row { display: flex; overflow-x: auto; padding-bottom: 4px; justify-content: center; }
.slide-images.row .slide-thumb { flex: 0 0 auto; width: clamp(120px, 30vw, 210px); }
.slide-images.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
/* строки с подписью (все картинки обучения рядом): мелкие плитки, переносятся на телефоне */
.slide-group { margin-top: 14px; }
.slide-group-label { font-weight: 800; color: #3450d2; margin-bottom: 6px; }
/* восемь картинок обучения в ОДИН ряд: два ряда по восемь держат экран низким и дают сравнить
   фон по всей строке сразу (иначе перенос делал слайд выше экрана) */
.slide-group .slide-images.row { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr));
  overflow: visible; margin-top: 0; }
@media (max-width: 600px) {
  .slide-group .slide-images.row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* телефон: при четырёх в ряд плитка 67 px и фон (дом, улица) не различить — по три */
@media (max-width: 480px) {
  .slide-group .slide-images.row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.slide-group .slide-images.row .slide-thumb { width: auto; }

/* ---------- multi_choice: задание с несколькими верными вариантами ---------- */
.mc-item { margin-top: 12px; }
.opt-btn.mc-opt { display: flex; align-items: center; gap: 4px; }
.opt-btn.mc-readonly { cursor: default; }
/* чекбокс перед вариантом: пустой квадрат, отмеченный — заполненный с галочкой */
.mc-mark { flex: none; width: 24px; height: 24px; border-radius: 7px; border: 3px solid #b9c4e8;
  background: #fff; position: relative; }
.mc-mark.on { background: #27ae60; border-color: #27ae60; }
.mc-mark.on::after { content: "✓"; position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; color: #fff; font-weight: 900; font-size: 15px; }
.opt-btn.mc-opt .opt-pic { margin: 0 4px 0 0; }
.opt-btn.mc-opt .opt-text { display: inline; }

/* полоска точек-заданий: отвеченные помечены, тап на любую переводит туда (правка тоже) */
.mc-dots { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 4px 14px; }
.mc-dot { flex: none; width: 34px; height: 34px; border-radius: 50%; background: #eef2ff; color: #3450d2;
  font-weight: 800; font-size: 14px; display: flex; align-items: center; justify-content: center; }
.mc-dot.done { background: #d9f2e3; color: #1d5e36; }
.mc-dot.active { outline: 3px solid #3450d2; outline-offset: 1px; }

/* все задания отвечены: список с правкой по тапу */
.mc-done-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.mc-done-item { display: flex; align-items: center; gap: 12px; width: 100%; background: #fff;
  border-radius: 14px; padding: 12px 16px; font-size: 16px; text-align: left;
  box-shadow: 0 2px 8px rgba(28,35,64,.08); }
.mc-done-n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: #d9f2e3; color: #1d5e36;
  font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; }
.mc-done-prompt { flex: 1; color: #3a4160; }
.mc-done-edit { flex: none; color: #3450d2; font-weight: 700; font-size: 13px; }

/* ---------- подсказка «Листай вниз» (student.js, scrollHint) ----------
   Низ зоны ответа ниже экрана: плашка у нижнего края. Тапы насквозь; по бокам место под руку. */
.scroll-hint { position: fixed; left: 0; right: 0; bottom: 14px; z-index: 18; display: flex;
  justify-content: center; padding: 0 84px; pointer-events: none; }
.scroll-hint-text, .scroll-hint-arrow { pointer-events: none; }
.scroll-hint:not(.hidden) { animation: scroll-hint-in .25s ease-out; }
.scroll-hint > .scroll-hint-text { display: inline-block; background: #3450d2; color: #fff; font-size: 17px;
  font-weight: 700; line-height: 1.25; text-align: center; padding: 10px 44px 10px 18px; border-radius: 999px;
  box-shadow: 0 6px 18px rgba(28,35,64,.25); }
/* стрелка вниз рисуется рамкой, не символом */
.scroll-hint-arrow { position: relative; width: 0; }
.scroll-hint-arrow::after { content: ""; position: absolute; right: 18px; top: 50%; width: 10px; height: 10px;
  margin-top: -8px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg);
  animation: scroll-hint-bob 1.2s ease-in-out infinite; }
@keyframes scroll-hint-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes scroll-hint-bob { 50% { margin-top: -4px; } }
@media (prefers-reduced-motion: reduce) {
  .scroll-hint:not(.hidden), .scroll-hint-arrow::after { animation: none; }
}
