/* ============================================================================
   Туториалы шаблонов (/kak-sdelat-*, /tutorials).

   Разметку рисует серверный рендер backend/src/services/tutorials/render.js —
   один и тот же HTML для SSR и для клиента, поэтому все классы `tp-*` живут
   здесь. Корень — `<main class="lp tp">`: от `.lp` (landing.css) берутся
   ширина колонки и бренд-токены, всё остальное задаёт `.tp`.
   ============================================================================ */

.tp {
  --tp-accent: var(--lp-accent, #b4ff39);
  --tp-accent-soft: rgba(180, 255, 57, .45);
  --tp-accent-glow: rgba(180, 255, 57, .22);
  --tp-on-accent: var(--bg, #0b0b0f);
  --tp-line: var(--lp-line, rgba(255, 255, 255, .09));
  --tp-surface: #131318;
  --tp-raised: rgba(255, 255, 255, .045);
  --tp-chip: rgba(255, 255, 255, .06);
  --tp-text: var(--text, #f6f7fb);
  --tp-text-soft: rgba(246, 247, 251, .78);
  --tp-muted: var(--muted, #8b8d98);
}

/* Двойной класс — осознанное переопределение отступов `.lp` (16px по краям). */
.lp.tp { padding: 8px 16px 96px; }

.tp :focus-visible {
  outline: 2px solid var(--tp-accent);
  outline-offset: 2px;
}

.tp-icon { flex: none; }

.tp-chips,
.tp-meta,
.tp-slots,
.tp-step-list,
.tp-cards,
.tp-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tp-section-title {
  margin: 0 0 16px;
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 700;
  letter-spacing: -.01em;
}

/* ── Хлебные крошки ─────────────────────────────────────────────────────── */
.tp-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 10px;
  padding: 4px 0 12px;
  font-size: 14px;
  color: var(--tp-muted);
}
.tp-crumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--tp-muted);
  text-decoration: none;
}
.tp-crumbs a:hover { color: var(--tp-accent); }
.tp-crumbs [aria-current] { color: var(--tp-text); }
.tp-crumbs-sep { opacity: .6; }

/* ── Герой ───────────────────────────────────────────────────────────────
   Порядок в DOM: описание → видео и запуск → промпт. На телефоне так и идёт
   сверху вниз; на десктопе промпт встаёт под описание в левой колонке. */
.tp-hero {
  display: grid;
  gap: 20px;
  padding: 20px;
  border: 1px solid var(--tp-line);
  border-radius: 24px;
  background: var(--tp-surface);
}

.tp-h1 {
  margin: 0 0 14px;
  font-size: clamp(26px, 5.2vw, 40px);
  line-height: 1.15;
  letter-spacing: -.02em;
  font-weight: 700;
  color: #fff;
}

.tp-lead {
  margin: 0 0 20px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--tp-text-soft);
}

.tp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.tp-chip {
  padding: 6px 12px;
  border: 1px solid var(--tp-line);
  border-radius: 10px;
  background: var(--tp-raised);
  font-size: 14px;
  font-weight: 500;
}

.tp-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  color: var(--tp-muted);
  font-size: 14px;
}
.tp-meta li { display: inline-flex; align-items: center; gap: 8px; }

/* Видео, требования к фото и запуск */
.tp-hero-side { display: grid; gap: 14px; align-content: start; }
.tp-media {
  overflow: hidden;
  border-radius: 20px;
  background: #000;
}
.tp-media.tp-shape-portrait {
  width: min(100%, 315px);
  margin-inline: auto;
  aspect-ratio: 9 / 16;
}
.tp-media.tp-shape-landscape { aspect-ratio: 16 / 9; }
.tp-media.tp-shape-square { aspect-ratio: 1; }
.tp-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tp-photos {
  padding: 16px;
  border-radius: 18px;
  background: var(--tp-raised);
}
.tp-photos-title { margin: 0; font-size: 15px; font-weight: 600; }
.tp-slots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tp-slot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px dashed var(--tp-accent-soft);
  border-radius: 12px;
  font-size: 14px;
}
.tp-slot .tp-icon { color: var(--tp-accent); }
.tp-photos-note { margin: 10px 0 0; font-size: 13px; color: var(--tp-muted); }

.tp-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 0 24px;
  border-radius: 16px;
  background: var(--tp-accent);
  box-shadow: 0 10px 30px var(--tp-accent-glow);
  color: var(--tp-on-accent);
  font-size: 17px;
  font-weight: 700;
  text-decoration: none;
  transition: transform .2s ease, box-shadow .2s ease;
}
.tp-cta:hover { transform: translateY(-1px); }

/* Промпт сцены */
.tp-prompt {
  padding: 16px;
  border-radius: 18px;
  background: var(--tp-raised);
}
.tp-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.tp-prompt-title { margin: 0; font-size: 16px; font-weight: 600; }
.tp-copy {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--tp-line);
  border-radius: 12px;
  background: var(--tp-chip);
  color: var(--tp-text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .2s ease, color .2s ease;
}
.tp-copy:hover { border-color: var(--tp-accent); color: var(--tp-accent); }
.tp-prompt-text {
  max-height: 14em;
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  border-radius: 12px;
  background: var(--bg, #0b0b0f);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--tp-text-soft);
}
.tp-prompt-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--tp-muted);
}

