/* ====================================================================
   Jahresanzeigen.de — DSGVO Cookie-Consent
   Self-contained, scoped under .ja-cc to avoid clashes with styles.css.
   Reuses the design tokens (CSS variables) defined in styles.css :root.
   Aesthetic: dark cockpit glass card + settings dialog.
   ==================================================================== */

/* ---------- Root: shared scope ------------------------------------- */
.ja-cc {
  /* fallbacks in case styles.css is missing — but normally inherited */
  --ja-cc-bg:        var(--ink-2, #0B1D3A);
  --ja-cc-border:    var(--rule-on-dark, rgba(127, 224, 255, 0.10));
  --ja-cc-border-2:  var(--glass-dark-border, rgba(127, 224, 255, 0.14));
  --ja-cc-text:      var(--text-on-dark, #E9F1FB);
  --ja-cc-soft:      var(--text-on-dark-soft, #93AECC);
  --ja-cc-mute:      var(--text-on-dark-mute, #5E7CA0);
  --ja-cc-brand:     var(--brand, #00B6F0);
  --ja-cc-glow:      var(--brand-glow, #7FE0FF);

  font-family: var(--font-body, system-ui, sans-serif);
  color: var(--ja-cc-text);
  -webkit-font-smoothing: antialiased;
}

/* hidden state — fully removed from a11y tree + pointer flow */
.ja-cc[hidden],
.ja-cc [hidden] { display: none !important; }

/* ---------- Banner (bottom-left desktop / full-width mobile) ------- */
.ja-cc__banner {
  position: fixed;
  z-index: 9000;                 /* above content + chatbot, but dismisses on choice */
  left: clamp(12px, 3vw, 28px);
  right: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vw, 28px);
  max-width: 460px;
  padding: clamp(20px, 3vw, 26px);
  border-radius: var(--r-lg, 22px);
  background:
    linear-gradient(155deg, rgba(17, 38, 74, 0.78) 0%, rgba(8, 19, 43, 0.82) 100%);
  border: 1px solid var(--ja-cc-border-2);
  box-shadow: var(--shadow-xl, 0 36px 96px rgba(5, 11, 28, 0.45));
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  isolation: isolate;
}
.ja-cc__banner::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 90% 0%, rgba(0, 182, 240, 0.16), transparent 55%);
  pointer-events: none;
  z-index: -1;
}

/* entrance animation — degrades gracefully via reduced-motion block */
.ja-cc__banner {
  animation: ja-cc-rise var(--t-slow, 520ms) var(--ease-spring, cubic-bezier(.22,1.2,.36,1)) both;
}
@keyframes ja-cc-rise {
  from { opacity: 0; transform: translateY(20px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}

.ja-cc__eyebrow {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ja-cc-glow);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.ja-cc__eyebrow::before {
  content: '';
  width: 18px; height: 1px;
  background: var(--ja-cc-brand);
  display: inline-block;
  flex: none;
}

.ja-cc__title {
  font-family: var(--font-display, sans-serif);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ja-cc-text);
  margin: 0 0 8px;
}

.ja-cc__text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ja-cc-soft);
  margin: 0 0 18px;
}
.ja-cc__text a {
  color: var(--ja-cc-glow);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(127, 224, 255, 0.4);
}
.ja-cc__text a:hover { text-decoration-color: var(--ja-cc-glow); }

/* button row — equal-weight accept / reject */
.ja-cc__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.ja-cc__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-family: var(--font-body, sans-serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  flex: 1 1 auto;
  min-width: 140px;
  transition:
    transform var(--t-base, 280ms) var(--ease-spring, cubic-bezier(.22,1.2,.36,1)),
    background var(--t-base, 280ms) var(--ease-out, cubic-bezier(.16,1,.3,1)),
    border-color var(--t-base, 280ms),
    box-shadow var(--t-base, 280ms);
}

/* both primary actions share identical visual weight (DSGVO: no dark pattern) */
.ja-cc__btn--accept,
.ja-cc__btn--reject {
  background: rgba(127, 224, 255, 0.06);
  border-color: rgba(127, 224, 255, 0.22);
  color: var(--ja-cc-text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ja-cc__btn--accept:hover,
.ja-cc__btn--reject:hover {
  background: rgba(127, 224, 255, 0.12);
  border-color: rgba(127, 224, 255, 0.40);
  transform: translateY(-2px);
}

/* settings link — clearly secondary, low emphasis */
.ja-cc__settings-link {
  flex: 0 0 auto;
  min-width: 0;
  width: 100%;
  background: none;
  border: none;
  margin-top: 4px;
  padding: 6px 4px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ja-cc-soft);
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(147, 174, 204, 0.4);
  transition: color var(--t-fast, 150ms);
}
.ja-cc__settings-link:hover { color: var(--ja-cc-glow); }

/* ---------- Modal / Settings dialog -------------------------------- */
.ja-cc__overlay {
  position: fixed;
  inset: 0;
  z-index: 9100;                 /* above the banner */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 4vw, 32px);
  background: rgba(5, 11, 28, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: ja-cc-fade var(--t-base, 280ms) var(--ease-out, cubic-bezier(.16,1,.3,1)) both;
}
@keyframes ja-cc-fade { from { opacity: 0; } to { opacity: 1; } }

.ja-cc__modal {
  width: 100%;
  max-width: 560px;
  max-height: min(86vh, 720px);
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl, 28px);
  background:
    linear-gradient(155deg, rgba(17, 38, 74, 0.92) 0%, rgba(8, 19, 43, 0.96) 100%);
  border: 1px solid var(--ja-cc-border-2);
  box-shadow: var(--shadow-xl, 0 36px 96px rgba(5, 11, 28, 0.45));
  backdrop-filter: blur(24px) saturate(150%);
  -webkit-backdrop-filter: blur(24px) saturate(150%);
  overflow: hidden;
  isolation: isolate;
  animation: ja-cc-pop var(--t-slow, 520ms) var(--ease-spring, cubic-bezier(.22,1.2,.36,1)) both;
}
@keyframes ja-cc-pop {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.ja-cc__modal-head {
  padding: clamp(22px, 4vw, 30px) clamp(22px, 4vw, 30px) 18px;
  border-bottom: 1px solid var(--ja-cc-border);
  position: relative;
}
.ja-cc__modal-title {
  font-family: var(--font-display, sans-serif);
  font-weight: 600;
  font-size: clamp(20px, 3vw, 24px);
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ja-cc-text);
  margin: 0 0 8px;
  padding-right: 40px;
}
.ja-cc__modal-intro {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ja-cc-soft);
  margin: 0;
}

.ja-cc__close {
  position: absolute;
  top: clamp(18px, 3vw, 24px);
  right: clamp(18px, 3vw, 24px);
  width: 36px; height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(127, 224, 255, 0.06);
  border: 1px solid var(--ja-cc-border);
  color: var(--ja-cc-soft);
  cursor: pointer;
  transition: background var(--t-fast, 150ms), color var(--t-fast, 150ms), border-color var(--t-fast, 150ms);
}
.ja-cc__close:hover {
  background: rgba(127, 224, 255, 0.12);
  border-color: rgba(127, 224, 255, 0.35);
  color: var(--ja-cc-glow);
}
.ja-cc__close svg { width: 16px; height: 16px; }

.ja-cc__modal-body {
  padding: clamp(18px, 3vw, 24px) clamp(22px, 4vw, 30px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

/* category row */
.ja-cc__cat {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--r-md, 16px);
  background: rgba(8, 19, 43, 0.55);
  border: 1px solid var(--ja-cc-border);
}
.ja-cc__cat-body { flex: 1 1 auto; min-width: 0; }
.ja-cc__cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display, sans-serif);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--ja-cc-text);
  margin: 0 0 4px;
}
.ja-cc__cat-flag {
  font-family: var(--font-mono, monospace);
  font-size: 9.5px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--ja-cc-glow);
  background: rgba(127, 224, 255, 0.10);
  border: 1px solid rgba(127, 224, 255, 0.20);
  border-radius: 999px;
  padding: 2px 8px;
}
.ja-cc__cat-flag--off {
  color: var(--ja-cc-mute);
  background: rgba(94, 124, 160, 0.10);
  border-color: rgba(94, 124, 160, 0.22);
}
.ja-cc__cat-desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ja-cc-soft);
  margin: 0;
}
.ja-cc__cat-note {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--ja-cc-mute);
  font-style: italic;
}

