/* ==========================================================================
   Srfx Cookie Consent — DSGVO Banner & Modal
   Design tokens from theme.json + existing mu-plugin patterns
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */

:root {
  --srfx-cc-bg:           #ffffff;
  --srfx-cc-surface:      #f9f9f9;
  --srfx-cc-text:         #111111;
  --srfx-cc-muted:        #636363;
  --srfx-cc-border:       #e5e5e5;
  --srfx-cc-disabled:     #A4A4A4;
  --srfx-cc-accent:       #c2a990;
  --srfx-cc-btn-dark:     #1a1a1a;
  --srfx-cc-btn-dark-txt: #ffffff;
  --srfx-cc-toggle-on:    #d8613c;
  --srfx-cc-toggle-off:   #d0d0d0;
  --srfx-cc-radius-card:  1rem;
  --srfx-cc-radius-btn:   0.375rem;
  --srfx-cc-shadow:       0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --srfx-cc-shadow-lg:    0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 4px 10px -3px rgba(0, 0, 0, 0.08);
  --srfx-cc-z-banner:     9990;
  --srfx-cc-z-overlay:    9995;
  --srfx-cc-z-modal:      9996;
  --srfx-cc-transition:   0.25s ease;
}

/* --------------------------------------------------------------------------
   Banner — Floating card, bottom-left on desktop
   -------------------------------------------------------------------------- */

#srfx-cookie-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: var(--srfx-cc-z-banner);
  box-sizing: border-box;
  width: calc(100% - 3rem);
  max-width: 500px;
  background: var(--srfx-cc-bg);
  border-radius: var(--srfx-cc-radius-card);
  box-shadow: var(--srfx-cc-shadow-lg);
  border: 1px solid var(--srfx-cc-border);
  padding: 1.5rem;
  font-family: "Inter", sans-serif;
  color: var(--srfx-cc-text);

  /* Entrance animation */
  transform: translateY(calc(100% + 2rem));
  opacity: 0;
  transition:
    transform var(--srfx-cc-transition),
    opacity   var(--srfx-cc-transition);
  will-change: transform, opacity;
}

#srfx-cookie-banner.srfx-cc--visible {
  transform: translateY(0);
  opacity: 1;
}

#srfx-cookie-banner.srfx-cc--hidden {
  transform: translateY(calc(100% + 2rem));
  opacity: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Banner — Header
   -------------------------------------------------------------------------- */

.srfx-cc-banner__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.srfx-cc-banner__icon {
  font-size: 1.125rem;
  line-height: 1;
  flex-shrink: 0;
}

.srfx-cc-banner__title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--srfx-cc-text);
  line-height: 1.3;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Banner — Body text
   -------------------------------------------------------------------------- */

.srfx-cc-banner__text {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--srfx-cc-muted);
  margin: 0 0 1.25rem;
}

.srfx-cc-banner__text a {
  color: var(--srfx-cc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.srfx-cc-banner__text a:hover {
  color: var(--srfx-cc-text);
}

/* --------------------------------------------------------------------------
   Banner — Actions
   -------------------------------------------------------------------------- */

.srfx-cc-banner__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Shared button base
   -------------------------------------------------------------------------- */

.srfx-cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--srfx-cc-radius-btn);
  font-family: "Inter", sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: opacity var(--srfx-cc-transition), background var(--srfx-cc-transition);
  border: 1.5px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  -webkit-appearance: none;
  appearance: none;
}

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

/* Primary — dark fill */
.srfx-cc-btn--primary {
  background: var(--srfx-cc-btn-dark);
  color: var(--srfx-cc-btn-dark-txt);
  border-color: var(--srfx-cc-btn-dark);
}

.srfx-cc-btn--primary:hover {
  opacity: 0.85;
}

/* Secondary — outline */
.srfx-cc-btn--secondary {
  background: transparent;
  color: var(--srfx-cc-text);
  border-color: var(--srfx-cc-text);
}

.srfx-cc-btn--secondary:hover {
  background: var(--srfx-cc-surface);
}

/* Ghost — text only */
.srfx-cc-btn--ghost {
  background: transparent;
  color: var(--srfx-cc-muted);
  border-color: transparent;
  padding-left: 0.25rem;
  padding-right: 0.25rem;
  font-weight: 400;
  font-size: 0.75rem;
}

.srfx-cc-btn--ghost:hover {
  color: var(--srfx-cc-text);
}

/* Full-width modifier */
.srfx-cc-btn--full {
  width: 100%;
}

/* --------------------------------------------------------------------------
   Modal overlay backdrop
   -------------------------------------------------------------------------- */

#srfx-cookie-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--srfx-cc-z-overlay);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);

  opacity: 0;
  pointer-events: none;
  transition: opacity var(--srfx-cc-transition);
}

#srfx-cookie-overlay.srfx-cc--visible {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Modal card
   -------------------------------------------------------------------------- */

#srfx-cookie-modal {
  position: fixed;
  z-index: var(--srfx-cc-z-modal);
  top: 50%;
  left: 50%;
  transform: translate(-50%, calc(-50% + 1rem));
  box-sizing: border-box;
  width: calc(100% - 2rem);
  max-width: 520px;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  background: var(--srfx-cc-bg);
  border-radius: var(--srfx-cc-radius-card);
  box-shadow: var(--srfx-cc-shadow-lg);
  border: 1px solid var(--srfx-cc-border);
  font-family: "Inter", sans-serif;
  color: var(--srfx-cc-text);

  opacity: 0;
  pointer-events: none;
  transition:
    opacity    var(--srfx-cc-transition),
    transform  var(--srfx-cc-transition);
  will-change: transform, opacity;
}

