/* ==========================================================================
   ПРАВОВОЙ ТЫЛ — тематические страницы (content/*.md через Jinja).
   Единый фирменный стиль, принят 14.08.2026: шапка, подвал, палитра и типографика
   переведены на витрину (см. base.html — /styles.css витрины подключён первым,
   этот файл подключён вторым и только добавляет то, чего в витрине нет).

   Здесь НЕТ переменных палитры и НЕТ шапки/подвала/кнопок — они уже есть в
   styles.css витрины и наследуются через каскад (var(--green), var(--paper),
   .site-header, .button-primary и т.д.). Ниже — только компоненты статейной
   страницы, которых в витрине не было: оглавление, боковая колонка с CTA,
   таблицы, блок «Вопросы и ответы», карточки «Смотрите также», форма заявки,
   липкая мобильная панель.
   ========================================================================== */

/* ===== Двухколоночная раскладка: статья + боковая колонка =====
   Мобильная доступность заявки (аудит 2.3): порядок блоков на <900px —
   CTA, затем оглавление, затем статья. Сделано через grid-template-areas,
   без дублирования разметки. */
.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  grid-template-areas: "article side";
  gap: clamp(28px, 4vw, 56px);
  align-items: start;
  padding: clamp(28px, 4vw, 48px) 0 clamp(40px, 5vw, 64px);
}

.content-article {
  grid-area: article;
  min-width: 0;
  overflow-wrap: break-word;
}

.content-side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: calc(var(--header-h, 98px) + 20px);
}

/* ===== Оглавление ===== */
.content-toc {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 20px 22px;
  background: var(--paper-light);
}

.content-toc-title {
  margin-bottom: 12px;
  color: var(--ink-faint);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.content-toc ol {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.content-toc li {
  counter-increment: toc;
  position: relative;
  padding-left: 24px;
  font-size: 13.5px;
  line-height: 1.45;
}

.content-toc li::before {
  content: counter(toc) ".";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--copper-text);
  font-family: var(--serif);
  font-weight: 600;
}

.content-toc a {
  color: var(--ink-muted);
}

.content-toc a:hover {
  color: var(--copper-text);
}

/* ===== Портрет юриста (только /o-yuriste/) ===== */
.content-portrait {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper-light);
}

.content-portrait img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
}

/* ===== Карточка CTA в боковой колонке и в блоке цены ===== */
.content-cta {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: clamp(20px, 2.4vw, 26px);
  background: var(--paper-light);
}

.content-cta h3 {
  margin-bottom: 8px;
  font-size: 19px;
}

.content-cta p {
  margin-bottom: 16px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.55;
}

.content-cta .button {
  width: 100%;
}

.content-cta-phone {
  display: block;
  margin-top: 12px;
  text-align: center;
  color: var(--copper-text);
  font-family: var(--serif);
  font-size: 17px;
}

.content-cta-phone:hover {
  color: var(--copper-deep);
}

.content-prices p {
  margin-bottom: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.85;
}

.content-prices strong {
  color: var(--copper-text);
}

.content-prices-note {
  margin-top: 14px;
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.55;
}

/* Мобильная доступность заявки (аудит 2.3): CTA — первый блок боковой колонки,
   оглавление — следом. Портрет (если есть) остаётся перед ними. */
@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "side" "article";
    gap: 24px;
  }

  .content-side {
    position: static;
  }

  .content-cta {
    order: -2;
  }

  .content-toc {
    order: -1;
  }
}

/* ===== Заголовки самостоятельных блоков (FAQ, форма, «смотрите также») =====
   Внутри статьи — с верхней линейкой, как в .razbor-section h2. В начале своей
   секции (форма, «смотрите также») — без неё, секция уже даёт отступ сверху. */
.content-block-title {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(22px, 2.6vw, 31px);
  color: var(--ink);
}

.content-article > .content-block-title {
  margin-top: clamp(30px, 4vw, 48px);
  padding-top: clamp(18px, 2.4vw, 26px);
  border-top: 1px solid var(--line);
}

/* ===== Таблицы =====
   На телефоне превращаются в карточки «показатель — значение», а не едут
   горизонтальной прокруткой. build.py добавляет data-label из <th>. */
.table-scroll {
  margin: 24px 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-light);
}

.razbor-section table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 14px;
}

.razbor-section th,
.razbor-section td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  color: var(--ink-muted);
}

.razbor-section th {
  background: var(--paper-rail);
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink);
  font-weight: 600;
  font-size: 12.5px;
}

.razbor-section tr:last-child td {
  border-bottom: 0;
}

/* ===== Вопросы и ответы ===== */
.faq {
  margin-top: 4px;
}

.faq details {
  border-bottom: 1px solid var(--line);
}

.faq summary {
  position: relative;
  padding: 15px 30px 15px 0;
  list-style: none;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.4;
}

.faq summary::-webkit-details-marker {
  display: none;
}

.faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 12px;
  color: var(--copper-text);
  font-size: 21px;
  font-weight: 400;
}

.faq details[open] summary::after {
  content: "\2212";
}

.faq details > div {
  padding: 0 0 18px;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.65;
}

.faq details > div p {
  margin-bottom: 12px;
}

.faq details > div p:last-child {
  margin-bottom: 0;
}