/* toggle switch (real checkbox, visually a switch) */
.ja-cc__toggle {
  position: relative;
  flex: none;
  width: 46px;
  height: 26px;
  margin-top: 2px;
}
.ja-cc__toggle input {
  position: absolute;
  opacity: 0;
  width: 100%; height: 100%;
  margin: 0;
  cursor: pointer;
}
.ja-cc__toggle input:disabled { cursor: not-allowed; }
.ja-cc__track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  /* OFF state: clearly neutral/dark — must NOT read as the cyan "on" colour. */
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: background var(--t-base, 280ms) var(--ease-out, ease), border-color var(--t-base, 280ms);
  pointer-events: none;
}
.ja-cc__track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  /* OFF knob: muted grey so the whole control reads as inactive. */
  background: #9fb3c8;
  box-shadow: 0 2px 4px rgba(5, 11, 28, 0.4);
  transition: transform var(--t-base, 280ms) var(--ease-spring, cubic-bezier(.22,1.2,.36,1)), background var(--t-base, 280ms);
}
.ja-cc__toggle input:checked + .ja-cc__track {
  background: linear-gradient(180deg, #0EC0F7 0%, #0090D6 100%);
  border-color: rgba(127, 224, 255, 0.65);
}
.ja-cc__toggle input:checked + .ja-cc__track::after {
  transform: translateX(20px);
  background: #ffffff;
}
.ja-cc__toggle input:disabled + .ja-cc__track {
  opacity: 1;
}
/* "Notwendig" is locked ON — keep it clearly cyan (just a touch softer to signal it's fixed). */
.ja-cc__toggle input:disabled:checked + .ja-cc__track {
  background: linear-gradient(180deg, #2aa9d6 0%, #1f86b8 100%);
  border-color: rgba(127, 224, 255, 0.4);
}
/* visible focus on keyboard nav */
.ja-cc__toggle input:focus-visible + .ja-cc__track {
  outline: 2px solid var(--ja-cc-glow);
  outline-offset: 3px;
}

.ja-cc__modal-foot {
  padding: 18px clamp(22px, 4vw, 30px) clamp(22px, 4vw, 28px);
  border-top: 1px solid var(--ja-cc-border);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ja-cc__modal-foot .ja-cc__btn { flex: 1 1 160px; }

/* the "save selection" button gets a touch more emphasis (primary intent) */
.ja-cc__btn--save {
  background: linear-gradient(180deg, #0EC0F7 0%, #0090D6 100%);
  color: #001525;
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(0, 182, 240, 0.30), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.ja-cc__btn--save:hover {
  box-shadow: 0 14px 40px rgba(0, 182, 240, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* shared focus-visible for all interactive bits */
.ja-cc__btn:focus-visible,
.ja-cc__settings-link:focus-visible,
.ja-cc__close:focus-visible {
  outline: 2px solid var(--ja-cc-glow);
  outline-offset: 3px;
}

/* a11y live region (visually hidden) */
.ja-cc__sr {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---------- Responsive: full-width banner on mobile --------------- */
@media (max-width: 560px) {
  .ja-cc__banner {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
  .ja-cc__btn--accept,
  .ja-cc__btn--reject {
    flex: 1 1 100%;
  }
  .ja-cc__modal-foot .ja-cc__btn { flex: 1 1 100%; }
}

/* ---------- Reduced motion: neutralise our animations -------------- */
@media (prefers-reduced-motion: reduce) {
  .ja-cc__banner,
  .ja-cc__overlay,
  .ja-cc__modal {
    animation: none !important;
  }
  .ja-cc__btn,
  .ja-cc__track,
  .ja-cc__track::after,
  .ja-cc__close,
  .ja-cc__settings-link {
    transition-duration: 0.001ms !important;
  }
  .ja-cc__btn:hover,
  .ja-cc__btn--save:hover { transform: none !important; }
}

/* ---------- Mobile: compact banner, side-by-side buttons, safe-area --- */
@media (max-width: 560px) {
  .ja-cc__banner {
    padding: 16px 16px 14px;
    bottom: max(10px, env(safe-area-inset-bottom));
  }
  .ja-cc__title { font-size: 16px; margin-bottom: 6px; }
  .ja-cc__text {
    font-size: 12.5px;
    line-height: 1.45;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  /* override the earlier full-width stacking — keep Accept + Nur notwendige side by side */
  .ja-cc__btn--accept,
  .ja-cc__btn--reject { flex: 1 1 0; min-width: 0; height: 44px; padding: 0 12px; font-size: 13px; }
  .ja-cc__settings-link { margin-top: 2px; padding: 6px 2px; }
}
