/**
 * onboarding.css — стили системы обучения MA_Onboarding.
 * Версия: 1.0.0 (2026-06-08)
 * Owner: Infrastructure Lead
 *
 * Только var(--*) из theme.css — нет hardcoded hex/rgba кроме скрим-значений
 * (overlay-scrim: rgba(0,0,0,0.6) — допустимое одноразовое значение по spec §6).
 *
 * z-index константы (нет новых CSS-переменных — только два значения по spec §6):
 *   --tour-backdrop-z: 10000  (выше sidebar:100, FAB:101, cookie:9300)
 *   --tour-tip-z:      10001  (подсказка над backdrop)
 *
 * Вся система работает поверх light/dark через наследование токенов.
 */

/* ─── Кнопка «Обучение» в .biz-row ───────────────────────────────────────── */

.ma-ob-launcher {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.ma-ob-btn {
  /* Наследует .biz-btn из page-shell.css */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ma-ob-icon {
  flex-shrink: 0;
  vertical-align: middle;
}

.ma-ob-label {
  /* Текст «Обучение» */
}

.ma-ob-chevron {
  flex-shrink: 0;
  vertical-align: middle;
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Шеврон развёрнут когда меню открыто */
.ma-ob-btn[aria-expanded="true"] .ma-ob-chevron {
  transform: rotate(180deg);
}

/* Точка завершения тура на кнопке */
.ma-ob-btn.ma-ob-completed::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  margin-left: 3px;
  flex-shrink: 0;
}

/* ─── Выпадающее меню ─────────────────────────────────────────────────────── */

.ma-ob-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 400;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  /* Скрыто по умолчанию */
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity 150ms cubic-bezier(0.4, 0, 0.2, 1),
    transform 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ma-ob-menu[aria-hidden="false"] {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ma-ob-menu-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 120ms;
}

/* Атрибут [hidden] должен перебивать display:flex .ma-ob-menu-item:
   пункт «Обучение по этому разделу» скрывается на страницах без шагов
   page-тура (см. _openMenu в onboarding.js). Класс специфичнее UA-правила
   [hidden]{display:none}, поэтому ставим явный гард. */
.ma-ob-menu-item[hidden],
.ma-ob-menu-divider[hidden] {
  display: none;
}

.ma-ob-menu-item:hover {
  background: var(--surface2);
}

.ma-ob-menu-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.ma-ob-menu-sub {
  font-size: 11px;
  font-weight: 400;
  color: var(--text2);
}

.ma-ob-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 2px 0;
}

/* ─── Spotlight (page tour) ──────────────────────────────────────────────── */

/*
 * Класс добавляется на подсвечиваемый элемент.
 * box-shadow 4000px — стандартный spotlight-трюк (покрывает любой viewport).
 * Второй слой box-shadow = акцентное кольцо вокруг элемента.
 * !important — перебить position/z-index страницы.
 */
.ma-tour-spotlight {
  position: relative !important;
  z-index: 10001 !important;
  border-radius: var(--radius-sm) !important;
  /* Дим+кольцо перенесены на .ma-tour-cutout (fixed, body-level): прежний
     box-shadow ПРЯМО здесь КЛИПАЛСЯ overflow:hidden-предками цели — на /returns/
     #ret-grid внутри #ret-table-container/#table-section/#ret-content → spotlight
     пропадал на шагах 5-9 (цель #ret-grid). 2026-06-28. */
  transition: box-shadow 200ms cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Вырез затемнения — отдельный fixed-элемент (см. _positionCutout в onboarding.js).
   Прямой ребёнок body → НЕ клипается overflow-предками цели. Дырка = box элемента
   (прозрачный, над целью), затемнение+кольцо = box-shadow наружу. left/top/width/
   height задаёт JS из getBoundingClientRect. pointer-events:none — клики проходят
   к цели (нужно для шагов requiresAction). */
.ma-tour-cutout {
  position: fixed;
  z-index: 10000;
  border-radius: var(--radius-sm);
  box-shadow:
    0 0 0 4000px rgba(0, 0, 0, 0.6),
    0 0 0 2px var(--accent);
  pointer-events: none;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Tooltip карточка (page tour coachmark) ─────────────────────────────── */

.ma-tour-tip {
  position: fixed;
  z-index: 10001;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08);
  padding: 20px 24px 16px;
  /* Начальное состояние — появление */
  opacity: 0;
  transition:
    opacity 150ms cubic-bezier(0.4, 0, 0.2, 1),
    top 200ms cubic-bezier(0.4, 0, 0.2, 1),
    left 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ma-tour-tip.ma-tour-tip--visible {
  opacity: 1;
}

/* Заголовок + счётчик шагов в одной строке */
.ma-tour-tip-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ma-tour-tip-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  flex: 1;
  margin: 0;
}

.ma-tour-tip-counter {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  flex-shrink: 0;
  padding-top: 2px;
}

.ma-tour-tip-body {
  font-size: 13px;
  font-weight: 400;
  color: var(--text2);
  line-height: 1.5;
  margin: 0 0 8px;
}

/* Строка с требуемым действием */
.ma-tour-tip-action-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
  margin: 0 0 12px;
  font-style: italic;
}

.ma-tour-tip-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.ma-tour-tip-footer .ma-tour-skip {
  margin-left: auto;
  font-size: 11px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ma-tour-tip-footer .ma-tour-skip:hover {
  color: var(--text);
}

/* ─── Портальный тур — модальное окно ───────────────────────────────────── */

.ma-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Появление */
  opacity: 0;
  transition: opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ma-tour-overlay.ma-tour-overlay--visible {
  opacity: 1;
}

.ma-tour-modal {
  position: relative;
  z-index: 10001;
  width: 520px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 28px 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Начальное состояние */
  transform: scale(0.96) translateY(8px);
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.ma-tour-overlay.ma-tour-overlay--visible .ma-tour-modal {
  transform: scale(1) translateY(0);
}

/* Заголовок модала */
.ma-tour-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.ma-tour-modal-icon {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 1px;
}

.ma-tour-modal-title-wrap {
  flex: 1;
}

.ma-tour-modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 2px;
  line-height: 1.3;
}

.ma-tour-modal-step-counter {
  font-size: 11px;
  color: var(--text2);
}

.ma-tour-modal-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text2);
  padding: 2px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 120ms, background 120ms;
  margin-top: -2px;
}

