/*
  Silktide Consent Manager — Ubex dark theme
  Base: https://silktide.com/consent-manager/
  Customized for Ubex: #0e0e0e bg, #8A2BE2 accent, Inter font
*/

/* --------------------------------
  Global Styles
-------------------------------- */
#stcm-wrapper {
  --boxShadow: 0 -4px 40px rgba(0, 0, 0, 0.5);
  --fontFamily: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --primaryColor: #8A2BE2;
  --backgroundColor: rgba(14, 14, 14, 0.98);
  --textColor: #a1a1aa;
  --backdropBackgroundColor: rgba(0, 0, 0, 0.6);
  --backdropBackgroundBlur: 0px;
  --iconColor: #8A2BE2;
  --iconBackgroundColor: #ffffff;
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 99999;
  pointer-events: none;
  border: 0px;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* --------------------------------
  Links
-------------------------------- */
#stcm-wrapper a {
  all: unset;
  display: inline-block;
  color: var(--primaryColor);
  text-decoration: underline;
}

#stcm-wrapper a:hover {
  cursor: pointer;
  color: #9b3cf3;
}

/* --------------------------------
  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 #8A2BE2;
  border-radius: 5px;
}

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

/* --------------------------------
  Buttons
-------------------------------- */
#stcm-wrapper .stcm-button {
  color: var(--backgroundColor);
  background-color: var(--primaryColor);
  border: 2px solid var(--primaryColor);
  padding: 10px 20px;
  text-decoration: none;
  text-align: center;
  display: inline-block;
  font-size: 14px;
  line-height: 24px;
  cursor: pointer;
  border-radius: 10px;
  font-weight: 600;
  font-family: var(--fontFamily);
  transition: all 0.2s ease;
}

/* Accept / primary */
#stcm-wrapper .stcm-button.stcm-button-primary {
  background: #8A2BE2;
  border-color: #8A2BE2;
  color: #fff;
}

#stcm-wrapper .stcm-button-primary:hover {
  background: #9b3cf3;
  border-color: #9b3cf3;
  color: #fff;
}

/* Reject / secondary */
#stcm-wrapper .stcm-button-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a1a1aa;
}

#stcm-wrapper .stcm-button-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* --------------------------------
  Banner
-------------------------------- */
#stcm-banner {
  font-family: var(--fontFamily);
  color: var(--textColor);
  background-color: var(--backgroundColor);
  box-sizing: border-box;
  padding: 24px;
  border-radius: 16px;
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.08);
  position: fixed;
  bottom: 16px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  width: auto;
  min-width: 600px;
  overflow: auto;
  max-width: calc(100% - 32px);
  max-height: calc(100vh - 32px);
  opacity: 0;
  animation: stcm-slide-down-bottom-center 350ms ease-out forwards;
  animation-delay: 0.3s;
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  text-align: center;
}

#stcm-banner.stcm-loaded {
  opacity: 1;
  transform: translateX(-50%);
  animation: none;
}

#stcm-banner.stcm-pos-center {
  top: 50%;
  left: 50%;
  bottom: auto;
  right: auto;
  position: fixed;
  transform: translate(-50%, -50%);
  animation: stcm-slide-down-center 350ms ease-out forwards;
}

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

#stcm-banner.stcm-pos-bottom-center {
  bottom: 16px;
  left: 50%;
  position: fixed;
  transform: translateX(-50%);
  animation: stcm-slide-down-bottom-center 350ms ease-out forwards;
}

#stcm-banner .stcm-preferences-button {
  display: flex;
  gap: 5px;
  border: none;
  padding: 15px 0px;
  background-color: transparent;
  color: var(--primaryColor);
  cursor: pointer;
  font-size: 14px;
  font-family: var(--fontFamily);
}

#stcm-banner .stcm-preferences-button span {
  display: block;
  white-space: nowrap;
  text-decoration: none;
  color: #8A2BE2;
}

#stcm-banner .stcm-preferences-button span:hover {
  color: #9b3cf3;
}

#stcm-banner p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--textColor);
  margin: 0px 0px 15px;
}

#stcm-banner a {
  display: inline-block;
  color: var(--primaryColor);
  text-decoration: underline;
  background-color: var(--backgroundColor);
}

#stcm-banner a:hover {
  color: #9b3cf3;
}

/* Replace Silktide logo with Ubex logo */
#stcm-banner a.stcm-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  fill: none;
  margin-left: auto;
  width: 80px;
  height: 28px;
  text-decoration: none;
  background: url('/assets/images/logo-ubex.svg') no-repeat center / contain;
}

#stcm-banner a.stcm-logo svg {
  display: none;
}

#stcm-banner .stcm-actions {
  display: flex;
  gap: 16px;
  flex-direction: column;
  margin-top: 24px;
  justify-content: center;
  align-items: center;
}

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

