/**
 * Datareporter WebCare - Embed Blocker Styles
 */

/* ============================================================================
   CSS Custom Properties
   ========================================================================= */
:root {
  --drwc-embed-overlay-bg: rgba(0, 0, 0, 0.85);
  --drwc-embed-text-color: #ffffff;
  --drwc-embed-button-bg: #004e70;
  --drwc-embed-button-hover: #00405e;
  --drwc-embed-border-radius: 4px;
  --drwc-embed-transition: all 0.3s ease;
  --drwc-embed-reveal-delay: 5s;   /* pending overlays (auto-unlock) reveal themselves after this, JS or not */
}

/* ============================================================================
   Embed Blocker Container
   Provider placeholders keep the first release's layout. Consent boxes and
   elements found by a service (drwc-embed-custom) keep the owner element:
   their layout rules sit in :where() with zero specificity so any theme or
   inline style wins.
   ========================================================================= */
.drwc-embed-blocker {
  position: relative;
  container-type: inline-size;
  container-name: embed-blocker;
}

.drwc-embed-blocker:not(.drwc-embed-custom) {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 300px;
  border-radius: var(--drwc-embed-border-radius);
  overflow: hidden;
}

:where(.drwc-embed-custom.drwc-embed-blocker) {
  display: block;
  min-height: 300px;
  border-radius: var(--drwc-embed-border-radius);
  overflow: hidden;
}

:where(.drwc-embed-custom.drwc-embed-blocker.drwc-embed-loaded) {
  overflow: visible;
}

/* ============================================================================
   Overlay
   ========================================================================= */
/* Scoped to the placeholder: overlay markup that arrives with the content (its placeholder class is stripped by
   the server) must render as plain content, not as a page-covering layer. :where() keeps the specificity at one
   class, so a theme's own .drwc-embed-overlay rule still wins by source order as it did before the scoping. */
:where(.drwc-embed-blocker) .drwc-embed-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  box-sizing: border-box;
  white-space: normal;      /* readable inside <pre> hosts */
  font-family: inherit;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: var(--drwc-embed-overlay-bg);
  backdrop-filter: blur(4px);
  z-index: 10;
}

/* ============================================================================
   Content
   ========================================================================= */
.drwc-embed-content {
  box-sizing: border-box;
  max-width: 100%;
  margin: auto;
  text-align: center;
  padding: 1em;
  color: var(--drwc-embed-text-color);
}

.drwc-embed-title {
  font-size: 1.25em;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.75em 0;
  padding: 0;
  color: var(--drwc-embed-text-color);
  overflow-wrap: anywhere;
}

.drwc-embed-description {
  font-size: 0.75em;
  line-height: 1.6;
  margin: 0 0 1em 0;
  color: rgba(255, 255, 255, 0.9);
}

/* ============================================================================
   Pending State (auto-unlock)
   A placeholder with an auto-unlock rule waits for the banner: overlay size and
   background stay, only text and button are invisible. The script removes the
   class after evaluating consent; the delayed animation reveals the content by
   CSS alone if the banner or the script never answers. Deliberately not gated
   on prefers-reduced-motion (an instant step, not a motion effect). The keyframe
   name drwc-embed-reveal is read by embed-blocker.js (animationend).
   ========================================================================= */
.drwc-embed-pending .drwc-embed-content {
  opacity: 0;
  visibility: hidden;   /* also out of the tab order and the accessibility tree while pending */
  /* !important: the usual theme reset "* { animation-delay: -1ms !important }" for reduced motion would collapse
     the delay and reveal (or, with "animation: none", never reveal) the overlay; a class rule outranks it. */
  animation: drwc-embed-reveal 0s var(--drwc-embed-reveal-delay) forwards !important;
}

@keyframes drwc-embed-reveal {
  to {
    opacity: 1;
    visibility: visible;
  }
}

/* ============================================================================
   Consent Button
   ========================================================================= */
.drwc-embed-consent-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.5em 1em;
  font-size: 0.85em;
  font-weight: bold;
  color: #ffffff;
  background: var(--drwc-embed-button-bg);
  border: none;
  border-radius: var(--drwc-embed-border-radius);
  cursor: pointer;
  transition: var(--drwc-embed-transition);
}

.drwc-embed-consent-btn:hover {
  background: var(--drwc-embed-button-hover);
  transform: translateY(-2px);
}

.drwc-embed-consent-btn:active {
  transform: translateY(0);
}

/* ============================================================================
   Loaded State
   ========================================================================= */
.drwc-embed-blocker.drwc-embed-loaded {
  min-height: 0;
  container-type: normal;   /* containment would stop the restored content's margins from collapsing */
}

.drwc-embed-blocker:not(.drwc-embed-custom).drwc-embed-loaded {
  background: transparent;
  overflow: visible;
}

.drwc-embed-blocker.drwc-embed-loaded .drwc-embed-overlay {
  display: none;
}

/* ============================================================================
   Responsive Design
   ========================================================================= */

@container embed-blocker (max-width: 400px) {
  .drwc-embed-content {
    padding: 0.5em;
  }

  .drwc-embed-title {
    font-size: 0.9em;
    margin-bottom: 0.5em;
  }

  .drwc-embed-description {
    font-size: 0.65em;
    margin-bottom: 0.75em;
    line-height: 1.4;
  }

  .drwc-embed-consent-btn {
    padding: 0.4em 0.75em;
    font-size: 0.75em;
  }
}

/* Fallback for browsers without container queries */
@supports not (container-type: inline-size) {
  @media (max-width: 768px) {
    .drwc-embed-content {
      padding: 0.75em;
    }

    .drwc-embed-title {
      font-size: 1em;
      margin-bottom: 0.5em;
    }

    .drwc-embed-description {
      font-size: 0.7em;
    }

    .drwc-embed-consent-btn {
      padding: 0.4em 0.85em;
      font-size: 0.8em;
    }
  }
}