.ma-tour-modal-close:hover {
  color: var(--text);
  background: var(--surface2);
}

.ma-tour-modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Разделитель */
.ma-tour-modal-divider {
  height: 1px;
  background: var(--border);
  margin: 0 -32px 20px;
}

/* Тело модала */
.ma-tour-modal-body {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.6;
  flex: 1;
  margin-bottom: 20px;
}

.ma-tour-modal-body p {
  margin: 0 0 10px;
}

.ma-tour-modal-body p:last-child {
  margin-bottom: 0;
}

/* Кнопка действия (actionHref) внутри модала */
.ma-tour-modal-action {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  transition: background 120ms;
}

.ma-tour-modal-action:hover {
  background: var(--surface2);
}

/* Точки-индикаторы шагов */
.ma-tour-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
}

.ma-tour-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  transition: background 200ms, transform 150ms;
  flex-shrink: 0;
}

.ma-tour-dot.ma-tour-dot--done {
  background: var(--text2);
}

.ma-tour-dot.ma-tour-dot--active {
  background: var(--accent);
  transform: scale(1.3);
}

/* Подвал с кнопками навигации */
.ma-tour-modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ma-tour-modal-footer .ma-tour-skip-link {
  margin-left: auto;
  font-size: 12px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ma-tour-modal-footer .ma-tour-skip-link:hover {
  color: var(--text);
}

/* ─── Кнопки навигации (Далее/Назад/Завершить) ───────────────────────────── */

/* Акцентная кнопка «Далее» / «Завершить» */
.ma-tour-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 150ms;
  white-space: nowrap;
}

.ma-tour-btn-primary:hover {
  opacity: 0.88;
}

.ma-tour-btn-primary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Вторичная кнопка «Назад» */
.ma-tour-btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  height: 28px;
  background: none;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}

.ma-tour-btn-secondary:hover {
  background: var(--surface2);
  color: var(--text);
}

.ma-tour-btn-secondary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ma-tour-btn-secondary:disabled {
  opacity: 0.35;
  cursor: default;
}

/* ─── Развилка портального тура (Разобрать подробно / Дальше) ─────────────── */

/*
 * Привязанная карточка портального шага (target задан).
 * Наследует .ma-tour-tip (fixed, surface, тень), но чуть шире под две кнопки.
 */
.ma-tour-portal-card {
  width: 360px;
}

/* Строка-рекомендация для ключевого раздела */
.ma-tour-recommend {
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.45;
  margin: 0 0 12px;
  padding: 8px 10px;
  background: var(--surface2);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm);
}

/* Контейнер двух кнопок развилки */
.ma-tour-fork {
  display: flex;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 10px;
}

/* Обе кнопки развилки тянутся на равную ширину */
.ma-tour-fork .ma-tour-fork-deep,
.ma-tour-fork .ma-tour-fork-next {
  flex: 1;
  justify-content: center;
  height: auto;
  min-height: 32px;
  padding: 6px 12px;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
}

/* Подвал развилки: «Назад» (ссылкой) слева, «Пропустить весь обзор» справа */
.ma-tour-modal-footer--fork {
  gap: 8px;
}

