/**
 * Websly Hover Flip Cards Styles
 * Era: 5.3
 *
 * Implements premium 3D book-flip and sliding page animations for the hover-flip-cards block.
 * Adapts to the 3-axis surface model and rounding variables automatically.
 */

.websly-hover-flip-cards-section {
    overflow: visible !important; /* Ensure 3D card overflow doesn't clip on section boundaries */
}

/* Perspective Wrapper container */
.ws-flip-card {
    position: relative;
    width: 100%;
    max-width: 320px;
    aspect-ratio: 3 / 4; /* Portrait book aspect ratio */
    min-height: 300px;
    cursor: pointer;
    perspective: 2000px;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important; /* Crucial for 3D translations and slide outs */
    display: block;
}

/* Base style for card faces */
.ws-card-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.6s ease, opacity 0.6s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* Base sheet (used by page-slide as a placeholder background book base) */
.ws-flip-card-base {
    z-index: 1;
    pointer-events: none;
    transform: translateZ(0px);
}

/* Inner face (Back sheet) */
.ws-flip-card-inner {
    z-index: 2;
    transform: translateZ(1px);
}

/* Cover face (Front sheet) */
.ws-flip-card-cover {
    z-index: 3;
    transform-origin: left center;
    transform: translateZ(2px);
}

/* ============================================================================
   VARIANT 1: Cover Flip (Book Swing)
   ============================================================================ */

.ws-flip-card.style-flip-cover:hover .ws-flip-card-cover {
    transform: rotateY(-80deg) translateZ(2px);
    box-shadow: 2px 4px 16px rgba(0, 0, 0, 0.15);
}

/* Keep inner flat behind */
.ws-flip-card.style-flip-cover .ws-flip-card-inner {
    transform: translateZ(1px);
}

/* ============================================================================
   VARIANT 2: Page Flip & Slide (Double Move)
   ============================================================================ */

.ws-flip-card.style-page-slide:hover {
    transform: rotateZ(-8deg);
}

/* Cover swings open slightly less to make room */
.ws-flip-card.style-page-slide:hover .ws-flip-card-cover {
    transform: rotateY(-70deg) translateZ(2px);
    box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.15);
}

/* Inner page slides out to the right and angles slightly */
.ws-flip-card.style-page-slide:hover .ws-flip-card-inner {
    transform: rotateZ(8deg) rotateX(-2deg) rotateY(-8deg) translateX(60%) translateZ(4px);
    box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 10; /* Float over the open cover */
}

/* ============================================================================
   Content Styling
   ============================================================================ */

.ws-flip-card-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: inherit; /* Align with resolved card radius */
    box-sizing: border-box;
}

/* Image styling */
.ws-flip-card-image {
    width: 100%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Full coverage image mode */
.ws-flip-card-content > .ws-flip-card-image.absolute {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    z-index: 1;
}

.ws-flip-card-content > .ws-flip-card-image.absolute img {
    width: 100%;
    height: 100%;
    object-cover: cover;
}

/* Hover trigger button styles */
button.ws-flip-card {
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    color: inherit;
    text-align: inherit;
}

/* Accessibility: reduce motion if user prefers it */
@media (prefers-reduced-motion: reduce) {
    .ws-flip-card,
    .ws-card-face {
        transition: none !important;
        transform: none !important;
    }
    .ws-flip-card:hover,
    .ws-flip-card-cover:hover,
    .ws-flip-card-inner:hover {
        transform: none !important;
    }
}
