/* ============================================================
   pricing.css — Pricing cards (2 tariffs)
   Depends on: variables.css, layout.css, components/card.css, components/badge.css
   ============================================================ */

.pricing {
  padding: var(--section-padding);
  background-color: var(--color-surface);
}

/* ── Layout: зафиксированный тариф слева + деталь-панель в центре +
   список остальных тарифов справа. На десктопе все три колонки
   растянуты по высоте до одинакового размера (align-items: stretch) —
   список из 7 строк естественно самый высокий, поэтому обе карточки
   стабильно подстраиваются под его высоту независимо от того, какой
   тариф сейчас открыт в центре. ── */
.pricing__layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: start;
}

@media (min-width: 1024px) {
  .pricing__layout {
    grid-template-columns: minmax(300px, 360px) 1fr minmax(240px, 300px);
    gap: var(--space-6);
    align-items: stretch;
  }

  .pricing__fixed  { order: 1; }
  .pricing-detail  { order: 2; }
  .tariff-list     { order: 3; }
}

/* ── Pricing card ───────────────────────────────────────── */
.pricing-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  transition: var(--transition-base);
}

.pricing-card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

/* Featured / recommended card */
.pricing-card--featured {
  border: 2px solid var(--color-primary);
}

/* ── Card header ────────────────────────────────────────── */
.pricing-card__title {
  font-size: var(--text-h4);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.pricing-card__subtitle {
  font-size: var(--text-body-m);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

/* ── Price ──────────────────────────────────────────────── */
.pricing-card__price {
  display: flex;
  align-items: flex-end;
  gap: var(--space-1);
  line-height: 1;
}

.pricing-card__amount {
  font-size: 36px;
  font-weight: var(--font-weight-extrabold);
  color: var(--color-text-primary);
  letter-spacing: var(--ls-heading);
}

.pricing-card__currency {
  font-size: var(--text-h3);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: 4px;
}

.pricing-card__period {
  font-size: var(--text-body-m);
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

/* ── Divider ────────────────────────────────────────────── */
.pricing-card__divider {
  height: 1px;
  background-color: var(--color-border);
}

/* ── Features list ──────────────────────────────────────── */
.pricing-card__features {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  flex: 1;
}

.pricing-card__feature {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--text-body-m);
  color: var(--color-text-secondary);
  line-height: var(--lh-body);
}

.pricing-card__feature-icon {
  width: 18px;
  height: 18px;
  color: var(--color-success);
  flex-shrink: 0;
  margin-top: 1px;
}

/* Features grow to fill available space → CTA sticks to bottom */
.pricing-card__features {
  flex: 1;
}

/* ── CTA button ─────────────────────────────────────────── */
.pricing-card__cta {
  margin-top: var(--space-2);
}

/* ── Promo block (first lesson 500₽) ────────────────────── */
.pricing__promo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-10) auto var(--space-8);
  padding: var(--space-4) var(--space-8);
  background-color: rgba(255, 217, 19, 0.15);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-lg);
  max-width: 480px;
  font-size: var(--text-body-l);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  text-align: center;
}

/* ── Bottom note ────────────────────────────────────────── */
.pricing__note {
  text-align: center;
  margin-top: var(--space-1);
  margin-bottom: 0;
  font-size: var(--text-caption);
  color: var(--color-text-muted);
}

/* When inside section-header, reduce its bottom margin */
.section-header:has(.pricing__note) {
  margin-bottom: var(--space-8);
}

/* ── CTA row ────────────────────────────────────────────── */
.pricing__cta {
  text-align: center;
  margin-top: var(--space-8);
}

/* ── Деталь-панель по центру: показывает выбранный тариф (по умолчанию
   «Комбо Гибкий»), переключается наведением/фокусом/кликом по списку
   справа и остаётся закреплённой после ухода курсора — до следующего
   наведения (см. js/pricing-tariffs.js). Панели переиспользуют
   .pricing-card. height:100% — чтобы видимая панель заполняла всю
   растянутую (align-items:stretch) высоту колонки. ── */
.pricing-detail {
  position: relative;
  height: 100%;
}

.pricing-detail__panel[hidden] {
  display: none;
}

.pricing-detail__panel {
  width: 100%;
  height: 100%;
  animation: tab-fade-in 0.25s ease;
}

/* ── Список остальных тарифов справа ──────────────────────
   .tariff-list__item — контейнер (div): рамка, фон, на мобильном
   ещё и overflow:hidden, чтобы обрезать анимацию разворота.
   .tariff-list__summary — кликабельная строка внутри (button).
   На мобильном пункт разворачивается вниз по тапу (см.
   js/pricing-tariffs.js) — .pricing-detail__panel переносится
   внутрь .tariff-list__item и раскрывается через max-height. ── */
.tariff-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tariff-list__item {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.tariff-list__item:hover,
.tariff-list__item:has(.tariff-list__summary:focus-visible),
.tariff-list__item.is-active {
  border-color: var(--color-primary);
}

.tariff-list__summary {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: none;
  border: none;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.tariff-list__summary:hover,
.tariff-list__item.is-active .tariff-list__summary {
  background-color: var(--color-primary-light);
}

.tariff-list__name {
  font-size: var(--text-body-m);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
}

.tariff-list__price {
  font-size: var(--text-caption);
  font-weight: var(--font-weight-extrabold);
  color: var(--color-primary);
}

.tariff-list__period {
  font-weight: var(--font-weight-regular);
  color: var(--color-text-muted);
  margin-left: 2px;
}

/* Шеврон — только на мобильном, где пункт разворачивается вниз;
   на десктопе переключение идёт через центральную деталь-панель */
.tariff-list__chevron {
  display: none;
}

@media (max-width: 1023.98px) {
  .tariff-list__summary {
    flex-direction: row;
    align-items: center;
    gap: var(--space-3);
  }

  .tariff-list__name {
    flex: 1;
  }

  .tariff-list__chevron {
    display: block;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--color-text-muted);
    transition: transform 0.25s ease;
  }

  .tariff-list__item.is-active .tariff-list__chevron {
    transform: rotate(180deg);
  }

  /* Деталь-панель, перенесённая внутрь пункта списка: без своей рамки/
     тени (она и так внутри карточки списка), заголовок и цена скрыты —
     то же самое уже показано в строке выше. */
  .tariff-list__item .pricing-detail__panel {
    width: 100%;
    height: auto;
    border: none;
    box-shadow: none;
    padding: 0 var(--space-4);
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    animation: none;
    transition: max-height 0.28s ease, opacity 0.2s ease, padding 0.2s ease;
  }

  .tariff-list__item .pricing-detail__panel.tariff-list__panel--open {
    max-height: 600px;
    opacity: 1;
    padding: 0 var(--space-4) var(--space-4);
  }

  .tariff-list__item .pricing-detail__panel .pricing-card__title,
  .tariff-list__item .pricing-detail__panel .pricing-card__price,
  .tariff-list__item .pricing-detail__panel .pricing-card__divider {
    display: none;
  }

  .tariff-list__item .pricing-detail__panel .pricing-card__subtitle {
    margin-top: 0;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
  }
}
