/* ============================================================
   Антим Клима — Complianz cookie banner reskin.
   Complianz generates its banner CSS into uploads/complianz/css/ (not in
   git) and injects it via JS, so load order can't be relied on. Every rule
   here is anchored on the container ID so it wins on specificity instead.
   Colors mirror the .ak tokens in home.css — the banner is appended to
   <body> outside the .ak wrapper, so the custom properties aren't inherited.
   ============================================================ */

#cmplz-cookiebanner-container .cmplz-cookiebanner {
  --cmplz_banner_width: 720px;
  --cmplz_banner_background_color: #ffffff;
  --cmplz_banner_border_color: transparent;
  --cmplz_banner_border_width: 0;
  --cmplz_banner_border_radius: 16px;
  --cmplz_banner_margin: 8px;
  --cmplz_text_color: #0f2133;
  --cmplz_hyperlink_color: #0072a8;
  --cmplz_text_font_size: 14px;
  --cmplz_text_line_height: 1.55;
  --cmplz_link_font_size: 13px;
  --cmplz_title_font_size: 12px;
  --cmplz_button_accept_background_color: #0072a8;
  --cmplz_button_accept_border_color: #0072a8;
  --cmplz_button_accept_text_color: #ffffff;
  --cmplz_button_deny_background_color: transparent;
  --cmplz_button_deny_border_color: #dce5ec;
  --cmplz_button_deny_text_color: #0f2133;
  --cmplz_button_settings_background_color: transparent;
  --cmplz_button_settings_border_color: #dce5ec;
  --cmplz_button_settings_text_color: #0f2133;
  --cmplz_button_border_radius: 12px;
  --cmplz_button_font_size: 14px;
  --cmplz_category_header_title_font_size: 14px;
  --cmplz_category_header_active_font_size: 12px;
  --cmplz_category_header_always_active_color: #12804a;
  --cmplz_category_body_font_size: 13px;
  --cmplz_slider_active_color: #0072a8;
  --cmplz_slider_inactive_color: #c5cdd6;
  --cmplz_slider_bullet_color: #ffffff;

  font-family: var(--ak-font);
  -webkit-font-smoothing: antialiased;
  padding: 20px 24px 22px;
  box-shadow: 0 24px 60px rgba(4, 24, 48, .35);
}

/* ---- placement: bottom-centered bar, no backdrop ----
   Complianz's generated CSS centers the banner, then a position module
   overrides it with `right/bottom + transform: initial`. These rules are
   anchored on the container ID so they win either way. The container stays
   a zero-size wrapper — no dimming overlay, page stays clickable. */
#cmplz-cookiebanner-container .cmplz-cookiebanner {
  position: fixed;
  top: auto;
  right: auto;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99998;
  width: var(--cmplz_banner_width);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
}

