/* ============================================================
   Страница «Практические модули» — /pages/modules-index.html и её EN-двойник.
   Разметку собирает protected/modules/src/build.mjs, прогресс рисует
   js/modules-index.js.

   Язык тот же, что у страницы тестирования (css/testing.css): системный
   шрифт, сгруппированные карточки, кольца прогресса, акцент — бирюза сайта.
   Цвета из css/tokens.css, для светлой темы переопределены ниже. Все классы
   с префиксом mx-: shared-styles.css задаёт голым section/h2/p/li свои
   отступы и цвет (часть — с !important), поэтому голого section здесь нет.
   ============================================================ */

.mx {
  --f-text: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --f-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', Roboto, sans-serif;
  --f-round: ui-rounded, 'SF Pro Rounded', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;

  --bg: var(--surface-base, #070b14);
  --fill: color-mix(in srgb, #fff 6%, var(--bg));
  --fill-2: color-mix(in srgb, #fff 10%, var(--bg));
  --fill-3: color-mix(in srgb, #fff 15%, var(--bg));
  --sep: rgba(255, 255, 255, .1);
  --label: var(--text-primary, #fff);
  --label-2: rgba(235, 235, 245, .64);
  --label-3: rgba(235, 235, 245, .36);
  --tint: #22d3ee;
  --tint-fill: #0e7490;
  --on-tint: #fff;
  --green: #30d158;
  --green-ink: #30d158;
  --orange: #ff9f0a;
  --orange-ink: #ffb340;
  --ring-pass: #30d158;
  --ring-scenes: #22d3ee;
  --shadow-1: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 10px 30px rgba(0, 0, 0, .28);
  --shadow-2: 0 24px 60px rgba(0, 0, 0, .5);
  --ease: cubic-bezier(.32, .72, 0, 1);
  --r-lg: 22px;
  --r-md: 16px;

  max-width: 1080px;
  margin: 0 auto;
  padding: 36px 24px 88px;
  font-family: var(--f-text);
  font-size: 17px;
  line-height: 1.4;
  color: var(--label);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

:root[data-theme="light"] .mx {
  --fill: #fff;
  --fill-2: #f0f1f5;
  --fill-3: #e4e6ec;
  --sep: rgba(60, 60, 67, .16);
  --label-2: var(--text-muted, #5a6675);
  --label-3: rgba(60, 60, 67, .42);
  --tint: #0e7490;
  --green: #34c759;
  --green-ink: #1f7a37;
  --orange: #ff9500;
  --orange-ink: #b25000;
  --ring-pass: #34c759;
  --ring-scenes: #0891b2;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, .05), 0 6px 20px rgba(15, 23, 42, .07);
  --shadow-2: 0 20px 50px rgba(15, 23, 42, .16);
}

.mx *, .mx *::before, .mx *::after { box-sizing: border-box; }
.mx [hidden] { display: none !important; }
/* Сброс весом ровно в один тег: перебивает голые p и li из shared-styles.css
   (он подключён раньше), но уступает любому классу ниже. */
:where(.mx) p, :where(.mx) li, :where(.mx) ol, :where(.mx) ul { color: inherit; line-height: inherit; margin: 0; padding: 0; list-style: none; }
:where(.mx) :where(button) { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
.mx h1, .mx h2, .mx h3 { margin: 0 !important; }
.mx a { text-decoration: none; }
.mx svg { flex-shrink: 0; }
.mx :focus-visible { outline: 2px solid var(--tint); outline-offset: 3px; }
.mx-ico { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Заголовок ──────────────────────────────────────────── */
.mx-head { margin-bottom: 24px; }
.mx-kicker { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tint); margin-bottom: 6px; }
.mx-title {
  font-family: var(--f-display);
  font-size: clamp(34px, 4.8vw, 54px);
  font-weight: 700;
  letter-spacing: -.028em;
  line-height: 1.04;
  text-wrap: balance;
}
.mx-sub { margin-top: 10px; font-size: 19px; color: var(--label-2); max-width: 62ch; text-wrap: pretty; }

/* ── Итоги и «следующий модуль» ─────────────────────────── */
.mx-top { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; }

.mx-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px 28px;
  align-items: center;
  padding: 24px 28px;
  border-radius: var(--r-lg);
  background: var(--fill);
  box-shadow: var(--shadow-1);
}
.mx-rings { width: 148px; height: 148px; }
.mx-rings svg { width: 100%; height: 100%; display: block; transform: rotate(-90deg); overflow: visible; }
.mx-rings circle { fill: none; stroke-width: 14; stroke-linecap: round; }
.mx-rings .is-pass { stroke: var(--ring-pass); }
.mx-rings .is-scenes { stroke: var(--ring-scenes); }
.mx-rings .is-track { opacity: .18; }
.mx-rings .is-val { transition: stroke-dashoffset 1.4s var(--ease); }
/* Пустое кольцо: у штриха с закруглёнными концами нулевой длины остаётся точка. */
.mx-rings .is-val.is-zero { visibility: hidden; }

.mx-legend { display: grid; gap: 16px; min-width: 0; }
.mx-legend-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.mx-dot { width: 10px; height: 10px; border-radius: 50%; }
.mx-dot.is-pass { background: var(--ring-pass); }
.mx-dot.is-scenes { background: var(--ring-scenes); }
.mx-legend-name { font-size: 15px; font-weight: 600; min-width: 0; }
.mx-legend-name span { display: block; font-size: 13px; font-weight: 500; color: var(--label-2); }
.mx-legend-val { font: 700 26px/1 var(--f-round); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mx-legend-val small { font-size: 15px; font-weight: 600; color: var(--label-2); }

.mx-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--sep);
  padding-top: 16px;
}
.mx-stat { display: grid; gap: 2px; padding: 0 12px; min-width: 0; }
.mx-stat:first-child { padding-left: 0; }
.mx-stat + .mx-stat { border-left: 1px solid var(--sep); }
.mx-stat b { font: 700 22px/1.15 var(--f-round); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mx-stat span { font-size: 13px; color: var(--label-2); }

.mx-next {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 22px 24px 24px;
  border-radius: var(--r-lg);
  color: #fff;
  background:
    radial-gradient(90% 70% at 10% 0%, rgba(103, 232, 249, .55), transparent 60%),
    radial-gradient(80% 90% at 100% 100%, #0b3b52, transparent 70%),
    linear-gradient(150deg, #0e7490, #0a5a72 55%, #073a4c);
  box-shadow: var(--shadow-1);
  transition: transform .5s var(--ease), box-shadow .4s;
}
.mx-next:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.mx-next:active { transform: scale(.98); }
.mx-next.is-done {
  background:
    radial-gradient(90% 70% at 10% 0%, rgba(110, 231, 183, .5), transparent 60%),
    radial-gradient(80% 90% at 100% 100%, #022c22, transparent 70%),
    linear-gradient(150deg, #047857, #065f46 55%, #043d2e);
}
.mx-next-glyph {
  position: absolute;
  right: -8%;
  bottom: -14%;
  width: 62%;
  height: auto;
  z-index: -1;
  opacity: .14;
  stroke-width: 1.3;
  transition: transform .8s var(--ease);
}
.mx-next:hover .mx-next-glyph { transform: translateX(10px); }
.mx-next-k {
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(0, 0, 0, .24);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.mx-next-num { margin-top: 18px; font: 700 64px/0.9 var(--f-round); letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.mx-next-title { margin-top: 10px; font: 700 22px/1.2 var(--f-display); letter-spacing: -.015em; text-wrap: balance; }
.mx-next-meta { margin: 4px 0 20px; font-size: 15px; opacity: .86; }
.mx-next-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: #fff;
  color: #0a4b5e;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.mx-next.is-done .mx-next-btn { color: #065f46; }
.mx-next-btn .mx-ico { font-size: 18px; stroke-width: 2.4; transition: transform .4s var(--ease); }
.mx-next:hover .mx-next-btn .mx-ico { transform: translateX(3px); }

/* ── Разделы ────────────────────────────────────────────── */
.mx-sec { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 44px 0 14px; }
.mx-sec h2 { font-family: var(--f-display); font-size: 24px; font-weight: 700; letter-spacing: -.018em; color: var(--label); }
.mx-sec span { font-size: 15px; color: var(--label-2); white-space: nowrap; }

.mx-how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.mx-how-item { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--r-lg); background: var(--fill); box-shadow: var(--shadow-1); }
.mx-how-item b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.mx-how-item p { margin-top: 4px; font-size: 15px; color: var(--label-2); line-height: 1.45; }
.mx-how-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; font-size: 23px; }
.mx-how-ico .mx-ico { stroke-width: 2.1; }
.mx-how-ico.is-scenes { background: linear-gradient(145deg, #7d7aff, #5856d6); }
.mx-how-ico.is-tasks { background: linear-gradient(145deg, #ffcc00, #ff9500); }
.mx-how-ico.is-exam { background: linear-gradient(145deg, #4ade80, #16a34a); }

.mx-note { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; font-size: 15px; color: var(--label-2); }
.mx-note .mx-ico { margin-top: 2px; font-size: 18px; color: var(--tint); }

/* Фильтр — появляется, когда есть что фильтровать */
.mx-seg {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 2px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: var(--fill-2);
}
.mx-seg button {
  min-height: 32px;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--label);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color .2s, box-shadow .2s;
}
.mx-seg button[aria-pressed="true"] { background: var(--fill-3); font-weight: 600; box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
:root[data-theme="light"] .mx-seg button[aria-pressed="true"] { background: #fff; }

/* ── Карточки модулей ───────────────────────────────────── */
.mx-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.mx-item { display: flex; }
.mx-item.is-out { display: none; }
.mx-card {
  position: relative;
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px 20px;
  border-radius: var(--r-lg);
  background: var(--fill);
  box-shadow: var(--shadow-1);
  color: var(--label);
  overflow: hidden;
  transition: transform .5s var(--ease), box-shadow .4s;
}
.mx-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.mx-card:active { transform: scale(.98); }
.mx-card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mx-card-n {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--fill-2);
  color: var(--label-2);
  transition: background-color .4s, color .4s;
}
.mx-card-n b { font: 700 17px/1 var(--f-round); font-variant-numeric: tabular-nums; }
.mx-card-n .mx-ico { display: none; font-size: 22px; stroke-width: 2.8; }
.mx-card-title { font-family: var(--f-display); font-size: 20px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; color: var(--label); }
.mx-card-desc { font-size: 15px; color: var(--label-2); line-height: 1.42; }
.mx-card-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: auto; padding-top: 12px; font-size: 13px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.mx-card-meta > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.mx-card-meta .mx-ico { font-size: 14px; }
.mx-free { padding: 1px 8px; border-radius: 999px; font-weight: 600; color: var(--green-ink); background: color-mix(in srgb, var(--green) 16%, transparent); }
.mx-card-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: transparent; }
.mx-card-bar i { display: block; height: 100%; width: 0; border-radius: 0 2px 2px 0; background: var(--ring-scenes); transition: width 1s var(--ease); }

.mx-chip {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--fill-2);
  color: var(--label-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mx-chip.is-scenes { background: color-mix(in srgb, var(--tint-fill) 20%, transparent); color: var(--tint); }
.mx-chip.is-best { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange-ink); }
.mx-chip.is-passed { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green-ink); }

/* начатый модуль: кольцо вокруг номера */
.mx-item.is-started .mx-card-n { box-shadow: inset 0 0 0 2px var(--tint); color: var(--tint); }
.mx-item.is-started .mx-card-bar { background: var(--fill-2); }
/* сданный: зелёный кружок с галочкой, полоса целиком */
.mx-item.is-passed .mx-card-n { background: var(--green); color: #fff; box-shadow: none; }
.mx-item.is-passed .mx-card-n b { display: none; }
.mx-item.is-passed .mx-card-n .mx-ico { display: block; }
.mx-item.is-passed .mx-card-bar i { background: var(--green); }
/* следующий по порядку: закрашенный номер и мягкое свечение */
.mx-item.is-next .mx-card { box-shadow: var(--shadow-1), 0 0 0 2px color-mix(in srgb, var(--tint) 70%, transparent); }
.mx-item.is-next .mx-card-n { background: var(--tint-fill); color: var(--on-tint); box-shadow: none; }
.mx-item.is-next .mx-card-n::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 50%;
  border: 2px solid var(--tint);
  opacity: 0;
  animation: mx-pulse 2.4s var(--ease) infinite;
}
@keyframes mx-pulse { 0% { opacity: .6; transform: scale(.9); } 70%, 100% { opacity: 0; transform: scale(1.25); } }

.mx-empty { padding: 28px 16px; text-align: center; color: var(--label-2); font-size: 15px; }

/* Появление карточек при прокрутке — только когда скрипт работает */
.mx.is-js .mx-item { opacity: 0; transform: translateY(14px); }
.mx.is-js .mx-item.is-in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .7s var(--ease); transition-delay: calc(var(--i, 0) * 50ms); }

/* ── Другие тренажёры ───────────────────────────────────── */
.mx-tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.mx-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: var(--fill);
  box-shadow: var(--shadow-1);
  color: var(--label);
  transition: transform .5s var(--ease), box-shadow .4s, background-color .2s;
}
.mx-row:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.mx-row:active { transform: scale(.98); }
.mx-row-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-size: 21px; }
.mx-row-ico .mx-ico { stroke-width: 2.1; }
.mx-row-ico.is-call { background: linear-gradient(145deg, #4ade80, #16a34a); }
.mx-row-ico.is-test { background: linear-gradient(145deg, #22d3ee, #0e7490); }
.mx-row-ico.is-case { background: linear-gradient(145deg, #c084fc, #9333ea); }
.mx-row-ico.is-lf { background: linear-gradient(145deg, #22d3ee, #4f46e5); }
.mx-row-text { flex: 1; min-width: 0; }
.mx-row-text b { display: block; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.mx-row-text span { display: block; margin-top: 1px; font-size: 14px; color: var(--label-2); }
.mx-chev { color: var(--label-3); font-size: 15px; stroke-width: 2.6; }

/* ── Адаптивность ───────────────────────────────────────── */
@media (max-width: 960px) {
  .mx-top { grid-template-columns: minmax(0, 1fr); }
  .mx-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .mx { padding: 24px 16px 64px; }
  .mx-sub { font-size: 17px; }
  .mx-summary { gap: 18px 20px; padding: 20px; }
  .mx-rings { width: 112px; height: 112px; }
  .mx-legend { gap: 12px; }
  .mx-legend-val { font-size: 21px; }
  .mx-stat { padding: 0 10px; }
  .mx-stat b { font-size: 17px; }
  .mx-stat span { font-size: 12px; }
  .mx-next { padding: 20px; }
  .mx-next-num { font-size: 52px; margin-top: 14px; }
  .mx-next-title { font-size: 20px; }
  .mx-sec { margin-top: 36px; }
  .mx-sec h2 { font-size: 22px; }
  .mx-how, .mx-tools { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mx-how-item { flex-direction: row; align-items: flex-start; padding: 16px; }
  .mx-how-ico { width: 40px; height: 40px; border-radius: 12px; font-size: 20px; }
  .mx-seg { display: grid; }
}
@media (max-width: 640px) {
  .mx-list { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mx-card { padding: 16px 18px 18px; }
}
@media (max-width: 380px) {
  .mx-summary { grid-template-columns: minmax(0, 1fr); justify-items: center; }
  .mx-legend { width: 100%; }
}
@media (hover: none) {
  .mx-card:hover, .mx-next:hover, .mx-row:hover { transform: none; box-shadow: var(--shadow-1); }
  .mx-item.is-next .mx-card:hover { box-shadow: var(--shadow-1), 0 0 0 2px color-mix(in srgb, var(--tint) 70%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .mx *, .mx *::before, .mx *::after { transition: none !important; animation: none !important; }
  .mx.is-js .mx-item { opacity: 1; transform: none; }
}
