/* 
 * Stories Carousel — Coverflow Style
 * stories-coverflow.css
 * 
 * Usage: Set 'style' => 'coverflow' in shortcode/block attributes
 */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;1,400&family=Outfit:wght@300;400;500;600&display=swap');

/* ── Variables ──────────────────────────────────────────── */
.sc-coverflow-wrapper {
    --cover-width:      340px;
    --cover-height:     480px;
    --spacing:          220px;
    --side-scale:       0.7;
    --side-opacity:     0.5;
    --reflection-h:     80px;
    --transition-time:  600ms;
    --transition-ease:  cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    --bg-start:         #1a1a2e;
    --bg-end:           #0f1419;
    --accent:           #e94560;
    --text-primary:     #e8e8e8;
    --text-muted:       rgba(232, 232, 232, 0.5);
    --border:           rgba(255, 255, 255, 0.08);
    
    --font-display:     'Cormorant Garamond', Georgia, serif;
    --font-body:        'Outfit', -apple-system, system-ui, sans-serif;
}

/* ── Wrapper ────────────────────────────────────────────── */
.sc-coverflow-wrapper {
    position: relative;
    width: 100%;
    padding: 4rem 2rem 8rem;
    background: linear-gradient(165deg, var(--bg-start) 0%, #16213e 50%, var(--bg-end) 100%);
    perspective: 1600px;
    perspective-origin: 50% 50%;
    font-family: var(--font-body);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.sc-coverflow-header {
    text-align: center;
    margin-bottom: 3rem;
}

.sc-coverflow-header h2 {
    font-family: var(--font-display);
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.5rem;
    letter-spacing: -0.02em;
}

.sc-coverflow-header p {
    font-size: 1.125rem;
    color: var(--text-muted);
    font-weight: 300;
    margin: 0;
}

/* ── Stage ──────────────────────────────────────────────── */
.sc-coverflow-stage {
    position: relative;
    height: calc(var(--cover-height) + var(--reflection-h) + 4rem);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2rem;
}

/* ── Track ──────────────────────────────────────────────── */
.sc-coverflow-track {
    position: relative;
    height: var(--cover-height);
    transform-style: preserve-3d;
    transition: transform var(--transition-time) var(--transition-ease);
}

/* ── Cover ──────────────────────────────────────────────── */
.sc-coverflow-cover {
    position: absolute;
    width: var(--cover-width);
    height: var(--cover-height);
    left: 50%;
    top: 0;
    margin-left: calc(var(--cover-width) / -2);
    
    background-size: cover;
    background-position: center;
    background-color: #1e1e2e;
    
    border-radius: 12px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    
    transform-style: preserve-3d;
    backface-visibility: hidden;
    cursor: pointer;
    overflow: hidden;
    
    transition: 
        transform var(--transition-time) var(--transition-ease),
        opacity var(--transition-time) ease,
        filter var(--transition-time) ease;
}

.sc-coverflow-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        160deg,
        rgba(26, 26, 46, 0) 0%,
        rgba(26, 26, 46, 0.3) 40%,
        rgba(26, 26, 46, 0.95) 100%
    );
    z-index: 1;
    border-radius: 12px;
}

.sc-coverflow-cover::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: var(--reflection-h);
    background: inherit;
    background-position: center bottom;
    transform: scaleY(-1);
    opacity: 0.15;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 70%);
    -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.3) 0%, transparent 70%);
    filter: blur(1px);
    border-radius: 12px 12px 0 0;
}

/* Content */
.sc-coverflow-content {
    position: absolute;
    inset: 0;
    z-index: 2;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    opacity: 0;
    transition: opacity var(--transition-time) ease;
}

.sc-coverflow-cover.is-active .sc-coverflow-content {
    opacity: 1;
    transition-delay: 150ms;
}

.sc-coverflow-category {
    display: inline-block;
    padding: 0.3rem 0.875rem;
    background: rgba(233, 69, 96, 0.15);
    border: 1px solid var(--accent);
    border-radius: 20px;
    color: var(--accent);
    font-size: 0.6875rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 1rem;
    align-self: flex-start;
}

.sc-coverflow-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
}

.sc-coverflow-title a {
    color: inherit;
    text-decoration: none;
    transition: color 250ms ease;
}

.sc-coverflow-title a:hover {
    color: var(--accent);
}

