/* ==========================================================================
   Токены
   ========================================================================== */

:root {
  --bg: oklch(0.975 0.006 75);
  --surface: #fff;
  --ink: oklch(0.26 0.015 55);
  --ink-soft: oklch(0.45 0.02 55);
  /* светлота 0.47, а не 0.5: на мелком тексте 0.5 не дотягивала до AA 4.5:1 */
  --ink-mute: oklch(0.47 0.02 55);
  --brand: oklch(0.55 0.13 45);
  --brand-hover: oklch(0.47 0.13 45);
  --brand-soft: oklch(0.93 0.03 45);
  --brand-soft-ink: oklch(0.45 0.12 45);
  --online: oklch(0.7 0.16 150);
  --online-ink: oklch(0.46 0.1 150);
  --line: oklch(0.92 0.008 75);
  --footer-bg: oklch(0.26 0.015 55);
  --footer-ink: oklch(0.82 0.01 75);
  --radius-sm: 14px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-1: 0 1px 4px oklch(0.3 0.02 55 / 0.08);
  --shadow-2: 0 8px 30px oklch(0.3 0.02 55 / 0.09);
  --msg-bg: oklch(0.955 0.008 75);
}

/* ==========================================================================
   Сброс и база
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }

body {
  margin: 0;
  font-family: 'Onest', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-hover); }
img { max-width: 100%; display: block; }
button { font-family: inherit; }
h1, h2, h3, h4, p, ul, ol { margin: 0; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.container {
  width: 100%;
  margin-inline: auto;
  padding-inline: 20px;
}

main { padding-bottom: 40px; }

/* ==========================================================================
   Шапка
   ========================================================================== */

.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  box-shadow: var(--shadow-1);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1080px;
  margin-inline: auto;
  padding: 14px 20px;
}

.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.logo:hover { color: var(--ink); }

/* иконка — голый <svg> внутри .logo, квадрат-подложка рисуется padding'ом на самом svg */
.logo svg {
  width: 30px;
  height: 30px;
  padding: 7px;
  box-sizing: border-box;
  border-radius: 9px;
  background: var(--brand);
  flex-shrink: 0;
  display: block;
}

.logo span { font-weight: 900; font-size: 17px; }

.nav { display: none; align-items: center; gap: 24px; }
.nav a { color: var(--ink); font-size: 15px; font-weight: 500; }
.nav a:hover { color: var(--brand); }

.mobile-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin-right: -10px;
  border: none;
  background: none;
  padding: 0;
  position: relative;
  cursor: pointer;
}
/* три голых <span> внутри .mobile-menu-btn — линии гамбургера по порядку */
.mobile-menu-btn span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: var(--ink);
  transform: translate(-50%, -50%);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.mobile-menu-btn span:nth-child(1) { margin-top: -6px; }
.mobile-menu-btn span:nth-child(3) { margin-top: 6px; }
.header.is-menu-open .mobile-menu-btn span:nth-child(1) { margin-top: 0; transform: translate(-50%, -50%) rotate(45deg); }
.header.is-menu-open .mobile-menu-btn span:nth-child(2) { opacity: 0; }
.header.is-menu-open .mobile-menu-btn span:nth-child(3) { margin-top: 0; transform: translate(-50%, -50%) rotate(-45deg); }

.mobile-nav {
  display: none;
  flex-direction: column;
  padding: 4px 20px 12px;
  border-top: 1px solid var(--line);
}
.header.is-menu-open .mobile-nav { display: flex; }
.mobile-nav a {
  padding: 13px 0;
  font-size: 15px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.mobile-nav a:last-child { border-bottom: none; }

/* ==========================================================================
   Герой
   ========================================================================== */

.hero { padding: 20px 0 8px; }

.hero-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero__text { display: flex; flex-direction: column; gap: 12px; }

.hero h1 {
  font-size: clamp(26px, 5vw, 40px);
  line-height: 1.18;
  font-weight: 900;
}

.hero__sub {
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-soft);
}

/* ==========================================================================
   Чат
   ========================================================================== */

.chat {
  background: var(--surface);
  border: 1.5px solid color-mix(in oklch, var(--brand) 30%, var(--line));
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 36px oklch(0.55 0.13 45 / 0.14);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
}

.chat__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}

/* .chat__head содержит: голый <span> (иконка-аватар) + голый <div> (заголовок + .chat__status) */
.chat__head > span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat__head > span svg { width: 18px; height: 18px; }

.chat__head > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
/* nowrap: на 320px заголовок иначе переносится и шапка разъезжается на три строки */
.chat__head > div > div:first-child {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat__reset {
  margin-left: auto;
  margin-right: -6px;
  flex-shrink: 0;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11.5px;
  font-family: inherit;
  color: var(--ink-mute);
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease;
}
.chat__reset:hover { color: var(--brand); background: var(--brand-soft); }
.chat__reset:disabled { opacity: 0.5; cursor: default; }
.chat__reset:disabled:hover { color: var(--ink-mute); background: none; }
.chat__reset[hidden] { display: none; }
.chat__reset-short { display: none; }

.chat__status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--online-ink);
  white-space: nowrap;
}
/* точка «онлайн» — голый <span> внутри .chat__status */
.chat__status > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--online);
  flex-shrink: 0;
  display: inline-block;
  animation: onlineDotPulse 2s ease-in-out infinite;
}

