/* House ad banner: one slim row under the header. Slides stack in a single grid cell so the
   banner is always as tall as its tallest slide and never jumps while rotating. */
.ad {
  position: relative;
  display: grid;
  margin: -14px 0 18px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface) 40%);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow-x: clip;   /* hides the sideways travel; overflow-y stays visible for the QR popover */
  --ad-dx: 48px;      /* where inactive slides wait (flips to the left when going back) */
}
.ad.is-back { --ad-dx: -48px; }

.ad__slide {
  grid-area: 1 / 1;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 3px 12px 3px 3px;
}
.ad__media { flex: none; display: block; line-height: 0; }
.ad__media img { width: 118px; height: 58px; border-radius: 7px; object-fit: cover; display: block; }
.ad__text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; color: var(--text); }
.ad__text:hover { text-decoration: none; color: var(--text); }
.ad__text strong { font-size: 15px; line-height: 1.25; }
.ad__text span { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad__text:hover strong { color: var(--accent); }

.ad__btn {
  flex: none;
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
}
.ad__btn:hover { background: var(--accent-hover); color: var(--on-accent); text-decoration: none; }
.ad__btn-short { display: none; }

/* Secondary "Our apps" button next to the Play button. */
.ad__more {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}
.ad__more:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* QR popover: costs no vertical space; desktop (hover-capable) only. */
.ad__qr { position: relative; flex: none; }
.ad__qrbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
  background: transparent;
}
.ad__pop {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  width: 184px;
  padding: 10px;
  text-align: center;
  color: #111;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(23, 36, 47, 0.35), 0 0 0 1px var(--border);
}
.ad__pop img { display: block; width: 164px; height: 164px; margin: 0 auto 6px; }
.ad__pop small { display: block; font-size: 11.5px; line-height: 1.35; color: #333; }
.ad__qr:hover .ad__pop, .ad__qr:focus-within .ad__pop { display: block; }

/* ---------- Carousel ---------- */
/* Waiting slides sit off to the side, invisible. Default state has no transition so a slide
   that has finished leaving snaps back to the waiting spot unseen. */
.ad--rotating .ad__slide {
  opacity: 0;
  visibility: hidden;
  transform: translateX(var(--ad-dx));
}
/* Entering: slide in and fade up, slightly after the old slide starts to leave. */
.ad--rotating .ad__slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s ease 0.12s, visibility 0s;
}
/* Leaving: drift the opposite way while fading quickly, then hide. */
.ad--rotating .ad__slide.is-out {
  transform: translateX(calc(var(--ad-dx) * -1));
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.6, 1), opacity 0.28s ease, visibility 0s linear 0.6s;
}
/* Fade-only variant (ADS_TRANSITION=fade). */
.ad--fade .ad__slide, .ad--fade .ad__slide.is-active, .ad--fade .ad__slide.is-out { transform: none; }
.ad--fade .ad__slide.is-active { transition: opacity 0.6s ease, visibility 0s; }
.ad--fade .ad__slide.is-out { transition: opacity 0.6s ease, visibility 0s linear 0.6s; }

/* Position dots, overlaid on the thumbnail so they add no height. */
.ad__dots {
  position: absolute;
  left: 3px;
  bottom: 5px;
  width: 118px;
  display: flex;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}
.ad__dot {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  cursor: pointer;
}
.ad__dot::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
  transition: width 0.25s ease, background 0.25s ease;
}
.ad__dot:hover::before { background: #fff; }
.ad__dot.is-active::before { width: 12px; background: #fff; }
.ad__dot:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 4px; }

/* Hairline that fills over one interval, so it's clear a change is coming. */
.ad__progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 100%;
  background: var(--accent);
  opacity: 0.65;
  transform: scaleX(0);
  transform-origin: left;
}
@keyframes ad-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (hover: none), (max-width: 760px) {
  .ad__qr { display: none; }
}
@media (max-width: 560px) {
  .ad { margin-top: -18px; }
  .ad__slide { gap: 10px; min-height: 52px; padding-right: 8px; }
  .ad__media img { width: 86px; height: 42px; }
  .ad__dots { width: 86px; bottom: 3px; }
  .ad__dot { width: 12px; height: 12px; }
  .ad__text strong { font-size: 14px; }
  .ad__text span { font-size: 12px; }
  .ad__btn { padding: 7px 12px; }
  .ad__more { padding: 8px 9px; }
  .ad__more span { display: none; }
  .ad__btn-long { display: none; }
  .ad__btn-short { display: inline; }
}
/* No movement for people who ask for less: plain quick fades (and the script won't auto-rotate). */
@media (prefers-reduced-motion: reduce) {
  .ad--rotating .ad__slide, .ad--rotating .ad__slide.is-active, .ad--rotating .ad__slide.is-out { transform: none; }
  .ad--rotating .ad__slide.is-active { transition: opacity 0.2s ease, visibility 0s; }
  .ad--rotating .ad__slide.is-out { transition: opacity 0.2s ease, visibility 0s linear 0.2s; }
  .ad__dot::before { transition: none; }
}
@media print { .ad { display: none; } }