.sc-coverflow-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sc-coverflow-meta-author {
    color: var(--text-primary);
    font-weight: 500;
}

.sc-coverflow-meta-sep {
    opacity: 0.3;
}

.sc-coverflow-excerpt {
    font-size: 0.875rem;
    line-height: 1.6;
    color: rgba(232, 232, 232, 0.7);
    margin-bottom: 1.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sc-coverflow-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-decoration: none;
    border-radius: 6px;
    align-self: flex-start;
    transition: all 250ms ease;
}

.sc-coverflow-cta:hover {
    background: #ff5573;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(233, 69, 96, 0.4);
}

.sc-coverflow-cta svg {
    transition: transform 250ms ease;
}

.sc-coverflow-cta:hover svg {
    transform: translateX(3px);
}

/* ── Positioning ────────────────────────────────────────── */
.sc-coverflow-cover.is-active {
    transform: translateX(0) translateZ(0) rotateY(0deg) scale(1);
    opacity: 1;
    filter: brightness(1);
    z-index: 10;
}

.sc-coverflow-cover.is-left-1 {
    transform: translateX(calc(var(--spacing) * -1)) translateZ(-300px) rotateY(35deg) scale(var(--side-scale));
    opacity: var(--side-opacity);
    filter: brightness(0.7);
    z-index: 5;
}

.sc-coverflow-cover.is-left-2 {
    transform: translateX(calc(var(--spacing) * -2)) translateZ(-500px) rotateY(40deg) scale(calc(var(--side-scale) * 0.8));
    opacity: calc(var(--side-opacity) * 0.6);
    filter: brightness(0.5);
    z-index: 4;
}

.sc-coverflow-cover.is-left-far {
    transform: translateX(calc(var(--spacing) * -3)) translateZ(-700px) rotateY(45deg) scale(calc(var(--side-scale) * 0.6));
    opacity: 0.2;
    filter: brightness(0.3);
    z-index: 3;
    pointer-events: none;
}

.sc-coverflow-cover.is-right-1 {
    transform: translateX(calc(var(--spacing) * 1)) translateZ(-300px) rotateY(-35deg) scale(var(--side-scale));
    opacity: var(--side-opacity);
    filter: brightness(0.7);
    z-index: 5;
}

.sc-coverflow-cover.is-right-2 {
    transform: translateX(calc(var(--spacing) * 2)) translateZ(-500px) rotateY(-40deg) scale(calc(var(--side-scale) * 0.8));
    opacity: calc(var(--side-opacity) * 0.6);
    filter: brightness(0.5);
    z-index: 4;
}

.sc-coverflow-cover.is-right-far {
    transform: translateX(calc(var(--spacing) * 3)) translateZ(-700px) rotateY(-45deg) scale(calc(var(--side-scale) * 0.6));
    opacity: 0.2;
    filter: brightness(0.3);
    z-index: 3;
    pointer-events: none;
}

/* ── Controls ───────────────────────────────────────────── */
.sc-coverflow-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-top: 3rem;
}

.sc-coverflow-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: all 250ms ease;
    backdrop-filter: blur(10px);
}

.sc-coverflow-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent);
    color: var(--accent);
    transform: scale(1.1);
}

.sc-coverflow-dots {
    display: flex;
    gap: 0.75rem;
}

.sc-coverflow-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: all 250ms ease;
}

.sc-coverflow-dot:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.2);
}

.sc-coverflow-dot.is-active {
    background: var(--accent);
    width: 24px;
    border-radius: 4px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .sc-coverflow-wrapper {
        --cover-width: 280px;
        --cover-height: 400px;
        --spacing: 180px;
    }
    
    .sc-coverflow-excerpt {
        -webkit-line-clamp: 2;
    }
}

@media (max-width: 640px) {
    .sc-coverflow-wrapper {
        --cover-width: 240px;
        --cover-height: 340px;
        --spacing: 140px;
        --reflection-h: 60px;
        padding: 2rem 1rem 6rem;
    }
    
    .sc-coverflow-content {
        padding: 1.5rem;
    }
    
    .sc-coverflow-excerpt {
        display: none;
    }
    
    .sc-coverflow-cover.is-left-far,
    .sc-coverflow-cover.is-right-far {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sc-coverflow-cover,
    .sc-coverflow-track,
    .sc-coverflow-content,
    .sc-coverflow-btn,
    .sc-coverflow-dot { transition: none; }
}