@keyframes onlineDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

.chat__log {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.chat__msg--bot,
.chat__msg--user {
  max-width: 88%;
  padding: 11px 14px;
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: break-word;
}
.chat__msg--bot {
  align-self: flex-start;
  background: var(--msg-bg);
  border-radius: 4px var(--radius-sm) var(--radius-sm) var(--radius-sm);
  /* промпт запрещает разметку, но перевод строки в ответе иначе схлопнется в пробел */
  white-space: pre-line;
}
.chat__msg--user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm) 4px var(--radius-sm) var(--radius-sm);
}

/* ссылка внутри ответа бота: длинный URL не должен рвать вёрстку на мобиле */
.chat__link {
  color: var(--brand);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  overflow-wrap: anywhere;
}
.chat__link:hover { color: var(--brand-hover); }

.chat__typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  background: var(--msg-bg);
  border-radius: 4px var(--radius-sm) var(--radius-sm) var(--radius-sm);
}
.chat__typing[hidden] { display: none; }
/* 3 голых <span> (точки) + .chat__typing-label с текстом стадии */
.chat__typing span:nth-child(-n+3) {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-mute);
  display: inline-block;
  animation: chatTypingPulse 1.2s ease-in-out infinite;
}
.chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.chat__typing span:nth-child(3) { animation-delay: 0.3s; }
.chat__typing-label { font-size: 12px; color: var(--ink-mute); }

@keyframes chatTypingPulse {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.85); }
  30% { opacity: 1; transform: scale(1); }
}

.chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 12px;
}
.chat__chip {
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
  border: none;
  border-radius: 100px;
  padding: 12px 16px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease;
}
.chat__chip:hover { background: oklch(0.89 0.035 45); }
.chat__quick[hidden] { display: none; }

.chat__input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
}

.chat__input {
  flex-grow: 1;
  min-width: 0;
  background: var(--msg-bg);
  border: none;
  outline: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  box-shadow: 0 0 0 1.5px var(--line);
  animation: chatInputBreathe 3.5s ease-in-out infinite;
}
.chat__input::placeholder { color: var(--ink-mute); }
.chat__input:focus {
  animation: none;
  box-shadow: 0 0 0 2px var(--brand);
}

@keyframes chatInputBreathe {
  0%, 100% { box-shadow: 0 0 0 1.5px var(--line); }
  50% { box-shadow: 0 0 0 1.5px color-mix(in oklch, var(--brand) 40%, transparent); }
}

.chat__send {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--brand);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.chat__send svg { width: 19px; height: 19px; }
.chat__send:hover {
  background: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px oklch(0.55 0.13 45 / 0.25);
}
.chat__send:disabled { opacity: 0.6; cursor: default; }

.chat__note {
  margin: 0;
  padding: 0 16px 14px;
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--ink-mute);
}
.chat__note a { color: var(--ink-mute); text-decoration: underline; text-underline-offset: 2px; }
.chat__note a:hover { color: var(--brand); }

/* ==========================================================================
   Факты (плитки 2x2 / 4 в ряд)
   ========================================================================== */

.facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.fact {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  box-shadow: var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.fact__label { font-size: 11.5px; color: var(--ink-mute); }
.fact__value { font-size: 13.5px; font-weight: 700; line-height: 1.35; }

/* ==========================================================================
   Чипы (документы / категории)
   ========================================================================== */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}
.chip {
  background: var(--surface);
  border-radius: 100px;
  padding: 12px 18px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  box-shadow: var(--shadow-1);
  transition: box-shadow 0.2s ease;
}
.chip:hover { color: var(--ink); box-shadow: var(--shadow-2); }

/* ==========================================================================
   Строки-списки (направления, связанные материалы)
   ========================================================================== */

.list-rows { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  color: var(--brand);
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { color: var(--brand-hover); }
.list-row__icon { flex-shrink: 0; color: var(--ink-mute); }

/* ==========================================================================
   Шаги
   ========================================================================== */

.steps { display: flex; flex-direction: column; gap: 24px; }
.step { display: flex; align-items: flex-start; gap: 14px; }
.step__num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.step__text { padding-top: 8px; font-size: 16px; line-height: 1.5; }

/* ==========================================================================
   Карточки курсов (каталоги)
   ========================================================================== */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { color: var(--ink); box-shadow: var(--shadow-2); transform: translateY(-2px); }
.card__title { font-size: 15px; font-weight: 700; line-height: 1.35; }
.card__price { font-size: 13.5px; color: var(--ink-soft); }

/* ==========================================================================
   Кнопки
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 15px 24px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease;
}
.btn:hover { color: #fff; background: var(--brand-hover); }

.btn--ghost {
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
}
.btn--ghost:hover { color: var(--brand-hover); background: var(--brand-soft); border-color: var(--brand-hover); }

/* ==========================================================================
   Хлебные крошки
   ========================================================================== */

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
  color: var(--ink-mute);
  margin-top: 16px;
  margin-bottom: 12px;
}
.breadcrumbs a { color: var(--ink-mute); }
.breadcrumbs a:hover { color: var(--brand); }
.breadcrumbs > *:not(:last-child)::after {
  content: "/";
  margin: 0 6px;
  color: var(--ink-mute);
  opacity: 0.5;
}