/* ── Тело: шаги запуска и статья ────────────────────────────────────────── */
.tp-body {
  display: grid;
  gap: 32px;
  margin-top: 40px;
}

.tp-step-list { display: grid; gap: 12px; }
.tp-step {
  display: grid;
  justify-items: start;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--tp-line);
  border-radius: 18px;
  background: var(--tp-raised);
}
.tp-step-num {
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--tp-chip);
  font-size: 12px;
  color: var(--tp-muted);
}
.tp-step:last-child .tp-step-num {
  background: var(--tp-accent);
  color: var(--tp-on-accent);
  font-weight: 600;
}
.tp-step-title { font-size: 16px; }
.tp-step-text { font-size: 14px; line-height: 1.5; color: var(--tp-muted); }

.tp-article { max-width: 720px; }
.tp-block + .tp-block { margin-top: 36px; }
.tp-block .tp-section-title {
  margin-bottom: 12px;
  font-size: 22px;
  line-height: 1.3;
}
.tp-block p {
  margin: 0;
  font-size: 16px;
  line-height: 1.75;
  color: var(--tp-text-soft);
}
.tp-list li {
  position: relative;
  padding-left: 22px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--tp-text-soft);
}
.tp-list li + li { margin-top: 8px; }
.tp-list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: .72em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tp-accent);
}

/* ── FAQ ────────────────────────────────────────────────────────────────── */
.tp-faq { max-width: 820px; margin-top: 64px; }
.tp-faq-item { border-bottom: 1px solid var(--tp-line); }
.tp-faq-item summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  list-style: none;
  cursor: pointer;
}
.tp-faq-item summary::-webkit-details-marker { display: none; }
.tp-faq-item summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-right: 2px solid var(--tp-muted);
  border-bottom: 2px solid var(--tp-muted);
  transform: rotate(45deg) translateY(-3px);
  transition: transform .2s ease;
}
.tp-faq-item[open] summary::after { transform: rotate(-135deg) translateY(-3px); }
.tp-faq-item p {
  margin: 0 0 18px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--tp-text-soft);
}

/* ── Карточки: «Ещё туториалы» (лента) и каталог (сетка) ────────────────── */
.tp-related { margin-top: 64px; }
.tp-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(170px, 220px);
  gap: 14px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
}
.tp-cards > li { scroll-snap-align: start; }
.tp-cards-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: visible;
}
.tp-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  border: 1px solid var(--tp-line);
  border-radius: 20px;
  background: var(--tp-surface);
  color: var(--tp-text);
  text-decoration: none;
  transition: border-color .2s ease, transform .2s ease;
}
.tp-card:hover { border-color: var(--tp-accent-soft); transform: translateY(-2px); }
.tp-card-media { display: block; aspect-ratio: 9 / 16; background: #000; }
.tp-card-media.tp-shape-landscape { aspect-ratio: 16 / 9; }
.tp-card-media.tp-shape-square { aspect-ratio: 1; }
.tp-card-media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tp-card-body { display: grid; gap: 8px; padding: 12px 14px 14px; }
.tp-card-title {
  display: -webkit-box;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.tp-card-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tp-card-meta span {
  padding: 3px 8px;
  border-radius: 8px;
  background: var(--tp-chip);
  font-size: 12px;
  color: var(--tp-muted);
}

/* Каталог */
.tp-catalog-head { max-width: 720px; margin-bottom: 28px; }
.tp-empty { color: var(--tp-muted); }
.tp-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 36px;
}
.tp-pager-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--tp-line);
  border-radius: 12px;
  color: var(--tp-text);
  text-decoration: none;
}
.tp-pager-link:hover { border-color: var(--tp-accent); color: var(--tp-accent); }
.tp-pager-page { font-size: 14px; color: var(--tp-muted); }

/* ── Планшет и десктоп ──────────────────────────────────────────────────── */
@media (min-width: 700px) {
  .lp.tp { padding-inline: 24px; }
  .tp-hero { padding: 28px; border-radius: 28px; }
  .tp-cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 980px) {
  /* Правая колонка — по ширине видео, чтобы видео, фото и кнопка совпадали. */
  .tp-hero {
    grid-template-columns: minmax(0, 1fr) 315px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "main side"
      "prompt side";
    gap: 20px 36px;
    padding: 32px;
  }
  .tp-hero-landscape { grid-template-columns: minmax(0, 1fr) 440px; }
  .tp-hero-square { grid-template-columns: minmax(0, 1fr) 360px; }
  .tp-hero-main { grid-area: main; }
  .tp-hero-side { grid-area: side; }
  .tp-prompt { grid-area: prompt; align-self: start; }
  .tp-media.tp-shape-portrait { width: 100%; }

  /* Шаги справа от статьи. Без sticky: глобальный overflow у body
     (styles.css) делает body контейнером прокрутки, и sticky не срабатывает. */
  .tp-body {
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas: "article steps";
    align-items: start;
    gap: 56px;
    margin-top: 56px;
  }
  .tp-article { grid-area: article; }
  .tp-steps { grid-area: steps; }
  .tp-cards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 1280px) {
  .tp-cards-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .tp-cta,
  .tp-card,
  .tp-faq-item summary::after { transition: none; }
  .tp-cta:hover,
  .tp-card:hover { transform: none; }
}
