/**
 * Reveal Swipe Cards Widget Styles.
 *
 * CSS for wipe-reveal card animations using clip-path and transform fallback.
 * Includes Pro styles for mask shapes, blur edge, and touch interactions.
 *
 * @package King_Addons
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */

.kng-rsc {
    --kng-rsc-columns: 3;
    --kng-rsc-gap: 24px;
    --kng-rsc-min-height: 320px;
    --kng-rsc-content-align: center;
    --kng-rsc-text-align: center;
    --kng-rsc-duration: 500ms;
    --kng-rsc-easing: ease-out;
    --kng-rsc-overlay-color: #2563eb;
    --kng-rsc-overlay-opacity: 1;
    --kng-rsc-blur-edge: 0px;
    --kng-rsc-mask-shape: rect;
}

/* ==========================================================================
   Grid Layout
   ========================================================================== */

.kng-rsc__grid {
    display: grid;
    grid-template-columns: repeat(var(--kng-rsc-columns), 1fr);
    gap: var(--kng-rsc-gap);
}

/* ==========================================================================
   Card Base
   ========================================================================== */

.kng-rsc-card {
    position: relative;
    min-height: var(--kng-rsc-min-height);
    overflow: hidden;
    border-radius: 12px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Hover Transform: Lift */
.kng-rsc--hover-lift .kng-rsc-card:hover {
    transform: translateY(-8px);
}

/* Hover Transform: Scale */
.kng-rsc--hover-scale .kng-rsc-card:hover {
    transform: scale(1.03);
}

/* Hover Transform: Tilt */
.kng-rsc--hover-tilt .kng-rsc-card:hover {
    transform: perspective(1000px) rotateX(2deg) rotateY(-2deg);
}

.kng-rsc-card__content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    justify-content: var(--kng-rsc-content-align);
    min-height: var(--kng-rsc-min-height);
    background: #ffffff;
}

.kng-rsc-card__inner {
    padding: 32px 24px;
    text-align: var(--kng-rsc-text-align);
}

/* ==========================================================================
   Reveal Overlay (Mask Layer)
   ========================================================================== */

.kng-rsc-card__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--kng-rsc-overlay-color);
    opacity: var(--kng-rsc-overlay-opacity);
    pointer-events: none;
    transition: transform var(--kng-rsc-duration) var(--kng-rsc-easing);
    will-change: transform;
}

/* Overlay content (icon or text) */
.kng-rsc-card__overlay-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 32px;
    transition: opacity 0.2s ease;
}

.kng-rsc-card.is-revealed .kng-rsc-card__overlay-content {
    opacity: 0;
}

/* Direction: Left to Right */
.kng-rsc-card--direction-left .kng-rsc-card__overlay {
    transform: translateX(0);
}

.kng-rsc-card--direction-left.is-revealed .kng-rsc-card__overlay {
    transform: translateX(100%);
}

/* Direction: Right to Left */
.kng-rsc-card--direction-right .kng-rsc-card__overlay {
    transform: translateX(0);
}

.kng-rsc-card--direction-right.is-revealed .kng-rsc-card__overlay {
    transform: translateX(-100%);
}

/* Direction: Top to Bottom */
.kng-rsc-card--direction-top .kng-rsc-card__overlay {
    transform: translateY(0);
}

.kng-rsc-card--direction-top.is-revealed .kng-rsc-card__overlay {
    transform: translateY(100%);
}

/* Direction: Bottom to Top */
.kng-rsc-card--direction-bottom .kng-rsc-card__overlay {
    transform: translateY(0);
}

.kng-rsc-card--direction-bottom.is-revealed .kng-rsc-card__overlay {
    transform: translateY(-100%);
}

/* Instant reveal (no animation) */
.kng-rsc-card.is-instant .kng-rsc-card__overlay {
    transition: none;
}

/* ==========================================================================
   Pro: Blur Edge Effect
   ========================================================================== */

.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    content: "";
    position: absolute;
    pointer-events: none;
}

/* Blur edge for horizontal wipe */
.kng-rsc-card--direction-left.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after,
.kng-rsc-card--direction-right.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    top: 0;
    bottom: 0;
    width: calc(var(--kng-rsc-blur-edge) * 2);
    background: linear-gradient(
        to right,
        transparent,
        var(--kng-rsc-overlay-color) 50%
    );
}

.kng-rsc-card--direction-left.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    left: calc(var(--kng-rsc-blur-edge) * -2);
}

.kng-rsc-card--direction-right.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    right: calc(var(--kng-rsc-blur-edge) * -2);
    background: linear-gradient(
        to left,
        transparent,
        var(--kng-rsc-overlay-color) 50%
    );
}

/* Blur edge for vertical wipe */
.kng-rsc-card--direction-top.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after,
.kng-rsc-card--direction-bottom.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    left: 0;
    right: 0;
    height: calc(var(--kng-rsc-blur-edge) * 2);
    background: linear-gradient(
        to bottom,
        transparent,
        var(--kng-rsc-overlay-color) 50%
    );
}

.kng-rsc-card--direction-top.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    top: calc(var(--kng-rsc-blur-edge) * -2);
}

.kng-rsc-card--direction-bottom.kng-rsc-card--blur-edge .kng-rsc-card__overlay::after {
    bottom: calc(var(--kng-rsc-blur-edge) * -2);
    background: linear-gradient(
        to top,
        transparent,
        var(--kng-rsc-overlay-color) 50%
    );
}

