/* EkoLinq theming for vanilla-cookieconsent v3.
   Maps the library's --cc-* custom properties onto the site tokens defined in
   css/refresh/styles.css. Load AFTER vendor/cookieconsent/cookieconsent.css. */

#cc-main {
  --cc-font-family: var(--mont);
  --cc-z-index: 2000;

  --cc-bg: #ffffff;
  --cc-primary-color: var(--d-green);

  /* Not --subtle-text-wbg (#00000088): composited on white that is ~4.5:1,
     which fails AA at the smaller mobile type below. #595959 is 7:1. */
  --cc-secondary-color: #595959;
  --cc-link-color: var(--m-green);

  --cc-btn-primary-bg: var(--m-green);
  --cc-btn-primary-color: #ffffff;
  --cc-btn-primary-border-color: var(--m-green);
  --cc-btn-primary-hover-bg: var(--d-green);
  --cc-btn-primary-hover-color: #ffffff;
  --cc-btn-primary-hover-border-color: var(--d-green);

  --cc-btn-secondary-bg: var(--off-white);
  --cc-btn-secondary-color: var(--d-green);
  --cc-btn-secondary-border-color: var(--border-grey);
  --cc-btn-secondary-hover-bg: var(--highlight-grey);
  --cc-btn-secondary-hover-color: var(--d-green);
  --cc-btn-secondary-hover-border-color: var(--l-grey);

  --cc-btn-border-radius: 6px;
  --cc-modal-border-radius: 10px;
  --cc-pm-toggle-border-radius: 20px;

  --cc-separator-border-color: var(--border-grey);
  --cc-cookie-category-block-bg: var(--off-white);
  --cc-cookie-category-block-border: var(--border-grey);
  --cc-cookie-category-block-hover-bg: var(--highlight-grey);
  --cc-cookie-category-block-hover-border: var(--l-grey);
  --cc-cookie-category-expanded-block-bg: transparent;
  --cc-section-category-border: var(--border-grey);

  --cc-toggle-on-bg: var(--m-green);
  --cc-toggle-off-bg: #6b6b6b;            /* 4.6:1 on white; --l-grey was 1.9:1 */
  --cc-toggle-readonly-bg: var(--l-green);
  --cc-toggle-readonly-knob-bg: #ffffff;
  --cc-toggle-readonly-knob-icon-color: var(--l-green);

  --cc-footer-bg: var(--off-white);
  --cc-footer-color: #595959;
  --cc-footer-border-color: var(--border-grey);

  --cc-overlay-bg: rgba(20, 38, 2, 0.65);
}

/* The site ships a single light theme; opt out of the library's automatic
   dark-mode inversion so the banner always matches the page. */
#cc-main.cc--darkmode { color-scheme: light; }

#cc-main .cm__title,
#cc-main .pm__title { font-weight: 600; }

/* ---- Accessibility ------------------------------------------------------ */

/* The library ships focus styles, but the themed backgrounds above reduce their
   contrast. Force a visible ring that clears both button fills. */
#cc-main button:focus-visible,
#cc-main a:focus-visible,
#cc-main [role="button"]:focus-visible {
  outline: 3px solid var(--m-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* WCAG 2.4.11 Focus Not Obscured: while the bar is showing, keep focused
   elements scrolled clear of it. --ek-cc-h is measured in consent.js. */
html.show--consent {
  scroll-padding-bottom: calc(var(--ek-cc-h, 0px) + 16px);
}
/* Scroll padding cannot help at the very end of the page (the footer links),
   so also let the page scroll far enough to clear the bar. */
html.show--consent body {
  padding-bottom: var(--ek-cc-h, 0px);
}

/* WCAG 2.5.8: 24x24 minimum target. 44px on touch, per 2.5.5 AAA. */
#cc-main .cm__btn,
#cc-main .pm__btn {
  min-height: 44px;
}

@media (prefers-reduced-motion: reduce) {
  #cc-main,
  #cc-main .cm-wrapper,
  #cc-main .pm-wrapper {
    --cc-modal-transition-duration: 0s;
  }
  #cc-main * {
    animation: none !important;
    transition: none !important;
  }
}

/* Windows High Contrast / forced-colors: keep the surface and its edges real. */
@media (forced-colors: active) {
  #cc-main .cm,
  #cc-main .pm {
    border: 1px solid CanvasText;
  }
  #cc-main .cm__btn,
  #cc-main .pm__btn {
    border: 1px solid ButtonText;
  }
}

/* ---- Desktop bar ------------------------------------------------------- */
/* `bar inline` lays the two buttons out side by side in the right-hand column.
   Stack them instead and let each fill that column, so the pair reads as one
   block rather than a row of competing actions. Three classes here deliberately
   clears the vendor's two-class rules without needing !important. */
#cc-main .cm--bar.cm--inline .cm__btn-group {
  grid-auto-flow: row;
}

#cc-main .cm--bar.cm--inline .cm__btn + .cm__btn {
  margin-left: 0;
  margin-top: 0.375rem;
}

#cc-main .cm--bar .cm__btn {
  width: 100%;
}

/* ---- Mobile ------------------------------------------------------------- */
/* The bar is persistent and non-dismissible, so it has to stay out of the way.
   Target is well under a quarter of a small viewport. */
@media (max-width: 640px) {
  #cc-main .cm {
    padding: 0.5em .25em;
    padding-bottom: .25em;
    gap: 0.6em;
  }

  #cc-main .cm__texts {
    padding: 0;
  }

  #cc-main .cm__title {
    font-size: 0.95rem;
    margin-bottom: 0.25em;
  }

  #cc-main .cm__desc {
    font-size: 0.8rem;
    line-height: 1.45;
  }

  #cc-main .cm__btns {
    padding: 0;
  }

  #cc-main .cm__btn {
    font-size: 0.85rem;
    padding: 0.6em 0.9em;
    min-height: 44px;
    width: 100%;
  }

  #cc-main .cm__footer {
    font-size: 0.75rem;
    padding: 0.5em 1em;
    padding-top: 0;
    background: transparent !important;
    border: none !important;
  }

  /* Cap the bar and scroll the text if a long translation ever overflows,
     so it can never swallow the viewport. */
  #cc-main .cm-wrapper .cm {
    max-height: 45vh;
    overflow-y: auto;
  }
  #cc-main .cm__btns {
    border-top: 0px !important;
  }
  #cc-main #cm__desc {
    margin-top: .5em !important;
  }
}

@media (max-width: 380px) {
  #cc-main .cm__desc { font-size: 0.75rem; }
  #cc-main .cm__btn  { font-size: 0.8rem; padding: 0.55em 0.7em; }
}

/* ---- Footer trigger ----------------------------------------------------- */
.ek-footer-legal-links button.ek-consent-link {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.ek-footer-legal-links button.ek-consent-link:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}
