/* ============================================================
   CARD STYLES - Result cards for 3★/4★/5★/6★
   ============================================================ */

/* --- Single Result Card --- */
.result-card-container {
    perspective: 1200px;
}

.result-card {
    position: relative;
    width: 280px;
    height: 420px;
    border-radius: 16px;
    overflow: hidden;
    transform: scale(0);
    animation: card-reveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes card-reveal {
    0% { transform: scale(0) rotateY(180deg); opacity: 0; }
    60% { transform: scale(1.05) rotateY(10deg); opacity: 1; }
    100% { transform: scale(1) rotateY(0deg); opacity: 1; }
}

.card-glow {
    position: absolute;
    inset: -4px;
    border-radius: 20px;
    z-index: -1;
    opacity: 0;
    animation: glow-in 0.8s 0.3s ease forwards;
}

@keyframes glow-in {
    to { opacity: 1; }
}

/* Rarity-specific glow */
.result-card.rarity-3 .card-glow {
    box-shadow: 0 0 30px rgba(92, 130, 168, 0.4), 0 0 60px rgba(92, 130, 168, 0.2);
}

.result-card.rarity-4 .card-glow {
    box-shadow: 0 0 30px rgba(180, 135, 208, 0.5), 0 0 80px rgba(180, 135, 208, 0.3);
}

.result-card.rarity-5 .card-glow {
    box-shadow: 0 0 40px rgba(232, 166, 48, 0.6), 0 0 100px rgba(232, 166, 48, 0.3),
                0 0 160px rgba(232, 166, 48, 0.15);
}

.result-card.rarity-6 .card-glow {
    box-shadow: 0 0 40px rgba(255, 105, 180, 0.6), 0 0 100px rgba(255, 215, 0, 0.4),
                0 0 180px rgba(0, 255, 255, 0.2);
    animation: glow-in 0.8s 0.3s ease forwards, rainbow-glow 3s ease-in-out infinite;
}

@keyframes rainbow-glow {
    0% { box-shadow: 0 0 40px rgba(255, 105, 180, 0.6), 0 0 100px rgba(255, 215, 0, 0.4); }
    33% { box-shadow: 0 0 40px rgba(0, 255, 255, 0.6), 0 0 100px rgba(255, 105, 180, 0.4); }
    66% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.6), 0 0 100px rgba(0, 255, 255, 0.4); }
    100% { box-shadow: 0 0 40px rgba(255, 105, 180, 0.6), 0 0 100px rgba(255, 215, 0, 0.4); }
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 16px 12px;
}

/* When card has a full image */
.result-card.has-image .card-inner {
    justify-content: flex-end;
}

/* Card backgrounds per rarity */
.result-card.rarity-3 .card-inner {
    background: linear-gradient(135deg, #1a2a40 0%, #344a6e 50%, #1a2a40 100%);
}

.result-card.rarity-4 .card-inner {
    background: linear-gradient(135deg, #2a1545 0%, #4a2870 50%, #2a1545 100%);
}

.result-card.rarity-5 .card-inner {
    background: linear-gradient(135deg, #3d2810 0%, #6b4c1e 50%, #3d2810 100%);
}

.result-card.rarity-6 .card-inner {
    background: linear-gradient(135deg, #1a0a0a 0%, #2a1020 50%, #0a0a1a 100%);
    overflow: hidden;
}

/* 6★ mystery/glitch card */
.result-card.rarity-6.mystery-card .card-name {
    font-family: 'Courier New', monospace;
    animation: glitch-text 0.15s infinite;
}

.result-card.rarity-6.mystery-card .card-inner::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.03) 2px,
        rgba(0, 255, 0, 0.03) 4px
    );
    z-index: 1;
    pointer-events: none;
    animation: scanline-scroll 2s linear infinite;
}

@keyframes scanline-scroll {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

@keyframes glitch-text {
    0% { transform: translate(0); opacity: 1; }
    20% { transform: translate(-2px, 1px); opacity: 0.8; }
    40% { transform: translate(2px, -1px); opacity: 1; }
    60% { transform: translate(-1px, -1px); opacity: 0.9; }
    80% { transform: translate(1px, 2px); opacity: 1; }
    100% { transform: translate(0); opacity: 0.85; }
}

.result-card.rarity-6.mystery-card .card-glow {
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.4), 0 0 60px rgba(0, 255, 0, 0.2);
    animation: glow-in 0.8s 0.3s ease forwards, mystery-glow 1.5s ease-in-out infinite;
}

@keyframes mystery-glow {
    0% { box-shadow: 0 0 30px rgba(255, 0, 0, 0.5), 0 0 60px rgba(0, 255, 0, 0.2); }
    50% { box-shadow: 0 0 50px rgba(0, 255, 100, 0.6), 0 0 80px rgba(255, 0, 0, 0.3); }
    100% { box-shadow: 0 0 30px rgba(255, 0, 0, 0.5), 0 0 60px rgba(0, 255, 0, 0.2); }
}

@keyframes rainbow-bg {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Card shimmer overlay */
.result-card .card-inner::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent 40%,
        rgba(255, 255, 255, 0.08) 50%,
        transparent 60%
    );
    background-size: 200% 200%;
    animation: card-shimmer 3s ease-in-out infinite;
    pointer-events: none;
    z-index: 3;
}

