/* SOVENOC: pro.css — craft-слой v3.3.
   Надстройка над tokens/base/layout/components/modern: НЕ переопределяет
   существующие компоненты массово, а закрывает точные пробелы уровня «проф».
   v1.5: дубли Component-переопределений (тосты, формы, опции, плоские
   поверхности, чекбоксы) слиты в родные файлы — один источник правды;
   здесь остались только сквозные слои: гигиена hover, скроллбары,
   таблицы, типографика, пикер, скролл к якорям, языковой переключатель.
   Все движения — за prefers-reduced-motion; цвета — только токены. */

/* --- 1. Гигиена hover: на тач-устройствах ничего не «залипает» - */
/* Все ховер-трансформы из components.css нейтрализуем там, где
   нет курсора (мобилки/тач-ноутбуки): фон может меняться, движение — нет */
@media (hover: none) {
  .btn:hover { transform: none; }
  .theme-toggle:hover { transform: none; }
  .explain-card:hover { transform: none; }
  .hero-mock:hover { transform: rotate(0.6deg); }
}

/* --- 2. Скроллбары в цвет темы --------------------------------- */
/* Firefox */
html {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--border-strong) 88%, transparent) transparent;
}
/* Chrome/Safari */
@supports selector(::-webkit-scrollbar) {
  ::-webkit-scrollbar { width: 10px; height: 10px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--border-strong) 88%, transparent);
    border-radius: var(--radius-pill);
    border: 2px solid transparent;
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--text-faint) 72%, transparent);
    background-clip: padding-box;
  }
  ::-webkit-scrollbar-corner { background: transparent; }
}

/* --- 3. Таблицы: прилипающая шапка в скролл-областях ----------- */
/* Работает только когда .table-wrap реально скроллится; шапка
   получает hairline-нижнюю границу (v1.5: слито из оверрайда §11 —
   было два конкурирующих определения box-shadow) */
.table-wrap .table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: none;
  border-bottom: 1px solid var(--border-strong);
}

/* --- 4. Современная типографика -------------------------------- */
/* Дисплейные заголовки не «виснут» сиротскими словами, абзацы
   без растянутых предпоследних строк */
@supports (text-wrap: balance) {
  h1, h2, h3, .hero-title, .empty-state h2 { text-wrap: balance; }
}
@supports (text-wrap: pretty) {
  p, li, dd, .form-hint { text-wrap: pretty; }
}

/* --- 5. Отделка мелочей ---------------------------------------- */
/* Без серого мигания при тапе по кнопкам/ссылкам на Android */
body { -webkit-tap-highlight-color: transparent; }
/* Числовые значения в таблицах и KPI — одинаковой ширины цифры */
.table td { font-variant-numeric: tabular-nums; }
/* Иконка-стрелка в текстовых ссылках не дёргает строку */
.streak-chip, .badge { font-variant-numeric: tabular-nums; }

/* --- Границы действия ------------------------------------------ */
/* Этот файл НЕ трогает: форму (components .form-*), тосты, опции,
   карточки и кнопки (их v4.0-поверхности слиты в родные файлы),
   навигацию и лендинг. Новые эффекты деградируют до текущего вида
   в старых движках. */

/* --- 6. v3.4: командный пикер (Ctrl+K) -------------------------- */
/* Нативный <dialog> + showModal: фокус-ловушка и Esc из коробки.
   Вход — @starting-style (как у поповеров), фон — блюр-бэкдроп. */
