/**
 * PowerEn overlay policy — phase 04
 *
 * All rules are scoped to the server-rendered body class so rollback only
 * requires dequeuing this file and removing the class filter.
 */

body.poweren-overlay-policy {
  --poweren-safe-bottom: env(safe-area-inset-bottom, 0px);
  --poweren-sticky-offset: 0px;
  --poweren-offer-offset: 0px;
  --poweren-bottom-clearance: 0px;
  --poweren-base-body-padding-bottom: 0px;
  --poweren-floating-gap: 14px;
}

body.poweren-overlay-policy.pw-bottom-clearance {
  padding-bottom: calc(
    var(--poweren-base-body-padding-bottom) +
    var(--poweren-bottom-clearance)
  ) !important;
}

/* Article offer: hidden during the first seconds and after the session limit. */
body.poweren-overlay-policy .all-desktop-text,
body.poweren-overlay-policy .mobile-swipe-main {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

body.poweren-overlay-policy .all-desktop-text.pw-offer-ready,
body.poweren-overlay-policy .mobile-swipe-main.pw-offer-ready {
  opacity: 1;
  pointer-events: auto;
  visibility: visible;
}

body.poweren-overlay-policy.pw-chat-open
  .all-desktop-text.pw-offer-ready,
body.poweren-overlay-policy.pw-chat-open
  .mobile-swipe-main.pw-offer-ready,
body.poweren-overlay-policy.pw-plugin-modal-open
  .all-desktop-text.pw-offer-ready,
body.poweren-overlay-policy.pw-plugin-modal-open
  .mobile-swipe-main.pw-offer-ready {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

body.poweren-overlay-policy #bottom-box-cta {
  bottom: var(--poweren-safe-bottom);
  box-sizing: border-box;
  min-height: 88px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 -12px 32px rgba(15, 23, 42, 0.1);
}

body.poweren-overlay-policy #bottom-box-cta .text {
  max-width: 760px;
  padding-left: clamp(24px, 5vw, 72px);
}

body.poweren-overlay-policy #bottom-box-cta .description {
  margin-bottom: 0;
}

body.poweren-overlay-policy #bottom-box-cta .btn-w {
  margin: 0;
  padding-left: 0;
}

body.poweren-overlay-policy #bottom-box-cta .btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

body.poweren-overlay-policy .closetext {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #475569;
  font: inherit;
  font-size: 24px;
  line-height: 1;
}

body.poweren-overlay-policy .closetext:hover {
  background: #f1f5f9;
  color: #0f172a;
}

body.poweren-overlay-policy .closetext:focus-visible,
body.poweren-overlay-policy .mobile-swipe:focus-visible,
body.poweren-overlay-policy .closebtn:focus-visible,
body.poweren-overlay-policy .dai-modal-close:focus-visible {
  outline: 3px solid rgba(3, 169, 244, 0.42);
  outline-offset: 3px;
}

/* Bottom sheet used by the mobile article offer. */
body.poweren-overlay-policy .mobile-swipe,
body.poweren-overlay-policy .closebtn {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
}

body.poweren-overlay-policy .mobile-swipe {
  min-height: calc(52px + var(--poweren-safe-bottom));
  padding: 10px 20px calc(10px + var(--poweren-safe-bottom));
  border-radius: 22px 22px 0 0;
  background: #fff;
  box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.12);
  line-height: 1.6;
}

body.poweren-overlay-policy .sidenav {
  max-height: min(55dvh, 420px);
  padding-bottom: var(--poweren-safe-bottom);
  border-radius: 22px 22px 0 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  transition: height 240ms ease;
}

body.poweren-overlay-policy .closebtn {
  position: sticky;
  right: auto;
  bottom: 0;
  left: auto;
  z-index: 2;
  display: block;
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  margin-top: 4px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  font-weight: 600;
  cursor: pointer;
}

/* Purchase bars reserve their iOS/Android safe area. */
@media (max-width: 992px) {
  body.poweren-overlay-policy .sticky-pay,
  body.poweren-overlay-policy .sticky-payn {
    box-sizing: border-box;
    height: calc(77px + var(--poweren-safe-bottom));
    padding-bottom: var(--poweren-safe-bottom);
  }
}

/*
 * Floating controls use the measured fixed-bar height. Only the compact
 * Goftino launcher is repositioned; the open cross-origin panel is not resized.
 */
body.poweren-overlay-policy .topbutton {
  bottom: calc(
    var(--poweren-bottom-clearance) +
    var(--poweren-floating-gap) +
    var(--poweren-safe-bottom)
  ) !important;
}

body.poweren-overlay-policy
  iframe#goftino_w[data-poweren-chat-state="compact"],
body.poweren-overlay-policy
  #goftino_w[data-poweren-chat-state="compact"] {
  bottom: calc(
    var(--poweren-bottom-clearance) +
    var(--poweren-floating-gap) +
    var(--poweren-safe-bottom)
  ) !important;
}

body.poweren-overlay-policy.pw-article-sheet-open iframe#goftino_w,
body.poweren-overlay-policy.pw-plugin-modal-open iframe#goftino_w,
body.poweren-overlay-policy.pw-article-sheet-open #goftino_w,
body.poweren-overlay-policy.pw-plugin-modal-open #goftino_w {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

body.poweren-overlay-policy.pw-plugin-modal-open .sticky-pay,
body.poweren-overlay-policy.pw-plugin-modal-open .sticky-payn,
body.poweren-overlay-policy.pw-plugin-modal-open .topbutton {
  opacity: 0 !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

/* Download After Info: keyboard focus and a compact mobile bottom sheet. */
body.poweren-overlay-policy .dai-modal-overlay {
  background: rgba(15, 23, 42, 0.58);
}

body.poweren-overlay-policy .dai-modal-close {
  min-width: 48px;
  min-height: 48px;
}

body.poweren-overlay-policy .dai-modal-inner:focus {
  outline: none;
}

@media (max-width: 600px) {
  body.poweren-overlay-policy
    .dai-modal-outer-holder.active
    .dai-popup-modal {
    right: 8px !important;
    bottom: var(--poweren-safe-bottom) !important;
    left: 8px !important;
    top: auto !important;
    width: auto !important;
    max-width: none !important;
    max-height: min(88dvh, 720px);
    border-radius: 22px 22px 0 0;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.poweren-overlay-policy .dai-popup-modal-inner {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (max-width: 359px) {
  body.poweren-overlay-policy .mobile-swipe-main {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.poweren-overlay-policy .sidenav,
  body.poweren-overlay-policy .all-desktop-text,
  body.poweren-overlay-policy .mobile-swipe-main,
  body.poweren-overlay-policy iframe#goftino_w {
    transition: none !important;
  }
}
