/* Perspective for 3D flip effect */
.perspective-1000 {
    perspective: 1000px;
}

/* Card basic styling */
.game-card {
    width: 240px;
    height: 380px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
    cursor: pointer;
}

/* Flipped state */
.game-card.flipped {
    transform: rotateY(180deg);
}

/* Card Faces */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 0.5rem; /* rounded-lg */
    overflow: hidden;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

.card-back {
    background-color: #292524; /* stone-800 */
    border: 4px solid #57534e; /* stone-600 */
    color: #a8a29e; /* stone-400 */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* geometric pattern for card back */
    background-image: radial-gradient(#57534e 2px, transparent 2px), radial-gradient(#57534e 2px, transparent 2px);
    background-size: 30px 30px;
    background-position: 0 0, 15px 15px;
}

.card-front {
    background-color: #fafaf9; /* stone-50 */
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
}

/* Rarity specific styles */
/* Normal */
.card-front.rarity-n {
    border: 4px solid #a8a29e; /* stone-400 */
}

/* Rare */
.card-front.rarity-r {
    border: 4px solid #38bdf8; /* sky-400 */
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.5) inset;
}
.rarity-label-r {
    color: #38bdf8;
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.8);
}

/* Ultra Rare */
.card-front.rarity-ur {
    border: 4px solid #fbbf24; /* amber-400 */
    box-shadow: 0 0 25px rgba(251, 191, 36, 0.6) inset, 0 0 15px rgba(251, 191, 36, 0.5);
    position: relative;
    overflow: hidden;
}

.card-front.rarity-ur::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(125deg, transparent 20%, rgba(255,255,255,0.7) 40%, rgba(255,255,255,0.9) 50%, rgba(255,255,255,0.7) 60%, transparent 80%);
    background-size: 200% 200%;
    animation: shine 3s infinite linear;
    mix-blend-mode: overlay;
    z-index: 20;
}

.rarity-label-ur {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 1);
}

@keyframes shine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Pack Opening Animations */
@keyframes packShake {
    0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
    25% { transform: translate(-52%, -50%) rotate(-3deg); }
    50% { transform: translate(-48%, -50%) rotate(3deg); }
    75% { transform: translate(-51%, -50%) rotate(-1deg); }
}

.pack-shake {
    animation: packShake 0.4s ease-in-out infinite;
}

@keyframes flashWhite {
    0% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

.flash {
    animation: flashWhite 0.8s ease-out forwards;
}

/* Card entry animation */
.card-enter {
    animation: cardDrop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes cardDrop {
    0% { opacity: 0; transform: translateY(-50px) scale(0.8); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

/* Collection view */
.collection-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.collection-toolbar-field {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: #a8a29e;
    background: linear-gradient(180deg, rgba(58, 51, 46, 0.55), rgba(41, 37, 36, 0.86));
    border: 1px solid rgba(120, 113, 108, 0.5);
    border-radius: 0.75rem;
    padding: 0.65rem 0.75rem 0.75rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.collection-toolbar-field > span {
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: #d6d3d1;
    font-weight: 600;
}

.collection-toolbar-field:focus-within {
    z-index: 35;
    border-color: rgba(212, 175, 55, 0.75);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28), 0 0 0 2px rgba(212, 175, 55, 0.18);
    transform: translateY(-1px);
}

.collection-toolbar-field .collection-dropdown.is-open {
    z-index: 40;
}

.collection-dropdown {
    position: relative;
}

.collection-dropdown-trigger {
    width: 100%;
    border: 1px solid rgba(120, 113, 108, 0.7);
    background: linear-gradient(180deg, rgba(67, 60, 54, 0.9), rgba(41, 37, 36, 0.96));
    color: #e7e5e4;
    border-radius: 0.55rem;
    padding: 0.68rem 0.85rem;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, background-color 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    outline: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

.collection-dropdown-trigger:hover {
    border-color: rgba(212, 175, 55, 0.55);
    background: linear-gradient(180deg, rgba(75, 67, 60, 0.92), rgba(51, 46, 42, 0.98));
}

.collection-dropdown-trigger:focus-visible {
    border-color: rgba(212, 175, 55, 0.9);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.collection-dropdown-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.collection-dropdown-caret {
    flex: 0 0 auto;
    width: 0.7rem;
    height: 0.7rem;
    border-right: 2px solid #d6d3d1;
    border-bottom: 2px solid #d6d3d1;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 0.2s ease;
}

.collection-dropdown.is-open .collection-dropdown-caret {
    transform: rotate(-135deg) translateY(-1px);
}

.collection-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    width: 100%;
    border-radius: 0.65rem;
    border: 1px solid rgba(212, 175, 55, 0.35);
    background: rgba(28, 25, 23, 0.98);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.42);
    max-height: 15rem;
    overflow-y: auto;
    padding: 0.35rem;
    z-index: 50;
}

.collection-dropdown-option {
    width: 100%;
    border: none;
    background: transparent;
    color: #e7e5e4;
    text-align: left;
    padding: 0.58rem 0.62rem;
    border-radius: 0.45rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.collection-dropdown-option:hover {
    background: rgba(87, 83, 78, 0.58);
}

.collection-dropdown-option.is-selected {
    background: rgba(212, 175, 55, 0.22);
    color: #f8e3a0;
}

.collection-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.collection-summary-panel {
    background: rgba(41, 37, 36, 0.92);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.collection-summary-label {
    color: #a8a29e;
    font-size: 0.875rem;
    letter-spacing: 0.08em;
}

.collection-summary-value {
    color: #fafaf9;
    font-family: 'Cinzel', serif;
    font-size: 2rem;
}

.collection-summary-sub {
    color: #a8a29e;
    font-size: 0.75rem;
}

.collection-empty {
    background: rgba(41, 37, 36, 0.9);
    border: 1px dashed rgba(168, 162, 158, 0.4);
    color: #d6d3d1;
    border-radius: 0.75rem;
    padding: 2rem 1.5rem;
    text-align: center;
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}

.collection-card {
    background: #fafaf9;
    border: 1px solid rgba(168, 162, 158, 0.5);
    border-radius: 0.9rem;
    overflow: hidden;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
}

.collection-card-image-wrap {
    position: relative;
    background: #e7e5e4;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.collection-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.collection-rarity-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.35rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(28, 25, 23, 0.8);
}

.collection-rarity-badge.rarity-n {
    color: #d6d3d1;
}

.collection-rarity-badge.rarity-r {
    color: #38bdf8;
}

.collection-rarity-badge.rarity-ur {
    color: #fbbf24;
}

.collection-card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-height: 170px;
}

.collection-card-title {
    color: #1c1917;
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.4;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.collection-card-artist {
    color: #44403c;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collection-card-date {
    color: #78716c;
    font-size: 0.75rem;
}

.collection-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.collection-card-chip {
    background: rgba(214, 211, 209, 0.8);
    color: #292524;
    font-size: 0.68rem;
    font-weight: 600;
    border-radius: 9999px;
    padding: 0.2rem 0.5rem;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.collection-card-meta {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(214, 211, 209, 0.9);
    color: #57534e;
    font-size: 0.8rem;
    font-weight: 600;
}
