/*
 * Home-page pop-up advertisement (templates/layout/popup_ad.html,
 * static/assets/script/popup-ad.js). Loaded only on the home page, and only
 * while an ad is live.
 */
html.wm-popup-ad-open {
    overflow: hidden;
    /* Keep the scrollbar's space so the page doesn't jump sideways. */
    scrollbar-gutter: stable;
}

.wm-popup-ad {
    /* The theme's `* { margin: 0 }` reset (style.css) cancels the UA's
       `margin: auto`, which is what centres a modal <dialog>. */
    position: fixed;
    inset: 0;
    margin: auto;
    height: fit-content;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: 0;
    border-top: 5px solid #076415;
    border-radius: 6px;
    background: #fff;
    color: #424242;
    font-family: 'Ubuntu', sans-serif;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
    overflow-x: hidden;
    overflow-y: auto;
}
.wm-popup-ad:focus { outline: none; }
.wm-popup-ad::backdrop {
    background: rgba(17, 24, 39, 0.62);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/* Entrance: one drop-and-bounce (or a fade), then three gold pulses on the button. */
@keyframes wm-popup-ad-bounce {
    0%   { opacity: 0; transform: translateY(-48px) scale(0.96); }
    55%  { opacity: 1; transform: translateY(10px) scale(1.01); }
    75%  { transform: translateY(-4px); }
    90%  { transform: translateY(2px); }
    100% { opacity: 1; transform: none; }
}
@keyframes wm-popup-ad-fade {
    0%   { opacity: 0; transform: scale(0.98); }
    100% { opacity: 1; transform: none; }
}
@keyframes wm-popup-ad-backdrop {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes wm-popup-ad-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(234, 156, 11, 0.65); }
    100% { box-shadow: 0 0 0 16px rgba(234, 156, 11, 0); }
}
.wm-popup-ad--bounce[open] { animation: wm-popup-ad-bounce 0.8s cubic-bezier(0.22, 1, 0.36, 1) both; }
.wm-popup-ad--fade[open] { animation: wm-popup-ad-fade 0.35s ease-out both; }
.wm-popup-ad[open]::backdrop { animation: wm-popup-ad-backdrop 0.35s ease-out both; }
.wm-popup-ad[open] .wm-popup-ad-cta { animation: wm-popup-ad-pulse 1.6s ease-out 0.9s 3; }

.wm-popup-ad-media {
    position: relative;
    height: 220px;
    background: #076415;
}
.wm-popup-ad-media--plain { height: 96px; }
.wm-popup-ad-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.wm-popup-ad-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #1f2937;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
}
.wm-popup-ad-close:hover { background: #fff; }
.wm-popup-ad-close:focus-visible,
.wm-popup-ad-later:focus-visible,
.wm-popup-ad-cta:focus-visible {
    outline: 3px solid #ea9c0b;
    outline-offset: 2px;
}
.wm-popup-ad-seal {
    position: absolute;
    left: 50%;
    bottom: -38px;
    width: 76px;
    height: 76px;
    padding: 4px;
    box-sizing: border-box;
    transform: translateX(-50%);
    border: 2px solid #ea9c0b;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.wm-popup-ad-seal img {
    display: block;
    width: 100%;
    height: 100%;
}

.wm-popup-ad-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 54px 48px 30px;
    text-align: center;
}
.wm-popup-ad-label {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 2px;
    background: #ea9c0b;
    color: #1f2937;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    line-height: 1.4;
    text-transform: uppercase;
}
.wm-popup-ad .wm-popup-ad-title {
    margin: 0;
    color: #076415;
    font-family: 'Ubuntu', sans-serif;
    font-size: 30px;
    font-weight: 700;
    line-height: 1.2;
    text-transform: none;
}
.wm-popup-ad-rule {
    display: block;
    width: 56px;
    height: 3px;
    background: #ea9c0b;
}
.wm-popup-ad .wm-popup-ad-message {
    max-width: 430px;
    margin: 0;
    color: #424242;
    font-size: 15px;
    line-height: 1.65;
}
.wm-popup-ad-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 12px 22px;
    margin-top: 8px;
}
.wm-popup-ad .wm-popup-ad-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 30px;
    border-radius: 4px;
    background: #076415;
    color: #fff;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
}
.wm-popup-ad .wm-popup-ad-cta:hover,
.wm-popup-ad .wm-popup-ad-cta:focus { background: #054d10; color: #fff; }
.wm-popup-ad-later {
    min-height: 48px;
    padding: 0 6px;
    border: 0;
    background: none;
    color: #64748b;
    font-family: inherit;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}
.wm-popup-ad-later:hover { color: #1f2937; }
.wm-popup-ad .wm-popup-ad-footnote {
    width: 100%;
    margin: 6px 0 0;
    padding-top: 14px;
    border-top: 1px solid #eaeaea;
    color: #64748b;
    font-size: 12px;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .wm-popup-ad-media { height: 150px; }
    .wm-popup-ad-media--plain { height: 72px; }
    .wm-popup-ad-seal { width: 60px; height: 60px; bottom: -30px; padding: 3px; }
    .wm-popup-ad-close { top: 10px; right: 10px; }
    .wm-popup-ad-body { gap: 12px; padding: 42px 22px 22px; }
    .wm-popup-ad .wm-popup-ad-title { font-size: 24px; }
    .wm-popup-ad .wm-popup-ad-message { font-size: 14px; line-height: 1.6; }
    .wm-popup-ad-actions { flex-direction: column; align-items: stretch; width: 100%; gap: 4px; margin-top: 6px; }
    .wm-popup-ad .wm-popup-ad-cta { min-height: 50px; }
    .wm-popup-ad-later { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .wm-popup-ad--bounce[open],
    .wm-popup-ad--fade[open],
    .wm-popup-ad[open]::backdrop,
    .wm-popup-ad[open] .wm-popup-ad-cta { animation: none; }
}
