/* ============================================================
   АРИФМАГИЯ — СВИТОК СЧЁТНЫХ ЗЕМЕЛЬ (большая карта)

   Карта — одна вертикальная полоса-свиток на весь мир.
   Прокрутка пальцем вверх = продвижение по миру. Регионы идут
   полосами, шов между ними невидим (нижний цвет полосы = верхний
   цвет следующей). Закрытые полосы сжаты в «туман» — карта
   физически РАСТЁТ по мере прохождения.

   Ширина сетки карты — 360 условных единиц (= дизайн-ширина
   телефона). На ноутбуке колонка не растягивается, а центрируется:
   свиток остаётся свитком, а свободное место отдано панели слева.
   ============================================================ */

.aq {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;                /* иначе флекс-ребёнок не даст скроллиться */
  display: flex; flex-direction: column;
}

/* ---------- шапка: Великий Счёт ---------- */
.aq-top {
  flex: 0 0 auto; z-index: 6;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: var(--paper);
  box-shadow: 0 6px 14px -10px rgba(45,27,69,.5);
}
.aq-top__where { flex: 1 1 auto; min-width: 0; }
.aq-top__reg {
  display: block; font-size: 15px; font-weight: 800; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aq-top__num { display: block; font-size: 12px; color: var(--ink-2); }
.aq-bar {
  display: block;                /* span по умолчанию инлайновый — высота игнорировалась */
  margin-top: 4px; height: 6px; border-radius: 4px;
  background: #EADFCB; overflow: hidden;
}
.aq-bar > i {
  display: block; height: 100%; width: 0;
  border-radius: 4px; background: var(--star);
  transition: width .5s cubic-bezier(.3,.9,.3,1);
}
.aq-sparks { flex: 0 0 auto; display: flex; gap: 3px; }
.aq-spark { width: 9px; height: 9px; border-radius: 50%; background: #E3D6BF; }
.aq-spark.on { background: #9B6BE0; box-shadow: 0 0 7px #9B6BE0; }

/* ---------- скроллер ---------- */
.aq-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;    /* родная инерция iOS */
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  scrollbar-width: none;
  /* КРИТИЧНО: у Chrome есть своя «якорная» прокрутка — когда земля
     разворачивается из тумана, он сам сдвигает scrollTop, и вместе с
     нашей компенсацией карту швыряло в самый низ, к Числограду.
     В Safari/iOS якоря нет, поэтому компенсацию считаем сами (JS),
     а браузерную — выключаем, чтобы не складывались. */
  overflow-anchor: none;
  /* «бумага» — 0 КБ: две сетки + пятна */
  background:
    radial-gradient(120% 60% at 20% 8%, rgba(255,255,255,.55), rgba(255,255,255,0) 60%),
    repeating-linear-gradient(0deg, rgba(45,27,69,.025) 0 1px, rgba(45,27,69,0) 1px 4px),
    var(--paper);
}
.aq-scroll::-webkit-scrollbar { display: none; }

.aq-col {
  position: relative;
  width: 100%; max-width: 420px; margin: 0 auto;
  /* воздух сверху и снизу: иначе самый верхний узел мира (Большая
     Клякса) и самый нижний (Рынок Числограда) физически нельзя
     вывести в центр экрана — прокрутка упирается в край */
  padding: 170px 0 48px;
  --sky: #5B4A7A; --ground: #E8C98A;
}
/* небо над вершиной мира */
.aq-col::before, .aq-col::after {
  content: ''; position: absolute; left: 0; right: 0; z-index: 0;
}
.aq-col::before { top: 0; height: 171px; background: linear-gradient(to bottom, var(--paper), var(--sky)); }
.aq-col::after  { bottom: 0; height: 49px; background: linear-gradient(to top, var(--paper), var(--ground)); }

/* ---------- полоса региона ---------- */
.aq-band {
  position: relative;
  width: 100%;
  overflow-anchor: none;
  content-visibility: auto;            /* не рисуем полосы вне экрана */
  contain-intrinsic-size: auto 900px;  /* высота известна — скролл не прыгает */
  --band: #3FBF8A;
}
.aq-band__art { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
/* растворение низа полосы в цвет следующей земли: шов не читается линейкой */
.aq-band::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 58px; z-index: 1;
  background: linear-gradient(to top, var(--seam, transparent), rgba(255,255,255,0));
  pointer-events: none;
}
.aq-band--shut::after { display: none; }
.aq-band__nodes { position: absolute; inset: 0; z-index: 2; }

/* подпись региона — табличка на обочине, не поверх тропы */
.aq-band__name {
  position: absolute; left: 10px; top: 12px; z-index: 2;
  padding: 5px 11px; border-radius: 12px;
  background: rgba(255,248,236,.92);
  font-size: 13px; font-weight: 800; color: var(--ink);
  box-shadow: 0 2px 0 rgba(45,27,69,.12);
}
.aq-band__name small { display: block; font-weight: 700; font-size: 11px; color: var(--ink-2); }
/* «можно сюда» — горит только когда дорог несколько, иначе это шум */
.aq-band__go {
  /* inline-block, а не block: блочная метка растягивалась во всю ширину
     таблички и на «Рынке Сдачи» выходила жёлтой полосой в 165 px против
     92 px на «Делимой Реке» — одна и та же подсказка выглядела как два
     разных элемента. Подпись земли кончается блочным <small>, так что
     метка всё равно встаёт на свою строку. */
  display: inline-block; margin-top: 4px; padding: 2px 8px; border-radius: 9px;
  background: var(--sun, #F2B705); color: #3A2A05;
  font-size: 11px; font-weight: 800; letter-spacing: .01em;
  animation: aq-go 1.8s ease-in-out infinite;
}
@keyframes aq-go { 0%, 100% { opacity: 1; } 50% { opacity: .62; } }
@media (prefers-reduced-motion: reduce) { .aq-band__go { animation: none; } }

/* закрытая полоса: сжата в туман. Земля ПРОСВЕЧИВАЕТ сквозь дымку —
   видно, что там мир, а не пустая строка списка */
.aq-band--shut .aq-band__art { filter: grayscale(.45) saturate(.95); opacity: .8; }
/* каждая закрытая земля держит СВОЙ цвет: свиток читается как стопка земель,
   а не как пустые полоски бумаги */
.aq-band--shut::before {
  content: ''; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, var(--band2, #ddd), var(--band, #ccc));
  opacity: .3;
}
.aq-band--shut .aq-band__nodes { display: none; }
.aq-band--shut .aq-tr-done { display: none; }   /* закрытая земля: цветной тропы ещё нет */
.aq-band--shut .aq-band__name { opacity: .75; }
.aq-fog {
  position: absolute; inset: 0; z-index: 3;
  display: flex; align-items: flex-end; justify-content: flex-end;
  gap: 8px; padding: 0 12px 11px;
  background:
    radial-gradient(70% 150% at 18% 60%, rgba(255,250,242,.7), rgba(255,250,242,0) 72%),
    radial-gradient(70% 150% at 72% 40%, rgba(255,250,242,.62), rgba(255,250,242,0) 72%),
    linear-gradient(0deg, rgba(255,250,242,.34), rgba(255,250,242,.14));
  animation: aq-drift 34s linear infinite alternate;
}
.aq-fog__lock {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(255,248,236,.95); display: grid; place-items: center;
  box-shadow: 0 1px 0 rgba(45,27,69,.14);
}
.aq-fog__lock i {
  display: block; width: 9px; height: 7px; margin-top: 3px;
  border-radius: 1.5px; background: #6B5B80; position: relative;
}
.aq-fog__lock i::before {
  content: ''; position: absolute; left: 1.5px; top: -5px;
  width: 6px; height: 6px; border: 1.6px solid #6B5B80;
  border-bottom: 0; border-radius: 4px 4px 0 0;
}
.aq-fog__need {
  font-size: 12px; font-weight: 800; color: #5C4E70;
  text-align: right; line-height: 1.2; padding-bottom: 4px;
  text-shadow: 0 1px 0 rgba(255,250,242,.9);
}
@keyframes aq-drift { from { background-position: 0 0, 0 0, 0 0; } to { background-position: 40px 0, -30px 0, 0 0; } }

/* пройденная полоса — туман ушёл, цвет вернулся */
.aq-band--clear .aq-band__art { filter: none; }
.aq-band--live .aq-band__art { transition: filter .8s ease; }

/* ---------- узлы ---------- */
.aq-node {
  position: absolute; left: var(--x); top: var(--y);
  transform: translate(-50%, -50%);
  z-index: 4;
  display: grid; place-items: center; gap: 3px;
  width: 72px; padding: 0; margin: 0;
  border: 0; background: none; font: inherit; color: var(--ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.aq-node__dot {
  position: relative;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: #FFFDF7;
  box-shadow: 0 2px 0 rgba(45,27,69,.18), 0 6px 14px rgba(45,27,69,.14);
  transition: transform .18s ease, box-shadow .18s ease;
}
.aq-node__dot svg { width: 24px; height: 24px; display: block; }
.aq-node__lbl {
  max-width: 96px;
  padding: 3px 7px; border-radius: 9px;
  background: rgba(255,248,236,.95);
  /* 10,5px на телефоне читается с прищуром — названия мест ребёнок читает
     постоянно, это не служебная подпись */
  font-size: 11.5px; font-weight: 800; line-height: 1.15;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  text-align: center;
  box-shadow: 0 1px 0 rgba(45,27,69,.1);
}
.aq-node__num {
  position: absolute; right: -6px; top: -8px;
  min-width: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--star); color: #3A2248;
  font-size: 11px; font-weight: 900; line-height: 18px; text-align: center;
}
/* искра Следа Нейро — слева, чтобы бирка с числом встала рядом, а не вместо */
.aq-node__trace {
  position: absolute; left: -6px; top: -8px;
  width: 18px; border-radius: 9px;
  background: #FFF4D6; color: #B07400;
  font-size: 11px; font-weight: 900; line-height: 18px; text-align: center;
  box-shadow: 0 1px 0 rgba(45,27,69,.14);
}

/* состояния */
.aq-node--shut { cursor: default; }
.aq-node--shut .aq-node__dot {
  background: #EFE6D6; box-shadow: none;
  outline: 2px dashed #CDBFA6; outline-offset: 2px;
}
.aq-node--shut .aq-node__dot svg { opacity: .35; }
.aq-node--shut .aq-node__lbl { display: none; }

.aq-node--open .aq-node__dot { outline: 3px solid var(--band); outline-offset: 2px; }
.aq-node--open .aq-node__dot::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  outline: 3px solid var(--band);
  animation: aq-pulse 2.4s ease-out infinite;
}
@keyframes aq-pulse {
  0%   { transform: scale(1);    opacity: .55; }
  70%  { transform: scale(1.55); opacity: 0; }
  100% { transform: scale(1.55); opacity: 0; }
}

.aq-node--done .aq-node__dot { background: var(--band); }
.aq-node--done .aq-node__dot svg { fill: #fff; stroke: #fff; opacity: .95; }

.aq-node--boss { width: 86px; }
.aq-node--boss .aq-node__dot { width: 60px; height: 60px; }
.aq-node--boss .aq-node__dot svg { width: 32px; height: 32px; }

.aq-node--focus .aq-node__dot { transform: scale(1.12); }
.aq-node--focus .aq-node__lbl { background: #fff; }
.aq-node--shake { animation: aq-shake .3s ease; }
@keyframes aq-shake {
  25% { transform: translate(-58%, -50%); } 75% { transform: translate(-42%, -50%); }
}

/* ---------- герой на тропе ---------- */
.aq-walker {
  position: absolute; z-index: 5;
  width: 54px; height: 80px;
  transform: translate(calc(-50% - 15px), -86%);   /* идёт сбоку, не закрывая узел */
  pointer-events: none;
  will-change: left, top;
}
.aq-walker svg { width: 100%; height: 100%; display: block; }
.aq-walker--go { animation: aq-bob .42s linear infinite; }
@keyframes aq-bob {
  0%,100% { margin-top: 0; } 50% { margin-top: -3px; }
}
.aq-walker__pet {
  position: absolute; left: -22px; bottom: 0; width: 28px; height: 28px;
  animation: aq-bob .5s linear infinite .1s;
}

/* ---------- нижняя плашка: что в фокусе ---------- */
.aq-foot {
  flex: 0 0 auto; z-index: 6;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px max(9px, env(safe-area-inset-bottom));
  background: var(--card);
  box-shadow: 0 -8px 18px -12px rgba(45,27,69,.5);
}
.aq-foot__txt { flex: 1 1 auto; min-width: 0; }
.aq-foot__t { display: block; font-size: 15px; font-weight: 800; }
.aq-foot__s { display: block; font-size: 12px; color: var(--ink-2); }
.aq-foot__go {
  flex: 0 0 auto; min-height: 44px; padding: 0 16px;
  border: 0; border-radius: 14px;
  background: var(--ink); color: #FFF8EC;
  font: inherit; font-size: 15px; font-weight: 800; cursor: pointer;
}
.aq-foot__go[disabled] { background: #E7DCC8; color: #8D7E9B; }
.aq-foot__go:active { transform: translateY(1px); }

/* ---------- ноутбук ----------
   Свиток не растягиваем: карта нарисована под 360, растянутая на 1200
   она разваливается. Колонка центрируется (max-width 420 выше), поля
   остаются полями — там потом встанет панель прогресса. */
@media (min-width: 900px) {
  .aq-col { box-shadow: 0 0 0 1px rgba(45,27,69,.06), 0 18px 40px -24px rgba(45,27,69,.5); }
}

@media (prefers-reduced-motion: reduce) {
  .aq-node--open .aq-node__dot::after,
  .aq-walker--go, .aq-walker__pet, .aq-fog { animation: none; }
}

/* ============================================================
   КАРТОЧКА МЕСТА (nooka-mq-mapglue.js)
   Единственный новый элемент интерфейса. Лист снизу, как в
   остальной игре: на 360×600 кнопки всегда у большого пальца,
   текст скроллится внутри карточки, а не уезжает за экран.
   ============================================================ */

/* экран карты занимает всю ширину: боковые отбивки .mq-sc тут мешают */
.mq-sc--map { padding-left: 0; padding-right: 0; }

.aqg { position: absolute; inset: 0; z-index: 20; display: flex; align-items: flex-end; }
.aqg__scrim { position: absolute; inset: 0; background: rgba(45,27,69,.42); }
.aqg__card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px; margin: 0 auto;
  max-height: 86dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  padding: 12px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--card, #fff);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -10px 30px rgba(45,27,69,.22);
  animation: aqg-up .22s cubic-bezier(.2,.9,.3,1) both;
}
@keyframes aqg-up { from { transform: translateY(14px); opacity: .6 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .aqg__card { animation: none } }

.aqg__head { display: flex; align-items: center; gap: 8px; }
.aqg__who {
  flex: 1 1 auto; min-width: 0;
  font-size: 12px; font-weight: 800; letter-spacing: .3px; text-transform: uppercase;
  color: var(--ink-2, #6B5B80);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.aqg__x {
  flex: 0 0 auto; width: 34px; height: 34px; border: 0; border-radius: 12px;
  background: #F4EADA; color: var(--ink, #2D1B45); font-size: 15px; cursor: pointer;
}
.aqg__ttl { margin: 2px 0 6px; font-size: 20px; font-weight: 800; letter-spacing: -.2px; }
.aqg__say { margin: 0; font-size: 15px; line-height: 1.5; color: var(--ink, #2D1B45); }
.aqg__say b { color: #6B4BE0; }

.aqg__task { margin-top: 12px; }
.aqg__q {
  font-size: 19px; font-weight: 800; line-height: 1.35;
  background: #FFF8EC; border: 2px solid var(--line, #EADFCB);
  border-radius: 14px; padding: 10px 12px;
}
.aqg__q small { display: block; margin-top: 3px; font-size: 12px; font-weight: 700; color: var(--ink-2, #6B5B80); }
.aqg__opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.aqg__opt {
  min-height: 52px; border: 0; border-radius: 14px; cursor: pointer;
  font: 800 20px/1 'Nunito', system-ui, sans-serif;
  background: #F4EADA; color: var(--ink, #2D1B45);
  box-shadow: 0 3px 0 rgba(45,27,69,.14);
}
.aqg__opt:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(45,27,69,.14); }
.aqg__opt--ok  { background: #C9F4DE; color: #1C7A52; }
.aqg__opt--no  { background: #FFD9CC; color: #B23A1C; }
.aqg__opt--dim { opacity: .45; }

.aqg__got {
  margin-top: 10px; padding: 9px 11px; border-radius: 12px;
  background: #FFF3D6; font-size: 14px; line-height: 1.45;
}
.aqg__got b { font-size: 17px; }
.aqg__trace { color: var(--ink-2, #6B5B80); font-size: 13px; }

.aqg__foot { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.aqg__foot .mq-btn { width: 100%; }

/* ноутбук: карточка не на всю высоту, а аккуратным листом по центру низа */
@media (min-width: 720px) and (min-height: 640px) {
  .aqg { align-items: center; }
  .aqg__card { border-radius: 20px; max-height: 76dvh; }
}

/* кнопка «← в Числоград» в шапке свитка */
/* 34×34 — это ноготь, а не палец: единственная кнопка ухода с карты должна
   попадаться с первого раза и на телефоне */
.aqg__home {
  flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 13px;
  background: var(--card, #fff); color: var(--ink, #2D1B45);
  font: 800 17px/1 'Nunito', system-ui, sans-serif; cursor: pointer;
  box-shadow: 0 2px 0 rgba(45,27,69,.12);
}
.aqg__home:active { transform: translateY(1px); box-shadow: none; }

/* финал: Нейро свободен — туман сошёл со всего свитка */
.aq-freed .aq-band__art { filter: none !important; opacity: 1 !important; }
.aq-freed .aq-fog { display: none; }

/* Рисованная иконка узла поверх запасного силуэта: картинка перекрывает
   SVG, а если файла нет — onerror её снимает и остаётся силуэт. */
.aq-node__dot { position: relative; }
.aq-node__pic {
  position: absolute; inset: 8%;
  width: 84%; height: 84%;
  object-fit: contain;
  z-index: 2;
  pointer-events: none;
}
.aq-node__pic + svg { opacity: 0; }        /* картинка пришла — силуэт прячем */
.aq-node--done .aq-node__pic { filter: grayscale(.55) brightness(1.08); opacity: .8; }
.aq-node--lock .aq-node__pic { filter: grayscale(1) brightness(1.25); opacity: .45; }

/* Ходок на тропе — картинка из труппы, а не SVG: ступни на тропе,
   питомец рядом и мельче. */
.aq-walker img { display: block; height: 100%; width: auto; margin: 0 auto;
                 object-fit: contain; object-position: bottom center; }
.aq-walker__pet img { height: 28px; width: auto; }

/* НОРА. Тёмный ход вбок от развилки: туда можно не ходить, и это должно
   читаться картинкой, а не подписью. Узлы норы темнее и чуть мельче —
   «там глубже», но различимы и нажимаются так же. */
.aq-node--dark .aq-node__dot {
  background: #3E3226;
  box-shadow: 0 2px 0 rgba(20,12,4,.35), inset 0 0 0 2px rgba(255,236,196,.22);
}
.aq-node--dark .aq-node__pic { filter: brightness(.82) saturate(.9); }
.aq-node--dark .aq-node__lbl {
  background: rgba(40,30,20,.9); color: #F6E8CE;
}
.aq-node--dark.aq-node--done .aq-node__dot { box-shadow: 0 2px 0 rgba(20,12,4,.35), inset 0 0 0 2px #E0B84A; }

/* кошелёк кристаллов в шапке свитка */
.aq-top__purse {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 9px;
  background: #EDE4FB; color: #5B3BB0; font-weight: 800;
}

/* «трудновато» — честная подсказка вместо замка: земля открыта, но ребёнок
   видит, что тема там старше его класса. Решает он сам. */
.aq-hard { color: #C2410C; font-weight: 800; }