@keyframes card-shimmer {
    0% { background-position: -100% -100%; }
    100% { background-position: 200% 200%; }
}

/* Card elements */
.card-icon {
    font-size: 80px;
    filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Full-card background image */
.card-img-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
}

.result-card.has-image .card-icon {
    display: none;
}

/* Dark gradient at bottom so text is readable */
.result-card.has-image .card-inner::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55%;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.4) 60%, transparent 100%);
    z-index: 1;
    pointer-events: none;
}

.result-card.has-image .card-name,
.result-card.has-image .card-type,
.result-card.has-image .card-stars,
.result-card.has-image .card-rarity,
.result-card.has-image .card-new-badge {
    position: relative;
    z-index: 2;
}

.card-img-fallback {
    font-size: 80px;
}

.result-multi-grid .card-img-fallback {
    font-size: 48px;
}

.card-name {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    letter-spacing: 1px;
}

.result-card.rarity-3 .card-name { color: #8ab4d8; }
.result-card.rarity-4 .card-name { color: #d4a0f5; }
.result-card.rarity-5 .card-name { color: #ffd700; }
.result-card.rarity-6 .card-name { color: #ffffff; text-shadow: 0 0 20px rgba(255, 255, 255, 0.8); }

.card-type {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.card-rarity {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 700;
    letter-spacing: 1px;
}

.result-card.rarity-3 .card-rarity { color: var(--star-3-color); }
.result-card.rarity-4 .card-rarity { color: var(--star-4-color); }
.result-card.rarity-5 .card-rarity { color: var(--star-5-color); }
.result-card.rarity-6 .card-rarity { color: var(--star-6-color); }

.card-stars {
    display: flex;
    gap: 2px;
    font-size: 18px;
}

.card-stars .star {
    opacity: 0;
    transform: scale(0);
    animation: star-pop 0.3s ease forwards;
}

.card-stars .star:nth-child(1) { animation-delay: 0.5s; }
.card-stars .star:nth-child(2) { animation-delay: 0.6s; }
.card-stars .star:nth-child(3) { animation-delay: 0.7s; }
.card-stars .star:nth-child(4) { animation-delay: 0.8s; }
.card-stars .star:nth-child(5) { animation-delay: 0.9s; }
.card-stars .star:nth-child(6) { animation-delay: 1.0s; }

@keyframes star-pop {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.result-card.rarity-3 .card-stars .star { color: var(--star-3-color); }
.result-card.rarity-4 .card-stars .star { color: var(--star-4-color); }
.result-card.rarity-5 .card-stars .star { color: var(--star-5-color); }
.result-card.rarity-6 .card-stars .star { color: var(--star-6-color); }

/* NEW badge */
.card-new-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    background: var(--genshin-gold);
    color: #1a1f3a;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 1px;
    animation: badge-flash 1s ease-in-out infinite;
}

@keyframes badge-flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* --- Multi Result Grid (10x) --- */
.result-multi-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    padding: 20px;
    max-width: 1100px;
}

.result-multi-grid .result-card {
    width: 180px;
    height: 270px;
    animation-delay: calc(var(--card-index) * 0.1s);
}

.result-multi-grid .card-icon {
    font-size: 48px;
}

.result-multi-grid .card-name {
    font-size: 14px;
}

.result-multi-grid .card-stars .star {
    font-size: 12px;
}

/* Responsive for multi-grid */
@media (max-width: 1000px) {
    .result-multi-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 8px;
    }
    .result-multi-grid .result-card {
        width: 140px;
        height: 210px;
    }
}

@media (max-width: 768px) {
    .result-multi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
