/**
 * TU Consent Manager — Banner Styles
 *
 * Mirrors the TuCookieBanner web component visual design while consuming
 * Temple University design tokens (--tu-*) for brand consistency.
 *
 * @package Temple\Plugin\ConsentManager
 */

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

.tu-cmp-banner {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 999999;
  font-family: var(
    --tu-font-ui,
    "owners-text",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif
  );
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--tu-color-text, #333);
  background: var(--tu-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-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-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-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-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-color-border-light, #dad7d1);
  border-radius: var(--tu-radius-md, 4px);
  background: var(--tu-color-surface, #ffffff);
  color: var(--tu-color-text, #333);
  font-family: var(
    --tu-font-ui,
    "owners-text",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    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-color-surface-alt, #f2eee8);
}

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

/* ════════════════════════════════════════════
   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-color-brand, #a41e35);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.tu-cmp-footer-links a:focus-visible {
  outline: 2px solid var(--tu-color-border-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-radius-md, 4px);
  font-size: 12px;
  font-weight: 700;
  font-family: var(
    --tu-font-button,
    "panel-sans-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-color-border-focus, #a41e35);
  outline-offset: 2px;
}

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

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

.tu-cmp-btn-reject {
  background: #000000;
  color: var(--tu-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-color-text, #333);
  border: 1px solid var(--tu-color-border, #bca685);
}

.tu-cmp-btn-cancel:hover {
  background: var(--tu-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-radius-md, 4px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-family: var(
    --tu-font-ui,
    "owners-text",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    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-color-border-light, #eee);
}

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

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

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

.tu-cmp-dialog-close:focus-visible {
  outline: 2px solid var(--tu-color-border-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.45;
  color: var(--tu-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-color-brand, #a41e35);
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

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

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

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

.tu-cmp-preference {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--tu-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-font-heading,
    "pennypacker-compressed",
    "Arial Narrow",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif
  );
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 4px;
  color: var(--tu-color-text, #222);
}

.tu-cmp-preference-label span {
  font-family: var(
    --tu-font-ui,
    "owners-text",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif
  );
  color: var(--tu-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-color-border, #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-color-surface, #fff);
  content: "";
  transition: transform 0.3s ease;
}

.tu-cmp-toggle input:checked + .tu-cmp-toggle-slider {
  background-color: var(--tu-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-color-border-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-color-brand, #a41e35);
}

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

/* ════════════════════════════════════════════
   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-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-color-text-muted, #888);
}

.tu-cmp-dialog-consent-id code {
  font-family: var(
    --tu-font-mono,
    "SFMono-Regular",
    Consolas,
    Menlo,
    "Courier New",
    monospace
  );
  font-size: 10px;
  color: var(--tu-color-text-muted, #999);
  background: var(--tu-color-surface-alt, #f5f5f5);
  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;
  /* Neutral dark box: a subtle radial gradient so the placeholder reads as an
     intentional video gate rather than a broken image. No image is ever
     requested from Google's image CDN before consent. */
  background: radial-gradient(
    ellipse at center,
    #1c1c1c 0%,
    #111111 65%,
    #0d0d0d 100%
  );
  border-radius: var(--tu-radius-md, 6px);
  overflow: hidden;
  box-sizing: border-box;
}

/* Compatibility with WordPress responsive embed wrapper */
.wp-block-embed.wp-has-aspect-ratio .tu-cmp-embed-placeholder,
.wp-embed-responsive .tu-cmp-embed-placeholder {
  position: absolute;
  inset: 0;
  height: 100%;
  aspect-ratio: auto;
}

.tu-cmp-embed-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  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: 440px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: #ffffff;
}

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

.tu-cmp-embed-icon svg path:first-child,
.tu-cmp-embed-icon svg circle,
.tu-cmp-embed-icon svg rect {
  fill: var(--tu-color-cherry, #990000);
}

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

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

.tu-cmp-embed-consent-link {
  color: #ffffff !important;
  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-consent-link:hover {
  color: #ffcccc !important;
  opacity: 0.95;
}

.tu-cmp-embed-consent-link:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 4px;
  border-radius: 2px;
}