/* ==========================================================================
   Pro: Mask Shapes (clip-path based)
   ========================================================================== */

/* Circle reveal from center */
.kng-rsc-card--mask-circle .kng-rsc-card__overlay {
    transform: none;
    clip-path: circle(150% at 50% 50%);
    transition: clip-path var(--kng-rsc-duration) var(--kng-rsc-easing);
}

.kng-rsc-card--mask-circle.is-revealed .kng-rsc-card__overlay {
    clip-path: circle(0% at 50% 50%);
}

/* Rounded rect reveal */
.kng-rsc-card--mask-rounded .kng-rsc-card__overlay {
    border-radius: 0;
    transition: transform var(--kng-rsc-duration) var(--kng-rsc-easing),
        border-radius var(--kng-rsc-duration) var(--kng-rsc-easing);
}

.kng-rsc-card--mask-rounded.is-revealed .kng-rsc-card__overlay {
    border-radius: 50%;
}

/* Diagonal wipe */
.kng-rsc-card--mask-diagonal .kng-rsc-card__overlay {
    transform: none;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    transition: clip-path var(--kng-rsc-duration) var(--kng-rsc-easing);
}

.kng-rsc-card--mask-diagonal.is-revealed .kng-rsc-card__overlay {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
}

/* Wave wipe */
.kng-rsc-card--mask-wave .kng-rsc-card__overlay {
    transform: none;
    clip-path: polygon(
        0% 0%,
        100% 0%,
        100% 100%,
        0% 100%
    );
    transition: clip-path var(--kng-rsc-duration) var(--kng-rsc-easing);
}

.kng-rsc-card--mask-wave.is-revealed .kng-rsc-card__overlay {
    clip-path: polygon(
        100% 0%,
        100% 0%,
        100% 100%,
        100% 100%
    );
}

/* ==========================================================================
   Card Content Elements
   ========================================================================== */

.kng-rsc-card__media {
    margin-bottom: 16px;
}

.kng-rsc-card__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: var(--kng-rsc-overlay-color);
}

.kng-rsc-card__icon svg {
    width: 48px;
    height: 48px;
    fill: currentColor;
}

.kng-rsc-card__image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.kng-rsc-card__title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    color: #111827;
}

.kng-rsc-card__description {
    margin: 0 0 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #6b7280;
}

.kng-rsc-card__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background-color: var(--kng-rsc-overlay-color);
    border: none;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.kng-rsc-card__button:hover {
    background-color: #1d4ed8;
    transform: translateY(-2px);
}

.kng-rsc-card__button:focus-visible {
    outline: 2px solid var(--kng-rsc-overlay-color);
    outline-offset: 3px;
}

/* ==========================================================================
   Badge
   ========================================================================== */

.kng-rsc-card__badge {
    position: absolute;
    z-index: 3;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    color: #ffffff;
    background-color: #ef4444;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kng-rsc-card__badge--top-left {
    top: 16px;
    left: 16px;
}

.kng-rsc-card__badge--top-right {
    top: 16px;
    right: 16px;
}

.kng-rsc-card__badge--bottom-left {
    bottom: 16px;
    left: 16px;
}

.kng-rsc-card__badge--bottom-right {
    bottom: 16px;
    right: 16px;
}

/* ==========================================================================
   Touch Swipe State (Pro)
   ========================================================================== */

.kng-rsc-card.is-dragging .kng-rsc-card__overlay {
    transition: none;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

.kng-rsc--reduced-motion .kng-rsc-card__overlay {
    transition-duration: 0.01ms !important;
}

@media (prefers-reduced-motion: reduce) {
    .kng-rsc:not(.kng-rsc--reduced-motion-off) .kng-rsc-card__overlay {
        transition-duration: 0.01ms !important;
    }
}

/* ==========================================================================
   Empty State (Editor)
   ========================================================================== */

.kng-rsc-empty {
    padding: 40px 24px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1024px) {
    .kng-rsc {
        --kng-rsc-columns: 2;
    }
}

@media (max-width: 767px) {
    .kng-rsc {
        --kng-rsc-columns: 1;
    }

    .kng-rsc-card__inner {
        padding: 24px 20px;
    }

    .kng-rsc-card__title {
        font-size: 18px;
    }

    .kng-rsc-card__description {
        font-size: 14px;
    }
}

/* ==========================================================================
   Editor Styles
   ========================================================================== */

body.elementor-editor-active .kng-rsc-card__overlay {
    pointer-events: none;
}

body.elementor-editor-active .kng-rsc-card:hover .kng-rsc-card__overlay {
    transform: translateX(100%);
}

body.elementor-editor-active .kng-rsc-card--direction-right:hover .kng-rsc-card__overlay {
    transform: translateX(-100%);
}

body.elementor-editor-active .kng-rsc-card--direction-top:hover .kng-rsc-card__overlay {
    transform: translateY(100%);
}

body.elementor-editor-active .kng-rsc-card--direction-bottom:hover .kng-rsc-card__overlay {
    transform: translateY(-100%);
}

body.elementor-editor-active .kng-rsc-card--mask-circle:hover .kng-rsc-card__overlay {
    clip-path: circle(0% at 50% 50%);
}

body.elementor-editor-active .kng-rsc-card--mask-diagonal:hover .kng-rsc-card__overlay,
body.elementor-editor-active .kng-rsc-card--mask-wave:hover .kng-rsc-card__overlay {
    clip-path: polygon(100% 0, 100% 0, 100% 100%, 100% 100%);
}
