/*
  Silktide Consent Manager — restyled for Flowversity
  Original: https://silktide.com/consent-manager/
*/

/* --------------------------------
  Global Styles
-------------------------------- */
#stcm-wrapper {
  --boxShadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 10px 30px -5px rgb(0 0 0 / 0.08);
  --fontFamily: var(--font-sans), ui-sans-serif, system-ui, sans-serif;
  --primaryColor: oklch(0.54 0.206 278.8);
  --backgroundColor: var(--card);
  --textColor: var(--foreground);
  --backdropBackgroundColor: oklch(0 0 0 / 30%);
  --backdropBackgroundBlur: 8px;
  --iconColor: var(--foreground);
  --iconBackgroundColor: var(--card);
  --borderColor: var(--border);
  --mutedText: var(--muted-foreground);
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  pointer-events: none;
  border: 0;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --------------------------------
  Links
-------------------------------- */
#stcm-wrapper a {
  all: unset;
  display: inline-block;
  color: var(--primaryColor);
  text-decoration: underline;
  text-decoration-color: oklch(0.705 0.213 47.6 / 40%);
  text-underline-offset: 2px;
  transition: text-decoration-color 200ms ease;
}

#stcm-wrapper a:hover {
  cursor: pointer;
  text-decoration-color: var(--primaryColor);
}

/* --------------------------------
  Focus Styles
-------------------------------- */
#stcm-wrapper a:focus,
#stcm-wrapper #stcm-banner button:focus,
#stcm-wrapper #stcm-modal button:focus,
#stcm-wrapper #stcm-icon:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--backgroundColor), 0 0 0 4px var(--primaryColor);
  border-radius: 6px;
}

#stcm-wrapper #stcm-icon:focus {
  border-radius: 50%;
}

/* --------------------------------
  General Button Styles
-------------------------------- */
#stcm-wrapper .stcm-button {
  color: var(--primaryColor);
  background-color: transparent;
  border: 1px solid var(--borderColor);
  padding: 8px 16px;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 200ms ease;
  letter-spacing: 0.01em;
}

#stcm-wrapper .stcm-button-primary {
  background-color: var(--primaryColor);
  color: oklch(1 0 0);
  border-color: transparent;
}

#stcm-wrapper .stcm-button-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 20px -5px oklch(0.705 0.213 47.6 / 40%);
}

#stcm-wrapper .stcm-button-secondary {
  background-color: transparent;
  color: var(--mutedText);
  border-color: var(--borderColor);
}

#stcm-wrapper .stcm-button-secondary:hover {
  color: var(--textColor);
  border-color: var(--textColor);
  background-color: oklch(0.705 0.213 47.6 / 5%);
}

/* --------------------------------
  Banner
-------------------------------- */
#stcm-banner {
  font-family: var(--fontFamily);
  color: var(--textColor);
  background-color: var(--backgroundColor);
  box-sizing: border-box;
  padding: 24px 28px;
  border-radius: 12px;
  pointer-events: auto;
  border: 1px solid var(--borderColor);
  position: fixed;
  bottom: 16px;
  right: 16px;
  width: 560px;
  overflow: auto;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  transform: translate(0, 20px);
  opacity: 0;
  animation: stcm-slide-up 400ms cubic-bezier(0.16, 1, 0.3, 1);
  animation-delay: 0.3s;
  animation-fill-mode: forwards;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 20px 40px -8px rgb(0 0 0 / 0.1);
}

#stcm-banner.stcm-loaded {
  opacity: 1;
  transform: none;
  animation: none;
}

#stcm-banner.stcm-pos-center {
  top: 50%;
  left: 50%;
  bottom: auto;
  right: auto;
  position: fixed;
  transform: translate(-50%, calc(-50% + 20px));
  animation: stcm-slide-down-center 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#stcm-banner.stcm-pos-bottom-left {
  bottom: 16px;
  left: 16px;
  position: fixed;
}

#stcm-banner.stcm-pos-bottom-center {
  bottom: 16px;
  left: 50%;
  position: fixed;
  transform: translate(-50%, 20px);
  animation: stcm-slide-up-bottom-center 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#stcm-banner .stcm-preferences-button {
  display: flex;
  gap: 5px;
  border: none;
  padding: 0;
  background-color: transparent;
  color: var(--mutedText);
  cursor: pointer;
  font-size: 13px;
  transition: color 200ms ease;
}

