/* ============================================================
   Баннер согласия и окно «Cookie preferences»
   (templates/analytics/_consent.html, логика — static/js/consent.js).

   Подключается на всех страницах с аналитикой поверх разных наборов стилей
   (base.css со своим html { font-size }, лендинг, статьи, чат), поэтому:
   всё скоупится префиксом .cc-, размеры — в px, а не в rem, и базовые
   сбросы base.css (cursor: default и т. п.) здесь перебиты явно.

   Палитра — тёплый набор новых страниц (кабинет, чат, ACA Marketplace):
   Hanken Grotesk, фон #fdf8f4, рамки #e4dcd5, текст #2a2420 / #4a433d,
   акцент #e25c42.

   Две главные кнопки — «Accept all» и «Reject non-essential» — одного вида
   и веса: отказ так же заметен, как согласие (без dark patterns). Заливка —
   тёмная (#2a2420): белый текст на ней читается с запасом.

   Утверждённые ширины макетов — 375 / 800 / 1280 (.memory-bank/ui-rules.md);
   баннер и окно проверены на всех трёх. Границы медиазапросов — те же, что
   у кабинета и страницы ACA Marketplace, чтобы раскладка переключалась с
   ними в одной точке: мобильный до 767px (375), планшет 768–1023px (800),
   десктоп от 1024px (1280).
   ============================================================ */

.cc-banner,
.cc-dialog {
  --cc-primary: #e25c42;
  --cc-primary-strong: #c94b32;
  --cc-page: #fdf8f4;
  --cc-surface: #f5efe9;
  --cc-border: #e4dcd5;
  --cc-ink: #2a2420;
  --cc-body: #4a433d;
  --cc-subtle: #6e655f;
  --cc-white: #ffffff;
  --cc-ease: cubic-bezier(0.16, 1, 0.3, 1);

  font-family: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--cc-ink);
  -webkit-font-smoothing: antialiased;
}

.cc-banner *,
.cc-dialog * {
  box-sizing: border-box;
}

/* --- Баннер ------------------------------------------------- */

/* Скрыт атрибутом hidden; виден, пока на <html> висит cc-pending (выбора
   нет). Класс ставит head-скрипт до первой отрисовки, снимает consent.js. */
.cc-pending .cc-banner {
  display: block;
}

.cc-banner {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9000;
  padding: 20px 24px;
  background-color: var(--cc-white);
  border-top: 1px solid var(--cc-border);
  box-shadow: 0 -8px 32px rgba(42, 36, 32, 0.08);
  animation: cc-rise 0.6s var(--cc-ease) both;
}

.cc-banner__inner {
  display: flex;
  align-items: center;
  gap: 32px;
  max-width: 1200px;
  margin: 0 auto;
}

.cc-banner__text {
  flex: 1 1 auto;
  min-width: 0;
}

.cc-banner__title {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--cc-ink);
}

.cc-banner__body {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--cc-body);
}

.cc-banner__actions {
  display: flex;
  flex: none;
  gap: 8px;
}

/* Место под баннером: страница не прячет под ним свой низ (в чат-форме —
   поле ввода). Высоту баннера держит в --cc-banner-h consent.js. */
.cc-pending body::after {
  content: "";
  display: block;
  height: var(--cc-banner-h, 0px);
}

/* Кнопка чата поддержки поднимается над баннером. margin у fixed-элемента
   сдвигает его от bottom, не трогая собственный отступ виджета. */
.cc-pending .floating-chat {
  margin-bottom: var(--cc-banner-h, 0px);
}

/* --- Кнопки и ссылка ---------------------------------------- */

.cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  margin: 0;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 99px;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease,
    transform 0.25s var(--cc-ease);
}

.cc-btn--primary {
  background-color: var(--cc-ink);
  color: var(--cc-white);
}

.cc-btn--secondary {
  background-color: var(--cc-white);
  border-color: var(--cc-border);
  color: var(--cc-ink);
}

@media (hover: hover) {
  .cc-btn--primary:hover {
    background-color: var(--cc-primary-strong);
  }

  .cc-btn--secondary:hover {
    border-color: var(--cc-primary);
    color: var(--cc-primary-strong);
  }

  .cc-link:hover {
    color: var(--cc-primary-strong);
  }

  .cc-dialog__close:hover {
    background-color: var(--cc-surface);
  }
}

.cc-btn:active {
  transform: scale(0.97);
}

