/* ============================================================
 * transitions.css — 10 slide-transition variants for Brand Upgrade deck.
 *
 * Activated by `body[data-transition="<id>"]`. Direction (next vs prev)
 * comes from `body[data-deck-direction="next|prev"]` set by transitions.js.
 *
 * State model:
 *   • [data-deck-active]                              — active pose
 *   • .is-leaving                                     — exit pose (just lost active)
 *   • everything else                                 — far-pose (never been seen)
 *
 * transitions.js stamps .is-leaving on the previous slide for the
 * duration of the transition, and overlay variants (wipe, letterbox,
 * flash) are driven from JS via dedicated overlay elements.
 * ============================================================ */

/* ─── base — applies to every variant ─────────────────────────── */
deck-stage > section {
    transition-property: opacity, transform, filter, clip-path;
    transition-duration: 0.55s;
    transition-timing-function: cubic-bezier(.2,.85,.25,1);
    /* GPU hint */
    will-change: opacity, transform, filter;
}
/* Only the active slide and the slide that is *currently leaving* are
   visible. Every other slide stays hidden (shadow DOM default), so
   when body[data-transition] flips between variants, far slides
   don't briefly flash as their clip-path / transform / opacity
   transitions back to a different variant's hidden pose. */
deck-stage > section[data-deck-active],
deck-stage > section.is-leaving {
    visibility: visible !important;
}
deck-stage > section:not([data-deck-active]) {
    pointer-events: none !important;
}

/* ─── 1. FADE — pure cross-fade ───────────────────────────────── */
body[data-transition="fade"] deck-stage > section {
    transition-duration: 0.45s;
}
body[data-transition="fade"] deck-stage > section:not([data-deck-active]) {
    opacity: 0;
}
body[data-transition="fade"] deck-stage > section[data-deck-active] {
    opacity: 1;
}

/* ─── 2. SLIDEUP — incoming rises from below ─────────────────── */
body[data-transition="slideup"] deck-stage > section {
    transition-duration: 0.6s;
}
body[data-transition="slideup"] deck-stage > section {
    opacity: 0;
    transform: translateY(80px);
}
body[data-transition="slideup"] deck-stage > section[data-deck-active] {
    opacity: 1;
    transform: translateY(0);
}
body[data-transition="slideup"] deck-stage > section.is-leaving {
    opacity: 0;
    transform: translateY(-40px);
}

/* ─── 3. BLUR — soft fade with focus shift ────────────────────── */
body[data-transition="blur"] deck-stage > section {
    transition-duration: 0.7s;
}
body[data-transition="blur"] deck-stage > section {
    opacity: 0;
    filter: blur(20px);
}
body[data-transition="blur"] deck-stage > section[data-deck-active] {
    opacity: 1;
    filter: blur(0);
}
body[data-transition="blur"] deck-stage > section.is-leaving {
    opacity: 0;
    filter: blur(20px);
}

/* ─── 4. WHIP — directional horizontal push with motion blur ──── */
body[data-transition="whip"] deck-stage > section {
    transition-duration: 0.6s;
    transition-timing-function: cubic-bezier(.5,0,.3,1);
}
body[data-transition="whip"] deck-stage > section { opacity: 0; }
body[data-transition="whip"] deck-stage > section[data-deck-active] {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
}
/* next direction: leaving exits LEFT, far slides queue on the RIGHT */
body[data-deck-direction="next"][data-transition="whip"] deck-stage > section:not([data-deck-active]) {
    transform: translateX(40%);
}
body[data-deck-direction="next"][data-transition="whip"] deck-stage > section.is-leaving {
    transform: translateX(-40%);
    filter: blur(10px);
}
/* prev direction: mirrored */
body[data-deck-direction="prev"][data-transition="whip"] deck-stage > section:not([data-deck-active]) {
    transform: translateX(-40%);
}
body[data-deck-direction="prev"][data-transition="whip"] deck-stage > section.is-leaving {
    transform: translateX(40%);
    filter: blur(10px);
}

