/* ==========================================================================
   GyroPlay — promotional blocks ("Reklama")
   --------------------------------------------------------------------------
   A SEPARATE stylesheet on purpose: static/css/style.css is a byte-for-byte
   copy of the Python app's, so nothing may be appended to it. This file is only
   requested on pages that actually render an ad.

   It reuses style.css's custom properties (--bg-card, --accent, --text, …) with
   fallbacks, so an ad follows the site theme — including light mode — without
   redefining the palette.
   ========================================================================== */

.gp-ad {
    --gp-ad-radius: 18px;
    --gp-ad-pad: 22px;
    font-family: inherit;
    color: var(--text, #e8ecf4);
}

/* [hidden] must win over the display values below, otherwise an ad with a delay
   would flash before ads.js gets a chance to run. */
.gp-ad[hidden] {
    display: none !important;
}

/* --- The card ---------------------------------------------------------- */

.gp-ad-box {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    margin: 0 auto;
    padding: var(--gp-ad-pad);
    background: var(--bg-card, #131824);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.09));
    border-radius: var(--gp-ad-radius);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

/* --- Close button (top-right, as requested) ---------------------------- */

.gp-ad-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    color: var(--text, #e8ecf4);
    cursor: pointer;
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 50%;
    /* Sits on top of media, so it needs its own contrast rather than the
       card background's. */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.gp-ad-close:hover,
.gp-ad-close:focus-visible {
    background: #e5484d;
    border-color: #e5484d;
    color: #fff;
    transform: rotate(90deg);
}

.gp-ad-close:focus-visible {
    outline: 2px solid var(--accent, #00d4ff);
    outline-offset: 2px;
}

/* --- Media ------------------------------------------------------------- */

.gp-ad-media {
    /* Cancels the card padding so media reaches the rounded edges. */
    margin: calc(var(--gp-ad-pad) * -1) calc(var(--gp-ad-pad) * -1) 18px;
    line-height: 0;
    background: rgba(0, 0, 0, 0.25);
}

.gp-ad-image,
.gp-ad-video {
    display: block;
    width: 100%;
    height: auto;
    max-height: 46vh;
    object-fit: cover;
}

.gp-ad-embed {
    position: relative;
    width: 100%;
    /* 16:9 without the padding-hack, supported everywhere we target. */
    aspect-ratio: 16 / 9;
}

.gp-ad-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- Text + buttons ---------------------------------------------------- */

.gp-ad-title {
    margin: 0 0 8px;
    /* Leaves room for the close button on narrow cards. */
    padding-right: 34px;
    font-size: 1.22rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text, #e8ecf4);
}

.gp-ad-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-muted, #94a3b8);
}

.gp-ad-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.gp-ad-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--text, #e8ecf4);
    background: var(--bg-hover, rgba(255, 255, 255, 0.06));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 12px;
    transition: transform 0.16s ease, filter 0.16s ease, background 0.16s ease;
}

.gp-ad-btn:hover {
    transform: translateY(-1px);
    background: var(--bg-hover, rgba(255, 255, 255, 0.1));
}

.gp-ad-btn-primary {
    color: #04121a;
    background: linear-gradient(135deg, var(--accent, #00d4ff), var(--accent-2, #7c5cff));
    border-color: transparent;
}

.gp-ad-btn-primary:hover {
    filter: brightness(1.08);
}

.gp-ad-btn:focus-visible {
    outline: 2px solid var(--accent, #00d4ff);
    outline-offset: 2px;
}

/* ==========================================================================
   Placements
   ========================================================================== */

/* --- modal: centered overlay ------------------------------------------- */

.gp-ad-modal {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* The page behind must not scroll away under the dialog on mobile. */
    overscroll-behavior: contain;
}

.gp-ad-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(4, 8, 15, 0.72);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.gp-ad-modal .gp-ad-box {
    position: relative;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    animation: gp-ad-pop 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes gp-ad-pop {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}

/* --- top / bottom: full-width strips ----------------------------------- */

.gp-ad-top,
.gp-ad-bottom {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 3500;
    padding: 10px 14px;
}

.gp-ad-top    { top: 0;    animation: gp-ad-drop 0.3s ease both; }
.gp-ad-bottom { bottom: 0; animation: gp-ad-rise 0.3s ease both; }

.gp-ad-top .gp-ad-box,
.gp-ad-bottom .gp-ad-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    padding: 14px 52px 14px 16px;
}

/* In a strip the media is a small thumbnail, not a hero image. */
.gp-ad-top .gp-ad-media,
.gp-ad-bottom .gp-ad-media {
    flex: 0 0 auto;
    width: 92px;
    margin: 0;
    overflow: hidden;
    border-radius: 10px;
}

.gp-ad-top .gp-ad-image,
.gp-ad-top .gp-ad-video,
.gp-ad-bottom .gp-ad-image,
.gp-ad-bottom .gp-ad-video {
    max-height: 62px;
}

/* A video embed cannot shrink to a thumbnail sensibly, so strips hide it. */
.gp-ad-top .gp-ad-embed,
.gp-ad-bottom .gp-ad-embed {
    display: none;
}

.gp-ad-top .gp-ad-body,
.gp-ad-bottom .gp-ad-body {
    flex: 1 1 240px;
    min-width: 0;
}

.gp-ad-top .gp-ad-title,
.gp-ad-bottom .gp-ad-title {
    padding-right: 0;
    font-size: 1.02rem;
}

.gp-ad-top .gp-ad-text,
.gp-ad-bottom .gp-ad-text {
    font-size: 0.88rem;
}

.gp-ad-top .gp-ad-actions,
.gp-ad-bottom .gp-ad-actions {
    flex: 0 0 auto;
    margin-top: 0;
}

@keyframes gp-ad-drop {
    from { transform: translateY(-100%); }
    to   { transform: none; }
}

@keyframes gp-ad-rise {
    from { transform: translateY(100%); }
    to   { transform: none; }
}

/* --- corner: floating card -------------------------------------------- */

.gp-ad-corner {
    position: fixed;
    right: 18px;
    /* Clears the back-to-top button and the cookie banner that style.css puts
       in the same corner. */
    bottom: 92px;
    z-index: 3400;
    max-width: calc(100vw - 36px);
    animation: gp-ad-slide 0.32s ease both;
}

.gp-ad-corner .gp-ad-box {
    padding: 18px;
}

.gp-ad-corner .gp-ad-media {
    margin: -18px -18px 14px;
}

.gp-ad-corner .gp-ad-image,
.gp-ad-corner .gp-ad-video {
    max-height: 180px;
}

@keyframes gp-ad-slide {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
}

/* --- inline: in the content flow -------------------------------------- */

.gp-ad-inline {
    display: block;
    padding: 0 20px;
    margin: 28px auto 36px;
}

/* ==========================================================================
   Responsive + accessibility
   ========================================================================== */

@media (max-width: 640px) {
    .gp-ad {
        --gp-ad-pad: 16px;
        --gp-ad-radius: 14px;
    }

    .gp-ad-title { font-size: 1.08rem; }

    .gp-ad-actions { flex-direction: column; }

    .gp-ad-btn { width: 100%; }

    /* A floating corner card is cramped on a phone; a bottom strip is not. */
    .gp-ad-corner {
        right: 10px;
        left: 10px;
        bottom: 84px;
        max-width: none;
    }

    .gp-ad-top .gp-ad-box,
    .gp-ad-bottom .gp-ad-box {
        padding: 12px 46px 12px 12px;
    }

    .gp-ad-top .gp-ad-media,
    .gp-ad-bottom .gp-ad-media {
        width: 64px;
    }

    .gp-ad-top .gp-ad-actions,
    .gp-ad-bottom .gp-ad-actions {
        flex: 1 1 100%;
    }
}

/* Respect a visitor who has asked for less motion: show the ad, skip the
   entrance animation. */
@media (prefers-reduced-motion: reduce) {
    .gp-ad-modal .gp-ad-box,
    .gp-ad-top,
    .gp-ad-bottom,
    .gp-ad-corner {
        animation: none;
    }

    .gp-ad-close:hover,
    .gp-ad-close:focus-visible {
        transform: none;
    }
}

/* Never print an ad. */
@media print {
    .gp-ad { display: none !important; }
}