dialog.command-palette {
  width: min(560px, calc(100vw - 2 * var(--sp-5)));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  /* v4.0: separation рамкой, не тенью (v1.5: слито из оверрайда) */
  box-shadow: none;
  overflow: hidden;
}
dialog.command-palette::backdrop {
  background: color-mix(in srgb, var(--surface-inverse) 36%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
@supports (transition-behavior: allow-discrete) {
  @media (prefers-reduced-motion: no-preference) {
    dialog.command-palette {
      opacity: 0;
      translate: 0 -10px;
      scale: 0.985;
      transition: opacity 220ms var(--ease), translate 220ms var(--ease),
                  scale 220ms var(--ease), overlay 220ms var(--ease),
                  display 220ms var(--ease);
      transition-behavior: allow-discrete;
    }
    dialog.command-palette[open] {
      opacity: 1;
      translate: 0 0;
      scale: 1;
      @starting-style {
        opacity: 0;
        translate: 0 -10px;
        scale: 0.985;
      }
    }
  }
}
.cmdk-search {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.cmdk-search svg { width: 17px; height: 17px; color: var(--text-faint); flex-shrink: 0; }
.cmdk-search input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-lg);
}
.cmdk-search input:focus { outline: none; }
.cmdk-search input::placeholder { color: var(--text-faint); }
.cmdk-search kbd { flex-shrink: 0; }
kbd {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}
.cmdk-list {
  list-style: none;
  margin: 0;
  padding: var(--sp-2);
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.cmdk-list li { margin: 0; }
.cmdk-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: 10px var(--sp-3);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
  text-align: left;
  cursor: pointer;
}
.cmdk-item svg { width: 16px; height: 16px; color: var(--text-faint); flex-shrink: 0; }
.cmdk-item .cmdk-group {
  margin-left: auto;
  flex-shrink: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-faint);
}
.cmdk-item.is-active,
.cmdk-item:hover {
  background: var(--accent-softer);
  color: var(--accent-strong);
}
.cmdk-item.is-active svg,
.cmdk-item:hover svg { color: var(--accent); }
.cmdk-empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--text-faint);
  font-size: var(--fs-sm);
}
.cmdk-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
  color: var(--text-faint);
  font-size: var(--fs-xs);
}
.cmdk-foot .cmdk-brand { margin-left: auto; font-weight: 700; letter-spacing: 0.12em; }
.cmdk-foot kbd { font-size: 10px; padding: 1px 5px; }

/* Хинт в топбаре/навигации: внешний вид — как у theme-toggle */
.cmdk-hint {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-pill);
  min-height: 38px;
  padding: 0 var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  transition: border-color var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease),
              background var(--motion-fast) var(--ease), transform var(--motion-fast) var(--ease);
}
.cmdk-hint:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-softer); }
.cmdk-hint svg { width: 15px; height: 15px; }
@media (max-width: 640px) {
  .cmdk-hint .cmdk-hint-label, .cmdk-hint kbd { display: none; }
  .cmdk-hint { min-height: 38px; width: 38px; padding: 0; justify-content: center; }
}

/* --- 7. v3.4: плавный скролл к якорям --------------------------- */
/* Учитываем sticky-навигацию (topbar 64px + посадка), отключаем при
   reduced-motion. scrollbar-gutter — в modern.css (@supports). */
html { scroll-padding-top: calc(var(--topbar-h) + var(--sp-5)); }
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* --- 8. v3.6: файловый input как брендовая кнопка --------------- */
/* Нативный «Choose File» выбивался из системы форм. Скрытый input
   остаётся фокусируемым (доступность), кнопка — обычный .btn. */