.section-title { font-size: 20px; font-weight: 900; line-height: 1.3; margin-bottom: 16px; }

/* ==========================================================================
   Ритм секций (страницы без своих .block/.hero отступов)
   ========================================================================== */

.section { margin-top: 36px; }

/* ==========================================================================
   SEO-текст (генерированный контент)
   ========================================================================== */

.seo-text {
  font-size: 15px;
  line-height: 1.6;
  max-width: 72ch;
  color: var(--ink);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  padding: 28px;
}
.seo-text > * + * { margin-top: 16px; }
.seo-text h2 { font-size: 20px; font-weight: 900; line-height: 1.3; margin-top: 32px; }
.seo-text h3 { font-size: 17px; font-weight: 700; line-height: 1.3; margin-top: 24px; }
.seo-text h4 { font-size: 15px; font-weight: 700; margin-top: 20px; }
.seo-text strong { font-weight: 700; }
.seo-text ul, .seo-text ol {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.seo-text li { line-height: 1.6; }

/* ==========================================================================
   Поиск
   ========================================================================== */

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-1);
}
.search__icon { flex-shrink: 0; color: var(--ink-mute); display: flex; }
.search__icon svg { width: 18px; height: 18px; }
.search__input {
  flex-grow: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
}
.search__input::placeholder { color: var(--ink-mute); }

.search__results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  overflow-y: auto;
  max-height: 320px;
  z-index: 40;
}
.search__result {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink);
}
.search__result:last-child { border-bottom: none; }
.search__result:hover { background: var(--bg); color: var(--ink); }

/* ==========================================================================
   Пагинация
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
}
.pagination__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.pagination__item:hover { color: var(--ink); background: var(--bg); }
.pagination__item.is-active { background: var(--brand); color: #fff; box-shadow: none; }
.pagination__item.is-active:hover { color: #fff; background: var(--brand); }
.pagination__item.is-disabled { opacity: 0.4; pointer-events: none; }

/* ==========================================================================
   Футер
   ========================================================================== */

/* .footer — фон на всю ширину; .footer__inner содержит напрямую: <strong>, <p>, <nav><a>...</a></nav>, <small> — без BEM-обёрток */
.footer {
  background: var(--footer-bg);
  color: var(--footer-ink);
  padding-block: 32px 46px;
}
.footer__inner {
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.footer strong { font-weight: 900; font-size: 15px; color: #fff; }
.footer p { margin: 0; font-size: 12.5px; line-height: 1.55; max-width: 60ch; }
.footer nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  font-size: 13px;
}
.footer nav a { color: var(--footer-ink); padding: 6px 0; }
.footer nav a:hover { color: #fff; }
.footer small { font-size: 11.5px; color: var(--footer-ink); opacity: 0.8; }

/* ==========================================================================
   Reveal-анимация
   ========================================================================== */

.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ==========================================================================
   Брейкпоинты
   ========================================================================== */

/* на самых узких экранах шапка чата не вмещает полную подпись кнопки */
@media (max-width: 380px) {
  .chat__reset-full { display: none; }
  .chat__reset-short { display: inline; }
  .chat__reset { padding-inline: 8px; }
}

@media (min-width: 640px) {
  .hero__sub { font-size: 16px; }
}

@media (min-width: 768px) {
  .nav { display: flex; }
  .mobile-menu-btn { display: none; }
  .mobile-nav { display: none; }
  .header.is-menu-open .mobile-nav { display: none; }

  .logo span { font-size: 18px; }

  .facts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .footer nav { flex-direction: row; flex-wrap: wrap; gap: 20px; }
}

@media (min-width: 980px) {
  .container { max-width: 1080px; padding-inline: 24px; }
  .container--narrow { max-width: 720px; }
  .header__inner { padding-inline: 24px; }
  .footer__inner { padding-inline: 24px; }

  .hero { padding: 48px 0 24px; }
  .hero__sub { font-size: 17px; }
  .hero-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr;
    grid-template-areas:
      "text chat"
      "search chat";
    column-gap: 48px;
    row-gap: 24px;
    align-items: start;
  }
  .hero-grid > .hero__text { grid-area: text; }
  .hero-grid > .chat { grid-area: chat; }
  .hero-grid > .search { grid-area: search; }

  .section-title { font-size: 26px; }
  .breadcrumbs { margin-top: 24px; }
  .section { margin-top: 60px; }

  .step__num { width: 48px; height: 48px; font-size: 20px; }
  .step__text { padding-top: 10px; font-size: 17px; }

  main { padding-bottom: 64px; }
}
