/* ============================================================
   3D Fractal — Cookie Consent Banner
   ============================================================ */

/* Consent already given — hide banner immediately via CSS, before any JS runs */
html[data-consent="given"] #cookieBanner { display: none !important; }

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #0f172a;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 20px 32px;
  display: none;
  flex-direction: column;
  gap: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cookie-banner-main {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.cookie-text {
  flex: 1;
  min-width: 220px;
}

.cookie-text p {
  font-size: 0.88rem !important;
  color: rgba(255,255,255,0.75) !important;
  line-height: 1.6 !important;
  margin: 0 !important;
}

.cookie-text a {
  color: rgba(255,255,255,0.55);
  text-decoration: underline;
  transition: color 0.2s;
}
.cookie-text a:hover { color: #fff; }

.cookie-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cookie-btn {
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, background 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.cookie-btn:hover { opacity: 0.85; }

.cookie-btn--accept {
  background: #005BFF;
  color: #fff;
}
.cookie-btn--reject {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.15);
}
.cookie-btn--custom {
  background: transparent;
  color: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.12);
  text-decoration: underline;
}

/* ── Customize panel ─────────────────────────────────────────── */
.cookie-customize-panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 20px 24px;
}

.cookie-toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.cookie-toggle-row:last-of-type { border-bottom: none; }

.cookie-toggle-info { flex: 1; }

.cookie-toggle-info strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  margin-bottom: 3px;
  font-family: inherit;
}
.cookie-toggle-info span {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.45);
  line-height: 1.5;
}

/* Toggle switch */
.cookie-toggle {
  position: relative;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
  cursor: pointer;
}
.cookie-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.cookie-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.18);
  border-radius: 22px;
  transition: background 0.25s;
}
.cookie-toggle input:checked + .cookie-toggle-slider { background: #005BFF; }
.cookie-toggle input:disabled + .cookie-toggle-slider { background: rgba(0,91,255,0.4); cursor: not-allowed; }

.cookie-toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}
.cookie-toggle input:checked + .cookie-toggle-slider::before { transform: translateX(18px); }

.cookie-customize-save {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

/* ── Floating preferences button ────────────────────────────── */
.cookie-pref-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0f172a;
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  transition: opacity 0.2s, transform 0.2s;
  font-family: inherit;
}
.cookie-pref-btn:hover {
  opacity: 0.85;
  transform: scale(1.08);
}
.cookie-pref-btn[aria-label] {
  position: relative;
}
.cookie-pref-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  right: 52px;
  bottom: 50%;
  transform: translateY(50%);
  background: #0f172a;
  color: rgba(255,255,255,0.85);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.12);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.cookie-pref-btn:hover::after { opacity: 1; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .cookie-banner {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom, 16px));
  }
  .cookie-banner-main { flex-direction: column; align-items: flex-start; gap: 16px; }
  .cookie-actions { width: 100%; flex-direction: column; }
  .cookie-btn { width: 100%; text-align: center; padding: 11px; }
  /* Hide gear button on mobile — use footer "Endre samtykke" link instead.
     The button overlaps Safari's toolbar and causes accidental taps. */
  .cookie-pref-btn { display: none !important; }
}
