/* ========================================
   ESTILOS DE CARTAS
   ======================================== */

/* Contenedor de las cartas */
.deck-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(0.5vmin, 3vw, 6vmin);
    align-self: center;
    margin-block: auto;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
} 

.hidden-by-panel {
    display: none !important;
}

.card-container {
    width: clamp(10vh, 10vw, 18vmin);
    aspect-ratio: 2 / 3;
    perspective: 60vmin;
    -webkit-perspective: 60vmin;
    -moz-perspective: 60vmin;
    filter: drop-shadow(0 1.2vmin 1vmin rgba(0,0,0,0.5));
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
    position: relative;
}  

/* La carta base */
.card {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
}

/* Animación cuando se añade la clase .is-flipped */
.card.is-flipped {
    animation: jump-in 0.8s forwards;
}

/* Animación cuando se quita la clase (vuelta al dorso) */
.card:not(.is-flipped) {
    animation: jump-out 0.6s forwards;
}

@keyframes jump-in {
    0% { transform: rotateY(0deg) translateY(0) scale(1); }
    30% { transform: rotateY(90deg) translateY(-5vh) scale(1.1); }
    60% { transform: rotateY(180deg) translateY(0) scale(1); }
    80% { transform: rotateY(180deg) translateY(-1vh) scale(1); }
    100% { transform: rotateY(180deg) translateY(0) scale(1); }
} 

@keyframes jump-out {
    0% { transform: rotateY(180deg) translateY(0); }
    50% { transform: rotateY(90deg) translateY(-3vh); }
    100% { transform: rotateY(0deg) translateY(0); }
} 

.card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -moz-backface-visibility: hidden;
    background: transparent !important;
    transform-style: preserve-3d;
    -webkit-transform-style: preserve-3d;
    -moz-transform-style: preserve-3d;
}

.card-back {
    transform: rotateY(180deg);
    -webkit-transform: rotateY(180deg);
    -moz-transform: rotateY(180deg);
    position: relative;
    overflow: hidden;
    border-radius: 0.6vmin;
}

/* Efecto de brillo en las cartas */
.card-back::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        transparent 40%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0.5) 55%,
        rgba(255, 255, 255, 0.3) 60%,
        transparent 70%,
        transparent 100%
    );
    transform: translateX(-100%) translateY(-100%) rotate(45deg);
    z-index: 10;
    pointer-events: none;
    animation: shine 3s ease-in-out infinite;
}

@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
    50% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
    100% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }
}

.back-template {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.back-content {
    position: absolute;
    top: 20%; 
    left: 12%;
    width: 76%;
    height: auto;
    max-height: 60%;
    z-index: 2;
    object-fit: cover;
    border-radius: 0.6vmin;
} 

/* Texto en las cartas */
.back-text {
    position: absolute;
    bottom: 12%;
    left: 0%;
    width: 100%;
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.name-box {
    width: 78%;
    max-width: 86%;
    min-width: 40%;
    margin: 0 auto;
    padding: clamp(0.45vmin, 1.2vw, 0.8vmin) 0;
    box-sizing: border-box;
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    --name-edge-width: clamp(1.2vmin, 3vw, 2.2vmin);
    --name-center-height: clamp(2.2vmin, 4.5vw, 2.8vmin);
}

.name-left, .name-right {
    flex: 0 0 var(--name-edge-width);
    height: var(--name-center-height);
    display: flex;
    align-items: center;
    justify-content: center;
    image-rendering: pixelated;
}

.name-left {
    align-items: end;
    justify-content: right;
}

.name-right {
    align-items: start;
    justify-content: left;
}

.name-left img, .name-right img {
    height: 100%;
    width: auto;
    display: block;
    image-rendering: pixelated;
}

.name-center {
    flex: 1 1 auto;
    height: var(--name-center-height);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 clamp(0.6vmin, 1.6vw, 1vmin);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
}

.name-center-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 0;
    image-rendering: pixelated;
}

.name-center .name-center-text {
    position: relative;
    z-index: 1;
    width: 100%;
    text-align: center;
}

.text-display {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.5rem;
    color: black;
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    display: inline-block;
    width: 100%;
    text-align: center;
    white-space: inherit;
    overflow: hidden;
}

.back-content { overflow: hidden; }
.back-content img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    display: block; 
    border-radius: inherit; 
}

/* ========================================
   RESPONSIVE - CARTAS
   ======================================== */

@media (max-width: 800px) {
    .card-container { 
        width: clamp(14vmin, 28vw, 26vmin); 
        aspect-ratio: 2 / 3; 
    }
    
    .deck-container {
        gap: clamp(1vmin, 2vw, 4vmin);
    }
    
    .text-display {
        font-size: clamp(0.4rem, 1.5vw, 0.55rem);
    }
}

@media (max-width: 480px) {
    .card-container { 
        width: clamp(18vmin, 44vw, 34vmin); 
        aspect-ratio: 2 / 3; 
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .deck-container {
        gap: 1.5vmin;
    }
    
    .card-container {
        width: clamp(12vh, 15vw, 16vh);
    }
    
    .text-display {
        font-size: clamp(0.35rem, 1.2vh, 0.45rem) !important;
        line-height: 1.2;
    }
    
    .name-box {
        --name-edge-width: clamp(1vh, 2vw, 1.5vh);
        --name-center-height: clamp(2vh, 3vw, 2.5vh);
    }
}

@media (max-width: 480px) and (orientation: portrait) {
    .deck-container {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, auto);
        gap: clamp(2vmin, 4vw, 4vmin);
        max-width: 95vw;
        justify-items: center;
    }
    
    .card-container {
        width: clamp(35vw, 40vw, 45vw);
        max-width: 180px;
    }
    
    .text-display {
        font-size: clamp(0.35rem, 2vw, 0.45rem) !important;
        line-height: 1.3;
        padding: 0 0.2rem;
    }
    
    .name-box {
        width: 85%;
        max-width: 90%;
        --name-edge-width: clamp(1vmin, 2.5vw, 2vmin);
        --name-center-height: clamp(2vmin, 4vw, 2.5vmin);
    }
    
    .name-center {
        padding: 0 clamp(0.3vmin, 1vw, 0.8vmin);
    }
}

@media (max-width: 360px) and (orientation: portrait) {
    .card-container {
        width: clamp(38vw, 42vw, 48vw);
    }
    
    .text-display {
        font-size: clamp(0.3rem, 1.8vw, 0.4rem) !important;
    }
    
    .deck-container {
        gap: clamp(1.5vmin, 3vw, 3vmin);
    }
}
