/* ============================================================
   Stage Kit — shared cinematic frame
   Ambient backdrop, masthead, loader, and state classes used by
   StageScene / StageMasthead / StageLoader across all pages.
   Promoted from the original DeckEditor de-* scoped styles.
   ============================================================ */

/* ============================================================
   Ambient backdrop — commander-art wash, color-identity aurora,
   and drifting motes. Behind all content, non-interactive, low
   opacity. Themed live via --art / --glow-1..3 on the page root.
   ============================================================ */

.stage-ambient {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Commander art bleeding from the top, heavily blurred, fading to void */
.stage-art-wash {
    position: absolute;
    inset: 0 0 auto 0;
    height: 62vh;
    background-image: var(--art);
    background-size: cover;
    background-position: center 20%;
    opacity: 0.24;
    filter: blur(46px) saturate(1.2);
    transform: scale(1.12);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0) 92%);
            mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0) 92%);
}

/* Soft drifting aurora orbs in the commander's mana colors */
.stage-aurora {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.30;
    will-change: transform;
}

.stage-aurora-1 {
    width: 46vw;
    height: 46vw;
    left: -10vw;
    top: -12vh;
    background: radial-gradient(circle, var(--glow-1), transparent 68%);
    animation: stage-drift-1 36s ease-in-out infinite;
}

.stage-aurora-2 {
    width: 40vw;
    height: 40vw;
    right: -8vw;
    top: 8vh;
    background: radial-gradient(circle, var(--glow-2), transparent 68%);
    animation: stage-drift-2 44s ease-in-out infinite;
}

.stage-aurora-3 {
    width: 32vw;
    height: 32vw;
    left: 32vw;
    top: 42vh;
    background: radial-gradient(circle, var(--glow-3), transparent 68%);
    animation: stage-drift-3 52s ease-in-out infinite;
}

@keyframes stage-drift-1 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(6vw, 4vh); }
}

@keyframes stage-drift-2 {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-5vw, 6vh); }
}

@keyframes stage-drift-3 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(3vw, -5vh) scale(1.12); }
}

/* Sparse rising motes — arcane dust */
.stage-motes {
    position: absolute;
    inset: 0;
}

/* Our own lettered mana pips (not official symbols) drifting upward. */
.stage-mote {
    position: absolute;
    bottom: -40px;
    width: var(--s);
    height: var(--s);
    border-radius: 50%;
    display: grid;
    place-items: center;
    font: 800 calc(var(--s) * 0.52) / 1 var(--font-ui);
    opacity: 0;
    animation: stage-rise var(--dur) linear var(--delay) infinite;
    will-change: transform, opacity;
}

