/* ============================================================================
 * Card Deck Cascade Widget
 * Self-contained CSS for the card-deck-cascade presentation widget.
 * Uses design tokens where available, with fallback values.
 * ========================================================================= */

.card-deck-cascade {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* --- Card --- */
.cd-card {
    position: absolute;
    opacity: 0;
    transform-origin: bottom center;
    transition: opacity 0.25s ease-out, transform 0.25s ease-out, box-shadow 0.25s ease-out;
    pointer-events: none;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    background: var(--about-bg-card, #1a1a2e);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    will-change: transform, opacity;
}

.cd-card img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: var(--radius-md, 8px);
}

/* --- Dealt (visible, stacked beneath active) --- */
.cd-card.cd-dealt {
    opacity: 0.35;
    pointer-events: auto;
}

/* --- Active (top card, full emphasis) --- */
.cd-card.cd-active {
    opacity: 1;
    pointer-events: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

/* Fan layout — deterministic offsets via custom properties.
   Each card rotates by (index - center) * spread degrees
   and translates horizontally by (index - center) * offset px. */
.card-deck-cascade.cd-fan .cd-card.cd-dealt,
.card-deck-cascade.cd-fan .cd-card.cd-active {
    transform:
        translateX(calc((var(--card-index) - (var(--card-total) - 1) / 2) * var(--cd-spread-x, 30px)))
        translateY(calc((var(--card-index) - (var(--card-total) - 1) / 2) * var(--cd-spread-y, -4px)))
        rotate(calc((var(--card-index) - (var(--card-total) - 1) / 2) * var(--cd-rotation, 3deg)));
}

.card-deck-cascade.cd-fan .cd-card.cd-active {
    transform:
        translateX(calc((var(--card-index) - (var(--card-total) - 1) / 2) * var(--cd-spread-x, 30px)))
        translateY(calc((var(--card-index) - (var(--card-total) - 1) / 2) * var(--cd-spread-y, -4px) - 12px))
        rotate(calc((var(--card-index) - (var(--card-total) - 1) / 2) * var(--cd-rotation, 3deg)))
        scale(1.03);
}

/* --- Caption --- */
.cd-card-caption {
    font-size: calc(0.75rem * var(--type-scale, 1));
    color: rgba(255, 255, 255, 0.85);
    text-align: center;
    padding: 4px 8px;
    line-height: 1.3;
}

/* Caption below card image */
.card-deck-cascade.cd-caption-below .cd-card-caption {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px);
}

/* Caption overlay on card */
.card-deck-cascade.cd-caption-overlay .cd-card-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 12px 8px 6px;
    border-radius: 0 0 var(--radius-md, 8px) var(--radius-md, 8px);
}

/* Caption hidden */
.card-deck-cascade.cd-caption-none .cd-card-caption {
    display: none;
}

/* --- Compact fallback (tiny containers) --- */
.card-deck-cascade.cd-compact .cd-card {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: calc(100% - 20px);
}

.card-deck-cascade.cd-compact .cd-card.cd-dealt:not(.cd-active) {
    opacity: 0;
}

.card-deck-cascade.cd-compact .cd-card.cd-active {
    opacity: 1;
    transform: none;
}

.cd-compact-dots {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 5px;
}

.cd-compact-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transition: background 0.2s;
}

.cd-compact-dot.cd-dot-active {
    background: rgba(255, 255, 255, 0.9);
}

/* --- Entrance animation for newly dealt card --- */
@keyframes cd-deal-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cd-card.cd-dealing {
    animation: cd-deal-in 0.2s ease-out forwards;
}
