/**
 * TU Consent Manager — Banner Styles
 *
 * Mirrors the TuCookieBanner web component visual design while consuming
 * Temple University design tokens (--tu-*) for brand consistency.
 *
 * Self-contained: the --tu-cmp-* bridge below resolves every token this
 * file consumes (globals first, current rendering as default), so the
 * banner renders identically with or without the TU global stylesheets.
 * fonts.css only loads the variable @font-face binaries.
 *
 * @package Temple\Plugin\ConsentManager
 */

/* Plugin token bridge — namespaced --tu-cmp-*, globals first, current
   rendering as the default. Mirrors the --tu-cmp-admin-* pattern in
   admin.css. */
:root {
  --tu-cmp-font-ui:
    "owners-text", "TU CMP Roboto", -apple-system, BlinkMacSystemFont,
    "Segoe UI", Helvetica, Arial, sans-serif;
  --tu-cmp-font-heading:
    "pennypacker-compressed", "TU CMP Roboto Condensed", "Arial Narrow",
    "TU CMP Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --tu-cmp-font-button:
    "panel-sans-mono", "TU CMP Roboto Mono", "SFMono-Regular", Consolas, Menlo,
    "Courier New", monospace;
  --tu-cmp-font-mono:
    "panel-sans-mono", "TU CMP Roboto Mono", "SFMono-Regular", Consolas, Menlo,
    "Courier New", monospace;
  --tu-cmp-color-text: var(
    --tu-color-contrast,
    var(--tu-preset-color-contrast, #222)
  );
  --tu-cmp-color-heading: var(
    --tu-color-contrast,
    var(--tu-preset-color-contrast, #222)
  );
  --tu-cmp-color-text-muted: #666;
  --tu-cmp-color-text-inverse: #ffffff;
  --tu-cmp-color-surface: var(
    --tu-color-base,
    var(--tu-preset-color-base, #ffffff)
  );
  --tu-cmp-color-surface-alt: var(
    --tu-color-tertiary,
    var(--tu-preset-color-tertiary, #f2eee8)
  );
  --tu-cmp-color-brand: var(
    --tu-color-primary,
    var(--tu-preset-color-primary, #a41e35)
  );
  --tu-cmp-color-brand-hover: var(
    --tu-color-primary-hover,
    var(--tu-preset-color-primary-hover, #941b30)
  );
  --tu-cmp-color-border: var(
    --tu-color-quaternary,
    var(--tu-preset-color-quaternary, #bca685)
  );
  --tu-cmp-color-track: #ccc;
  --tu-cmp-color-track-locked: #8c8f94;
  --tu-cmp-color-border-light: #eee;
  --tu-cmp-color-focus: var(
    --tu-color-primary,
    var(--tu-preset-color-primary, #a41e35)
  );
  --tu-cmp-color-info: var(
    --tu-color-quinary,
    var(--tu-preset-color-quinary, #ceecf9)
  );
  --tu-cmp-radius-sm: 2px;
  --tu-cmp-radius-md: 4px;
  --tu-cmp-radius-embed: 6px;
  --tu-cmp-radius-lg: 12px;
}

/* ════════════════════════════════════════════
   Banner Wrapper
   ════════════════════════════════════════════ */

.tu-cmp-banner {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999999;
  font-family: var(
    --tu-cmp-font-ui,
    "owners-text",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif
  );
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--tu-cmp-color-text, #333);
  background: var(--tu-cmp-color-surface, #ffffff);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  animation: tu-cmp-slide-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
}

.tu-cmp-banner--fade-out {
  animation: tu-cmp-fade-out 0.25s cubic-bezier(0.2, 0, 0, 1) forwards;
  pointer-events: none;
}

/* ════════════════════════════════════════════
   Banner Layouts
   ════════════════════════════════════════════ */

/* Floating card: padded away from the viewport edges with rounded corners. */
.tu-cmp-banner--float {
  right: 20px;
  bottom: 20px;
  left: 20px;
  border-radius: var(--tu-cmp-radius-lg, 12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

/* Bottom-right card: constrained width, anchored to the bottom-right. */
.tu-cmp-banner--bottom-right {
  right: 20px;
  bottom: 20px;
  left: auto;
  max-width: 480px;
  border-radius: var(--tu-cmp-radius-lg, 12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

/* Bottom-left card: constrained width, anchored to the bottom-left. */
.tu-cmp-banner--bottom-left {
  right: auto;
  bottom: 20px;
  left: 20px;
  max-width: 480px;
  border-radius: var(--tu-cmp-radius-lg, 12px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
}

/* The full-width bottom bar keeps its default square bottom corners. */
.tu-cmp-banner--bar {
  border-radius: 0;
}

/* Corner cards align the footer links to the start/left. */
.tu-cmp-banner--bottom-right .tu-cmp-buttons,
.tu-cmp-banner--bottom-left .tu-cmp-buttons {
  justify-content: flex-start;
}

/* ════════════════════════════════════════════
   Banner Animations
   ════════════════════════════════════════════ */

@keyframes tu-cmp-slide-in {
  from {
    opacity: 0;
    transform: translateY(calc(100% + 24px));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tu-cmp-fade-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}

@keyframes tu-cmp-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tu-cmp-banner {
    animation: none;
    transform: none;
  }

  .tu-cmp-banner--fade-out {
    animation: none;
    opacity: 0;
  }

  .tu-cmp-withdraw {
    animation: none;
  }
}

.tu-cmp-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
}

.tu-cmp-content {
  flex: 1;
  min-width: 300px;
}

.tu-cmp-content p {
  margin: 0;
}

.tu-cmp-message p {
  margin: 0 0 8px;
}

.tu-cmp-message p:last-child {
  margin-bottom: 0;
}

.tu-cmp-content a,
.tu-cmp-message a {
  color: var(--tu-cmp-color-brand, #a41e35);
  text-decoration: underline;
}

.tu-cmp-dialog-intro .tu-cmp-policy-links {
  display: block;
  margin-top: 6px;
  font-size: 13px;
}

/* ════════════════════════════════════════════
   Withdrawal Link
   ════════════════════════════════════════════ */

.tu-cmp-withdraw {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 999998;
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid var(--tu-cmp-color-border-light, #eee);
  border-radius: var(--tu-cmp-radius-md, 4px);
  background: var(--tu-cmp-color-surface, #ffffff);
  color: var(--tu-cmp-color-text, #333);
  font-family: var(
    --tu-cmp-font-ui,
    "owners-text",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif
  );
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  cursor: pointer;
  animation: tu-cmp-fade-in 0.2s ease forwards;
}

.tu-cmp-withdraw:hover {
  background: var(--tu-cmp-color-surface-alt, #f2eee8);
}

.tu-cmp-withdraw:focus-visible {
  outline: 2px solid var(--tu-cmp-color-focus, #a41e35);
  outline-offset: 2px;
}

/* Floating button positions: bottom-right (default) or bottom-left. */
.tu-cmp-withdraw--bottom-right {
  right: 20px;
  left: auto;
}

.tu-cmp-withdraw--bottom-left {
  right: auto;
  left: 20px;
}

/* ════════════════════════════════════════════
   Buttons
   ════════════════════════════════════════════ */

.tu-cmp-buttons {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.tu-cmp-btn-group {
  display: flex;
  gap: 10px;
}

.tu-cmp-footer-links {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  font-size: 12px;
  line-height: 1.4;
  justify-content: flex-start;
  text-align: left;
}

.tu-cmp-footer-links a {
  color: var(--tu-cmp-color-brand, #a41e35);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tu-cmp-footer-links a:hover {
  color: var(--tu-cmp-color-brand-hover, #941b30);
  text-decoration: none;
}

.tu-cmp-footer-links a:focus-visible {
  outline: 2px solid var(--tu-cmp-color-focus, #a41e35);
  outline-offset: 2px;
  border-radius: 2px;
}

.tu-cmp-policy-sep {
  margin: 0 6px;
  color: #8c8f94;
  font-weight: 400;
  user-select: none;
}

.tu-cmp-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--tu-cmp-radius-md, 4px);
  font-size: 12px;
  font-weight: 700;
  font-family: var(
    --tu-cmp-font-button,
    "panel-sans-mono",
    "TU CMP Roboto Mono",
    "SFMono-Regular",
    Consolas,
    Menlo,
    "Courier New",
    monospace
  );
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.1s ease;
}

.tu-cmp-btn:active {
  transform: scale(0.96);
}

.tu-cmp-btn:focus-visible {
  outline: 2px solid var(--tu-cmp-color-focus, #a41e35);
  outline-offset: 2px;
}

.tu-cmp-btn-accept,
.tu-cmp-btn-save,
.tu-cmp-btn-ok {
  background: var(--tu-cmp-color-brand, #a41e35);
  color: var(--tu-cmp-color-text-inverse, #ffffff);
  border: 1px solid var(--tu-cmp-color-brand, #a41e35);
}

.tu-cmp-btn-accept:hover,
.tu-cmp-btn-save:hover,
.tu-cmp-btn-ok:hover {
  background: var(--tu-cmp-color-brand-hover, #941b30);
}

.tu-cmp-btn-reject {
  background: #000000;
  color: var(--tu-cmp-color-text-inverse, #ffffff);
  border: 1px solid #000000;
}

.tu-cmp-btn-reject:hover {
  background: #2b2b2b;
  border-color: #2b2b2b;
}

.tu-cmp-btn-cancel {
  background: transparent;
  color: var(--tu-cmp-color-text, #333);
  border: 1px solid var(--tu-cmp-color-border, #bca685);
}

.tu-cmp-btn-cancel:hover {
  background: var(--tu-cmp-color-surface-alt, #f2eee8);
}

/* ════════════════════════════════════════════
   Dialog (Preferences Panel)
   ════════════════════════════════════════════ */

.tu-cmp-dialog {
  width: 90%;
  max-width: 480px;
  margin: auto;
  padding: 0;
  border: none;
  border-radius: var(--tu-cmp-radius-md, 4px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-family: var(
    --tu-cmp-font-ui,
    "owners-text",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif
  );
  font-weight: 400;
}

.tu-cmp-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.tu-cmp-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 20px 0 20px;
  border-bottom: 1px solid var(--tu-cmp-color-border-light, #eee);
}

.tu-cmp-dialog-header h2 {
  margin: 0 0 10px 0;
  font-family: var(
    --tu-cmp-font-heading,
    "pennypacker-compressed",
    "TU CMP Roboto Condensed",
    "Arial Narrow",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif
  );
  font-size: 18px;
  font-weight: 700;
  color: var(--tu-cmp-color-heading, #222);
}

.tu-cmp-dialog-close {
  padding: 0;
  border: none;
  background: none;
  color: var(--tu-cmp-color-text-muted, #666);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.tu-cmp-dialog-close:hover {
  color: var(--tu-cmp-color-text, #333);
}

.tu-cmp-dialog-close:focus-visible {
  outline: 2px solid var(--tu-cmp-color-focus, #a41e35);
  outline-offset: 2px;
  border-radius: 2px;
}

.tu-cmp-dialog-body {
  padding: 20px;
}

.tu-cmp-dialog-intro {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--tu-cmp-color-text-muted, #666);
}

.tu-cmp-dialog-policy-links {
  font-size: 13px;
  line-height: 1.4;
}

.tu-cmp-dialog-policy-links a {
  color: var(--tu-cmp-color-brand, #a41e35);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tu-cmp-dialog-policy-links a:hover {
  color: var(--tu-cmp-color-brand-hover, #941b30);
  text-decoration: none;
}

/* ════════════════════════════════════════════
   GPC Badge
   ════════════════════════════════════════════ */

.tu-cmp-gpc-badge {
  display: inline-block;
  padding: 6px 12px;
  margin-bottom: 8px;
  background: var(--tu-cmp-color-info, #ceecf9);
  color: var(--tu-cmp-color-heading, #222);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--tu-cmp-radius-sm, 2px);
}

.tu-cmp-gpc-notice {
  margin: 0 0 16px;
  font-family: var(
    --tu-cmp-font-ui,
    "owners-text",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif
  );
  color: var(--tu-cmp-color-text-muted, #666);
  font-size: 13px;
  display: block;
}

/* ════════════════════════════════════════════
   Preference Items
   ════════════════════════════════════════════ */

.tu-cmp-preference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--tu-cmp-color-border-light, #eee);
}

.tu-cmp-preference:last-child {
  border-bottom: none;
}

.tu-cmp-preference-label {
  flex: 1;
}

.tu-cmp-preference-label label {
  display: block;
  cursor: pointer;
}

.tu-cmp-preference-label strong {
  display: block;
  font-family: var(
    --tu-cmp-font-heading,
    "pennypacker-compressed",
    "TU CMP Roboto Condensed",
    "Arial Narrow",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif
  );
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--tu-cmp-color-heading, #222);
}

.tu-cmp-preference-label span {
  font-family: var(
    --tu-cmp-font-ui,
    "owners-text",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif
  );
  color: var(--tu-cmp-color-text-muted, #666);
  font-size: 13px;
  display: block;
}

/* ════════════════════════════════════════════
   Toggle Switches
   ════════════════════════════════════════════ */

.tu-cmp-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.tu-cmp-toggle input {
  width: 0;
  height: 0;
  opacity: 0;
}

.tu-cmp-toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background-color: var(--tu-cmp-color-track, #ccc);
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.tu-cmp-toggle-slider::before {
  position: absolute;
  bottom: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--tu-cmp-color-surface, #ffffff);
  content: "";
  transition: transform 0.3s ease;
}

.tu-cmp-toggle input:checked + .tu-cmp-toggle-slider {
  background-color: var(--tu-cmp-color-brand, #a41e35);
}

.tu-cmp-toggle input:checked + .tu-cmp-toggle-slider::before {
  transform: translateX(24px);
}

.tu-cmp-toggle input:focus-visible + .tu-cmp-toggle-slider {
  outline: 2px solid var(--tu-cmp-color-focus, #a41e35);
  outline-offset: 2px;
}

.tu-cmp-toggle--disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tu-cmp-toggle--disabled .tu-cmp-toggle-slider {
  background-color: var(--tu-cmp-color-brand, #a41e35);
}

.tu-cmp-toggle--disabled .tu-cmp-toggle-slider::before {
  transform: translateX(24px);
}

/* GPC-locked marketing toggle: visibly disabled + non-interactive. */
.tu-cmp-toggle--gpc-locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.tu-cmp-toggle--gpc-locked .tu-cmp-toggle-slider {
  background-color: var(--tu-cmp-color-track-locked, #8c8f94);
  cursor: not-allowed;
}

.tu-cmp-toggle input:disabled + .tu-cmp-toggle-slider {
  cursor: not-allowed;
}

.tu-cmp-toggle input:disabled:focus-visible + .tu-cmp-toggle-slider {
  outline-style: dashed;
}

/* Inline explanation shown under the marketing label when GPC locks it. */
.tu-cmp-gpc-note {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  color: var(--tu-cmp-color-text-muted, #666);
}

.tu-cmp-gpc-note[hidden] {
  display: none;
}

/* ════════════════════════════════════════════
   Dialog Footer
   ════════════════════════════════════════════ */

.tu-cmp-dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--tu-cmp-color-border-light, #eee);
}

/* ════════════════════════════════════════════
   Consent ID Display
   ════════════════════════════════════════════ */

.tu-cmp-dialog-consent-id {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 20px 12px;
  font-size: 11px;
  color: var(--tu-cmp-color-text-muted, #666);
}

.tu-cmp-dialog-consent-id code {
  font-family: var(
    --tu-cmp-font-mono,
    "panel-sans-mono",
    "TU CMP Roboto Mono",
    "SFMono-Regular",
    Consolas,
    Menlo,
    "Courier New",
    monospace
  );
  font-size: 10px;
  color: var(--tu-cmp-color-text-muted, #666);
  background: var(--tu-cmp-color-surface-alt, #f2eee8);
  padding: 2px 6px;
  border-radius: 3px;
}

/* ════════════════════════════════════════════
   Responsive
   ════════════════════════════════════════════ */

@media (max-width: 600px) {
  .tu-cmp-container {
    flex-direction: column;
    align-items: stretch;
  }

  .tu-cmp-content {
    min-width: auto;
  }

  .tu-cmp-buttons {
    justify-content: center;
    align-items: center;
  }

  /* Corner cards center the footer links on small screens. */
  .tu-cmp-banner--bottom-right .tu-cmp-buttons,
  .tu-cmp-banner--bottom-left .tu-cmp-buttons {
    align-items: center;
  }

  .tu-cmp-btn-group {
    width: 100%;
    justify-content: center;
  }

  .tu-cmp-buttons .tu-cmp-btn {
    flex: 1;
    text-align: center;
  }

  .tu-cmp-footer-links {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .tu-cmp-dialog {
    width: 95%;
    max-width: none;
  }

  /* On small screens, corner cards expand to fill the width. */
  .tu-cmp-banner--bottom-right,
  .tu-cmp-banner--bottom-left {
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .tu-cmp-banner--float {
    right: 12px;
    left: 12px;
  }
}

/* ════════════════════════════════════════════
   Embed / Video Consent Placeholder
   ════════════════════════════════════════════ */

.tu-cmp-embed-placeholder {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  /* Modern dark gate: layered pure-CSS gradients — a stronger brand-cherry
     glow top left, a faint cool fill light bottom right, over a deep angled
     red-to-black base — so the placeholder reads as an intentional media
     gate rather than a broken image. No image is ever requested from
     third-party CDNs before consent. */
  background:
    radial-gradient(
      140% 110% at 10% 6%,
      rgba(164, 30, 53, 0.55) 0%,
      rgba(164, 30, 53, 0.18) 45%,
      rgba(164, 30, 53, 0) 70%
    ),
    radial-gradient(
      100% 100% at 88% 92%,
      rgba(96, 140, 190, 0.14) 0%,
      rgba(96, 140, 190, 0) 52%
    ),
    linear-gradient(135deg, #2e1318 0%, #1a1013 40%, #0a0a0d 100%);
  border-radius: var(--tu-cmp-radius-embed, 6px);
  overflow: hidden;
  box-sizing: border-box;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 -24px 48px rgba(0, 0, 0, 0.45);
}

/* Faint dot-matrix texture over the gate — pure CSS, fading toward the
   edges so the consent card stays the focal point. */
.tu-cmp-embed-placeholder::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(
    rgba(255, 255, 255, 0.09) 1px,
    transparent 1.5px
  );
  background-size: 18px 18px;
  -webkit-mask-image: radial-gradient(
    90% 90% at 50% 50%,
    #000 30%,
    transparent 100%
  );
  mask-image: radial-gradient(90% 90% at 50% 50%, #000 30%, transparent 100%);
  pointer-events: none;
}

/* Compatibility with WordPress responsive embed wrapper.
   Only video embeds (wp-has-aspect-ratio) get the padding-top wrapper that
   gives the wrapper height — and core only provides that height when the
   theme opts in (body.wp-embed-responsive). Non-video embeds (SoundCloud,
   Spotify, Twitter, Instagram, etc.) and themes without the body class have
   no intrinsic wrapper height, so the placeholder must stay in normal flow
   with its own aspect-ratio or it collapses to 0px. */
body.wp-embed-responsive .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper
  > .tu-cmp-embed-placeholder,
body.wp-embed-responsive
  .wp-has-aspect-ratio
  .wp-block-embed__wrapper
  > .tu-cmp-embed-placeholder {
  position: absolute;
  inset: 0;
  height: 100%;
  aspect-ratio: auto;
}

/* Classic-era responsive wrappers: older markup (and classic themes) carry
   wp-embed-aspect-{ratio} without the newer wp-has-aspect-ratio class, and
   reserve the video box with a ::before padding-top hack
   (.wp-embed-aspect-16-9 .wp-block-embed__wrapper::before { padding-top:
   56.25% }). A video placeholder left in-flow there sizes the box twice —
   its own 16/9 ratio plus the ::before padding — leaving a large whitespace
   gap, so it must fill the wrapper absolutely just like above. Flow
   placeholders (audio/social) are excluded via :not() and stay in-flow. */
body.wp-embed-responsive .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper
  > .tu-cmp-embed-placeholder:not(.tu-cmp-embed--flow) {
  position: absolute;
  inset: 0;
  height: 100%;
  aspect-ratio: auto;
}

/* Flow placeholders (audio players, tweets, Instagram, TikTok) never take
   the 16/9 video box — in block context there is no classic wrapper to
   carry sizing, so the placeholder itself flows with a min-height matching
   the player's height (inlined by EmbedBlocker). Without this rule the base
   16/9 aspect-ratio above (plus any aspect-ratio wrapper) leaves a large
   whitespace gap under short embeds such as SoundCloud/Spotify. */
.tu-cmp-embed-placeholder.tu-cmp-embed--flow:not(.tu-cmp-embed--classic) {
  position: relative;
  aspect-ratio: auto;
}

/* A flow placeholder inside a video-ratio wrapper must stay in-flow even
   when the theme opts into responsive embeds: higher specificity than the
   absolute-fill rule above so audio/social gates never escape flow. */
body.wp-embed-responsive .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper
  > .tu-cmp-embed-placeholder.tu-cmp-embed--flow,
body.wp-embed-responsive
  .wp-has-aspect-ratio
  .wp-block-embed__wrapper
  > .tu-cmp-embed-placeholder.tu-cmp-embed--flow {
  position: relative;
  inset: auto;
  height: auto;
  aspect-ratio: auto;
}

/* Restored flow iframes (audio/social) size to their own height. When the
   surrounding block still enforces a video aspect ratio, relax it so no
   whitespace gap remains under the player after consent. */
.wp-block-embed__wrapper > iframe[data-tu-cmp-unblocked][data-flow="true"] {
  aspect-ratio: auto;
}

/* Flow embeds must never reserve a video box via core's ::before
   padding-top hack (e.g. .wp-embed-aspect-21-9 .wp-block-embed__wrapper::before
   { padding-top: 42.85% } plus .wp-has-aspect-ratio …::before { padding-top:
   50% }). Core assigns those aspect classes even to fixed-height audio
   embeds such as Spotify, so the reserved padding stacks on top of the
   in-flow 152px gate and leaves a large whitespace gap. EmbedBlocker strips
   the aspect classes server-side and tags the figure .tu-cmp-flow-embed —
   kill the reserved box there. The :has() rules below cover cached markup
   rendered before the marker shipped (direct flow placeholder, nested
   classic flow wrapper, or restored flow iframe inside the wrapper). */
body.wp-embed-responsive .wp-block-embed.tu-cmp-flow-embed
  .wp-block-embed__wrapper::before,
body.wp-embed-responsive
  .wp-block-embed.tu-cmp-flow-embed
  .wp-block-embed__wrapper::after {
  content: none !important;
  display: none !important;
  padding-top: 0 !important;
}

body.wp-embed-responsive
  .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper:has(
    > .tu-cmp-embed-placeholder.tu-cmp-embed--flow
  )::before,
body.wp-embed-responsive
  .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper:has(> .tu-cmp-classic-embed--flow)::before,
body.wp-embed-responsive
  .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper:has(
    > iframe[data-tu-cmp-unblocked][data-flow="true"]
  )::before,
body.wp-embed-responsive
  .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper:has(
    > .tu-cmp-embed-placeholder.tu-cmp-embed--flow
  )::before,
body.wp-embed-responsive
  .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper:has(> .tu-cmp-classic-embed--flow)::before,
body.wp-embed-responsive
  .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper:has(
    > iframe[data-tu-cmp-unblocked][data-flow="true"]
  )::before {
  content: none !important;
  display: none !important;
  padding-top: 0 !important;
}

/* ════════════════════════════════════════════
   Classic (non-block) embeds — in-flow sizing
   ════════════════════════════════════════════
   Classic oEmbed / raw <iframe> embeds have no
   .wp-block-embed__wrapper sized ancestor. On classic themes
   body.wp-embed-responsive provides no padding-top wrapper for bare
   iframes, so the server wraps the placeholder in .tu-cmp-classic-embed,
   which carries the intrinsic ratio (mirroring the block wrapper for FSE
   themes) and persists after consent as the restored iframe's sized
   ancestor. The wrapper is always in-flow (position: relative), so neither
   the placeholder nor the restored iframe can escape flow and overlap page
   content. Original iframe dimensions are preserved via
   --tu-cmp-embed-ratio so 4:3, 21:9, and vertical Shorts keep their shape;
   audio/social embeds use the --flow variant (content height, min-height). */

.tu-cmp-classic-embed {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
  border-radius: var(--tu-cmp-radius-embed, 6px);
  box-sizing: border-box;
  isolation: isolate;
}

/* Video classic: wrapper carries the intrinsic ratio. */
.tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow) {
  aspect-ratio: var(--tu-cmp-embed-ratio, 16 / 9);
  min-height: 240px;
}

/* Video classic placeholder fills its wrapper (never the page). */
.tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow)
> .tu-cmp-embed-placeholder.tu-cmp-embed--classic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
}

/* Flow classic (audio players, tweets, Instagram, TikTok): content height. */
.tu-cmp-classic-embed--flow {
  aspect-ratio: auto;
}

.tu-cmp-classic-embed--flow > .tu-cmp-embed-placeholder.tu-cmp-embed--classic {
  position: relative;
  inset: auto;
  width: 100%;
  aspect-ratio: auto;
}

/* Restored classic iframe keeps the wrapper's box (video: fill). */
.tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow)
> iframe[data-tu-cmp-unblocked],
.tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow) > iframe[data-category] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: 100%;
  border: 0;
}

/* Restored classic iframe (flow): full width, own height. */
.tu-cmp-classic-embed--flow > iframe[data-tu-cmp-unblocked],
.tu-cmp-classic-embed--flow > iframe[data-category] {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
}

/* Classic themes add wp-embed-responsive to <body> to opt into responsive
   embeds. Re-assert our in-flow box there at higher specificity so theme or
   core `.wp-has-aspect-ratio iframe { position: absolute }` rules written
   for block wrappers cannot pull the bare classic placeholder/iframe out of
   flow against the wrong ancestor. */
body.wp-embed-responsive .tu-cmp-classic-embed {
  position: relative;
  width: 100%;
  max-width: 100%;
}

body.wp-embed-responsive
  .tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow) {
  aspect-ratio: var(--tu-cmp-embed-ratio, 16 / 9);
}

body.wp-embed-responsive
  .tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow)
  > .tu-cmp-embed-placeholder.tu-cmp-embed--classic {
  position: absolute;
  inset: 0;
  height: 100%;
}

/* wpautop wraps raw classic iframes in <p>, leaving
   <p><div class="tu-cmp-classic-embed">…</div></p> (div-in-p). Collapse the
   empty paragraph box so it contributes no extra gap around the embed. */
p:has(> .tu-cmp-classic-embed),
p:has(> .tu-cmp-embed-placeholder) {
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;
}

/* Restored block iframe outside an aspect-ratio wrapper keeps full width. */
.wp-block-embed__wrapper > iframe[data-tu-cmp-unblocked] {
  width: 100%;
  max-width: 100%;
}

/* Restored video iframe inside a classic-era aspect wrapper must fill the
   ::before-reserved box (mirroring the placeholder rule above) instead of
   stacking in-flow on top of it — otherwise the same whitespace gap returns
   after consent on themes that ship only the padding half of the hack.
   Flow restores (audio/social) are excluded; they size to their own height
   after the JS strips the wrapper's aspect classes. */
body.wp-embed-responsive .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper
  > iframe[data-tu-cmp-unblocked]:not([data-flow="true"]) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Nested classic-in-block: the block's inner oEmbed HTML is gated first
   (classic context), then the block-level filter sees the placeholder and
   bails — leaving a .tu-cmp-classic-embed wrapper nested directly inside
   .wp-block-embed__wrapper (as with YouTube oEmbed 500x281 above). Under a
   responsive aspect wrapper the ::before padding already reserves the video
   box, so the nested wrapper must fill it absolutely instead of adding its
   own in-flow ratio box on top (which doubles the height). The inline
   aspect-ratio style goes inert once offsets + height are all definite, and
   min-height is reset so short boxes (narrow screens) cannot overflow the
   reserved box. The wrapper persists after consent, so the restored iframe
   keeps the same box. Flow (audio/social) nests stay in-flow. */
body.wp-embed-responsive .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper,
body.wp-embed-responsive
  .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper {
  position: relative;
}

body.wp-embed-responsive
  .wp-block-embed[class*="wp-embed-aspect-"]
  .wp-block-embed__wrapper
  > .tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow),
body.wp-embed-responsive
  .wp-block-embed.wp-has-aspect-ratio
  .wp-block-embed__wrapper
  > .tu-cmp-classic-embed:not(.tu-cmp-classic-embed--flow) {
  position: absolute;
  inset: 0;
  height: 100%;
  min-height: 0;
  aspect-ratio: auto;
}

.tu-cmp-embed-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  box-sizing: border-box;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.tu-cmp-embed-card {
  max-width: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #ffffff;
}

.tu-cmp-embed-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tu-cmp-embed-icon svg {
  width: 48px;
  height: 48px;
  fill: currentColor;
  flex-shrink: 0;
}

.tu-cmp-embed-placeholder:hover .tu-cmp-embed-icon {
  transform: scale(1.1);
}

.tu-cmp-embed-text {
  margin: 0;
  font-family: var(
    --tu-cmp-font-ui,
    "owners-text",
    "TU CMP Roboto",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Helvetica,
    Arial,
    sans-serif
  );
  font-size: 15px;
  line-height: 1.45;
  color: #ffffff;
}

.tu-cmp-embed-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

/* Audio/social placeholders (Spotify, SoundCloud, tweets, etc.) often have
   a much smaller in-flow box than video embeds. Give the action buttons
   extra vertical breathing room so the gate never feels cramped. */
.tu-cmp-embed--flow .tu-cmp-embed-actions {
  padding-top: 8px;
  padding-bottom: 4px;
}

.tu-cmp-embed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--tu-cmp-radius-md, 4px);
  font-family: var(
    --tu-cmp-font-button,
    "panel-sans-mono",
    "TU CMP Roboto Mono",
    "SFMono-Regular",
    Consolas,
    Menlo,
    "Courier New",
    monospace
  );
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    transform 0.1s ease;
}

.tu-cmp-embed-btn:active {
  transform: scale(0.96);
}

.tu-cmp-embed-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
  border-radius: var(--tu-cmp-radius-md, 4px);
}

.tu-cmp-embed-btn--primary {
  background: #ffffff;
  color: #1a1013;
  border-color: #ffffff;
}

.tu-cmp-embed-btn--primary:hover {
  background: #f2eee8;
  border-color: #f2eee8;
  color: #1a1013;
}

.tu-cmp-embed-btn--secondary {
  background: transparent;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.55);
}

.tu-cmp-embed-btn--secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.8);
  color: #ffffff;
}

.tu-cmp-embed-external-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: currentColor;
}

/* Legacy inline link styles: kept for backwards compatibility with cached
   placeholders and externally-injected test markup that still renders the
   consent gate as a single paragraph. The :not() exclusion prevents these
   declarations from overriding the new .tu-cmp-embed-btn styles on updated
   placeholders that also carry the legacy class names. */
.tu-cmp-embed-card .tu-cmp-embed-consent-link:not(.tu-cmp-embed-btn),
.tu-cmp-embed-card .tu-cmp-embed-external-link:not(.tu-cmp-embed-btn) {
  color: #ffffff;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
  font-weight: 600;
  transition:
    color 0.15s ease,
    opacity 0.15s ease;
  cursor: pointer;
}

.tu-cmp-embed-card .tu-cmp-embed-consent-link:not(.tu-cmp-embed-btn):hover,
.tu-cmp-embed-card .tu-cmp-embed-external-link:not(.tu-cmp-embed-btn):hover {
  color: #ffcccc;
  opacity: 0.95;
}

.tu-cmp-embed-card
  .tu-cmp-embed-consent-link:not(.tu-cmp-embed-btn):focus-visible,
.tu-cmp-embed-card
  .tu-cmp-embed-external-link:not(.tu-cmp-embed-btn):focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
  border-radius: 2px;
}

.tu-cmp-embed-sep {
  margin: 0 4px;
  opacity: 0.7;
}