/* ─── 5. WIPE — accent green bar sweeps across (overlay) ──────── */
/* Slide itself just opacity-swaps; the bar element steals the eye. */
body[data-transition="wipe"] deck-stage > section {
    transition-duration: 0.35s;
}
body[data-transition="wipe"] deck-stage > section:not([data-deck-active]) { opacity: 0; }
body[data-transition="wipe"] deck-stage > section[data-deck-active] { opacity: 1; }

.transition-wipe {
    position: fixed;
    top: 0; bottom: 0;
    left: -120vw;
    width: 100vw;
    z-index: 2147483400;
    pointer-events: none;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(72,176,102,0.0) 5%,
        rgba(72,176,102,0.85) 35%,
        #5ec97c 50%,
        rgba(72,176,102,0.85) 65%,
        rgba(72,176,102,0.0) 95%,
        transparent 100%
    );
    box-shadow: 0 0 60px rgba(72,176,102,0.4);
    transform: translateX(0);
    transition: none;
}
.transition-wipe.is-running {
    transition: transform 0.85s cubic-bezier(.65,0,.35,1);
    transform: translateX(240vw);
}
/* direction-aware: prev runs right-to-left */
body[data-deck-direction="prev"] .transition-wipe {
    left: auto; right: -120vw;
    transform: translateX(0);
}
body[data-deck-direction="prev"] .transition-wipe.is-running {
    transform: translateX(-240vw);
}

/* ─── 6. IRIS — circular reveal from center ──────────────────── */
body[data-transition="iris"] deck-stage > section {
    transition-property: clip-path, opacity;
    transition-duration: 0.7s;
    transition-timing-function: cubic-bezier(.65,0,.35,1);
}
body[data-transition="iris"] deck-stage > section {
    opacity: 1;
    clip-path: circle(0% at 50% 50%);
}
body[data-transition="iris"] deck-stage > section[data-deck-active] {
    clip-path: circle(80% at 50% 50%);
}
body[data-transition="iris"] deck-stage > section.is-leaving {
    clip-path: circle(0% at 50% 50%);
    opacity: 0;
}

/* ─── 7. CARDSTACK — outgoing falls back, incoming slides over ── */
body[data-transition="cardstack"] deck-stage > section {
    transition-duration: 0.7s;
    transition-timing-function: cubic-bezier(.2,.85,.25,1);
}
body[data-transition="cardstack"] deck-stage > section {
    opacity: 0;
    transform: translateY(100%);
    z-index: 1;
}
body[data-transition="cardstack"] deck-stage > section[data-deck-active] {
    opacity: 1;
    transform: translateY(0);
    z-index: 2;
}
body[data-transition="cardstack"] deck-stage > section.is-leaving {
    opacity: 0.35;
    transform: scale(0.9) translateY(-30px);
    z-index: 1;
    filter: brightness(0.6);
}

/* ─── 8. LETTERBOX — black bars close, swap, open (overlay) ──── */
body[data-transition="letterbox"] deck-stage > section {
    transition-duration: 0s;  /* instant swap under the bars */
}
body[data-transition="letterbox"] deck-stage > section:not([data-deck-active]) { opacity: 0; }
body[data-transition="letterbox"] deck-stage > section[data-deck-active] { opacity: 1; }

.transition-letterbox {
    position: fixed;
    left: 0; right: 0;
    background: #000;
    z-index: 2147483400;
    pointer-events: none;
    height: 0;
    will-change: height;
}
.transition-letterbox--top { top: 0; }
.transition-letterbox--bot { bottom: 0; }
.transition-letterbox.is-closing {
    transition: height 0.32s cubic-bezier(.6,0,.3,1);
    height: 50vh;
}
.transition-letterbox.is-opening {
    transition: height 0.42s cubic-bezier(.3,.0,.2,1);
    height: 0;
}

/* ─── 9. FLASH — accent green frame for 90ms (overlay) ────────── */
body[data-transition="flash"] deck-stage > section {
    transition-duration: 0.25s;
}
body[data-transition="flash"] deck-stage > section:not([data-deck-active]) { opacity: 0; }
body[data-transition="flash"] deck-stage > section[data-deck-active] { opacity: 1; }

