/**
 * banner.css
 * Static styling for the shared UI.Banner celebration slot (banner.js).
 *
 * Layering: the OUTER .achievement-banner owns fixed positioning and centers
 * with margin-inline auto — it carries NO transform, ever, so WAAPI motion on
 * .achievement-banner__body can never dislodge the slot (the historical
 * transform-clobber bug). All motion is transform/opacity on the body and its
 * children, driven by banner.js.
 */

.achievement-banner {
    position: fixed;
    top: max(12px, env(safe-area-inset-top));
    left: 0;
    right: 0;
    margin-inline: auto;
    z-index: 100000;
    width: min(calc(100vw - max(24px, env(safe-area-inset-left)) - max(24px, env(safe-area-inset-right))), clamp(320px, 36vw, 680px));
    min-width: 0;
    pointer-events: none;
}

.achievement-banner__body {
    position: relative;
    display: flex;
    align-items: center;
    gap: clamp(10px, 1.1vmin, 20px);
    padding: clamp(12px, 1.15vmin, 22px) clamp(16px, 1.7vmin, 32px);
    background: linear-gradient(135deg, #2a2a4a, #1a1a2e);
    border: 2px solid #ffd700;
    border-radius: clamp(10px, 0.8vmin, 18px);
    overflow: hidden;
    will-change: transform, opacity;
}

/* Ambient glow lives on its own layer so the pulse animates opacity only
   (compositor-friendly), never the box-shadow itself. */
.achievement-banner-glow {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow:
        inset 0 0 26px rgba(255, 215, 0, 0.18),
        0 4px 34px rgba(255, 215, 0, 0.5);
    opacity: 0.55;
    pointer-events: none;
    animation: achievement-glow-pulse 2.6s ease-in-out infinite;
}

@keyframes achievement-glow-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 0.95; }
}

/* One-shot light sweep; banner.js drives its translate, this just shapes it. */
.achievement-banner-shine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 42%;
    background: linear-gradient(
        105deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 244, 200, 0.22) 45%,
        rgba(255, 255, 255, 0) 100%
    );
    opacity: 0;
    pointer-events: none;
}

.achievement-banner-icon {
    font-size: clamp(2rem, 3.2vmin, 3.5rem);
    line-height: 1;
}

.achievement-banner-image {
    width: clamp(52px, 5vmin, 84px);
    aspect-ratio: 3 / 4;
    height: auto;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid rgba(255, 215, 0, 0.5);
}

.achievement-banner-image--landscape {
    width: clamp(96px, 9vmin, 156px);
    aspect-ratio: 16 / 9;
    height: auto;
}

.achievement-banner-content {
    flex: 1;
    min-width: 0;
}

.achievement-banner-title {
    color: #ffd700;
    font-weight: bold;
    font-size: clamp(1rem, 1.15vmin, 1.35rem);
    letter-spacing: 0.02em;
    margin-bottom: 4px;
}

.achievement-banner-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: clamp(0.8rem, 0.95vmin, 1.1rem);
    overflow-wrap: anywhere;
}

/* Forge-style reveal: framed image with rarity glow + radial spark burst. */
.achievement-banner-frame {
    position: relative;
    display: inline-flex;
    flex: 0 0 auto;
}

.achievement-banner--reveal .achievement-banner-image {
    box-shadow: 0 0 18px rgba(255, 215, 0, 0.65);
}

.achievement-banner-sparks {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.achievement-banner-spark {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff6cf 0%, #ffd700 55%, rgba(255, 215, 0, 0) 100%);
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: achievement-spark 720ms ease-out var(--spark-delay, 0ms) both;
}

@keyframes achievement-spark {
    0% {
        transform: translate(-50%, -50%) scale(0.4);
        opacity: 0;
    }
    18% {
        opacity: 1;
    }
    100% {
        transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, 0px))) scale(1);
        opacity: 0;
    }
}

/* Graceful degrade: engines without WAAPI still fade the body out on close
   (animations, when present, win over this transition). */
.achievement-banner.closing .achievement-banner__body {
    opacity: 0;
    transition: opacity 0.26s ease-in;
}

.achievement-live-region {
    position: fixed;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (max-width: 540px) {
    .achievement-banner {
        width: calc(100vw - 20px);
    }

    .achievement-banner__body {
        padding: 10px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .achievement-banner-glow,
    .achievement-banner-spark {
        animation: none;
    }

    .achievement-banner-spark {
        opacity: 0;
    }
}

/* ── Banner debug panel (UI.BannerDebug) ──────────────────────────────
   Mounted only under the debug gating triad; developer-facing.

   IT SHARES A CORNER WITH THE LOBBY QUEST RAIL, and it wins. This panel is
   fixed at bottom-left with `z-index: 10500`; the quest rail sits in flow at
   `2100`, so in the lobby the panel lands squarely on the rail's own debug
   buttons and swallows every click. Reported plainly: "debug win buttns
   covered by another debug banner" — and it is why a click that Playwright
   reported as delivered banked nothing.

   Only the LOBBY has that conflict, so only the lobby moves it. In a match the
   bottom-left is free and the panel stays exactly where its user expects it. */

.banner-debug-panel {
    /* The panel's BACKGROUND is not a target — only its buttons are. It is
       `position: fixed` at z-index 10500 and, in the lobby, moves to the
       bottom-right (below), which is where the chrome-menu trigger and
       #feedback-link live. Its padding then swallowed their clicks: with
       `DEBUG_MODE=true` — which the checked-in `.env` carries — four
       feedback.spec.js cases, one gameplay.spec.js case and the real PvP
       rematch spec all failed with "banner-debug-panel intercepts pointer
       events", and a developer clicking Feedback in the lobby got nothing.
       Re-enable pointer-events on the controls only. */
    pointer-events: none;
    position: fixed;
    left: 12px;
    bottom: 56px;
    /* Above every gameplay overlay (mulligan 9700, game-end 9999, tutorial
       hints 10000) so banners are previewable from ANY state; still far below
       the banners themselves (100000). Debug-only surface. */
    z-index: 10500;
    max-width: 300px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(16, 12, 30, 0.92);
    border: 1px dashed rgba(255, 215, 0, 0.45);
    color: #e8e2f8;
    font-size: 12px;
}

/* Out of the quest rail's corner while the lobby owns the screen. */
body:not(.game-active) .banner-debug-panel {
    left: auto;
    right: 12px;
}

.banner-debug-title {
    /* The collapsed panel IS this control, so it is the one part that must
       always take a click. */
    pointer-events: auto;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #ffd700;
    margin-bottom: 6px;
}

/* Collapsed is the default: the panel shrinks to its own title and stops
   being a 300x240 obstacle over whatever the corner actually belongs to. */
.banner-debug-panel[data-open="false"] .banner-debug-row,
.banner-debug-panel[data-open="false"] .banner-debug-status {
    display: none;
}

.banner-debug-panel[data-open="false"] .banner-debug-title {
    margin-bottom: 0;
}

.banner-debug-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.banner-debug-btn {
    /* The panel above is click-transparent; its buttons are the only targets. */
    pointer-events: auto;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(60, 50, 100, 0.6);
    color: #f2edff;
    font-size: 11px;
    cursor: pointer;
}

.banner-debug-btn:hover {
    background: rgba(90, 75, 150, 0.75);
}

.banner-debug-status {
    margin: 6px 0 0;
    min-height: 1.2em;
    color: rgba(255, 255, 255, 0.75);
    font-size: 11px;
}
