/* ============================================================================
   University of Michigan Athletics — preroll ad state
   Loads after css/player.css and inherits its custom properties.

   Audio creative (the usual case for this player):
     .preroll-ad-wrapper.preroll-audio-mode renders as the same pill as the
     other states — pulse dot, "Advertisement", then Learn More / Skip on the
     right. The pill chrome itself is defined once in player.css.

   Video creative (possible when a tag offers no audio media file):
     the wrapper leaves the pill and becomes a rounded 16:9 panel with the
     badge and buttons in its corners.
   ============================================================================ */

/* =====================================================
   AUDIO CREATIVE — inline pill row
   ===================================================== */

/* Keep the media element live but out of sight. */
.preroll-audio-mode .preroll-ad-video {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

/* Maize pulse dot, centered in the same lane the round play button occupies
   in the other states, so the left text edge never shifts between states. */
.preroll-audio-mode::before {
  content: '';
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  margin: 0 calc((var(--control-size) - 14px) / 2);
  background: var(--um-maize);
  border-radius: 50%;
  box-shadow: 0 0 12px rgba(255, 203, 5, 0.55);
  animation: audio-pulse 1.6s ease-in-out infinite;
}

@keyframes audio-pulse {
  0%, 100% { transform: scale(1);    opacity: 0.7; }
  50%      { transform: scale(1.25); opacity: 1; }
}

/* In audio mode the overlay is not an overlay at all — it is the pill's
   content row. */
.preroll-audio-mode .preroll-ad-overlay {
  position: static;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.preroll-audio-mode .preroll-ad-badge {
  margin-right: auto;   /* pushes Learn More / Skip to the right edge */
  background: none;
  padding: 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================================================
   VIDEO CREATIVE — rounded panel
   ===================================================== */
.preroll-ad-wrapper:not(.preroll-audio-mode) {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 200px;           /* fallback where aspect-ratio is unsupported */
  background: #000;            /* video letterbox */
  border: 1px solid var(--pill-border);
  border-radius: 16px;
  box-shadow: var(--pill-shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-ad-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-ad-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-ad-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 39, 76, 0.85);
  color: var(--um-white);
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-skip-button {
  position: absolute;
  bottom: 12px;
  right: 12px;
}

.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-learn-more {
  position: absolute;
  bottom: 12px;
  left: 12px;
}

/* =====================================================
   SKIP BUTTON — both modes
   The entry animation fades opacity only. Animating `transform` here would
   win over the :hover and :active transforms below for the life of the
   element, because animation-fill-mode: forwards outranks normal declarations.
   ===================================================== */
.preroll-skip-button {
  order: 2;                    /* after Learn More in the pill row */
  flex-shrink: 0;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-ui);
  white-space: nowrap;
  cursor: default;
  border-radius: 999px;
  pointer-events: auto;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease,
              transform 0.2s ease, box-shadow 0.3s ease;
  opacity: 0;
  animation: preroll-fade-in 0.4s ease 0.5s forwards;
}

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

/* Ready to skip: blue-on-maize, an approved accessible pairing. */
.preroll-skip-button.preroll-skip-ready {
  background: var(--um-maize);
  color: var(--um-blue);
  border-color: transparent;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(255, 203, 5, 0.35);
}

.preroll-skip-button.preroll-skip-ready:hover,
.preroll-skip-button.preroll-skip-ready:focus-visible {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 0 0 4px rgba(255, 203, 5, 0.25), 0 4px 14px rgba(0, 0, 0, 0.35);
  outline: none;
}

.preroll-skip-button.preroll-skip-ready:active {
  transform: translateY(0);
}

/* =====================================================
   LEARN MORE — both modes
   ===================================================== */
.preroll-learn-more {
  order: 1;
  flex-shrink: 0;
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  white-space: nowrap;
  border-radius: 999px;
  pointer-events: auto;
  transition: color 0.2s ease, background 0.2s ease;
  opacity: 0;
  animation: preroll-fade-in 0.4s ease 0.3s forwards;
}

.preroll-learn-more:hover,
.preroll-learn-more:focus-visible {
  color: var(--um-white);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

/* In the video panel the transparent treatments need a scrim to stay legible
   over arbitrary creative. */
.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-skip-button,
.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-learn-more {
  background: rgba(0, 39, 76, 0.85);
  color: var(--um-white);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.preroll-ad-wrapper:not(.preroll-audio-mode) .preroll-skip-button.preroll-skip-ready {
  background: var(--um-maize);
  color: var(--um-blue);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 480px) {
  /* "Advertisement" (set by preroll-manager.js) crowds the pill on phones.
     Swap the visible text for "Ad" without touching the lib; assistive tech
     still reads the full DOM text. */
  .preroll-audio-mode .preroll-ad-badge {
    font-size: 0;
  }

  .preroll-audio-mode .preroll-ad-badge::before {
    content: 'Ad';
    font-size: 12px;
    letter-spacing: 0.06em;
  }

  .preroll-skip-button,
  .preroll-learn-more {
    padding: 8px 12px;
    font-size: 12px;
  }

  .preroll-learn-more {
    padding: 8px 8px;
  }
}

/* Below 360px the row cannot hold the disclosure badge, Learn More, and Skip.
   Learn More is the supplementary control, so it yields; the "Ad" disclosure
   and the Skip button always survive. */
@media (max-width: 359px) {
  .preroll-audio-mode .preroll-learn-more {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preroll-audio-mode::before {
    animation: none;
  }

  .preroll-skip-button,
  .preroll-learn-more {
    animation: none;
    opacity: 1;
    transition: none;
  }
}