.transition-flash {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at center, #6ad985 0%, #48b066 60%, #2d7a45 100%);
    z-index: 2147483400;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.06s ease;
    mix-blend-mode: screen;
}
.transition-flash.is-on { opacity: 1; transition: opacity 0.05s ease-out; }
.transition-flash.is-off { opacity: 0; transition: opacity 0.18s ease-in; }

/* ─── 10. DIAGONAL — slanted wipe from top-right to bottom-left ─ */
body[data-transition="diagonal"] deck-stage > section {
    transition-property: clip-path, opacity;
    transition-duration: 0.7s;
    transition-timing-function: cubic-bezier(.6,0,.3,1);
}
/* All polygons have 4 vertices in TL → TR → BR → BL order for
   smooth interpolation. Each pair is a slanted band moving across. */
body[data-transition="diagonal"] deck-stage > section {
    opacity: 1;
    clip-path: polygon(130% 0, 150% 0, 90% 100%, 70% 100%);
}
body[data-transition="diagonal"] deck-stage > section[data-deck-active] {
    clip-path: polygon(-30% 0, 150% 0, 90% 100%, -90% 100%);
}
body[data-transition="diagonal"] deck-stage > section.is-leaving {
    clip-path: polygon(-90% 0, -30% 0, -90% 100%, -110% 100%);
    opacity: 0;
}
/* prev direction: mirror (left-to-right slash) */
body[data-deck-direction="prev"][data-transition="diagonal"] deck-stage > section {
    clip-path: polygon(-50% 0, -30% 0, -110% 100%, -130% 100%);
}
body[data-deck-direction="prev"][data-transition="diagonal"] deck-stage > section[data-deck-active] {
    clip-path: polygon(-50% 0, 130% 0, 90% 100%, -90% 100%);
}
body[data-deck-direction="prev"][data-transition="diagonal"] deck-stage > section.is-leaving {
    clip-path: polygon(130% 0, 150% 0, 110% 100%, 90% 100%);
    opacity: 0;
}

/* ─── Reduced motion: disable all special transitions, use fade ─ */
@media (prefers-reduced-motion: reduce) {
    deck-stage > section {
        transition: opacity 0.15s ease !important;
        transform: none !important;
        filter: none !important;
        clip-path: none !important;
    }
    .transition-wipe,
    .transition-letterbox,
    .transition-flash { display: none !important; }
}

/* ============================================================
 * TRANSITIONS PICKER PANEL
 * ============================================================ */
.tx-panel {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2147483500;
    width: 280px;
    background: rgba(14, 14, 14, 0.94);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.55), 0 2px 8px rgba(0,0,0,0.4);
    color: #e8e8e8;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 13px;
    transform: translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.22s cubic-bezier(.2,.85,.25,1);
    overflow: hidden;
}
.tx-panel.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.tx-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.tx-panel__title {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #48b066;
}
.tx-panel__close {
    appearance: none;
    background: transparent;
    border: 0;
    color: rgba(255,255,255,0.55);
    width: 22px; height: 22px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.tx-panel__close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.tx-panel__close svg { width: 12px; height: 12px; }

.tx-panel__list {
    max-height: 56vh;
    overflow-y: auto;
    padding: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.tx-panel__list::-webkit-scrollbar { width: 6px; }
.tx-panel__list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }

.tx-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border: 1px solid transparent;
}
.tx-option:hover { background: rgba(255,255,255,0.04); }
.tx-option.is-active {
    background: rgba(72,176,102,0.10);
    border-color: rgba(72,176,102,0.30);
}
.tx-option__num {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.42);
    width: 18px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.tx-option.is-active .tx-option__num { color: #48b066; }
.tx-option__swatch {
    width: 36px; height: 24px;
    border-radius: 5px;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.08);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}
