/* Админка, вкладка «Генерация карт» (admin-gen.js). Макет — Figma 554:46279: слева карта, справа «Условия генерации»,
   размер и переключатели, внизу «Клетки карты». Шрифты — только Rubik и Onest (--font и --text из admin.css).
   Блоки по правилу владельца: рамка — слоем поверх (::after), сам блок со скруглением и overflow: hidden. */

/* страница макета — во всю ширину окна: пока открыта эта вкладка, основная колонка админки не ужимается до 1440 */
.adm:has(#adm-gen:not([hidden])) { max-width: none; }
.adm-gen { margin: 0 -24px -40px; }
.gen { display: flex; flex-direction: column; gap: 32px; padding: 80px; background: #fafafa; }

/* ---------- верх: карта и правая колонка ---------- */
.gen__top { display: grid; grid-template-columns: minmax(0, 1fr) 356px; gap: 32px; align-items: start; }
/* блок карты — 850 в высоту, как в макете, но не выше окна; условий справа бывает больше, чем в макете, колонка тогда
   длиннее карты — карта при прокрутке остаётся на экране (под шапкой админки) */
.gen__map { position: sticky; top: 72px; min-width: 0; height: min(850px, calc(100vh - 88px)); min-height: 420px; background: #e0e0e0; overflow: hidden; }
.gen__side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.gen__head { display: flex; flex-direction: column; gap: 12px; }
.gen__h { margin: 0; color: #1a1a1a; font: 700 24px/56px var(--text); }
.gen__lead { margin: 0; color: #555; font: 400 16px/24px var(--text); }

/* инструменты карты: «+», «−», «К старту» — справа сверху, как в игре */
.gen__tools { position: absolute; z-index: 5; top: 30px; right: 40.3px; display: flex; align-items: flex-start; gap: 7.2px; }
.gen-zoom {
  flex: none; display: block; width: 30.6px; height: 30.6px; margin: 0; padding: 0;
  border: 2.25px solid #040403; border-radius: 50%; background: #fcf3e5; color: #040403; cursor: var(--cur-act, pointer);
}
.gen-zoom { position: relative; }
.gen-zoom svg { position: absolute; left: -2.25px; top: -2.25px; width: 30.6px; height: 30.6px; fill: currentColor; } /* знак — контуром из макета */
.gen-zoom:disabled { border-color: #b9ad98; color: #8c8272; cursor: var(--cur-off, default); }
.gen-tostart {
  flex: none; height: 30.6px; margin: 0; padding: 0 10.8px;
  border: 2.25px solid #040403; border-radius: 899.1px; background: #fcf3e5; color: #040403; box-shadow: 0 2.7px 0 #040403;
  font: 700 12.06px/1 var(--font); white-space: nowrap; cursor: var(--cur-act, pointer);
}
.gen-tostart:active:not(:disabled) { transform: translateY(2.7px); box-shadow: 0 0 0 #040403; }
.gen-tostart:disabled { border-color: #b9ad98; color: #8c8272; box-shadow: 0 2.7px 0 #b9ad98; cursor: var(--cur-off, default); }
.gen-zoom:hover:not(:disabled), .gen-tostart:hover:not(:disabled) { background: #fff8e6; }

/* карта: поле целиком ужимается под блок (transform: scale), .gen__sizer держит под него место — как в игре */
.gen__view { position: absolute; inset: 0; display: grid; padding: 76px 24px 24px; overflow: auto; }
.gen__sizer { position: relative; margin: auto; }
.gen__note { position: absolute; z-index: 4; left: 24px; right: 24px; top: 50%; margin: 0; transform: translateY(-50%); color: #555; font: 400 16px/24px var(--text); text-align: center; }
.gen__note:empty { display: none; }
.gen__note.is-err { color: #1a1a1a; }

/* Плитки — те же, что в игре (ui-test/game.css, #board .tile; Figma «Клетка поля», 273:614 … 273:716): 68 × 68,
   цветная, белая обводка 2, скругление 3, внутри белый «дом» 42 × 42 с подписью, в углу «№». */
.gen-board {
  position: absolute; left: 0; top: 0; transform-origin: 0 0; box-sizing: border-box;
  background-color: var(--board-bg, #f6f5f2);
  background-image: linear-gradient(var(--board-grid, #e3e0d8) 1px, transparent 1px), linear-gradient(90deg, var(--board-grid, #e3e0d8) 1px, transparent 1px);
  background-size: 68px 68px; background-position: 34px 34px;
  box-shadow: inset 0 0 0 1px #d8d3c6; border-radius: 6px;
}
.gen-tile { position: relative; flex: none; box-sizing: border-box; width: 68px; height: 68px; border: 2px solid #fff; border-radius: 3px; color: #111; }
.gen-board .gen-tile { position: absolute; }
.gen-tile__house {
  position: absolute; left: 11px; top: 11px; width: 42px; height: 42px; border-radius: 4px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.gen-tile__label { color: #111; font: 700 16px/normal var(--font); text-align: center; }
.gen-tile__no { position: absolute; left: 2px; top: 1px; font: 600 8px/normal var(--font); white-space: nowrap; }
.gen-arrow { position: absolute; z-index: 3; line-height: 0; }
/* опасный отрезок: самый тяжёлый кусок пути — коралловая рамка на каждой его клетке */
.gen-board .gen-tile.is-danger { z-index: 2; outline: 4px solid var(--c-coral); outline-offset: -4px; }
.gen-board .gen-tile.is-flash { animation: gen-flash 1s ease-out; }
@keyframes gen-flash { 0% { box-shadow: 0 0 0 10px #ffd54f; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- карточки справа ---------- */
.gen-card { position: relative; border-radius: 28px; overflow: hidden; background: #fcf3e5; }
.gen-card::after { content: ""; position: absolute; inset: 0; z-index: 2; border: 3px solid #040403; border-radius: inherit; pointer-events: none; }
.gen-card--cond { flex: none; display: flex; flex-direction: column; gap: 16px; padding: 23px; color: #555; font: 400 16px/24px var(--text); }
.gen-card--cond p { margin: 0; overflow-wrap: anywhere; }
.gen-card--cond .is-danger { color: #1a1a1a; }
.gen-card--cond .is-danger::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 3px solid var(--c-coral); border-radius: 2px; vertical-align: -1px; }
.gen-card--set { flex: none; display: flex; flex-direction: column; gap: 16px; margin: 0; }
.gen-set { display: flex; flex-direction: column; gap: 16px; padding: 23px 23px 0; }
.gen-set__h { margin: 0; color: #121212; font: 700 21.723px/27.154px var(--font); }

/* размер карты: выбранный — чёрный, утоплен; остальные — кремовые, с тенью-ступенькой */
.gen-sizes { display: flex; align-items: flex-start; gap: 8px; height: 48px; }
.gen-size {
  flex: 1 1 0; min-width: 0; height: 45px; margin: 0; padding: 0 8px 2px;
  border: 2px solid #000; border-radius: 30px; background: #fcf3e5; color: #040403; box-shadow: 0 3px 0 #040403, 0 4px 0 #d7d0c3;
  font: 600 15px/1 var(--font); text-align: center; cursor: var(--cur-act, pointer);
}
.gen-size[aria-checked="true"] { height: 48px; padding: 0 8px 1px; border-color: #040403; background: #040403; color: #ffc629; box-shadow: 0 1px 0 #d7d0c3; }
.gen-size:hover:not([aria-checked="true"]) { background: #fff8e6; }

/* переключатели: выключен — жёлтая рамка, светлый жёлоб, чёрный ползунок слева; включён — светлая рамка, чёрный жёлоб, жёлтый ползунок справа */
.gen-sw { display: flex; flex-direction: column; gap: 4px; }
.gen-sw__row { display: flex; align-items: center; gap: 16px; }
.gen-sw__title { flex: 1 1 0; min-width: 0; color: #1a1a1a; font: 600 15px/20px var(--text); cursor: var(--cur-act, pointer); }
.gen-sw__hint { margin: 0; color: #555; font: 400 12px/1 var(--text); }
.gen-toggle {
  flex: none; display: flex; align-items: center; width: 30px; height: 17px; margin: 0; padding: 3px;
  border: 1px solid #121212; border-radius: 30px; background: #fccd0b; cursor: var(--cur-act, pointer);
}
.gen-toggle__track { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-start; height: 9px; border-radius: 40px; background: #fff8e6; }
.gen-toggle__knob { flex: none; width: 9px; height: 9px; border-radius: 50%; background: #121212; }
.gen-toggle[aria-checked="true"] { background: #fff8e6; }
.gen-toggle[aria-checked="true"] .gen-toggle__track { justify-content: flex-end; background: #121212; }
.gen-toggle[aria-checked="true"] .gen-toggle__knob { background: #fccd0b; }
.gen-toggle:focus-visible, .gen-size:focus-visible, .gen-zoom:focus-visible, .gen-tostart:focus-visible { outline: 3px solid #040403; outline-offset: 2px; }

/* «Сгенерировать» — жёлтая полоса во весь низ карточки */
.gen-go {
  display: flex; align-items: center; justify-content: center; width: 100%; min-height: 51px; margin: 0; padding: 10px 20px 13px;
  border: 0; background: #fccd0b; color: #040403; font: 600 14.935px/20.365px var(--font); white-space: nowrap; cursor: var(--cur-act, pointer);
}
.gen-go:hover:not(:disabled) { background: #ffd83a; }
.gen-go:disabled { cursor: var(--cur-off, default); opacity: .6; }
.gen-go:focus-visible { outline: 3px solid #040403; outline-offset: -6px; }

/* ---------- низ: «Клетки карты» ---------- */
.gen__legend { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.gen-legend { display: flex; align-items: stretch; gap: 36px; }
.gen-legend__col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
/* пунктир между колонками: штрих 11,5 через 11,5, толщина 2, круглые концы — как Line 1 в макете */
.gen-legend__sep {
  flex: none; width: 2px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='23.09'%3E%3Cpath d='M1 1v11.55' stroke='%238c8272' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") repeat-y center top;
}
.gen-legend__grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; }
.gen-item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.gen-item__text { display: flex; flex-direction: column; justify-content: center; gap: 10px; min-width: 0; }
.gen-item__name { color: #1a1a1a; font: 400 13px/18px var(--text); overflow-wrap: anywhere; }
.gen-item__n { color: #111; font: 700 20px/normal var(--font); white-space: nowrap; }
/* класса или клетки на карте нет — серым */
.gen-item.is-none .gen-tile { filter: grayscale(1); opacity: .45; }
.gen-item.is-none .gen-item__name, .gen-item.is-none .gen-item__n { color: #9a9a9a; }

/* ---------- окно поуже: меньше поля, легенда в один столбец из двух ---------- */
@media (max-width: 1500px) {
  .gen { padding: 48px; }
  .gen-legend { flex-direction: column; gap: 24px; }
  .gen-legend__sep { width: auto; height: 2px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='23.09' height='2'%3E%3Cpath d='M1 1h11.55' stroke='%238c8272' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") repeat-x left center; }
  .gen-legend__grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
/* узкий экран и телефон: карта сверху, под ней условия, размер с переключателями и клетки карты */
@media (max-width: 1100px) {
  .gen { gap: 24px; padding: 24px; }
  .gen__top { grid-template-columns: minmax(0, 1fr); }
  .gen__map { position: relative; top: auto; height: min(850px, 80vh); min-height: 0; }
}
@media (max-width: 640px) {
  .adm-gen { margin: 0 -12px -32px; }
  .gen { gap: 20px; padding: 16px 12px 24px; }
  .gen__map { height: min(100vw, 70vh); }
  .gen__tools { top: 12px; right: 12px; }
  .gen__view { padding: 54px 10px 10px; }
  .gen__h { font-size: 22px; line-height: 32px; }
  .gen__head { gap: 6px; }
  .gen-legend__grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
