/*
 * The 3D Deadpool buddy (deadpool-buddy.js) and the places it appears:
 * its speech balloon, the 404 page (Big Box world, so it uses bigbox.css
 * tokens) and the cameo on the Deadpool pages. Needs deadpool.css loaded for
 * the self-hosted comic faces.
 */

/* ---------- the buddy itself ---------- */

.dpb-host { position: relative; }
.dpb-canvas { display: block; width: 100%; height: 100%; }

.dpb-bubble {
    position: absolute;
    left: 50%;
    top: 2%;
    z-index: 2;
    max-width: min(260px, 90%);
    margin: 0;
    padding: 12px 18px;
    background: #f3f0ec;
    color: #141012;
    border: 3px solid #141012;
    border-radius: 50% / 46%;
    font-family: "Comic Neue", "Barlow Condensed", sans-serif;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 8px) scale(0.85);
    transition: opacity 0.2s, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.dpb-bubble.is-on { opacity: 1; transform: translate(-50%, 0) scale(1); }
.dpb-bubble::after {
    content: "";
    position: absolute;
    left: 40%;
    bottom: -13px;
    width: 18px;
    height: 18px;
    background: #f3f0ec;
    border-right: 3px solid #141012;
    border-bottom: 3px solid #141012;
    transform: skewX(25deg) rotate(40deg);
}

/* no WebGL: a lettered SFX stands in for the figure */
.dpb-fallback::before {
    content: "Deadpool was here";
    display: grid;
    place-items: center;
    height: 100%;
    font-family: "Bangers", "Arial Narrow", sans-serif;
    font-size: clamp(28px, 4vw, 44px);
    color: #ffd23f;
    text-align: center;
}

/* ---------- 404 page (Big Box world + Deadpool) ---------- */

.nf-page .bigbox-shell { padding-top: clamp(24px, 4vw, 56px); padding-bottom: clamp(40px, 6vw, 80px); }

.nf-sleeve {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    max-width: 1180px;
    min-height: clamp(460px, 64vh, 640px);
    margin: 0 auto;
    background: var(--ink-2, #17171c);
    border: 1px solid var(--line-bright, rgba(242, 237, 225, 0.22));
    border-radius: 3px;
    overflow: hidden;
}
/* the gold spine bar every Big Box sleeve carries */
.nf-sleeve::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    background: linear-gradient(180deg, var(--gold-bright, #e6c777), var(--gold-deep, #8a6a2d));
}

.nf-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 14px;
    padding: clamp(28px, 4vw, 56px) clamp(24px, 4vw, 52px) clamp(28px, 4vw, 56px) clamp(32px, 5vw, 64px);
}
.nf-code {
    margin: 0;
    font-family: var(--font-display, "Anton", sans-serif);
    font-size: clamp(110px, 16vw, 220px);
    line-height: 0.82;
    letter-spacing: 0.01em;
    color: var(--gold, #c9a24b);
    text-shadow: 0 2px 0 var(--gold-deep, #8a6a2d), 0 18px 40px rgba(0, 0, 0, 0.55);
}
.nf-page h1.nf-title {
    margin: 0;
    font-family: var(--font-display, "Anton", sans-serif);
    font-size: clamp(34px, 4.4vw, 58px);
    font-weight: 400;
    line-height: 0.98;
    letter-spacing: 0.01em;
    text-transform: uppercase;
    color: var(--paper, #f2ede1);
}
.nf-dek {
    margin: 0;
    max-width: 46ch;
    font-family: var(--font-body, "Alegreya", serif);
    font-size: 18px;
    line-height: 1.55;
    color: var(--cream-muted, #b8ae98);
}
.nf-dek code {
    padding: 1px 6px;
    background: var(--ink-3, #202027);
    border: 1px solid var(--line, rgba(242, 237, 225, 0.12));
    color: var(--gold-bright, #e6c777);
    font-size: 0.85em;
    word-break: break-all;
}
/* Deadpool's yellow narration box, crossing over into the Big Box world */
.nf-caption {
    align-self: flex-start;
    max-width: 40ch;
    margin: 8px 0 4px;
    padding: 10px 16px 12px;
    background: #ffd23f;
    color: #141012;
    border: 3px solid #141012;
    font-family: "Comic Neue", "Barlow Condensed", sans-serif;
    font-weight: 700;
    font-size: clamp(16px, 1.5vw, 19px);
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    transform: rotate(-1.2deg);
    box-shadow: 0 18px 30px -16px rgba(0, 0, 0, 0.75);
}
.nf-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }

/* the stage: a spotlit shelf the figure stands on */
.nf-stage {
    position: relative;
    min-height: 420px;
    border-left: 1px solid var(--line, rgba(242, 237, 225, 0.12));
    background:
        radial-gradient(ellipse 55% 60% at 50% 42%, rgba(230, 199, 119, 0.22), transparent 70%),
        radial-gradient(rgba(242, 237, 225, 0.05) 22%, transparent 24%) 0 0 / 12px 12px,
        var(--ink, #0d0d10);
}
.nf-buddy {
    position: absolute;
    inset: 4% 0 7% 0;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}
.nf-buddy:focus:not(:focus-visible), .dpb-cameo-stage:focus:not(:focus-visible) { outline: none; }
.nf-buddy:focus-visible { outline: 2px solid var(--gold-bright, #e6c777); outline-offset: -6px; }
.nf-plank {
    position: absolute;
    left: 10%;
    right: 10%;
    bottom: 8%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold, #c9a24b), transparent);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.6);
}
.nf-sfx {
    position: absolute;
    right: 8%;
    top: 9%;
    font-family: "Bangers", "Arial Narrow", sans-serif;
    font-size: clamp(30px, 3.4vw, 46px);
    line-height: 1;
    letter-spacing: 0.03em;
    color: #ffd23f;
    -webkit-text-stroke: 2px #141012;
    paint-order: stroke fill;
    text-shadow: 0 4px 0 #141012;
    transform: rotate(10deg);
    pointer-events: none;
}

@media (max-width: 860px) {
    .nf-sleeve { grid-template-columns: 1fr; }
    .nf-stage { min-height: 360px; border-left: 0; border-top: 1px solid var(--line, rgba(242, 237, 225, 0.12)); order: -1; }
}

/* ---------- cameo on the Deadpool pages ---------- */

.dpb-cameo {
    position: fixed;
    /* clear of the site's round back-to-top button in the corner */
    right: clamp(64px, 6vw, 96px);
    bottom: 0;
    z-index: 1500;
    width: clamp(220px, 23vw, 300px);
    height: clamp(290px, 31vw, 390px);
    transform: translateY(105%);
    transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}
.dpb-cameo.is-in { transform: translateY(14%); }
.dpb-cameo-stage {
    position: absolute;
    inset: 0;
    padding: 0;
    background: none;
    border: 0;
    cursor: pointer;
}
/* the cameo canvas is narrow; the balloon floats out to his left */
.dpb-cameo .dpb-bubble {
    left: auto;
    right: 62%;
    top: 6%;
    width: max-content;
    max-width: 220px;
    transform: translateY(8px) scale(0.85);
    transform-origin: right bottom;
}
.dpb-cameo .dpb-bubble.is-on { transform: none; }
.dpb-cameo .dpb-bubble::after { left: auto; right: 14px; }
.dpb-cameo-close {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: #f3f0ec;
    border: 3px solid #141012;
    cursor: pointer;
}
.dpb-cameo-close svg { width: 14px; height: 14px; }
.dpb-cameo-close:focus-visible, .dpb-cameo-stage:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .dpb-cameo, .dpb-bubble { transition: none; }
}