/* Кнопка-ссылка «Назад» в подвале развилки (не конкурирует с фокусом развилки) */
.ma-tour-btn-link {
  font-size: 12px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ma-tour-btn-link:hover:not(:disabled) {
  color: var(--text);
}

.ma-tour-btn-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.ma-tour-btn-link:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Подсветка кнопки-лаунчера «Обучение» во время портального тура */
.ma-ob-btn.ma-ob-btn--tour-hint {
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: var(--radius-sm);
}

/* Поднять весь лаунчер над затемнением spotlight (4000px box-shadow на target),
   чтобы кнопку «Обучение» было хорошо видно во время портального тура. */
.ma-ob-launcher.ma-ob-launcher--tour-hint {
  z-index: 10002;
}

/* ─── Экран обратной связи (финальный шаг) ────────────────────────────────── */

.ma-tour-feedback {
  text-align: center;
  padding: 8px 0 4px;
}

.ma-tour-feedback-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 4px;
}

.ma-tour-feedback-sub {
  font-size: 13px;
  color: var(--text2);
  margin: 0 0 20px;
}

/* Звёзды рейтинга */
.ma-tour-stars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 20px;
}

.ma-tour-star {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--text2);
  transition: color 120ms, transform 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ma-tour-star:hover,
.ma-tour-star.ma-tour-star--hover,
.ma-tour-star.ma-tour-star--selected {
  color: var(--warning);
}

.ma-tour-star:hover {
  transform: scale(1.15);
}

.ma-tour-star:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Метка + textarea */
.ma-tour-feedback-label {
  display: block;
  font-size: 12px;
  color: var(--text2);
  text-align: left;
  margin-bottom: 6px;
}

.ma-tour-feedback-textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  transition: border-color 150ms;
  outline: none;
}

.ma-tour-feedback-textarea:focus-visible {
  border-color: var(--accent);
}

.ma-tour-feedback-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
}

.ma-tour-feedback-skip {
  font-size: 12px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ma-tour-feedback-skip:hover {
  color: var(--text);
}

/* Сообщение «Спасибо!» */
.ma-tour-feedback-thanks {
  font-size: 14px;
  color: var(--success);
  font-weight: 500;
  padding: 12px 0;
  display: none;
}

.ma-tour-feedback-thanks.ma-tour-feedback-thanks--visible {
  display: block;
}

/* ─── Экран выбора персоны-проводника (Ася / Штурман) ─────────────────────── */

/*
 * Переиспользует .ma-tour-overlay + .ma-tour-modal (по центру, surface, тень).
 * Ниже — только специфика экрана выбора: шапка, подзаголовок, две карточки.
 */
.ma-ob-persona-modal {
  /* Шире обычного модала: две карточки рядом */
  width: 600px;
}

.ma-ob-persona-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ma-ob-persona-headline {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
  flex: 1;
}

.ma-ob-persona-sub {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
  margin: 0 0 20px;
}

/* Две карточки персон рядом (на узком экране — в столбик) */
.ma-ob-persona-grid {
  display: flex;
  gap: 14px;
  margin-bottom: 18px;
}

.ma-ob-persona-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
  padding: 20px 16px 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 150ms, box-shadow 150ms;
}

.ma-ob-persona-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* Медальон персоны — готовая круглая картинка (256×256, прозрачный фон вне
   круга). Контейнер БЕЗ фон-круга/обводки, чтобы не было «круг в круге». */
.ma-ob-persona-photo {
  display: block;
  width: 104px;
  height: 104px;
  object-fit: contain;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.ma-ob-persona-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.25;
}

.ma-ob-persona-role {
  font-size: 12px;
  color: var(--text2);
  margin: 0 0 6px;
  line-height: 1.3;
}

.ma-ob-persona-visiting {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin: 0 0 14px;
  flex: 1;
}

/* Кнопка «Выбрать X» — наследует .ma-tour-btn-primary, тянется по ширине карточки */
.ma-ob-persona-choose {
  width: 100%;
  justify-content: center;
  height: auto;
  min-height: 32px;
}

/* Низ: «начнём, выберете позже» — текстовая ссылка по центру */
.ma-ob-persona-later {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 12px;
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ma-ob-persona-later:hover {
  color: var(--text);
}

.ma-ob-persona-later:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Узкий экран (ноутбук/планшет) — карточки в столбик */
@media (max-width: 560px) {
  .ma-ob-persona-grid {
    flex-direction: column;
  }
}

/* ─── Уменьшение движения ─────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .ma-tour-spotlight,
  .ma-tour-tip,
  .ma-tour-overlay,
  .ma-tour-modal,
  .ma-ob-menu,
  .ma-ob-chevron,
  .ma-tour-dot,
  .ma-ob-persona-card {
    transition: none !important;
  }
}