.cc-btn:focus-visible,
.cc-link:focus-visible,
.cc-dialog__close:focus-visible,
.cc-switch__input:focus-visible + .cc-switch__track {
  outline: 2px solid var(--cc-primary);
  outline-offset: 2px;
}

.cc-btn span,
.cc-btn svg {
  cursor: pointer;
}

/* Шрифт и кегль — от абзаца: стили лендинга задают ссылкам свои. */
.cc-link {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: var(--cc-ink);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  transition: color 0.3s ease;
}

/* --- Окно настроек ------------------------------------------ */

.cc-dialog {
  width: calc(100% - 32px);
  max-width: 560px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  background-color: var(--cc-white);
  border: 0;
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(42, 36, 32, 0.18);
}

.cc-dialog[open] {
  animation: cc-pop 0.45s var(--cc-ease) both;
}

.cc-dialog::backdrop {
  background-color: rgba(42, 36, 32, 0.45);
}

.cc-dialog__box {
  padding: 32px;
}

.cc-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}

/* font-family явно: стили лендинга задают заголовкам свой шрифт. */
.cc-dialog__title {
  margin: 0;
  font-family: inherit;
  font-size: 24px;
  line-height: 32px;
  font-weight: 600;
  color: var(--cc-ink);
}

.cc-dialog__close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -2px -6px 0 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 50%;
  color: var(--cc-subtle);
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.cc-dialog__close svg,
.cc-dialog__close path {
  cursor: pointer;
}

.cc-dialog__intro {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 20px;
  color: var(--cc-body);
}

.cc-cats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.cc-cat {
  padding: 16px;
  background-color: var(--cc-page);
  border: 1px solid var(--cc-border);
  border-radius: 16px;
}

.cc-cat__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.cc-cat__title {
  margin: 0;
  font-size: 16px;
  line-height: 24px;
  font-weight: 600;
  color: var(--cc-ink);
}

label.cc-cat__title {
  cursor: pointer;
}

.cc-cat__always {
  flex: none;
  padding: 2px 10px;
  background-color: var(--cc-surface);
  border-radius: 99px;
  font-size: 12px;
  line-height: 20px;
  font-weight: 500;
  color: var(--cc-subtle);
}

.cc-cat__text,
.cc-cat__note {
  margin: 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--cc-body);
}

.cc-cat__note {
  margin-top: 8px;
  color: var(--cc-subtle);
}

.cc-cat__note[hidden] {
  display: none;
}

/* --- Переключатель ------------------------------------------ */

.cc-switch {
  position: relative;
  display: inline-flex;
  flex: none;
  width: 44px;
  height: 24px;
}

.cc-switch__input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.cc-switch__input:disabled {
  cursor: not-allowed;
}

.cc-switch__track {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #cfc6be;
  border-radius: 99px;
  transition: background-color 0.3s ease;
}

.cc-switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background-color: var(--cc-white);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(42, 36, 32, 0.2);
  transition: transform 0.3s var(--cc-ease);
}

.cc-switch__input:checked + .cc-switch__track {
  background-color: var(--cc-primary-strong);
}

.cc-switch__input:checked + .cc-switch__track::after {
  transform: translateX(20px);
}

.cc-switch__input:disabled + .cc-switch__track {
  opacity: 0.5;
}

.cc-dialog__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* --- Движение ----------------------------------------------- */

@keyframes cc-rise {
  from {
    transform: translateY(100%);
  }
  to {
    transform: none;
  }
}

@keyframes cc-pop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-banner,
  .cc-dialog[open] {
    animation: none;
  }

  .cc-btn,
  .cc-switch__track,
  .cc-switch__track::after {
    transition: none;
  }
}

/* --- Планшет: кнопки под текстом ---------------------------- */

@media (max-width: 1023px) {
  .cc-banner__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
}

/* --- Мобильный ---------------------------------------------- */

@media (max-width: 767px) {
  .cc-banner {
    padding: 16px;
  }

  /* «Принять» и «Отклонить» — рядом и поровну, «Настроить» — строкой ниже. */
  .cc-banner__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .cc-banner__actions .cc-btn--secondary {
    grid-column: 1 / -1;
  }

  .cc-btn {
    padding: 0 12px;
    white-space: normal;
    text-align: center;
  }

  .cc-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 20px;
  }

  .cc-dialog__box {
    padding: 20px;
  }

  .cc-dialog__title {
    font-size: 20px;
    line-height: 28px;
  }

  .cc-dialog__actions {
    flex-direction: column;
  }

  .cc-dialog__actions .cc-btn {
    width: 100%;
  }
}