#stcm-banner .stcm-preferences-button span {
  display: block;
  white-space: nowrap;
  text-decoration: none;
  text-decoration-line: underline;
  text-decoration-color: transparent;
  text-underline-offset: 2px;
  transition: text-decoration-color 200ms ease;
}

#stcm-banner .stcm-preferences-button:hover span {
  text-decoration-color: var(--mutedText);
  color: var(--textColor);
}

#stcm-banner p {
  font-size: 13.5px;
  line-height: 22px;
  color: var(--mutedText);
  margin: 0 0 16px;
}

#stcm-banner a {
  display: inline-block;
  color: var(--primaryColor);
  text-decoration: underline;
  text-decoration-color: oklch(0.705 0.213 47.6 / 40%);
  text-underline-offset: 2px;
  background-color: transparent;
}

#stcm-banner a:hover {
  text-decoration-color: var(--primaryColor);
}

#stcm-banner a.stcm-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  fill: var(--mutedText);
  margin-left: auto;
  width: 40px;
  height: 40px;
  text-decoration: none;
  opacity: 0.3;
  transition: opacity 200ms ease;
}

#stcm-banner a.stcm-logo:hover {
  opacity: 0.6;
}

#stcm-banner .stcm-actions {
  display: flex;
  gap: 10px;
  flex-direction: column;
  margin-top: 20px;
}

@media (min-width: 600px) {
  #stcm-banner .stcm-actions {
    flex-direction: row;
    align-items: center;
  }
}

#stcm-banner .stcm-actions-row {
  display: flex;
  gap: 10px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  flex-grow: 1;
}

/* --------------------------------
  Modal
-------------------------------- */
#stcm-modal {
  display: none;
  pointer-events: auto;
  overflow: auto;
  width: 720px;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 64px);
  border: 1px solid var(--borderColor);
  transform: translate(0px, 20px);
  opacity: 0;
  animation: stcm-slide-up 400ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 20px 40px -8px rgb(0 0 0 / 0.1);
  font-family: var(--fontFamily);
  color: var(--textColor);
  flex-direction: column;
  padding: 28px 32px;
  background-color: var(--backgroundColor);
  border-radius: 12px;
  box-sizing: border-box;
}

/* --------------------------------
  Modal — Header
-------------------------------- */
#stcm-modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--borderColor);
}

#stcm-modal h1 {
  font-family: var(--fontFamily);
  color: var(--textColor);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

#stcm-modal .stcm-modal-close {
  display: inline-flex;
  border: none;
  padding: 8px;
  cursor: pointer;
  background: transparent;
  color: var(--mutedText);
  border-radius: 6px;
  transition: color 200ms ease, background-color 200ms ease;
}

#stcm-modal .stcm-modal-close:hover {
  color: var(--textColor);
  background-color: oklch(0.705 0.213 47.6 / 8%);
}

#stcm-modal .stcm-modal-close svg {
  fill: currentColor;
}

/* --------------------------------
  Modal — Content
-------------------------------- */
#stcm-modal section {
  flex: 1;
  margin-top: 8px;
}

#stcm-modal section::-webkit-scrollbar {
  display: block;
  width: 4px;
}

#stcm-modal section::-webkit-scrollbar-thumb {
  background-color: var(--borderColor);
  border-radius: 10px;
}

#stcm-modal p {
  font-size: 13.5px;
  line-height: 22px;
  color: var(--mutedText);
  margin: 0 0 24px;
}

#stcm-modal p:last-of-type {
  margin: 0;
}

#stcm-modal fieldset {
  padding: 16px 0;
  border: none;
  margin: 0;
  border-top: 1px solid var(--borderColor);
}

#stcm-modal fieldset:first-of-type {
  border-top: none;
  padding-top: 8px;
}

#stcm-modal fieldset:last-of-type {
  border-bottom: none;
}

#stcm-modal legend {
  padding: 0;
  margin: 0 0 4px;
  font-weight: 600;
  color: var(--textColor);
  font-size: 14px;
  letter-spacing: -0.01em;
}

#stcm-modal .stcm-consent-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

/* --------------------------------
  Modal — Switches
-------------------------------- */
#stcm-modal .stcm-toggle {
  flex-shrink: 0;
  position: relative;
  display: inline-block;
  height: 28px;
  width: 52px;
  cursor: pointer;
}

