/* Cookie consent: a small bottom-left card + a granular preferences modal.
   Uses the theme's design tokens (--white surface, --black ink, --brand green,
   --border) so it inherits light/dark mode automatically and merges with the
   rest of the site. Markup: template-parts/cookie-consent.php. Logic:
   assets/js/cookie-consent.js. */

/* The hidden state must beat the component's own display rules. The modal sets
   display:flex, which would otherwise override the UA [hidden] rule and leave a
   full-screen, click-trapping overlay on the page. Higher specificity than the
   plain .ss-cc-modal{display:flex} rule, so it wins regardless of source order. */
.ss-cc-banner[hidden],
.ss-cc-modal[hidden] {
  display: none;
}

/* Accessible brand green for text + white-on-green. The site's --brand (#1E9E55)
   is only ~3.46:1 on white, below WCAG AA for normal text, so the consent UI
   uses a darker green on the light card and a lighter green on the dark card. */
.ss-cc-banner,
.ss-cc-modal {
  --ss-cc-accent: #15863f;
}

[data-theme="dark"] .ss-cc-banner,
[data-theme="dark"] .ss-cc-modal {
  --ss-cc-accent: #34c06e;
}

/* ───────────────────────── Bottom-left card ───────────────────────── */
.ss-cc-banner {
  position: fixed;
  z-index: 1100;
  left: 20px;
  bottom: 20px;
  width: min(380px, calc(100vw - 40px));
  background: var(--white);
  color: var(--black);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px 22px 18px;
  box-shadow: 0 14px 40px rgba(16, 24, 20, 0.16);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.ss-cc-banner.is-visible {
  opacity: 1;
  transform: none;
}

[data-theme="dark"] .ss-cc-banner {
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5);
}

.ss-cc-banner__head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.ss-cc-emoji {
  font-size: 20px;
  line-height: 1;
}

.ss-cc-banner__title {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  color: var(--black);
}

.ss-cc-banner__text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
}

.ss-cc-link {
  color: var(--ss-cc-accent);
  font-weight: 600;
  text-decoration: underline;
}

.ss-cc-link:hover {
  text-decoration: none;
}

.ss-cc-banner__actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.ss-cc-banner__actions .ss-cc-btn {
  flex: 1;
}

.ss-cc-prefs-link {
  display: block;
  margin: 12px auto 0;
  padding: 4px 6px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
}

.ss-cc-prefs-link:hover {
  color: var(--ss-cc-accent);
}

.ss-cc-prefs-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ───────────────────────── Buttons (pills) ───────────────────────── */
.ss-cc-btn {
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  line-height: 1;
  padding: 12px 18px;
  border-radius: 99px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.ss-cc-btn:hover {
  transform: translateY(-1px);
}

.ss-cc-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Accept and Reject sit side by side at the same size, so neither is harder to
   choose than the other (GDPR / ePrivacy: reject must be as easy as accept). */
.ss-cc-btn--primary {
  background: #15863f;
  color: #ffffff;
}

.ss-cc-btn--primary:hover {
  background: #11743c;
}

.ss-cc-btn--neutral {
  background: var(--surface);
  color: var(--black);
  border-color: var(--border);
}

.ss-cc-btn--neutral:hover {
  border-color: var(--text-soft);
}

.ss-cc-btn--ghost {
  background: transparent;
  color: var(--ss-cc-accent);
  border-color: var(--ss-cc-accent);
}

.ss-cc-btn--ghost:hover {
  background: rgba(30, 158, 85, 0.08);
}

/* ───────────────────────── Preferences modal ───────────────────────── */
.ss-cc-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.ss-cc-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 10, 0.55);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ss-cc-modal.is-visible .ss-cc-modal__overlay {
  opacity: 1;
}

.ss-cc-modal__dialog {
  position: relative;
  width: min(520px, 100%);
  max-height: 85vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--white);
  color: var(--black);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(12px) scale(0.985);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.ss-cc-modal.is-visible .ss-cc-modal__dialog {
  opacity: 1;
  transform: none;
}

.ss-cc-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.ss-cc-modal__title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--black);
}

.ss-cc-modal__close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.ss-cc-modal__close:hover {
  color: var(--black);
  border-color: var(--text-soft);
}

.ss-cc-modal__close:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.ss-cc-modal__intro {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 18px;
}

.ss-cc-cats {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ss-cc-cat {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.ss-cc-cat:first-child {
  border-top: 0;
  padding-top: 0;
}

.ss-cc-cat__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ss-cc-cat__name {
  font-size: 15.5px;
  font-weight: 600;
  color: var(--black);
}

.ss-cc-cat__desc {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 6px 0 0;
}

/* ───────────────────────── Toggle switch ───────────────────────── */
.ss-cc-switch {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* The real checkbox sits on top, transparent, and captures clicks + keyboard;
   the track below is the visual (pointer-events disabled so clicks fall through
   to the input). */
.ss-cc-switch input {
  position: absolute;
  top: 0;
  left: 0;
  width: 46px;
  height: 26px;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.ss-cc-switch__track {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 99px;
  background: var(--border-soft);
  transition: background 0.2s ease;
  pointer-events: none;
}

.ss-cc-switch__track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.ss-cc-switch input:checked + .ss-cc-switch__track {
  background: var(--brand);
}

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

.ss-cc-switch input:focus-visible + .ss-cc-switch__track {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* "Strictly necessary" is locked on: hide the visual toggle, show an "Always on"
   pill. The disabled checkbox stays visually hidden (NOT display:none, which
   would drop it from the accessibility tree) so assistive tech still announces
   it as on; the badge conveys the same to sighted users. */
.ss-cc-switch--locked .ss-cc-switch__track {
  display: none;
}

.ss-cc-switch--locked input {
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

.ss-cc-switch__badge {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  background: #15863f;
  padding: 5px 11px;
  border-radius: 99px;
  white-space: nowrap;
}

.ss-cc-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.ss-cc-modal__actions .ss-cc-btn {
  flex: 1 1 auto;
  min-width: 120px;
}

/* ───────────────────────── Footer reopen link ───────────────────────── */
/* .main-footer is dark (#0F1814) in BOTH themes, so its text is white. This
   button is not a <p>/<a>, so it does not inherit the footer's text-color rule;
   set white explicitly and mirror the copyright line's responsive sizes. */
.footer-cookie-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 16px;
  line-height: 24px;
  color: #ffffff;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.85;
}

@media (max-width: 1600px) {
  .footer-cookie-btn {
    font-size: 14px;
    line-height: 22px;
  }
}

@media (max-width: 768px) {
  .footer-cookie-btn {
    font-size: 12px;
    line-height: 20px;
  }
}

.footer-cookie-btn:hover {
  opacity: 1;
}

.footer-cookie-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ───────────────────────── Motion / small screens ───────────────────────── */
@media (max-width: 420px) {
  .ss-cc-banner {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }
}

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

  .ss-cc-banner,
  .ss-cc-modal__dialog {
    transform: none !important;
  }
}