#srfx-cookie-modal.srfx-cc--visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%);
}

/* --------------------------------------------------------------------------
   Modal — Header
   -------------------------------------------------------------------------- */

.srfx-cc-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--srfx-cc-border);
  position: sticky;
  top: 0;
  background: var(--srfx-cc-bg);
  z-index: 1;
}

.srfx-cc-modal__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--srfx-cc-text);
  margin: 0;
}

.srfx-cc-modal__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--srfx-cc-muted);
  border-radius: var(--srfx-cc-radius-btn);
  transition: color var(--srfx-cc-transition), background var(--srfx-cc-transition);
  flex-shrink: 0;
}

.srfx-cc-modal__close:hover {
  color: var(--srfx-cc-text);
  background: var(--srfx-cc-surface);
}

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

.srfx-cc-modal__close svg {
  display: block;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Modal — Body
   -------------------------------------------------------------------------- */

.srfx-cc-modal__body {
  padding: 0.5rem 1.5rem;
}

.srfx-cc-modal__intro {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--srfx-cc-muted);
  padding: 1rem 0 0.5rem;
}

/* --------------------------------------------------------------------------
   Consent category rows
   -------------------------------------------------------------------------- */

.srfx-cc-category {
  border-top: 1px solid var(--srfx-cc-border);
  padding: 1rem 0;
}

.srfx-cc-category:last-of-type {
  border-bottom: 1px solid var(--srfx-cc-border);
}

.srfx-cc-category__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.375rem;
}

.srfx-cc-category__name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--srfx-cc-text);
  margin: 0;
}

.srfx-cc-category__desc {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--srfx-cc-muted);
  margin: 0 0 0.375rem;
}

.srfx-cc-category__tools {
  font-size: 0.6875rem;
  color: var(--srfx-cc-disabled);
  margin: 0;
}

/* "Immer aktiv" badge for necessary cookies */
.srfx-cc-category__always {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--srfx-cc-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */

.srfx-cc-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.srfx-cc-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.srfx-cc-toggle__track {
  position: relative;
  display: block;
  width: 2.625rem;
  height: 1.375rem;
  background: var(--srfx-cc-toggle-off);
  border-radius: 9999px;
  transition: background var(--srfx-cc-transition);
  flex-shrink: 0;
}

.srfx-cc-toggle__thumb {
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 1rem;
  height: 1rem;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--srfx-cc-transition);
}

/* Checked state */
.srfx-cc-toggle input[type="checkbox"]:checked ~ .srfx-cc-toggle__track {
  background: var(--srfx-cc-toggle-on);
}

.srfx-cc-toggle input[type="checkbox"]:checked ~ .srfx-cc-toggle__track .srfx-cc-toggle__thumb {
  transform: translateX(1.25rem);
}

/* Focus ring on the track for keyboard navigation */
.srfx-cc-toggle input[type="checkbox"]:focus-visible ~ .srfx-cc-toggle__track {
  outline: 2px solid var(--srfx-cc-accent);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Modal — Footer / Actions
   -------------------------------------------------------------------------- */

.srfx-cc-modal__footer {
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  position: sticky;
  bottom: 0;
  background: var(--srfx-cc-bg);
  border-top: 1px solid var(--srfx-cc-border);
}

.srfx-cc-modal__footer-row {
  display: flex;
  gap: 0.5rem;
}

/* --------------------------------------------------------------------------
   Footer re-open link
   -------------------------------------------------------------------------- */

.srfx-consent-footer-link {
  text-align: center;
  padding: 0.5rem 0;
}

.srfx-consent-footer-link button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  color: var(--wp--preset--color--contrast-2, #636363);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0.25rem;
  transition: color 0.2s ease;
}

.srfx-consent-footer-link button:hover {
  color: var(--wp--preset--color--contrast, #111111);
}

/* --------------------------------------------------------------------------
   Responsive — mobile
   -------------------------------------------------------------------------- */

@media (max-width: 600px) {
  #srfx-cookie-banner {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: 100%;
    border-radius: var(--srfx-cc-radius-card) var(--srfx-cc-radius-card) 0 0;
    border-bottom: none;
  }

  #srfx-cookie-banner::before {
    left: 1rem;
    right: 1rem;
  }

  .srfx-cc-banner__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .srfx-cc-btn--ghost {
    text-align: center;
    padding: 0.4rem 0.5rem;
  }

  #srfx-cookie-modal {
    top: auto !important;
    bottom: 0;
    left: 0 !important;
    right: 0;
    width: auto !important;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--srfx-cc-radius-card) var(--srfx-cc-radius-card) 0 0;
    border-bottom: none;
    transform: translateY(1rem) !important;
  }

  #srfx-cookie-modal.srfx-cc--visible {
    transform: translateY(0) !important;
  }

  .srfx-cc-modal__footer-row {
    flex-direction: column;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  #srfx-cookie-banner,
  #srfx-cookie-modal,
  #srfx-cookie-overlay,
  .srfx-cc-toggle__track,
  .srfx-cc-toggle__thumb {
    transition: none !important;
  }
}