/* Per-variant swatch visuals (small motion previews) */
.tx-option[data-id="perslide"] .tx-option__swatch::after {
    content: ''; position: absolute; inset: 0;
    background:
        linear-gradient(135deg,
            rgba(72,176,102,0.0) 0%,
            rgba(72,176,102,0.0) 25%,
            #48b066 27%, #48b066 38%,
            rgba(72,176,102,0.0) 40%,
            rgba(72,176,102,0.0) 60%,
            #5ec97c 62%, #5ec97c 73%,
            rgba(72,176,102,0.0) 75%);
}
.tx-option[data-id="fade"] .tx-option__swatch::after {
    content: ''; position: absolute; inset: 4px; border-radius: 3px;
    background: linear-gradient(90deg, #2a2a2a, #4a4a4a);
}
.tx-option[data-id="slideup"] .tx-option__swatch::after {
    content: ''; position: absolute; left: 6px; right: 6px; bottom: 5px; height: 8px;
    background: #48b066; border-radius: 2px;
}
.tx-option[data-id="blur"] .tx-option__swatch::after {
    content: ''; position: absolute; inset: 5px; border-radius: 3px;
    background: #48b066; filter: blur(3px); opacity: 0.7;
}
.tx-option[data-id="whip"] .tx-option__swatch::after {
    content: ''; position: absolute; top: 8px; bottom: 8px; left: 4px; width: 22px;
    background: linear-gradient(90deg, transparent, #48b066);
    filter: blur(1px);
}
.tx-option[data-id="wipe"] .tx-option__swatch::after {
    content: ''; position: absolute; top: 0; bottom: 0; left: 14px; width: 6px;
    background: #48b066; box-shadow: 0 0 8px #48b066;
}
.tx-option[data-id="iris"] .tx-option__swatch::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 16px; height: 16px; margin: -8px 0 0 -8px;
    border-radius: 50%; background: #48b066;
}
.tx-option[data-id="cardstack"] .tx-option__swatch::after {
    content: ''; position: absolute; left: 6px; right: 6px; top: 4px; bottom: 9px;
    background: #48b066; border-radius: 3px;
    box-shadow: 4px 4px 0 -1px #2d6f44;
}
.tx-option[data-id="letterbox"] .tx-option__swatch::before,
.tx-option[data-id="letterbox"] .tx-option__swatch::after {
    content: ''; position: absolute; left: 0; right: 0; height: 7px; background: #fff; opacity: 0.85;
}
.tx-option[data-id="letterbox"] .tx-option__swatch::before { top: 0; }
.tx-option[data-id="letterbox"] .tx-option__swatch::after { bottom: 0; }
.tx-option[data-id="flash"] .tx-option__swatch::after {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(circle, #6ad985, #48b066);
}
.tx-option[data-id="diagonal"] .tx-option__swatch::after {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, transparent 30%, #48b066 35%, #48b066 55%, transparent 60%);
}

.tx-option__name {
    font-size: 13px;
    font-weight: 500;
    color: #e8e8e8;
    flex: 1;
}
.tx-option__hint {
    font-family: ui-monospace, monospace;
    font-size: 10px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 0.02em;
}
.tx-option.is-active .tx-option__name { color: #fff; }

.tx-panel__foot {
    padding: 10px 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
}
.tx-panel__hint {
    font-family: ui-monospace, monospace;
    font-size: 10px;
    color: rgba(255,255,255,0.42);
    letter-spacing: 0.04em;
}
.tx-panel__preview-btn {
    appearance: none;
    background: rgba(72,176,102,0.12);
    border: 1px solid rgba(72,176,102,0.30);
    color: #5ec97c;
    font-family: ui-monospace, monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.tx-panel__preview-btn:hover { background: rgba(72,176,102,0.22); color: #fff; }

/* Floating launch button (when host hasn't activated the panel) */
.tx-launch {
    display: none !important;
}
.tx-launch__legacy {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 2147483499;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px 10px 12px;
    background: rgba(14,14,14,0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    color: #e8e8e8;
    font-family: ui-monospace, monospace;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.18s, border-color 0.18s, transform 0.18s, opacity 0.2s;
    opacity: 1;
}
.tx-launch:hover {
    background: rgba(72,176,102,0.12);
    border-color: rgba(72,176,102,0.30);
    color: #5ec97c;
    transform: translateY(-1px);
}
.tx-launch[hidden] { display: none; }
.tx-launch__icon {
    width: 14px; height: 14px;
    display: inline-flex; align-items: center; justify-content: center;
}
.tx-launch__icon svg { width: 14px; height: 14px; }
body.webpage-mode .tx-launch,
body.webpage-mode .tx-panel { display: none; }
