/* =========================================================================
   COOKIE CONSENT — banner + preference panel
   Loaded on every page (linked in <head>; js/cookie-consent.js also injects
   it if missing). Reuses the site's design tokens from css/site-styles.css
   (--blue-deep, --blue-mid, --sky-*, --ink, --line, --radius-*, --ease,
   --font-sans) with sensible fallbacks so it still renders if they're absent.
   z-index: header 900 < banner 1000 < panel 1100.
   ========================================================================= */

.cc-banner[hidden],
.cc-overlay[hidden] {
  display: none !important;
}

/* Visually hidden live region for screen-reader announcements */
.cc-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------- Banner ---------------------------- */
.cc-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  pointer-events: none;
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 0.45s var(--ease, cubic-bezier(0.22, 1, 0.36, 1)),
    transform 0.45s var(--ease, cubic-bezier(0.22, 1, 0.36, 1));
  font-family: var(--font-sans, "Montserrat", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif);
}
.cc-banner.cc-show {
  opacity: 1;
  transform: none;
}
.cc-banner__inner {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 540px);
  gap: 1rem 2rem;
  align-items: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.5rem 1.6rem 1.35rem;
  background: linear-gradient(135deg, #ffffff 0%, #faf8fd 55%, #f1ecf8 100%);
  border: 1px solid var(--line, #e2ddee);
  border-radius: var(--radius-lg, 20px);
  box-shadow:
    0 -6px 30px -14px rgba(46, 33, 64, 0.22),
    0 24px 54px -24px rgba(40, 72, 136, 0.4);
}
.cc-banner__inner::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(100deg, var(--blue-deep, #284888), var(--blue-mid, #9a5cad));
}
.cc-banner__title {
  margin: 0 0 0.35rem;
  color: var(--blue-deep, #284888);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.cc-banner__desc {
  margin: 0;
  color: var(--ink, #2e2140);
  font-size: 0.9rem;
  line-height: 1.6;
}
.cc-banner__desc a,
.cc-panel__intro a {
  color: var(--blue-deep, #284888);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cc-banner__desc a:hover,
.cc-panel__intro a:hover {
  color: var(--blue-mid, #9a5cad);
}
.cc-banner__note {
  margin: 0.55rem 0 0;
  color: var(--ink-soft, #6b5a72);
  font-size: 0.8rem;
  line-height: 1.5;
}
.cc-banner__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.cc-banner__actions .cc-btn--ghost {
  grid-column: 1 / -1;
}

/* ---------------------------- Buttons ---------------------------- */
.cc-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0.65rem 1.1rem;
  border: 2px solid transparent;
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.25s var(--ease, ease),
    color 0.25s var(--ease, ease),
    border-color 0.25s var(--ease, ease),
    box-shadow 0.25s var(--ease, ease),
    transform 0.25s var(--ease, ease);
}
.cc-btn--primary {
  color: #fff;
  background: linear-gradient(120deg, var(--blue-deep, #284888), var(--blue-mid, #9a5cad));
  box-shadow: 0 14px 28px -14px rgba(40, 72, 136, 0.55);
}
.cc-btn--primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px -14px rgba(40, 72, 136, 0.65);
}
/* Accept and Reject carry equal visual weight */
.cc-btn--secondary {
  color: var(--blue-deep, #284888);
  background: #fff;
  border-color: var(--blue-deep, #284888);
}
.cc-btn--secondary:hover {
  background: var(--sky-100, #ebe9f6);
}
.cc-btn--ghost {
  color: var(--blue-deep, #284888);
  background: transparent;
  border-color: var(--line, #e2ddee);
  min-height: 42px;
}
.cc-btn--ghost:hover {
  background: var(--sky-50, #f5f4fb);
  border-color: var(--sky-200, #d9dcf0);
}
.cc-btn:active {
  transform: scale(0.98);
}
.cc-btn:focus-visible,
.cc-close:focus-visible,
.cc-banner a:focus-visible,
.cc-panel a:focus-visible {
  outline: 3px solid var(--blue-bright, #3d94d6);
  outline-offset: 3px;
  border-radius: 10px;
}

/* ---------------------- Preference panel ---------------------- */
.cc-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(46, 33, 64, 0.55);
  opacity: 0;
  transition: opacity 0.3s var(--ease, ease);
  font-family: var(--font-sans, "Montserrat", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif);
}
.cc-overlay.cc-show {
  opacity: 1;
}
.cc-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(88vh, 760px);
  background: #fff;
  border-radius: var(--radius-lg, 20px);
  box-shadow: 0 40px 90px -30px rgba(46, 33, 64, 0.6);
  overflow: hidden;
  outline: none;
  transform: translateY(14px);
  transition: transform 0.35s var(--ease, ease);
}
.cc-overlay.cc-show .cc-panel {
  transform: none;
}
.cc-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: linear-gradient(100deg, var(--blue-deep, #284888), var(--blue-mid, #9a5cad));
}
.cc-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem 1.5rem 0.75rem;
  background: linear-gradient(180deg, #f5f4fb, #fff);
}
.cc-panel__title {
  margin: 0;
  color: var(--blue-deep, #284888);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  background: none;
  -webkit-text-fill-color: currentColor;
}
.cc-close {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line, #e2ddee);
  border-radius: 50%;
  background: #fff;
  color: var(--blue-deep, #284888);
  cursor: pointer;
  transition: background 0.25s var(--ease, ease);
}
.cc-close:hover {
  background: var(--sky-100, #ebe9f6);
}
.cc-panel__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 1.5rem 1rem;
}
.cc-panel__intro {
  margin: 0 0 1.1rem;
  color: var(--ink, #2e2140);
  font-size: 0.9rem;
  line-height: 1.6;
}
.cc-cats {
  display: grid;
  gap: 0.75rem;
}
.cc-cat {
  padding: 1rem 1.1rem;
  background: var(--sky-50, #f5f4fb);
  border: 1px solid var(--line, #e2ddee);
  border-radius: var(--radius-md, 14px);
}
.cc-cat__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.cc-cat__name {
  color: var(--blue-deep, #284888);
  font-size: 0.98rem;
  font-weight: 800;
}
label.cc-cat__name {
  cursor: pointer;
  flex: 1 1 auto;
}
.cc-cat__desc {
  margin: 0.5rem 0 0;
  color: var(--ink-soft, #6b5a72);
  font-size: 0.85rem;
  line-height: 1.6;
}
.cc-always {
  flex: none;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--sky-200, #d9dcf0);
  color: var(--blue-deep, #284888);
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Toggle switch (a real checkbox, so keyboard + screen readers work natively) */
.cc-switch {
  position: relative;
  flex: none;
  display: inline-block;
  width: 54px;
  height: 32px;
}
.cc-switch__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}
.cc-switch__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #857d92; /* >= 3:1 against white */
  transition: background 0.25s var(--ease, ease);
}
.cc-switch__track::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s var(--ease, ease);
}
.cc-switch__input:checked + .cc-switch__track {
  background: linear-gradient(120deg, var(--blue-deep, #284888), var(--blue-mid, #9a5cad));
}
.cc-switch__input:checked + .cc-switch__track::after {
  transform: translateX(22px);
}
.cc-switch__input:focus-visible + .cc-switch__track {
  outline: 3px solid var(--blue-bright, #3d94d6);
  outline-offset: 3px;
}

.cc-panel__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1px solid var(--line, #e2ddee);
  background: #fff;
}
.cc-panel__foot .cc-btn--primary {
  flex: 1 1 100%;
}
.cc-panel__foot .cc-btn--secondary {
  flex: 1 1 200px;
}
.cc-status {
  margin: 0;
  padding: 0 1.5rem;
  min-height: 0;
  color: var(--blue-deep, #284888);
  font-size: 0.85rem;
  font-weight: 700;
}
.cc-status:not(:empty) {
  padding-bottom: 1rem;
}

/* Stop the page scrolling behind the open panel */
html.cc-lock,
html.cc-lock body {
  overflow: hidden;
}

/* --------- Keep floating buttons + footer clear of the banner --------- */
html.cc-banner-open body {
  padding-bottom: var(--cc-offset, 0px);
}
html.cc-banner-open .fab {
  bottom: calc(max(var(--fab-gap, 20px), env(safe-area-inset-bottom)) + var(--cc-offset, 0px));
  transition:
    transform 0.3s var(--ease, ease),
    box-shadow 0.3s var(--ease, ease),
    opacity 0.3s var(--ease, ease),
    visibility 0.3s,
    bottom 0.35s var(--ease, ease);
}

/* ---------------------------- Responsive ---------------------------- */
@media (max-width: 980px) {
  .cc-banner__inner {
    grid-template-columns: minmax(0, 1fr);
    padding: 1.35rem 1.25rem 1.2rem;
  }
  .cc-banner__actions {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 600px) {
  .cc-banner {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  .cc-banner__inner {
    gap: 0.9rem;
    padding: 1.2rem 1rem 1rem;
    border-radius: 18px;
  }
  .cc-banner__title {
    font-size: 1rem;
  }
  .cc-banner__desc {
    font-size: 0.86rem;
  }
  .cc-banner__actions {
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .cc-banner__actions .cc-btn--ghost {
    grid-column: auto;
  }
  /* Preference panel becomes a bottom sheet on phones */
  .cc-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .cc-panel {
    width: 100%;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 20px 20px 0 0;
  }
  .cc-panel__head,
  .cc-panel__body,
  .cc-panel__foot,
  .cc-status {
    padding-left: 1.1rem;
    padding-right: 1.1rem;
  }
  .cc-panel__foot {
    padding-bottom: max(1.1rem, env(safe-area-inset-bottom));
  }
  .cc-panel__foot .cc-btn--secondary {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-banner,
  .cc-overlay,
  .cc-panel,
  .cc-btn,
  .cc-switch__track,
  .cc-switch__track::after {
    transition: none !important;
  }
  .cc-banner,
  .cc-panel {
    transform: none !important;
  }
}

@media (forced-colors: active) {
  .cc-switch__track {
    border: 2px solid ButtonText;
  }
  .cc-switch__input:checked + .cc-switch__track {
    background: Highlight;
  }
}

@media print {
  .cc-banner,
  .cc-overlay {
    display: none !important;
  }
}
