/**
 * MTG Card Flip Animation
 * 
 * CSS for double-faced cards (transform, modal_dfc, flip, reversible)
 * Uses 3D transforms for realistic card flip effect.
 *
 * @package MTG_Engine
 * @version 6.1.0
 */

/* ==========================================================================
   Flip Container
   ========================================================================== */

.mtg-card-flipper {
    perspective: 1000px;
    position: relative;
    display: block;
    /* Cambiato da inline-block per riempire il contenitore */
    width: 100%;
    /* Forza larghezza piena */
    max-width: 100%;
}

.mtg-card-flipper-inner {
    position: relative;
    width: 100%;
    height: 100%;
    /* Fix per layout collasso con immagini absolute */
    aspect-ratio: 5 / 7;
    /* Standard MTG Card Ratio */
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

/* Flipped state */
.mtg-card-flipper.flipped .mtg-card-flipper-inner {
    transform: rotateY(180deg);
}

/* Card faces */
.mtg-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 12px;
    overflow: hidden;
}

.mtg-card-face-front {
    z-index: 2;
}

.mtg-card-face-back {
    transform: rotateY(180deg);
    z-index: 1;
}

.mtg-card-face img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
}

/* ==========================================================================
   Flip Button
   ========================================================================== */

.mtg-flip-button {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 36px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0 0 12px 12px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 100;
    transform: none;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: background 0.2s ease;
    box-shadow: none;
}

.mtg-flip-button:hover {
    background: rgba(0, 0, 0, 0.95);
    border-color: rgba(255, 255, 255, 0.3);
    transform: none;
}

.mtg-flip-button:active {
    background: #000;
    transform: none;
}

/* Flip icon using CSS */
/* Flip icon using CSS - REMOVED, now in HTML */
.mtg-flip-button::before {
    content: none;
}

/* Alternative: SVG icon */
.mtg-flip-button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* ==========================================================================
   DFC Indicator Badge
   ========================================================================== */

.mtg-dfc-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mtg-dfc-badge.transform {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.mtg-dfc-badge.modal_dfc {
    background: linear-gradient(135deg, #2193b0 0%, #6dd5ed 100%);
}

.mtg-dfc-badge.flip {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* ==========================================================================
   Face Labels (shown on hover)
   ========================================================================== */

.mtg-face-label {
    position: absolute;
    bottom: 50px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    white-space: nowrap;
}

.mtg-card-flipper:hover .mtg-face-label {
    opacity: 1;
}

/* ==========================================================================
   Gallery Integration
   ========================================================================== */

.mtgci2-gallery-item .mtg-card-flipper {
    width: 100%;
}

.mtgci2-gallery-item .mtg-card-flipper-inner {
    aspect-ratio: 488 / 680;
    /* Standard MTG card ratio */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mtg-flip-button {
        width: 32px;
        height: 32px;
        bottom: 8px;
        right: 8px;
        transform: none;
    }

    .mtg-flip-button:hover {
        transform: scale(1.1);
        background: rgba(0, 0, 0, 0.9);
    }

    .mtg-flip-button:active {
        transform: scale(0.95);
    }

    .mtg-flip-button::before {
        font-size: 18px;
    }

    .mtg-dfc-badge {
        font-size: 9px;
        padding: 2px 6px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.mtg-flip-button:focus {
    outline: 2px solid #4a9eff;
    outline-offset: 2px;
}

.mtg-flip-button:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader text */
.mtg-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}