/* Complianz sizes the text/category columns off --cmplz_banner_width minus
   its own 42px padding allowance; ours is wider, so let them just fill. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories {
  width: 100%;
}

/* header: small label left, round close chip right */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-header {
  grid-template-columns: 1fr auto;
  align-items: center;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-logo { display: none; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-title {
  grid-column: 1;
  justify-self: start;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
  color: #627386;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-close {
  grid-column: 2;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #f2f6f9;
  color: #627386;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background .15s, color .15s;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-close:hover,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-close:focus-visible {
  font-size: inherit;
  line-height: 1;
  background: #dce5ec;
  color: #0f2133;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-close svg { width: 14px; height: 14px; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-divider {
  border: 0;
  border-top: 1px solid #dce5ec;
  margin-left: -24px;
  margin-right: -24px;
}

/* message: the banner text contains an <h2> that inherits the theme's
   page-heading size — pull it down to a card title */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message {
  color: #3d4f61;
  margin-right: 0;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message h2 {
  font-family: var(--ak-font-d);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: #0f2133;
  margin: 0 0 8px;
  padding: 0;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message br { display: none; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message a { font-weight: 600; }

/* buttons: theme pills — cyan accept, ghost outline for the rest */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn {
  min-height: 46px;
  padding: 12px 18px;
  font-family: inherit;
  font-weight: 800;
  line-height: 1;
  border-width: 1.5px;
  transition: background .15s, border-color .15s, color .15s;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-accept:hover {
  background-color: #0b2a4a;
  border-color: #0b2a4a;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-deny:hover,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-view-preferences:hover,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-save-preferences:hover,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-manage-options:hover {
  background-color: #fff;
  border-color: #3d4f61;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn:focus-visible {
  outline: 3px solid #00a0dc;
  outline-offset: 2px;
}

/* policy links */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-links a {
  color: #0072a8;
  font-weight: 600;
  text-underline-offset: 3px;
}

/* preferences: category rows on the theme surface tint, cyan toggles */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category {
  background-color: #f2f6f9;
  border-radius: 10px;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category:not(:last-child) { margin-bottom: 8px; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header { padding: 12px 14px; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header .cmplz-category-title { font-weight: 700; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header .cmplz-always-active { font-weight: 700; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header .cmplz-category-toggle { color: #627386; }
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-description {
  color: #3d4f61;
  line-height: 1.5;
  padding: 0 14px 12px;
}
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-banner-checkbox input.cmplz-consent-checkbox:focus + .cmplz-label:before {
  box-shadow: 0 0 0 3px #00a0dc;
}

/* mobile: same bottom bar, full width minus a small gutter */
@media (max-width: 768px) {
  #cmplz-cookiebanner-container .cmplz-cookiebanner {
    width: calc(100% - 24px);
    max-width: none;
    bottom: 12px;
    padding: 18px 20px 20px;
    max-height: calc(100dvh - 24px);
  }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-divider {
    margin-left: -20px;
    margin-right: -20px;
  }
}

/* "Управление на съгласието" tab that peeks up after consent — navy pill.
   Complianz's own rule for it is #id .class and loads after this file, so
   the element selector is the tiebreaker. */
#cmplz-manage-consent button.cmplz-manage-consent {
  font-family: var(--ak-font);
  font-size: 13px;
  font-weight: 700;
  color: #ffffff;
  background-color: #0b2a4a;
  border: 0;
  border-radius: 999px 999px 0 0;
  padding: 14px 20px 16px;
  box-shadow: 0 -8px 24px rgba(4, 24, 48, .25);
}
#cmplz-manage-consent button.cmplz-manage-consent:hover,
#cmplz-manage-consent button.cmplz-manage-consent:focus {
  background-color: #123a63;
}

/* keyboard focus on the per-category chevron + close chip */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header .cmplz-category-toggle:focus-visible,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-close:focus-visible {
  outline: 3px solid #00a0dc;
  outline-offset: 2px;
  border-radius: 999px;
}

/* Short landscape screens (phones turned sideways, ≤500px tall): Complianz's
   own max-height:400px rules `zoom` the banner to 0.6 and the buttons to 0.5
   (≈5px text, 18px-tall buttons) and leave an empty header gap. Undo that:
   normal size, compact padding, the three buttons on one row. */
@media (orientation: landscape) and (max-height: 500px) {
  #cmplz-cookiebanner-container .cmplz-cookiebanner {
    zoom: 1; height: auto; gap: 8px; grid-row-gap: 8px;
    padding: 12px 20px 12px !important; bottom: 8px;
    max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); overflow-y: auto;
  }
  /* header row (small label + close) collapses into a corner close button */
  /* Complianz's flex column (from its own rule) stays — never set display here:
     the ID selector would beat .cmplz-dismissed { display: none } */
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-header { position: absolute; top: 10px; right: 12px; margin: 0 !important; max-height: none; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-title,
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-divider-header { display: none; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message { padding-right: 40px; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-close { zoom: 1 !important; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-body { margin-top: 0 !important; max-height: none; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message h2 { font-size: 16px; margin-bottom: 4px; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message { font-size: 13px; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons { flex-direction: row; gap: 8px !important; }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn {
    zoom: 1 !important; flex: 1 1 0; height: 44px !important; min-height: 44px !important;
    padding: 0 12px !important; font-size: 14px !important; line-height: 1.2 !important;
  }
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-documents,
  #cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-information { zoom: 1 !important; }
}

/* Complianz hides the "manage consent" tab ≤768px (phones get the
   "Настройки за бисквитки" link in the mobile legal line instead, see
   template-parts/mobile-tabbar.php). From 769px up to the desktop layout
   it peeked over our fixed tabbar (z 9998 vs 900) and caught taps meant for
   Профил: tuck it behind the bars (z under the tabbar 900 / sticky bar 899)
   and lift it by their height, so it peeks out above them exactly as it
   peeks from the screen edge elsewhere. Complianz animates `bottom`
   (peek ↔ slide in on hover/focus), so the lift is a transform and that
   animation keeps working on top of it. */
@media (min-width: 769px) and (max-width: 1023px) {
  body:has(.ak .tabbar) #cmplz-manage-consent button.cmplz-manage-consent {
    z-index: 898 !important;
    border: 1px solid rgba(255, 255, 255, .28); border-bottom: 0; /* edge stays visible over navy bands */
    transform: translateY(calc(-1 * (var(--ak-tabbar-h, 0px) + var(--ak-sticky-h, 0px) + env(safe-area-inset-bottom))));
  }
}