.file-btn { display: inline-flex; }
.file-btn .btn { cursor: pointer; }
.file-btn input[type="file"]:focus-visible + .btn {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* --- 9. v3.5: произношение / пиньинь / IPA --------------------------- */
.word-lemma {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.25;
  letter-spacing: 0.01em;
}
.word-lemma--zh {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 600;
  letter-spacing: 0.06em;
}
.word-pron {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-pill, 999px);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.4;
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  transition: background var(--motion-fast, 150ms) ease, border-color var(--motion-fast, 150ms) ease,
              color var(--motion-fast, 150ms) ease;
}
.word-pron:hover,
.word-pron:focus-visible {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
  color: var(--accent-strong, var(--accent));
  outline: none;
}
.word-pron--zh {
  font-family: ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  font-variant-numeric: normal;
}
.word-pron--ipa {
  font-family: "Charis SIL", "Doulos SIL", "Lucida Sans Unicode", ui-sans-serif, sans-serif;
  letter-spacing: 0.02em;
}
.word-pron .word-pron-icon {
  width: 14px;
  height: 14px;
  opacity: 0.75;
  flex-shrink: 0;
}
.btn-speak[data-speaking="1"],
.word-pron[data-speaking="1"] {
  color: var(--accent-strong, var(--accent));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.vocab-card-hero {
  text-align: center;
  padding: var(--sp-4, 1rem) 0 var(--sp-3, 0.75rem);
}
.vocab-card-hero .word-lemma { margin: 0; }
.vocab-card-hero .word-pron { margin-top: 0.5rem; }
.vocab-table-pron {
  display: block;
  margin-top: 2px;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}


/* ── Route continue + program path (global, v1.0.4) ─────────────────────────
   Must live in pro.css: dashboard does not load study.css. */
.route-continue {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg, 20px);
  /* v4.0: тон вместо рамки и тени (v1.5: слито из оверрайда §11) */
  border: 1px solid transparent;
  background: var(--surface);
  box-shadow: none;
  margin-bottom: var(--sp-5);
  padding: var(--sp-5);
}
.route-continue__body {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  justify-content: space-between;
  align-items: flex-end;
}
.route-continue__eyebrow {
  display: inline-block;
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--bronze);
  font-weight: 700;
  margin-bottom: 6px;
}
.route-continue h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 2.8vw, 1.75rem);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.route-continue__meta {
  margin: 0 0 8px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.route-continue__reason {
  margin: 0;
  max-width: 36rem;
  font-size: var(--fs-sm);
  line-height: 1.5;
  color: var(--text);
}
.route-continue__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.program-path {
  display: grid;
  gap: 12px;
}
.program-path__module {
  border-radius: var(--radius-lg);
  /* v4.0: тон вместо рамки и тени (v1.5: слито из оверрайда §11) */
  border: 1px solid transparent;
  background: var(--surface);
  padding: 16px;
  box-shadow: none;
}
.program-path__module h2 {
  margin: 0;
  font-size: var(--fs-xl);
  font-family: var(--font-serif);
  letter-spacing: -0.02em;
}
.program-path__lesson {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  margin-top: 8px;
}
.program-path__lesson:hover {
  border-color: var(--border);
}
.program-path__lesson .btn {
  flex-shrink: 0;
}

/* --- 10. v4.0: чистые поверхности — сводка миграции (v1.5) ---------
   Плоские поверхности (box-shadow: none, border transparent) слиты
   в родные определения: components.css (.card/.stat/.btn/.option/
   .form-*/.hero-*/.table-wrap/.readiness-ring/.route-continue),
   study.css (.study-*) и dialog.command-palette (§6 выше).
   Отдельные оверрайды удалены — двойных стилей больше нет. */

