/* css/character-intro.css
   Rarity-scaled character introduction "spectacle" screen.
   Gold-on-dark aesthetic. All animations are transform/opacity only (GPU-friendly).
   Per-rarity theming is driven by the --ci-key / --ci-accent / --ci-char custom
   properties set inline by characterIntro.js, plus the .char-intro-<rarity> class. */

.char-intro-overlay {
    position: fixed;
    inset: 0;
    z-index: 9400;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    opacity: 0;
    background: radial-gradient(ellipse at center,
        rgba(10, 10, 16, 0.72) 0%,
        rgba(3, 3, 6, 0.94) 70%,
        rgba(0, 0, 0, 0.98) 100%);
    transition: opacity 0.28s ease;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.char-intro-overlay.char-intro-active { opacity: 1; }
.char-intro-overlay.char-intro-exit { opacity: 0; }

/* ── Backdrop (vignette / blackout) ── */
.char-intro-backdrop {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at center,
        rgba(0, 0, 0, 0) 30%,
        rgba(0, 0, 0, 0.7) 100%);
    opacity: 0;
    animation: char-intro-vignette 0.5s ease-out forwards;
}

@keyframes char-intro-vignette {
    from { opacity: 0; transform: scale(1.15); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Ray / rune layers ── */
.char-intro-rays {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-intro-ray {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 140vh;
    margin-left: -2px;
    margin-top: -70vh;
    transform-origin: 50% 50%;
    background: linear-gradient(to top,
        rgba(255, 255, 255, 0) 0%,
        var(--ci-accent, #fff) 50%,
        rgba(255, 255, 255, 0) 100%);
    opacity: 0;
    will-change: opacity, transform;
    animation: char-intro-ray-sweep 2.6s ease-out forwards;
}

@keyframes char-intro-ray-sweep {
    0%   { opacity: 0; }
    25%  { opacity: 0.55; }
    100% { opacity: 0; }
}

.char-intro-rune-ring,
.char-intro-starburst {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 340px;
    height: 340px;
    margin: -170px 0 0 -170px;
    border-radius: 50%;
    border: 2px dashed var(--ci-key, #B388FF);
    box-shadow: 0 0 40px var(--ci-key, #B388FF);
    opacity: 0;
    will-change: transform, opacity;
    animation: char-intro-rune-spin 5s linear forwards;
}

.char-intro-starburst {
    border-style: solid;
    border-width: 3px;
    box-shadow: 0 0 80px var(--ci-key, #FFD54F), inset 0 0 60px var(--ci-key, #FFD54F);
    animation: char-intro-starburst 3.2s ease-out forwards;
}

@keyframes char-intro-rune-spin {
    0%   { opacity: 0; transform: rotate(0deg) scale(0.6); }
    20%  { opacity: 0.8; }
    100% { opacity: 0.25; transform: rotate(180deg) scale(1); }
}

@keyframes char-intro-starburst {
    0%   { opacity: 0; transform: scale(0.2); }
    30%  { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(2.4); }
}

/* ── Particles ── */
.char-intro-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.char-intro-sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ci-accent, #fff);
    box-shadow: 0 0 8px var(--ci-accent, #fff);
    opacity: 0;
    will-change: transform, opacity;
    animation: char-intro-sparkle 1.2s ease-out forwards;
}

@keyframes char-intro-sparkle {
    0%   { opacity: 0; transform: scale(0); }
    40%  { opacity: 1; transform: scale(1.4); }
    100% { opacity: 0; transform: scale(0.2) translateY(-24px); }
}

.char-intro-goldrain {
    position: absolute;
    top: -10%;
    width: 3px;
    height: 26px;
    border-radius: 2px;
    background: linear-gradient(to bottom,
        rgba(255, 213, 79, 0), var(--ci-key, #FFD54F));
    box-shadow: 0 0 6px var(--ci-key, #FFD54F);
    opacity: 0;
    will-change: transform, opacity;
    animation: char-intro-goldrain 2s linear forwards;
}

@keyframes char-intro-goldrain {
    0%   { opacity: 0; transform: translateY(0); }
    10%  { opacity: 0.9; }
    100% { opacity: 0; transform: translateY(115vh); }
}

/* ── Shockwave rings & common flare ── */
.char-intro-shock {
    position: absolute;
    inset: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.char-intro-ring {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--ci-key, #4FC3F7);
    box-shadow: 0 0 30px var(--ci-key, #4FC3F7);
    opacity: 0;
    will-change: transform, opacity;
    animation: char-intro-ring 1.1s ease-out forwards;
}

@keyframes char-intro-ring {
    0%   { opacity: 0.9; transform: scale(0.2); }
    100% { opacity: 0; transform: scale(4.5); }
}

.char-intro-flare {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle,
        var(--ci-accent, #fff) 0%,
        rgba(255, 255, 255, 0) 65%);
    opacity: 0;
    will-change: transform, opacity;
    animation: char-intro-flare 1.2s ease-out forwards;
}

@keyframes char-intro-flare {
    0%   { opacity: 0; transform: scale(0.3); }
    35%  { opacity: 0.7; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.6); }
}

/* ── Content / nameplate ── */
.char-intro-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 24px 32px;
    max-width: 620px;
    transform: translateY(28px);
    opacity: 0;
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
}

.char-intro-revealed .char-intro-content {
    transform: translateY(0);
    opacity: 1;
}

.char-intro-gem {
    width: 26px;
    height: 26px;
    margin: 0 auto 14px;
    background: var(--ci-key, #A8B0BC);
    box-shadow: 0 0 22px var(--ci-key, #A8B0BC);
    transform: rotate(45deg) scale(0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s;
}

.char-intro-revealed .char-intro-gem {
    transform: rotate(45deg) scale(1);
}

.char-intro-name {
    font-size: clamp(2.2rem, 7vw, 4.4rem);
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1.05;
    color: var(--ci-char, #fff);
    text-shadow: 0 0 24px var(--ci-key, #fff), 0 2px 6px rgba(0, 0, 0, 0.6);
}

.char-intro-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(0.4em) scale(0.8);
    will-change: transform, opacity;
    animation: char-intro-letter-in 0.5s ease-out forwards;
}

@keyframes char-intro-letter-in {
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.char-intro-title {
    margin-top: 10px;
    font-size: clamp(0.85rem, 2.4vw, 1.15rem);
    font-weight: 700;
    letter-spacing: 0.42em;
    text-indent: 0.42em;
    text-transform: uppercase;
    color: var(--ci-key, #A8B0BC);
    opacity: 0;
    transition: opacity 0.4s ease 0.25s;
}

.char-intro-revealed .char-intro-title { opacity: 0.95; }

.char-intro-flavor {
    margin: 16px auto 0;
    max-width: 460px;
    font-size: clamp(0.85rem, 2vw, 1rem);
    font-style: italic;
    line-height: 1.45;
    color: rgba(230, 230, 240, 0.82);
    opacity: 0;
    transition: opacity 0.5s ease 0.4s;
}

.char-intro-revealed .char-intro-flavor { opacity: 1; }

/* ── NEW badge ── */
.char-intro-new-badge {
    position: absolute;
    top: -6px;
    right: 18px;
    padding: 4px 12px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: #1a1206;
    background: linear-gradient(135deg, #FFE082, #FFB300);
    border-radius: 4px;
    box-shadow: 0 0 16px rgba(255, 193, 7, 0.7);
    transform: rotate(8deg) scale(0);
    animation: char-intro-badge-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s forwards;
}

@keyframes char-intro-badge-pop {
    to { transform: rotate(8deg) scale(1); }
}

/* ── Legendary banner ── */
.char-intro-legend-banner {
    margin-top: 22px;
    font-size: clamp(0.8rem, 2.2vw, 1.05rem);
    font-weight: 800;
    letter-spacing: 0.5em;
    text-indent: 0.5em;
    color: #FFF3C4;
    text-shadow: 0 0 20px var(--ci-key, #FFD54F);
    opacity: 0;
    transform: scale(0.85);
}

.char-intro-banner-in .char-intro-legend-banner {
    animation: char-intro-legend-banner 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes char-intro-legend-banner {
    0%   { opacity: 0; transform: scale(0.85); letter-spacing: 0.2em; }
    100% { opacity: 1; transform: scale(1); letter-spacing: 0.5em; }
}

/* ── Rarity flavour overrides ── */
.char-intro-legendary {
    background: radial-gradient(ellipse at center,
        rgba(20, 14, 2, 0.82) 0%,
        rgba(2, 2, 4, 0.97) 72%,
        rgba(0, 0, 0, 1) 100%);
}

.char-intro-legendary .char-intro-name {
    font-family: Georgia, 'Times New Roman', serif;
    letter-spacing: 0.08em;
}

/* Legendary starts fully black, then the burst lets the stage through. */
.char-intro-legendary .char-intro-rays,
.char-intro-legendary .char-intro-particles {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.char-intro-legendary.char-intro-burst .char-intro-rays,
.char-intro-legendary.char-intro-burst .char-intro-particles {
    opacity: 1;
}

.char-intro-epic .char-intro-name {
    text-shadow: 0 0 30px var(--ci-key, #B388FF), 0 2px 6px rgba(0, 0, 0, 0.7);
}

/* ── Screen shake (overlay only — never the body) ── */
.char-intro-shaking {
    animation: char-intro-shake 0.4s ease-in-out;
}

@keyframes char-intro-shake {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-6px, 4px); }
    40% { transform: translate(7px, -5px); }
    60% { transform: translate(-5px, -4px); }
    80% { transform: translate(4px, 5px); }
}

/* Skipping snaps content to its resting state without further motion. */
.char-intro-skipped .char-intro-content {
    transition-duration: 0.12s;
}
.char-intro-skipped .char-intro-letter {
    animation-duration: 0.12s;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .char-intro-content { padding: 18px 20px; }
    .char-intro-rune-ring,
    .char-intro-starburst {
        width: 240px;
        height: 240px;
        margin: -120px 0 0 -120px;
    }
    .char-intro-flare { width: 220px; height: 220px; }
    .char-intro-new-badge { right: 8px; }
    .char-intro-title { letter-spacing: 0.3em; text-indent: 0.3em; }
    .char-intro-legend-banner { letter-spacing: 0.32em; text-indent: 0.32em; }
}

/* Respect reduced-motion: keep the reveal, drop the churn. */
@media (prefers-reduced-motion: reduce) {
    .char-intro-ray,
    .char-intro-sparkle,
    .char-intro-goldrain,
    .char-intro-ring,
    .char-intro-flare,
    .char-intro-shaking {
        animation-duration: 0.01ms !important;
    }
}
