/* DW Tools Popups — frontend variant styles + animations.
 *
 * Per-popup tweaks (bg color, accent, size width) come in via CSS custom
 * properties scoped in the inline <style id="dw-popups-vars"> block.
 *
 * The engine adds .is-open to play the entrance animation and .is-closing
 * for the exit. [hidden] is used to fully detach when not visible.
 */

.dw-popup,
.dw-popup * {
    box-sizing: border-box;
}

.dw-popup[hidden] {
    display: none !important;
}

.dw-popup {
    --dw-popup-bg: #ffffff;
    --dw-popup-accent: #1d2327;
    --dw-popup-width: 520px;

    position: fixed;
    z-index: 999999;
    color: inherit;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Overlay — only used by centered modal. */
.dw-popup__overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0;
    transition: opacity 200ms ease;
    pointer-events: none;
}

.dw-popup__panel {
    position: relative;
    background: var(--dw-popup-bg);
    color: var(--dw-popup-accent);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
    border-radius: 8px;
    padding: 28px 28px 24px;
    line-height: 1.55;
}

.dw-popup__body :first-child {
    margin-top: 0;
}
.dw-popup__body :last-child {
    margin-bottom: 0;
}

.dw-popup__close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 32px;
    height: 32px;
    line-height: 1;
    border: 0;
    background: transparent;
    color: currentColor;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.55;
    border-radius: 4px;
}
.dw-popup__close:hover,
.dw-popup__close:focus {
    opacity: 1;
    outline: none;
    background: rgba(0, 0, 0, 0.06);
}

/* ---------------------------------------------------------------------------
 * Variant: centered modal
 * ------------------------------------------------------------------------- */
.dw-popup--centered-modal {
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.dw-popup--centered-modal .dw-popup__overlay {
    pointer-events: auto;
}

.dw-popup--centered-modal .dw-popup__panel {
    width: 100%;
    max-width: var(--dw-popup-width);
    max-height: calc(100vh - 48px);
    overflow: auto;
}

/* ---------------------------------------------------------------------------
 * Variant: slide-in (bottom-right, no overlay)
 * ------------------------------------------------------------------------- */
.dw-popup--slide-in {
    bottom: 20px;
    right: 20px;
    max-width: calc(100vw - 40px);
}

.dw-popup--slide-in .dw-popup__overlay {
    display: none;
}

.dw-popup--slide-in .dw-popup__panel {
    width: var(--dw-popup-width);
    max-width: 100%;
    border-radius: 10px;
}

/* ---------------------------------------------------------------------------
 * Variant: bar (top / bottom)
 * ------------------------------------------------------------------------- */
.dw-popup--bar-top,
.dw-popup--bar-bottom {
    left: 0;
    right: 0;
}
.dw-popup--bar-top    { top: 0; }
.dw-popup--bar-bottom { bottom: 0; }

.dw-popup--bar-top .dw-popup__overlay,
.dw-popup--bar-bottom .dw-popup__overlay {
    display: none;
}

.dw-popup--bar-top .dw-popup__panel,
.dw-popup--bar-bottom .dw-popup__panel {
    width: 100%;
    max-width: none;
    border-radius: 0;
    padding: 14px 56px 14px 20px;
    box-shadow: none;
    text-align: center;
}

/* ---------------------------------------------------------------------------
 * Variant: full-screen
 * ------------------------------------------------------------------------- */
.dw-popup--fullscreen {
    inset: 0;
}

.dw-popup--fullscreen .dw-popup__overlay {
    display: none;
}

.dw-popup--fullscreen .dw-popup__panel {
    width: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: none;
    overflow: auto;
}

/* ---------------------------------------------------------------------------
 * Animations — entrance and exit
 *
 * The engine toggles .is-open (entrance) and .is-closing (exit). [hidden] is
 * removed at the start of show() and re-added on transitionend during close().
 * ------------------------------------------------------------------------- */
.dw-popup .dw-popup__panel {
    transition: opacity 220ms ease, transform 220ms ease;
}

/* fade — opacity only, panel doesn't move. */
.dw-popup[data-anim="fade"] .dw-popup__panel {
    opacity: 0;
}
.dw-popup[data-anim="fade"].is-open .dw-popup__panel {
    opacity: 1;
}
.dw-popup[data-anim="fade"].is-closing .dw-popup__panel {
    opacity: 0;
}

/* scale — quick zoom-in. Centered modal / fullscreen / slide-in all benefit. */
.dw-popup[data-anim="scale"] .dw-popup__panel {
    opacity: 0;
    transform: scale(0.94);
}
.dw-popup[data-anim="scale"].is-open .dw-popup__panel {
    opacity: 1;
    transform: scale(1);
}
.dw-popup[data-anim="scale"].is-closing .dw-popup__panel {
    opacity: 0;
    transform: scale(0.94);
}

/* slide — direction depends on variant.
 * - slide-in / bar-bottom: from below
 * - bar-top: from above
 * - centered modal / fullscreen: from below (subtle lift)
 */
.dw-popup[data-anim="slide"] .dw-popup__panel {
    opacity: 0;
    transform: translateY(16px);
}
.dw-popup[data-anim="slide"].is-open .dw-popup__panel {
    opacity: 1;
    transform: translateY(0);
}
.dw-popup[data-anim="slide"].is-closing .dw-popup__panel {
    opacity: 0;
    transform: translateY(16px);
}

.dw-popup--bar-top[data-anim="slide"] .dw-popup__panel {
    transform: translateY(-16px);
}
.dw-popup--bar-top[data-anim="slide"].is-closing .dw-popup__panel {
    transform: translateY(-16px);
}

/* Overlay fade (centered modal only) */
.dw-popup--centered-modal.is-open .dw-popup__overlay {
    opacity: 1;
}
.dw-popup--centered-modal.is-closing .dw-popup__overlay {
    opacity: 0;
}

/* Reduced motion — instant transitions. */
@media (prefers-reduced-motion: reduce) {
    .dw-popup .dw-popup__panel,
    .dw-popup__overlay {
        transition: none !important;
    }
    .dw-popup[data-anim] .dw-popup__panel {
        transform: none !important;
    }
}