.faq details > div a {
  color: var(--copper-text);
  border-bottom: 1px solid rgba(158, 82, 48, 0.34);
}

/* ===== «Чего я не делаю» ===== */
.notdo {
  margin-top: 40px;
  padding: clamp(20px, 2.4vw, 26px);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-light);
}

.notdo h3 {
  margin-bottom: 12px;
  font-size: 17px;
  color: var(--ink);
}

.notdo ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notdo li {
  position: relative;
  padding-left: 18px;
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 1.55;
}

.notdo li::before {
  content: "\2014";
  position: absolute;
  left: 0;
  color: var(--line-strong);
}

.notdo-foot {
  margin-top: 14px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.6;
}

/* ===== Секция «Опишите свою ситуацию» ===== */
.content-request {
  padding: clamp(40px, 5vw, 64px) 0;
  border-top: 1px solid var(--line);
  background: var(--paper-light);
}

.content-request-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.62fr);
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
}

.content-request-sub {
  max-width: 60ch;
  margin-bottom: 22px;
  color: var(--ink-muted);
  font-size: 15px;
  line-height: 1.6;
}

/* ===== Форма заявки =====
   Состав и id/name полей не менялись (server/app.py, static/app.js,
   server/test_contact_validation.js на них завязаны) — меняется только вид. */
.content-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  color: var(--ink-muted);
  font-size: 13px;
}

.req {
  color: var(--copper-deep);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--paper-light);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.4;
}

.field textarea {
  min-height: 128px;
  padding-top: 12px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--copper-fill);
}

.field-hint {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.55;
}

/* .consent input уже стилизован в styles.css витрины (17×17, --copper) без
   привязки к .request-form — переопределять не нужно. Здесь только цвет ссылок:
   в витрине .consent a — светлый (--peach) для тёмно-зелёной секции, на бумаге
   его не видно, поэтому переопределяем через более конкретный селектор. */
.content-form .consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 2px 0;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

.content-form .consent a {
  color: var(--copper-text);
  border-bottom: 1px solid rgba(158, 82, 48, 0.34);
}

.content-form .consent a:hover {
  border-bottom-color: var(--copper-text);
}

.form-status {
  display: none;
  margin-top: 4px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  font-size: 13.5px;
  line-height: 1.6;
}

.form-status.ok {
  display: block;
  border-left: 3px solid #5c7a45;
  background: #f1f3ec;
  color: #3b4b2c;
}

.form-status.err {
  display: block;
  border-left: 3px solid var(--copper-deep);
  background: var(--copper-tint);
  color: var(--copper-deep);
}

/* ===== Смотрите также ===== */
.content-related {
  padding: clamp(36px, 4.6vw, 56px) 0;
  border-top: 1px solid var(--line-strong);
  background: var(--paper-rail);
}

.content-related-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 8px;
}

.content-related-item {
  display: block;
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper-light);
  transition: border-color 0.18s ease;
}

.content-related-item:hover {
  border-color: var(--line-strong);
}

.content-related-item .t {
  margin-bottom: 6px;
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
}

.content-related-item .d {
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ===== Юридические документы (privacy/oferta/soglasie) =====
   Текст не менялся — только чуть плотнее типографика, чем в статье. */
.content-legal ol,
.content-legal ul {
  padding-left: 22px;
}

/* ===== Липкая нижняя панель на мобильном (аудит 2.3) =====
   Кнопки «Позвонить» и «Описать ситуацию» доступны с любого места длинной
   статьи. Анимации нет, поэтому уважать prefers-reduced-motion нечего —
   панель просто всегда на месте, без входной анимации. */
.mobile-cta-bar {
  display: none;
}

@media (max-width: 900px) {
  body.has-mobile-cta {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px));
  }

  .mobile-cta-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    gap: 1px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--line-strong);
    box-shadow: 0 -6px 18px rgba(28, 41, 38, 0.16);
  }

  .mobile-cta-bar a {
    flex: 1 1 50%;
    display: flex;
    min-height: 52px;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
  }

  .mobile-cta-call {
    background: var(--paper-light);
    color: var(--ink);
  }

  .mobile-cta-form {
    background: var(--copper-fill);
    color: #fff8f1;
  }
}

/* ===== Адаптив ===== */
@media (max-width: 900px) {
  .content-request-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .content-related-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .field-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .content-related-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .table-scroll {
    margin: 18px 0;
    border: 0;
    background: transparent;
    overflow: visible;
  }

  .table-scroll table,
  .table-scroll tbody,
  .table-scroll tr,
  .table-scroll td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .table-scroll table {
    max-width: 100%;
    font-size: 13.5px;
  }

  .table-scroll thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }

  .table-scroll tr {
    margin-top: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--paper-light);
  }

  .table-scroll tr:first-child {
    margin-top: 0;
  }

  .table-scroll td {
    display: grid;
    grid-template-columns: minmax(7rem, 0.42fr) minmax(0, 1fr);
    gap: 6px 12px;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .table-scroll td:last-child {
    border-bottom: 0;
  }

  .table-scroll td::before {
    content: attr(data-label);
    min-width: 0;
    color: var(--ink-faint);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1.4;
    text-transform: uppercase;
  }
}

@media (prefers-reduced-motion: reduce) {
  .content-related-item {
    transition: none;
  }
}
