/* ArthaBase cookie consent banner + preferences modal.
   Styled to the site design tokens (DM Sans, terracotta "icy" accent). */

#ab-consent {
  --ab-accent: #c95628;
  --ab-accent-hover: #e0743b;
  --ab-ink: #0b1221;
  --ab-ink-soft: #475569;
  --ab-surface: #ffffff;
  --ab-border: rgba(11, 18, 33, 0.12);
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
}

#ab-consent[aria-hidden='true'] .ab-consent-banner:not(.is-visible) {
  pointer-events: none;
}

/* ---- Banner -------------------------------------------------------------- */

.ab-consent-banner {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  left: auto;
  z-index: 9999;
  width: min(30rem, calc(100vw - 2rem));
  background: var(--ab-surface);
  color: var(--ab-ink);
  border: 1px solid var(--ab-border);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(11, 18, 33, 0.22);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}

.ab-consent-banner.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.ab-consent-body {
  padding: 1.25rem 1.35rem 1.35rem;
}

.ab-consent-titlebar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
}

.ab-consent-icon {
  font-size: 1.35rem;
  line-height: 1;
  color: var(--ab-accent);
}

.ab-consent-title {
  margin: 0;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ab-ink);
}

.ab-consent-modal-head h2,
.ab-consent-title {
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  color: var(--ab-ink);
}

.ab-consent-text {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--ab-ink-soft);
}

.ab-consent-text a {
  color: var(--ab-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ab-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

/* ---- Buttons ------------------------------------------------------------- */

.ab-consent-btn {
  flex: 1 1 auto;
  min-width: 9rem;
  padding: 0.7rem 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.ab-consent-btn--primary {
  background: var(--ab-accent);
  border-color: var(--ab-accent);
  color: #fff;
}

.ab-consent-btn--primary:hover {
  background: var(--ab-accent-hover);
  border-color: var(--ab-accent-hover);
}

.ab-consent-btn--ghost {
  background: transparent;
  border-color: var(--ab-border);
  color: var(--ab-ink);
}

.ab-consent-btn--ghost:hover {
  border-color: rgba(11, 18, 33, 0.28);
  background: rgba(11, 18, 33, 0.03);
}

.ab-consent-btn:focus-visible {
  outline: 2px solid var(--ab-accent);
  outline-offset: 2px;
}

/* ---- Preferences modal --------------------------------------------------- */

.ab-consent-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ab-consent-modal[hidden] {
  display: none;
}

.ab-consent-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 33, 0.55);
  backdrop-filter: blur(2px);
}

.ab-consent-modal-panel {
  position: relative;
  width: 100%;
  max-width: 32rem;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--ab-surface);
  color: var(--ab-ink);
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(11, 18, 33, 0.32);
  padding: 1.5rem 1.6rem 1.6rem;
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ab-consent-modal.is-open .ab-consent-modal-panel {
  opacity: 1;
  transform: scale(1);
}

.ab-consent-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.ab-consent-modal-head h2 {
  margin: 0;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ab-ink);
}

.ab-consent-modal-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--ab-ink-soft);
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}

.ab-consent-modal-close:hover {
  background: rgba(11, 18, 33, 0.06);
  color: var(--ab-ink);
}

.ab-consent-cats {
  list-style: none;
  margin: 1.1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.85rem;
}

.ab-consent-cat {
  border: 1px solid var(--ab-border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}

.ab-consent-cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.ab-consent-cat-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.ab-consent-cat-always {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ab-accent);
}

.ab-consent-cat-desc {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ab-ink-soft);
}

/* Toggle switch */
.ab-consent-switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
  flex: none;
  cursor: pointer;
}

.ab-consent-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.ab-consent-slider {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 33, 0.22);
  border-radius: 999px;
  transition: background-color 0.2s ease;
}

.ab-consent-slider::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.ab-consent-switch input:checked + .ab-consent-slider {
  background: var(--ab-accent);
}

.ab-consent-switch input:checked + .ab-consent-slider::before {
  transform: translateX(18px);
}

.ab-consent-switch input:focus-visible + .ab-consent-slider {
  outline: 2px solid var(--ab-accent);
  outline-offset: 2px;
}

.ab-consent-switch input:disabled {
  cursor: not-allowed;
}

.ab-consent-switch input:disabled + .ab-consent-slider {
  background: var(--ab-accent);
  opacity: 0.45;
}

.ab-consent-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

@media (max-width: 480px) {
  .ab-consent-banner {
    left: 0.75rem;
    right: 0.75rem;
    bottom: 0.75rem;
    max-width: none;
  }
  .ab-consent-btn {
    min-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ab-consent-banner,
  .ab-consent-modal-panel {
    transition: none;
  }
}