#stcm-modal .stcm-toggle:focus-within {
  outline: none;
  box-shadow: 0 0 0 2px var(--backgroundColor), 0 0 0 4px var(--primaryColor);
  border-radius: 25px;
}

#stcm-modal .stcm-toggle input {
  opacity: 0;
  position: absolute;
}

#stcm-modal .stcm-toggle-track {
  position: relative;
  display: block;
  height: 28px;
  width: 52px;
  background: var(--borderColor);
  border-radius: 25px;
  transition: background-color 200ms ease;
}

#stcm-modal .stcm-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  display: block;
  height: 24px;
  width: 24px;
  background: oklch(1 0 0);
  border-radius: 50%;
  transition: left 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

#stcm-modal .stcm-toggle-off,
#stcm-modal .stcm-toggle-on {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: oklch(1 0 0);
  position: absolute;
  top: 8px;
  right: 10px;
  transition: right 200ms ease, opacity 200ms ease;
}

#stcm-modal .stcm-toggle-off {
  color: var(--mutedText);
  opacity: 1;
}

#stcm-modal .stcm-toggle-on {
  opacity: 0;
}

#stcm-modal .stcm-toggle input:checked + .stcm-toggle-track {
  background: var(--primaryColor);
}

#stcm-modal .stcm-toggle input:checked ~ .stcm-toggle-thumb {
  left: calc(100% - 26px);
}

#stcm-modal .stcm-toggle input:checked ~ .stcm-toggle-off {
  right: calc(100% - 26px);
  opacity: 0;
}

#stcm-modal .stcm-toggle input:checked ~ .stcm-toggle-on {
  right: calc(100% - 28px);
  opacity: 1;
}

#stcm-modal .stcm-toggle input:disabled + .stcm-toggle-track {
  background: var(--primaryColor);
  opacity: 0.6;
}

/* --------------------------------
  Modal — Footer
-------------------------------- */
#stcm-modal footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--borderColor);
}

@media (min-width: 600px) {
  #stcm-modal footer {
    flex-direction: row;
    align-items: center;
  }
}

#stcm-modal footer a {
  margin-left: auto;
  padding: 0;
}

#stcm-modal footer a.stcm-credit-link {
  text-decoration: none;
  font-size: 11px;
  color: var(--mutedText);
  opacity: 0.5;
}

#stcm-modal footer a.stcm-credit-link:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* --------------------------------
  Cookie Icon
-------------------------------- */
#stcm-icon {
  display: none;
  position: fixed;
  bottom: 16px;
  left: 16px;
  justify-content: center;
  align-items: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  padding: 0;
  border: 1px solid var(--borderColor);
  background-color: var(--iconBackgroundColor);
  cursor: pointer;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.05), 0 4px 12px rgb(0 0 0 / 0.06);
  pointer-events: auto;
  animation: stcm-fade-in 0.3s ease-in-out forwards;
  transition: box-shadow 200ms ease, border-color 200ms ease;
}

#stcm-icon:hover {
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.06), 0 8px 20px rgb(0 0 0 / 0.08);
  border-color: var(--primaryColor);
}

#stcm-icon.stcm-pos-bottom-right {
  left: auto;
  right: 16px;
}

#stcm-icon svg {
  fill: var(--mutedText);
  width: 20px;
  height: 20px;
}

/* --------------------------------
  Backdrop
-------------------------------- */
#stcm-backdrop {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--backdropBackgroundColor);
  backdrop-filter: blur(var(--backdropBackgroundBlur));
  pointer-events: all;
}

/* --------------------------------
  Animations
-------------------------------- */
@keyframes stcm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes stcm-slide-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes stcm-slide-down-center {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 20px));
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes stcm-slide-up-bottom-center {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* --------------------------------
  Animation — backdrop click feedback
-------------------------------- */
@keyframes stcm-nudge {
  0%, 100% { right: 16px; }
  10%, 30%, 50%, 70%, 90% { right: 20px; }
  20%, 40%, 60%, 80% { right: 12px; }
}

#stcm-banner.stcm-nudge {
  animation: stcm-nudge 1s ease-in-out;
}

#stcm-modal.stcm-nudge {
  animation: stcm-nudge 0.5s ease-in-out;
}

@media (prefers-reduced-motion: reduce) {
  #stcm-banner.stcm-nudge,
  #stcm-modal.stcm-nudge {
    animation: stcm-pulse 0.5s ease-in-out;
  }

  @keyframes stcm-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
  }
}