#stcm-banner .stcm-actions-row {
  display: flex;
  gap: 16px;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex-grow: 0;
}

/* --------------------------------
  Modal
-------------------------------- */
#stcm-modal {
  display: none;
  pointer-events: auto;
  overflow: auto;
  width: 800px;
  max-width: 90vw;
  max-height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  transform: translate(0px, -20px);
  opacity: 0;
  animation: stcm-slide-up-center 350ms ease-out forwards;
  box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.5);
  font-family: var(--fontFamily);
  color: var(--textColor);
  flex-direction: column;
  padding: 24px;
  background-color: var(--backgroundColor);
  border-radius: 16px;
  box-sizing: border-box;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* ── Modal - Header ── */
#stcm-modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}

#stcm-modal h1 {
  font-family: var(--fontFamily);
  color: #ffffff;
  font-size: 20px;
  font-weight: 600;
  margin: 0px;
}

#stcm-modal .stcm-modal-close {
  display: inline-flex;
  border: none;
  padding: 10px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  color: var(--primaryColor);
  border-radius: 8px;
  transition: background 0.2s ease;
}

#stcm-modal .stcm-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

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

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

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

#stcm-modal section::-webkit-scrollbar-thumb {
  background-color: rgba(100, 60, 180, 0.4);
  border-radius: 10px;
}

#stcm-modal p {
  font-size: 14px;
  line-height: 1.55;
  color: #a1a1aa;
  opacity: 0.6;
  margin: 0px 0px 15px;
}

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

/* ── Modal - Fieldsets ── */
#stcm-modal fieldset {
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  margin: 0px 0px 12px;
}

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

/* Pull legend inside the fieldset box */
#stcm-modal legend {
  float: left;
  width: 100%;
  padding: 16px 16px 0 16px;
  margin: 0;
  font-weight: 600;
  color: #ffffff;
  font-size: 15px;
  box-sizing: border-box;
}

/* Consent row: text left, toggle right, vertically centered */
#stcm-modal .stcm-consent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 16px 16px 16px;
  clear: both;
}

#stcm-modal .stcm-consent-row p {
  margin: 0;
  flex: 1;
  min-width: 0;
}

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

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

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

/* Unchecked */
#stcm-modal .stcm-toggle-track {
  position: relative;
  display: block;
  height: 34px;
  width: 74px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 25px;
}

#stcm-modal .stcm-toggle-thumb {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 2px;
  display: block;
  height: 30px;
  width: 30px;
  background: #ffffff;
  border-radius: 50%;
  transition: left 150ms ease-out;
}

#stcm-modal .stcm-toggle-off,
#stcm-modal .stcm-toggle-on {
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 8px;
  transition: right 150ms ease-out, opacity 150ms ease-out;
}

#stcm-modal .stcm-toggle-off {
  opacity: 1;
}

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

/* Checked */
#stcm-modal .stcm-toggle input:checked + .stcm-toggle-track {
  background: #8A2BE2;
}

#stcm-modal .stcm-toggle input:checked ~ .stcm-toggle-thumb {
  left: calc(100% - 32px);
  top: 50%;
  transform: translateY(-50%);
}

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

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

#stcm-modal .stcm-toggle input:disabled + .stcm-toggle-track {
  opacity: 0.65;
  filter: grayscale(100%);
  cursor: not-allowed;
}

/* ── Modal - Footer ── */
#stcm-modal footer {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 24px;
}

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

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

#stcm-modal footer a.stcm-credit-link {
  display: none;
}

/* ── Cookie Icon ── */
#stcm-icon {
  display: none;
  position: fixed;
  bottom: 10px;
  left: 10px;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  padding: 0px;
  border: none;
  background-color: var(--iconColor);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(138, 43, 226, 0.3);
  pointer-events: auto;
  animation: stcm-fade-in 0.3s ease-in-out forwards;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

#stcm-icon:hover {
  box-shadow: 0 4px 20px rgba(138, 43, 226, 0.5);
  transform: scale(1.05);
}

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

#stcm-icon svg {
  fill: var(--iconBackgroundColor);
}

/* ── 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-down {
  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-down-bottom-center {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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

@keyframes stcm-nudge {
  0%, 100% { right: 16px; }
  10%, 30%, 50%, 70%, 90% { right: 20px; }
  20%, 40%, 60%, 80% { right: 12px; }
}

/* Banner uses left+transform centering, so disable the right-based nudge */
#stcm-banner.stcm-nudge {
  animation: none;
}

#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; }
  }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #stcm-banner {
    padding: 20px;
    border-radius: 14px;
    min-width: unset;
    width: calc(100% - 32px);
  }

  #stcm-modal {
    padding: 20px;
    border-radius: 14px;
    max-width: calc(100% - 32px);
  }
}
