/**
 * Klaro consent banner + modal — QS brand styling.
 *
 * Klaro v0.7 DOM hierarchy (наблюдаемо из bundle):
 *   #klaro (mount root — inline-style CSS vars: --notice-top, --notice-left, …)
 *     .klaro (Klaro's React wrapper)
 *       .cookie-notice (banner) → .cn-body, .cn-ok > .cn-buttons
 *         > .cm-btn.cm-btn-success / .cm-btn-decline / .cm-btn-info …
 *       #cookieScreen.cookie-modal (modal — opens via «Auswahl anpassen»)
 *         > .cm-bg (backdrop), .cm-modal с .cm-header/.cm-body/.cm-footer
 *
 * Tokens consumed:
 *   --ink-1, --ink-2, --rule, --bg-warm, --cream, --brand-crimson
 *   --radius-sm (8px), --radius-md (12px)
 *   Mona Sans (400 / 600 only — per glossary lock).
 *
 * `klaro.js` у нас no-css variant — мы owner всех визуальных стилей.
 */

/* ─── Reset Klaro defaults ─── */
.klaro,
.klaro * {
  box-sizing: border-box;
  font-family: 'Mona Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.klaro {
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-1, #1a1a1a);
}

/* ─── Notice (bottom bar) ─── */
.klaro .cookie-notice {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: 16px;
  max-width: 760px;
  margin: 0 auto;
  background: var(--bg-warm, #faf7f2);
  border: 1px solid var(--rule, #e5e0d8);
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(20, 14, 8, 0.18), 0 2px 8px rgba(20, 14, 8, 0.06);
  padding: 22px 24px;
  z-index: 99999;
}

.klaro .cookie-notice .cn-body {
  padding: 0;
  margin: 0;
}

.klaro .cookie-notice .cn-body h1 {
  display: none; /* No header в notice — slot занят `description` flow. */
}

.klaro .cookie-notice .cn-body p,
.klaro .cookie-notice .cn-body strong {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--ink-1, #1a1a1a);
  margin: 0 0 16px;
}

.klaro .cookie-notice .cn-body p:last-child {
  margin-bottom: 0;
}

.klaro .cookie-notice .cn-ok {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 0;
  margin: 0;
  background: none;
}

/* ─── Buttons ─── */
.klaro .cm-btn,
.klaro .cn-buttons button,
.klaro .cookie-notice .cn-buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
  text-decoration: none;
}

/* Button variants — ВСЕ rules explicitly set bg + color + text-decoration в
   BASE и в HOVER. Reason: Klaro v0.7 buttons often combine modifiers (e.g.
   `cm-btn cm-btn-success cm-btn-info`), и без explicit overrides на hover
   color от info-rule просачивается через bg от success-rule → invisible text.
   Specificity bump `.klaro .cm-btn.cm-btn-X` (0,3,0) beats `.klaro .cm-btn-X`
   (0,2,0). И `text-decoration: none` явный — даже если info-modifier ставит
   underline, success/danger/success-var его reset'ят. */

/* Info / Learn-more — text-link styled. ALWAYS overridable если кнопка
   ALSO имеет success/danger/etc modifier. */
.klaro .cm-btn-info,
.klaro .cm-btn-lern-more {
  background: transparent;
  border-color: transparent;
  color: var(--brand-crimson, #dc3b55);
  padding: 10px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.klaro .cm-btn-info:hover,
.klaro .cm-btn-lern-more:hover {
  color: #c52f47;
  text-decoration-thickness: 2px;
}

/* Primary (Accept all + Save selection) — brand-crimson filled. Wins на hover
   против info через higher specificity + explicit color/text-decoration. */
.klaro .cm-btn.cm-btn-success,
.klaro .cm-btn.cm-btn-accept,
.klaro .cm-btn.cm-btn-accept-all {
  background: var(--brand-crimson, #dc3b55);
  border-color: var(--brand-crimson, #dc3b55);
  color: #fff;
  text-decoration: none;
}

.klaro .cm-btn.cm-btn-success:hover,
.klaro .cm-btn.cm-btn-accept:hover,
.klaro .cm-btn.cm-btn-accept-all:hover {
  background: #c52f47;
  border-color: #c52f47;
  color: #fff;
  text-decoration: none;
}

/* Secondary success-var (Accept selected, в notice) — outline ink. */
.klaro .cm-btn.cm-btn-success-var {
  background: transparent;
  border-color: var(--ink-2, #525252);
  color: var(--ink-1, #1a1a1a);
  text-decoration: none;
}

.klaro .cm-btn.cm-btn-success-var:hover {
  background: var(--cream, #fff8ec);
  border-color: var(--ink-1, #1a1a1a);
  color: var(--ink-1, #1a1a1a);
  text-decoration: none;
}

/* Danger (Decline all) — outline, no scary red. TTDSG-friendly equal-
   prominence — same visual weight as primary. */
.klaro .cm-btn.cm-btn-danger,
.klaro .cm-btn.cm-btn-decline {
  background: transparent;
  border-color: var(--rule, #e5e0d8);
  color: var(--ink-2, #525252);
  text-decoration: none;
}

.klaro .cm-btn.cm-btn-danger:hover,
.klaro .cm-btn.cm-btn-decline:hover {
  background: var(--cream, #fff8ec);
  border-color: var(--ink-1, #1a1a1a);
  color: var(--ink-1, #1a1a1a);
  text-decoration: none;
}

/* In-text link (Datenschutz reference). */
.klaro .cm-link {
  color: var(--brand-crimson, #dc3b55);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-thickness 180ms ease;
}

.klaro .cm-link:hover {
  text-decoration-thickness: 2px;
}

/* ─── Modal (Auswahl anpassen) ─── */
.klaro .cm-bg {
  background: rgba(20, 14, 8, 0.55);
  backdrop-filter: blur(2px);
  z-index: 99998;
}

.klaro .cm-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: var(--bg-warm, #faf7f2);
  border: 1px solid var(--rule, #e5e0d8);
  border-radius: 16px;
  box-shadow: 0 32px 80px rgba(20, 14, 8, 0.32);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.klaro .cm-modal .cm-header {
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--rule, #e5e0d8);
  position: relative;
}

.klaro .cm-modal .cm-header h1,
.klaro .cm-modal .cm-header .title {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink-1, #1a1a1a);
  margin: 0 32px 8px 0;
  letter-spacing: -0.01em;
}

.klaro .cm-modal .cm-header .hide {
  position: absolute;
  top: 18px;
  right: 18px;
  background: transparent;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2, #525252);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 180ms ease, color 180ms ease;
}

.klaro .cm-modal .cm-header .hide:hover {
  background: var(--cream, #fff8ec);
  color: var(--ink-1, #1a1a1a);
}

.klaro .cm-modal .cm-header p {
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-2, #525252);
  margin: 0;
}

.klaro .cm-modal .cm-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 28px 20px;
}

.klaro .cm-modal .cm-body ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ─── Purpose row (Statistik & Analyse / Marketing / Externe Dienste) ─── */
.klaro .cm-modal .cm-body .cm-purpose,
.klaro .cm-modal .cm-body .cm-services li {
  border-bottom: 1px solid var(--rule, #e5e0d8);
  padding: 16px 0;
}

.klaro .cm-modal .cm-body .cm-purpose:last-child,
.klaro .cm-modal .cm-body .cm-services li:last-child {
  border-bottom: none;
}

.klaro .cm-list-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-1, #1a1a1a);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.klaro .cm-list-description {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-2, #525252);
  margin-top: 6px;
}

/* ─── Toggle switch ─── */
/* Klaro v0.7 toggle DOM:
     <input type="checkbox" class="cm-list-input">
     <label class="cm-list-label">
       <span class="cm-list-title">…</span>
       <span class="cm-switch">
         <div class="slider round[ active]"></div>
       </span>
     </label>
   .slider.round.active is ALWAYS emitted by Klaro (hardcoded — `active`
   класс не state-driven). Реальное состояние — на input[type=checkbox]
   через :checked. Поэтому styling по `input:checked ~ * .slider`
   sibling-combinator. */

/* Hide actual checkbox — Klaro toggles state via React, switch — пurely visual. */
.klaro input.cm-list-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* Switch wrapper — inline pill alignment. */
.klaro .cm-switch {
  display: inline-block;
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 38px;
  margin-right: 12px;
  vertical-align: middle;
}

/* Slider track — off-state default. */
.klaro .cm-switch .slider,
.klaro .cm-switch .slider.round {
  position: absolute;
  inset: 0;
  background: #d4cdc0;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 200ms ease;
}

/* Slider knob — moves left ↔ right via translateX. */
.klaro .cm-switch .slider::before,
.klaro .cm-switch .slider.round::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* Checked state — checkbox is sibling to label, label contains .cm-switch. */
.klaro input.cm-list-input:checked ~ label .cm-switch .slider {
  background: var(--brand-crimson, #dc3b55);
}

.klaro input.cm-list-input:checked ~ label .cm-switch .slider::before {
  transform: translateX(16px);
}

/* Required service (no decline allowed) — crimson but slightly faded, cursor
   not-allowed. */
.klaro input.cm-list-input.required ~ label .cm-switch .slider,
.klaro input.cm-list-input:disabled ~ label .cm-switch .slider {
  background: var(--brand-crimson, #dc3b55);
  opacity: 0.55;
  cursor: not-allowed;
}

.klaro input.cm-list-input.required ~ label .cm-switch .slider::before,
.klaro input.cm-list-input:disabled ~ label .cm-switch .slider::before {
  transform: translateX(16px);
}

/* «half-checked» — purpose switch когда некоторые services on, не all. */
.klaro input.cm-list-input.half-checked ~ label .cm-switch .slider {
  background: var(--brand-crimson, #dc3b55);
  opacity: 0.6;
}

.klaro input.cm-list-input.half-checked ~ label .cm-switch .slider::before {
  transform: translateX(8px);
}

/* ─── Purpose row layout ─── */
.klaro .cm-list-label {
  display: flex;
  align-items: flex-start;
  gap: 0;
  cursor: pointer;
}

.klaro .cm-list-label .cm-list-title {
  flex: 1;
}

/* Required marker. */
.klaro .cm-required {
  color: var(--ink-2, #525252);
  font-size: 12px;
  font-weight: 400;
  font-style: italic;
  margin-left: 6px;
}

/* Opt-out marker (если service default=true). */
.klaro .cm-opt-out {
  color: var(--brand-crimson, #dc3b55);
  font-size: 12px;
  font-weight: 400;
  font-style: italic;
  margin-left: 6px;
}

/* ─── Services collapsible inside purpose ─── */
.klaro .cm-services {
  margin-top: 12px;
  padding-left: 50px; /* indented под toggle */
  border-top: 1px dashed var(--rule, #e5e0d8);
  padding-top: 12px;
  list-style: none;
}

.klaro .cm-caret {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--ink-2, #525252);
  text-decoration: none;
}

.klaro .cm-caret:hover {
  color: var(--brand-crimson, #dc3b55);
}

/* ─── Modal footer (buttons) ─── */
.klaro .cm-modal .cm-footer {
  border-top: 1px solid var(--rule, #e5e0d8);
  padding: 16px 28px;
  background: var(--cream, #fff8ec);
}

.klaro .cm-modal .cm-footer .cm-footer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.klaro .cm-modal .cm-footer .cm-powered-by {
  display: none; /* Klaro attribution opt-out — we link them в /datenschutz instead. */
}

/* ─── Mobile ─── */
@media (max-width: 640px) {
  .klaro .cookie-notice {
    left: 8px;
    right: 8px;
    bottom: 8px;
    padding: 18px 18px;
  }

  .klaro .cookie-notice .cn-ok {
    flex-direction: column;
    align-items: stretch;
  }

  .klaro .cookie-notice .cn-ok .cm-btn {
    width: 100%;
  }

  .klaro .cm-modal {
    width: calc(100vw - 16px);
    max-height: calc(100vh - 32px);
    border-radius: 12px;
  }

  .klaro .cm-modal .cm-header,
  .klaro .cm-modal .cm-body,
  .klaro .cm-modal .cm-footer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .klaro .cm-modal .cm-footer .cm-footer-buttons {
    flex-direction: column;
  }

  .klaro .cm-modal .cm-footer .cm-footer-buttons .cm-btn {
    width: 100%;
  }
}

/* ─── Reduced motion ─── */
@media (prefers-reduced-motion: reduce) {
  .klaro *,
  .klaro *::before {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