/* --- 11. v4.0: переключатель языка (сайдбар) ------------------------ */
.lang-switch { position: relative; margin: 0 var(--sp-2) var(--sp-3); }
.lang-switch summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-softer);
  color: var(--accent-strong);
  font-weight: 600;
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}
.lang-switch summary::-webkit-details-marker { display: none; }
.lang-switch summary:hover { background: var(--accent-soft); }
.lang-switch summary svg { width: 17px; height: 17px; flex-shrink: 0; }
.lang-switch__name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* v1.6: специфичность выше правила summary svg — без !important */
.lang-switch summary .lang-switch__chev { width: 14px; height: 14px; transition: rotate var(--motion-fast) var(--ease); }
.lang-switch[open] .lang-switch__chev { rotate: 180deg; }
.lang-switch__menu {
  margin-top: 6px;
  padding: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  gap: 4px;
}
.lang-switch__title {
  margin: 0 4px 4px;
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-caps);
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}
.lang-switch__menu form { display: contents; }
.lang-switch__menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}
.lang-switch__menu button:hover { background: var(--accent-softer); color: var(--accent-strong); }
.lang-switch__menu button.is-current { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.lang-switch__menu button svg { width: 15px; height: 15px; margin-left: auto; }
.lang-switch__native { font-weight: 600; }
.lang-switch__ru { color: var(--text-faint); font-size: var(--fs-xs); }
.lang-switch__menu button:hover .lang-switch__ru,
.lang-switch__menu button.is-current .lang-switch__ru { color: inherit; opacity: 0.75; }
.lang-switch__hint { margin: 6px 4px 0; font-size: var(--fs-xs); color: var(--text-faint); }
/* v1.11.0 (FR-LANG-7): блок «Скоро» — языки без опубликованных программ */
.lang-switch__upcoming {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  opacity: 0.65;
}
.lang-switch__upcoming .lang-switch__native { font-weight: 600; }
/* Метка текущего языка изучения в шапке (FR-LANG-7) */
.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full, 999px);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  background: var(--surface, transparent);
}
.lang-chip svg { width: 15px; height: 15px; color: var(--accent); }
@media (max-width: 860px) {
  .lang-chip { min-height: 32px; padding: 4px 9px; }
  .lang-chip span { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
/* Мобильный: нижний лист */
@media (max-width: 860px) {
  .lang-switch { margin: 0; }
  .lang-switch summary { min-height: 40px; padding: 6px 10px; }
  .lang-switch[open] .lang-switch__menu {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 300;
    margin: 0;
    padding: var(--sp-4);
    padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom, 0px));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border: 0;
  }
  /* v1.5: шторка-подложка и блокировка скролла под листом (JS ставит
     data-sheet-open на body); подложка на 290 — ниже листа (300) */
  body[data-sheet-open] { overflow: hidden; }
  body[data-sheet-open]::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 290;
    background: color-mix(in srgb, var(--surface-inverse) 40%, transparent);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }
}
@media (max-width: 860px) and (prefers-reduced-motion: no-preference) {
  @supports (transition-behavior: allow-discrete) {
    .lang-switch[open] .lang-switch__menu { animation: sheet-up 260ms var(--ease-spring); }
    body[data-sheet-open]::after { animation: sheet-fade 200ms var(--ease); }
  }
}
@keyframes sheet-up {
  from { translate: 0 100%; }
  to { translate: 0 0; }
}
@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* --- 12. v4.0: словарь языка ---------------------------------------- */
.lang-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease), color var(--motion-fast) var(--ease);
}
.lang-tab:hover { background: var(--accent-softer); color: var(--accent-strong); }
.lang-tab.is-active { background: var(--accent-soft); color: var(--accent-strong); }
.lang-tab__ru { color: var(--text-faint); font-size: var(--fs-xs); font-weight: 500; }
.lang-tab.is-active .lang-tab__ru,
.lang-tab:hover .lang-tab__ru { color: inherit; opacity: 0.75; }
.dict-lemma { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
.dict-lemma--zh { letter-spacing: 0.04em; }
.dict-pos { display: inline-block; margin-left: 6px; font-size: var(--fs-xs); color: var(--text-faint); }
.dict-in { display: inline-flex; align-items: center; gap: 5px; color: var(--ok); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.dict-in svg { width: 15px; height: 15px; }
.dict-table td { vertical-align: middle; }
@media (max-width: 640px) {
  .dict-table, .dict-table tbody, .dict-table tr, .dict-table td { display: block; }
  .dict-table thead { display: none; }
  .dict-table tr { position: relative; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .dict-table tr:last-child { border-bottom: 0; }
  .dict-table td { border: 0; padding: 2px 0; }
  .dict-table td:nth-child(5) { position: absolute; top: 12px; right: 10px; }
  .dict-table td:nth-child(1) { padding-right: 130px; }
  .dict-table td:nth-child(2) { padding-top: 4px; }
  .dict-table td:nth-child(3) { display: flex; align-items: center; gap: 6px; }
}