.stage-mote--w { background: var(--mana-w); color: #5a4a1e; }
.stage-mote--u { background: var(--mana-u); color: #fff; }
.stage-mote--b { background: var(--mana-b); color: #fff; }
.stage-mote--r { background: var(--mana-r); color: #fff; }
.stage-mote--g { background: var(--mana-g); color: #06120c; }
.stage-mote--c { background: var(--mana-c); color: #1a1a1a; }

/* Logo motes: the site mark drifting in place of mana pips on non-deck pages.
   Sparser + larger than pips, lower opacity — a subtle brand texture and a
   future sponsor/advert slot (swap MoteImageUrl). */
.stage-motes--logo { opacity: 0.7; }

.stage-mote-logo {
    background: none;
    border-radius: 0;
    width: calc(var(--s) * 1.6);
    height: calc(var(--s) * 1.6);
    object-fit: contain;
}

@keyframes stage-rise {
    0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
    10% { opacity: 0.26; }
    88% { opacity: 0.2; }
    100% { transform: translateY(-114vh) translateX(var(--drift)) rotate(var(--spin)); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .stage-aurora { animation: none; }
    .stage-motes { display: none; }
}

/* ── Page header (masthead) ─────────────────────────────────── */

.stage-masthead {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
    padding: 18px 22px;
    border-radius: var(--radius-card);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-card);
    isolation: isolate;
}

/* Cinematic hero backdrop: commander art bleeds in from the right,
   behind a dark gradient scrim so the title/stats stay legible. */
.stage-hero {
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image:
        linear-gradient(105deg, var(--surf) 6%, rgba(18, 23, 20, 0.62) 48%, rgba(18, 23, 20, 0.18) 100%),
        var(--art);
    background-size: cover, cover;
    background-position: center, right 26%;
    background-repeat: no-repeat;
    filter: saturate(1.1);
}

/* extra vignette to seat the art into the card */
.stage-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
}

/* ── Compact commander display (fixed, lives in the header) ─────── */

.stage-commanders {
    display: flex;
    gap: 6px;
    flex: 0 0 auto;
}

.stage-commander {
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    line-height: 0;
    border-radius: 7px;
}

.stage-commander-art {
    display: block;
    width: 40px;
    height: 56px;
    object-fit: cover;
    object-position: center 18%; /* favour the art crop over the text box */
    border-radius: 7px;
    border: 1px solid var(--line);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
    transition: outline-color 0.12s ease;
    outline: 2px solid transparent;
}

.stage-commander:hover .stage-commander-art,
.stage-commander:focus-visible .stage-commander-art {
    outline-color: var(--deck-accent, var(--jade));
}

.stage-id {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.stage-eyebrow {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--deck-accent, var(--ink-3));
    font-weight: 700;
    opacity: 0.92;
}

.stage-title {
    font-family: var(--font-disp);
    font-size: 24px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

/* ── Deck fingerprint: mana curve + color pie + stats ──────────── */

.stage-fingerprint {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 0 0 auto;
    /* minimal dark panel so the charts/text stay legible over the commander art */
    padding: 9px 14px;
    border-radius: 12px;
    background: rgba(7, 9, 8, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.07);
}

.stage-curve {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 34px;
    width: 70px;
}

.stage-curve-bar {
    flex: 1;
    min-height: 2px;
    border-radius: 1.5px 1.5px 0 0;
    background: var(--deck-accent-grad, var(--jade));
    opacity: 0.85;
}

.stage-pie {
    position: relative;
    width: 32px;
    height: 32px;
    flex: 0 0 auto;
}

.stage-pie-ring {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* background (conic-gradient) is set inline from the color pie */
    -webkit-mask: radial-gradient(transparent 38%, #000 41%);
            mask: radial-gradient(transparent 38%, #000 41%);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.stage-fp-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    white-space: nowrap;
}

.stage-fp-row {
    font-size: 12px;
    color: var(--ink-2);
}

.stage-fp-row b {
    color: var(--ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-right: 4px;
}

.stage-fp-sub {
    font-size: 11px;
    color: var(--ink-3);
}

/* ── Status / notice states ─────────────────────────────────── */

.stage-status {
    padding: 48px 0;
    text-align: center;
    color: var(--ink-2);
    font-size: 14px;
}

/* ── Loading skeleton (previews the editor materializing) ───────── */

.stage-loading {
    padding-top: 20px;
}

/* shimmer base */
.stage-sk {
    position: relative;
    overflow: hidden;
    background: var(--surf-raised);
    border-radius: 8px;
}

.stage-sk::after {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
    animation: stage-sk-sweep 1.5s ease-in-out infinite;
}

@keyframes stage-sk-sweep {
    100% { transform: translateX(100%); }
}

.stage-sk-masthead {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    margin-bottom: 22px;
}

.stage-sk-commander {
    width: 40px;
    height: 56px;
    flex: 0 0 auto;
    border-radius: 7px;
}

.stage-sk-id {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.stage-sk-eyebrow { width: 90px; height: 9px; }
.stage-sk-title { width: 230px; height: 22px; }

/* Skeleton toolkit: provided for page-shaped <StageLoader Skeleton> fragments
   (masthead bar, toolbar pills, section heads). Some are unused by the current
   default/grid skeletons — kept intentionally as the shared skeleton vocabulary. */
.stage-sk-fingerprint {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 34px;
}

.stage-sk-bar { width: 8px; border-radius: 2px; }

.stage-sk-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.stage-sk-pill { height: 32px; border-radius: var(--radius-ctrl); }

.stage-sk-secthead {
    width: 180px;
    height: 16px;
    margin: 6px 0 14px 4px;
}

.stage-sk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.stage-sk-card {
    aspect-ratio: 5 / 7;
    border-radius: 10px;
}

/* ── Flavor: pulsing mana pips + rotating captions ─────────────── */

.stage-loading-flavor {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 32px;
}

.stage-loading-pips {
    display: flex;
    gap: 6px;
}

.stage-loading-pips span {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    opacity: 0.35;
    animation: stage-pip-pulse 1.4s ease-in-out infinite;
}

.stage-loading-pips span:nth-child(2) { animation-delay: 0.12s; }
.stage-loading-pips span:nth-child(3) { animation-delay: 0.24s; }
.stage-loading-pips span:nth-child(4) { animation-delay: 0.36s; }
.stage-loading-pips span:nth-child(5) { animation-delay: 0.48s; }

@keyframes stage-pip-pulse {
    0%, 100% { opacity: 0.3; transform: translateY(0) scale(0.9); }
    40% { opacity: 1; transform: translateY(-4px) scale(1.1); }
}

.stage-loading-captions {
    position: relative;
    width: 200px;
    height: 1.4em;
    font-size: 13.5px;
    color: var(--ink-2);
    font-style: italic;
}

.stage-loading-captions span {
    position: absolute;
    left: 0;
    white-space: nowrap;
    opacity: 0;
    animation: stage-cap-cycle 6s ease-in-out infinite;
}

.stage-loading-captions span:nth-child(2) { animation-delay: 2s; }
.stage-loading-captions span:nth-child(3) { animation-delay: 4s; }

@keyframes stage-cap-cycle {
    0%, 4% { opacity: 0; transform: translateY(5px); }
    8%, 28% { opacity: 1; transform: translateY(0); }
    33%, 100% { opacity: 0; transform: translateY(-5px); }
}

@media (prefers-reduced-motion: reduce) {
    .stage-sk::after,
    .stage-loading-pips span { animation: none; }
    .stage-loading-captions span:first-child { opacity: 1; animation: none; }
    .stage-loading-captions span:not(:first-child) { display: none; }
}

.stage-notice {
    padding: 14px 18px;
    border-radius: var(--radius-ctrl);
    border: 1px solid var(--line);
    background: var(--surf-raised);
    color: var(--ink-2);
    font-size: 14px;
    margin-top: 24px;
}

.stage-notice--error {
    border-color: var(--danger);
    background: rgba(204, 75, 63, 0.08);
    color: var(--danger-text);
}

.stage-notice--warning {
    border-color: rgba(217, 189, 113, 0.48);
    background: rgba(217, 189, 113, 0.12);
    color: #F0DFA9;
}

.stage-notice--success {
    border-color: rgba(91, 168, 107, 0.5);
    background: rgba(91, 168, 107, 0.1);
    color: var(--jade-bright);
}

.stage-empty {
    margin-top: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
}

.stage-empty-text {
    color: var(--ink-2);
    font-size: 15px;
    margin: 0;
}

.stage-empty-cta {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 11px 20px;
    border-radius: var(--radius-ctrl);
    background: linear-gradient(180deg, var(--gold), #c9912f);
    color: #1a1305;
    font-weight: 700;
    font-size: 13.5px;
    text-decoration: none;
}

.stage-empty-cta:hover {
    filter: brightness(1.06);
}

/* ── Intensity modifiers ────────────────────────────────────────
   Full = base rules above. Subtle/Chrome reduce layers & motion. */

/* Subtle: no art-wash, dimmer + slower auroras, fewer motes. */
.stage-ambient--subtle .stage-art-wash { display: none; }
.stage-ambient--subtle .stage-aurora { opacity: 0.18; }
.stage-ambient--subtle .stage-aurora-1 { animation-duration: 54s; }
.stage-ambient--subtle .stage-aurora-2 { animation-duration: 66s; }
.stage-ambient--subtle .stage-aurora-3 { animation-duration: 78s; }

/* Chrome: a single faint, static glow; no art, no motes, no motion. */
.stage-ambient--chrome .stage-art-wash,
.stage-ambient--chrome .stage-aurora-2,
.stage-ambient--chrome .stage-aurora-3,
.stage-ambient--chrome .stage-motes { display: none; }
.stage-ambient--chrome .stage-aurora-1 { opacity: 0.10; animation: none; }

/* Logo motes are the brand presence on neutral pages, so keep them on chrome
   pages (which otherwise hide motes) — but still hide all motes when the user
   prefers reduced motion. */
.stage-ambient--chrome .stage-motes--logo { display: block; }
@media (prefers-reduced-motion: reduce) {
    .stage-motes--logo,
    .stage-ambient--chrome .stage-motes--logo { display: none; }
}

/* Contained scope: fill the nearest positioned ancestor instead of the viewport. */
.stage-ambient--contained { position: absolute; }

/* ── Masthead variants & trailing slot ─────────────────────────── */
.stage-masthead-trailing { margin-left: auto; flex: 0 0 auto; }
.stage-id-mana { margin-top: 4px; }

/* Optional subtitle / description line beneath the title. */
.stage-lede {
    margin: 6px 0 0;
    max-width: 60ch;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink-2);
}

/* Tall = cinematic hero moment (≈ old HeroBand Tall). */
.stage-masthead--tall {
    min-height: 300px;
    align-items: flex-end;
    padding: 26px 28px;
}
.stage-masthead--tall .stage-title { font-size: clamp(2rem, 4vw, 3rem); }

/* Compact = slim persistent band (the DeckEditor default). */
.stage-masthead--compact { align-items: center; }
