/*
 * YTHS Popup — popup.css
 * WCAG 2.1 AA compliant
 * Colors: #0e2f5e (navy), #8b0fb8 (purple), #00857d (teal)
 */

/* ── Custom properties ─────────────────────────────────────── */
:root {
  --yths-navy:   #0e2f5e;
  --yths-purple: #8b0fb8;
  --yths-teal:   #00857d;
  --yths-white:  #ffffff;
  --yths-light:  #f4f6fb;
  --yths-text:   #1a1a1a;
  --yths-radius: 12px;
  --yths-focus:  3px solid #ffd700; /* gold — high contrast on all brand colours */
}

/* ── Overlay / backdrop ────────────────────────────────────── */
#yths-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background-color: rgba(14, 47, 94, 0.72); /* navy at 72% — contrast OK */
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* Hidden state — use attribute so JS can toggle `hidden` */
#yths-popup-overlay[hidden] {
  display: none !important;
}

/* Animate in when visible */
#yths-popup-overlay:not([hidden]) #yths-popup-dialog {
  animation: yths-fadein 0.22s ease-out both;
}

@keyframes yths-fadein {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Dialog box ────────────────────────────────────────────── */
#yths-popup-dialog {
  display: flex;
  flex-direction: row;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  overflow: hidden;
  border-radius: var(--yths-radius);
  box-shadow: 0 8px 40px rgba(14, 47, 94, 0.38);
  background: var(--yths-navy);
  position: relative;
}

/* ── Panels ────────────────────────────────────────────────── */
.yths-popup-panel {
  flex: 1;
}

/* Left — text */
.yths-popup-panel--text {
  padding: 48px 40px 40px;
  background: var(--yths-navy);
  color: var(--yths-white);
  display: flex;
  flex-direction: column;
  gap: 20px;
  justify-content: center;
}

/* Right — image */
.yths-popup-panel--image {
  flex: 0 0 45%;
  overflow: hidden;
  background: var(--yths-navy);
}

.yths-popup-panel--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Typography ────────────────────────────────────────────── */
#yths-popup-heading {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 700;
  line-height: 1.25;
  color: var(--yths-white);
}

#yths-popup-content {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--yths-white);
}

/* ── Action row ────────────────────────────────────────────── */
.yths-popup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.yths-popup-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  border: 2px solid transparent;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

/* Focus ring — meets WCAG 2.4.7 / 2.4.11 */
.yths-popup-btn:focus-visible {
  outline: var(--yths-focus);
  outline-offset: 3px;
}

/* CTA: teal background, white text — contrast ≈ 5.5:1 ✓ */
.yths-popup-btn--cta {
  background-color: var(--yths-teal);
  color: var(--yths-white);
  border-color: var(--yths-teal);
}
.yths-popup-btn--cta:hover,
.yths-popup-btn--cta:focus-visible {
  background-color: #006b64;
  border-color: #006b64;
  color: var(--yths-white);
}

/* Close: outlined ghost on navy */
.yths-popup-btn--close {
  background-color: transparent;
  color: var(--yths-white);
  border-color: rgba(255, 255, 255, 0.7);
}
.yths-popup-btn--close:hover,
.yths-popup-btn--close:focus-visible {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: var(--yths-white);
  color: var(--yths-white);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 600px) {
  #yths-popup-dialog {
    flex-direction: column;
    max-height: 95vh;
    overflow-y: auto;
  }

  .yths-popup-panel--image {
    flex: none;
    aspect-ratio: 1 / 1;
    width: 100%;
    order: -1;   /* image on top on mobile */
  }

  .yths-popup-panel--text {
    padding: 32px 24px 28px;
  }
}

/* ── Reduced motion ────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #yths-popup-overlay:not([hidden]) #yths-popup-dialog {
    animation: none;
  }
}

/* ── High-contrast mode (forced-colors) ───────────────────── */
@media (forced-colors: active) {
  .yths-popup-btn {
    border: 2px solid ButtonText;
  }
}
