/* AILab Products — общие стили всех страниц.
   Токены: OKLCH — источник истины, hex-строка перед каждым — фолбэк для
   браузеров без oklch (иначе var() резолвится в unset и разваливает вёрстку).
   Темы: light — базовая на :root; dark задаётся ДВАЖДЫ — через
   prefers-color-scheme (гард :root:not([data-theme='light'])) и через
   явный выбор :root[data-theme='dark'] (переключатель, см. theme.js). */

:root {
  color-scheme: light dark;
  --bg: #f7f8fa;
  --bg: oklch(0.98 0.002 250);
  --surface: #fefeff;
  --surface: oklch(0.998 0.001 250);
  --text: #191b1d;
  --text: oklch(0.22 0.005 250);
  --muted: #616467;
  --muted: oklch(0.5 0.006 250);
  --border: #dcdee0;
  --border: oklch(0.9 0.003 250);
  --accent: #00774b;
  --accent: oklch(0.5 0.12 160);
  --on-accent: #fefeff;
  --on-accent: oklch(0.998 0.001 250);
  --shadow-rest: 0 1px 3px rgba(25, 30, 40, 0.05);
  --shadow-hover: 0 2px 12px rgba(25, 30, 40, 0.08);
}
:root[data-theme='light'] {
  color-scheme: light;
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #161719;
  --bg: oklch(0.205 0.004 250);
  --surface: #1f2122;
  --surface: oklch(0.245 0.004 250);
  --text: #e6e8ea;
  --text: oklch(0.93 0.003 250);
  --muted: #95999c;
  --muted: oklch(0.68 0.006 250);
  --border: #333638;
  --border: oklch(0.33 0.005 250);
  --accent: #52c794;
  --accent: oklch(0.75 0.13 162);
  --on-accent: #161719;
  --on-accent: oklch(0.205 0.004 250);
  --shadow-rest: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-hover: 0 2px 12px rgba(0, 0, 0, 0.3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #161719;
    --bg: oklch(0.205 0.004 250);
    --surface: #1f2122;
    --surface: oklch(0.245 0.004 250);
    --text: #e6e8ea;
    --text: oklch(0.93 0.003 250);
    --muted: #95999c;
    --muted: oklch(0.68 0.006 250);
    --border: #333638;
    --border: oklch(0.33 0.005 250);
    --accent: #52c794;
    --accent: oklch(0.75 0.13 162);
    --on-accent: #161719;
    --on-accent: oklch(0.205 0.004 250);
    --shadow-rest: 0 1px 3px rgba(0, 0, 0, 0.25);
    --shadow-hover: 0 2px 12px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
  margin: 0;
}
body {
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
    Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 64px 24px 64px;
}

/* Шапка: бренд слева, переключатель темы справа */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 17px;
}
.brand-name {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.01em;
}
.theme-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.theme-switch button {
  appearance: none;
  touch-action: manipulation;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition:
    color 0.15s ease,
    background-color 0.15s ease;
}
.theme-switch button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-rest);
}
.theme-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

h1 {
  font-size: clamp(33px, 5.2vw, 44px);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: -0.022em;
  text-wrap: balance;
  max-width: 16ch;
  margin-bottom: 22px;
}
.intro {
  color: var(--muted);
  font-size: 17.5px;
  max-width: 60ch;
  text-wrap: pretty;
}
.intro + .intro {
  margin-top: 14px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px;
  margin-top: 60px;
}
@media (max-width: 700px) {
  .grid {
    grid-template-columns: 1fr;
  }
  main {
    padding-top: 40px;
  }
  .top {
    margin-bottom: 40px;
  }
}
.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 30px 28px 26px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-rest);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
.card[data-product] {
  cursor: pointer;
}
.card[data-product]:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}
/* Последняя (нечётная) карточка занимает всю строку */
.grid .card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}
/* Кнопка-заголовок внутри карточки: выглядит как текст, открывает модалку */
.card-open {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-align: start;
  cursor: pointer;
  touch-action: manipulation;
}
.card-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}
.card .tag {
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.card h2 {
  font-size: 19px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.012em;
}
.card p {
  color: var(--muted);
  font-size: 15px;
  text-wrap: pretty;
  flex: 1;
}
.card .link {
  color: var(--accent);
  font-size: 14.5px;
  font-weight: 550;
  margin-top: 6px;
}
.card .link .arrow {
  display: inline-block;
  transition: translate 0.15s ease;
}
.card[data-product]:hover .link .arrow {
  translate: 3px 0;
}
a.link {
  text-decoration: none;
  width: fit-content;
}
a.link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.card .link.muted {
  color: var(--muted);
}
footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 28px 24px;
}

/* Модалка расширенного описания (нативный <dialog>) */
.modal {
  /* margin: auto возвращает UA-центрирование, убитое reset'ом * { margin: 0 }.
     position НЕ переопределять: UA-стиль dialog:modal { position: fixed } и
     есть якорь для absolute ✕; position: relative ставил диалог в поток
     документа и открытие проматывало страницу вверх (баг, PR #8) */
  margin: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  width: min(560px, calc(100dvw - 32px));
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
  box-shadow: var(--shadow-hover);
}
.modal::backdrop {
  background: rgba(8, 10, 12, 0.55);
}
.modal-inner {
  position: relative;
  padding: 30px 28px 26px;
  overflow: auto;
  overscroll-behavior: contain;
  max-height: calc(100vh - 64px);
  max-height: calc(100dvh - 64px);
}
.modal-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-content h2 {
  font-size: 22px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.012em;
  padding-inline-end: 32px;
}
.modal-content p,
.modal-content ul {
  color: var(--muted);
  font-size: 15px;
  text-wrap: pretty;
}
.modal-content ul {
  margin: 0;
  padding-inline-start: 20px;
  display: grid;
  gap: 7px;
}
.modal-content .link {
  color: var(--accent);
  font-size: 14.5px;
  font-weight: 550;
  margin-top: 6px;
}
.modal-content .link.muted {
  color: var(--muted);
}
.modal-close {
  appearance: none;
  position: absolute;
  z-index: 1;
  top: 16px;
  inset-inline-end: 16px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}
.modal-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .theme-switch button,
  .modal-close,
  .card .link .arrow {
    transition: none;
  }
  .card[data-product]:hover .link .arrow {
    translate: none;
  }
}
