/**
 * UNDO Collective - Playground Styles
 * Physics-Based Carousel & Component Labs — Performance Optimized
 */

/* ── Global Playground Layout ── */
.carousel-wrapper {
    position: relative;
    max-width: 1600px;
    margin: 4rem auto;
    perspective: 1200px;
    padding-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Fixed height container to prevent CLS */
    height: 700px;
    justify-content: center;
}

.carousel-container {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    display: flex;
    justify-content: center;
    align-items: center;
}

.carousel-card {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 85vw;
    max-width: 1400px;
    height: 500px;
    /* Fixed height for 16:9 screens */
    background: rgba(13, 13, 13, 0.6);
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 32px;
    padding: 3rem;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -50%) translateZ(-300px) rotateY(0deg);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5);
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.8s ease;
    will-change: transform, opacity;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Card States ── */
.carousel-card.card-active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) translateZ(0) rotateY(0deg);
    z-index: 10;
    border-color: rgba(255, 255, 255, 0.08);
}

.carousel-card.card-next {
    opacity: 0.4;
    transform: translate(-20%, -50%) translateZ(-150px) rotateY(-15deg);
    z-index: 5;
}

.carousel-card.card-prev {
    opacity: 0.4;
    transform: translate(-80%, -50%) translateZ(-150px) rotateY(15deg);
    z-index: 5;
}

.carousel-card.card-hidden {
    opacity: 0;
    transform: translate(-50%, -50%) translateZ(-500px);
    z-index: 0;
}

/* ── Content Layout ── */
.card-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: hidden;
    /* Disable internal scroll per user request */
    padding-right: 0.5rem;
    /* Removed overscroll-behavior: contain to allow page scroll when card is at edge */
}

/* Custom Scrollbar for Card */
.card-content::-webkit-scrollbar {
    width: 6px;
}

.card-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.card-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

.card-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

.card-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, #fff 30%, #569cd6);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-align: left;
    letter-spacing: -0.02em;
}

.lab-section {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    overflow-y: hidden;
    /* Disable internal scroll per user request */
    overflow-x: hidden;
    padding-right: 1rem;
    align-content: start;
}

/* Custom Scrollbar */
.lab-section::-webkit-scrollbar {
    width: 6px;
}

.lab-section::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.lab-section::-webkit-scrollbar-track {
    background: transparent;
}

/* ── Navigation Controls (Sides) ── */
.carousel-nav {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    padding: 0 1rem;
    /* Closer to edge */
}

.nav-btn {
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn:hover {
    background: #fff;
    color: #000;
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.3);
}

.nav-btn:active {
    transform: scale(0.9);
}

.nav-dots {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 101;
    pointer-events: auto;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.dot.active {
    background: #fff;
    width: 40px;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

/* ── Lab Toggle Buttons (Sound/Haptic) ── */
.lab-toggle {
    background: rgba(255, 255, 255, 0.05);
    /* Glass variant */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    padding: 0.6rem 1.2rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.lab-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.lab-toggle.active {
    background: rgba(86, 156, 214, 0.15);
    /* Blue tint */
    border-color: rgba(86, 156, 214, 0.4);
    color: #fff;
    box-shadow: 0 0 12px rgba(86, 156, 214, 0.15);
}

.lab-toggle .icon {
    font-size: 1.1rem;
}

/* ── Lab Item Styles ── */
.lab-item {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    align-items: flex-start;
}

.item-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.2em;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
}

.flex-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

/* ── LAB 1: BUTTONS ── */
.btn {
    position: relative;
    padding: 0.8rem 2rem;
    border-radius: 14px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    user-select: none;
}

/* Primary - Bounce & Glow */
.btn-primary {
    background: #fff;
    color: #000;
}

.btn-primary:active {
    animation: bounceClick 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Secondary - Scale & Border */
.btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-secondary:hover {
    border-color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.btn-secondary:active {
    transform: scale(0.95);
}

/* Gradient - Shift */
.btn-gradient {
    background: linear-gradient(90deg, #FF3CAC 0%, #784BA0 50%, #2B86C5 100%);
    background-size: 200% auto;
    color: #fff;
}

.btn-gradient:hover {
    background-position: right center;
}

/* Glass - Blur & Shine */
.btn-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.btn-glass:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.15);
}

/* Neon - Flicker */
.btn-neon {
    background: transparent;
    border: 2px solid #0ff;
    color: #0ff;
    text-shadow: 0 0 5px #0ff;
    box-shadow: 0 0 5px #0ff, inset 0 0 5px #0ff;
}

.btn-neon:hover {
    background: #0ff;
    color: #000;
    box-shadow: 0 0 20px #0ff, inset 0 0 10px #0ff;
}

/* 3D - Depth */
.btn-3d {
    background: #ff5f6d;
    color: #fff;
    box-shadow: 0 6px 0 #b92b36;
    transform: translateY(-4px);
}

.btn-3d:active {
    transform: translateY(2px);
    box-shadow: 0 0 0 #b92b36;
}

/* Magnet - Sticky (handled in JS) */
.btn-magnet {
    background: #222;
    color: #fff;
    border: 1px solid #444;
}

/* Ripple */
.btn-ripple {
    position: relative;
    background: #4A00E0;
    color: #fff;
    overflow: hidden;
}

.btn-ripple .ripple {
    position: absolute;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    transform: scale(0);
    animation: rippleAnim 0.6s linear;
}

/* Shiny Sweep */
.btn-shiny {
    background: #111;
    color: #fff;
    border: 1px solid #333;
}

.btn-shiny::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(skewX(-25deg), transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-25deg);
    transition: 0.5s;
}

.btn-shiny:hover::before {
    left: 150%;
}

/* Loading */
.btn-loading {
    background: #333;
    color: #aaa;
    pointer-events: none;
}

@keyframes bounceClick {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(0.9);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes rippleAnim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ── LAB 2: CONTROLS ── */
.slider-container-custom {
    position: relative;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-top: 10px;
}

.slider-fill-gradient {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 0%;
    /* JS updates this */
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    border-radius: 10px;
    pointer-events: none;
    z-index: 0;
}

/* Custom Range Input on top of custom container */
.slider-container-custom .range-slider {
    position: absolute;
    top: -10px;
    /* Center thumb vertically? thumb is 24px, track is 6px. */
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 24px;
    /* Match thumb height area */
    background: transparent;
    z-index: 1;
    margin: 0;
}

.slider-box {
    width: 100%;
    margin-bottom: 2rem;
}

/* Glow Slider - Plasma Ambience */
.input-range {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
}

.input-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.input-range:hover::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 25px rgba(255, 255, 255, 0.8);
}

/* Physics Tilt Slider (JS handles tilt) */
.phys-slider::-webkit-slider-thumb {
    width: 30px;
    height: 12px;
    border-radius: 4px;
    background: #569cd6;
}

/* Toggles */
.toggle-wrapper {
    display: flex;
    gap: 2rem;
}

.switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #333;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #2196F3;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

/* Switch 2 - distinct */
.switch-alt .slider {
    background-color: #4a1c1c;
}

.switch-alt input:checked+.slider {
    background-color: #ff4757;
}

.switch-alt .slider:before {
    border-radius: 4px;
}

/* Advanced Inputs */
.adv-input-group {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 80%;
    margin: 0 auto;
}

.adv-input {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    text-align: center;
    transition: 0.3s;
}

.adv-input:focus {
    border-color: #569cd6;
    box-shadow: 0 0 15px rgba(86, 156, 214, 0.2);
    transform: scale(1.02);
}

/* ── LAB 3: MATERIALS (New!) ── */
.materials-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    width: 100%;
}

.mat-card {
    height: 120px;
    border-radius: 16px;
    cursor: pointer;
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s;
    overflow: hidden;
}

.mat-card:hover {
    transform: translateY(-5px) scale(1.05);
    z-index: 2;
}

/* Glass */
.mat-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Wood */
.mat-wood {
    background: #5d4037;
    background-image: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.05) 0px, rgba(255, 255, 255, 0.05) 2px, transparent 2px, transparent 10px);
    border: 1px solid #3e2723;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Metal */
.mat-metal {
    background: linear-gradient(135deg, #bdc3c7, #2c3e50);
    border: 1px solid #7f8c8d;
}

/* Sand */
.mat-sand {
    background: #e1c699;
    background-image: radial-gradient(rgba(0, 0, 0, 0.1) 15%, transparent 16%);
    background-size: 4px 4px;
    color: #5d4037;
}

/* Grass */
.mat-grass {
    background: #2ecc71;
    border-bottom: 4px solid #27ae60;
}

/* ── LAB 4: DYNAMICS ── */
.fluid-canvas {
    width: 100%;
    height: 200px;
    background: #000;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
}

.cursor-blob {
    position: absolute;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(66, 133, 244, 0.8), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    transform: translate(-50%, -50%);
    filter: blur(20px);
    mix-blend-mode: screen;
}

/* ── LAB 5: MAGIC ── */
.magic-container {
    width: 100%;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.juice-ball {
    width: 150px;
    height: 150px;
    background: radial-gradient(circle at 30% 30%, #ff0, #f0f, #00f);
    border-radius: 50%;
    filter: blur(10px) contrast(20);
    position: relative;
    cursor: grab;
    transition: transform 0.1s;
}

/* Global Controls */
.global-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.ctrl-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: #aaa;
    font-size: 0.8rem;
    cursor: pointer;
}

.ctrl-btn.active {
    background: #fff;
    color: #000;
}

/* ── Loaders ── */
.loader-dots {
    display: inline-block;
    width: 24px;
    height: 8px;
    background: radial-gradient(circle closest-side, currentColor 90%, transparent) 0% 50%,
        radial-gradient(circle closest-side, currentColor 90%, transparent) 50% 50%,
        radial-gradient(circle closest-side, currentColor 90%, transparent) 100% 50%;
    background-size: calc(100%/3) 100%;
    background-repeat: no-repeat;
    animation: loader-dots 1s infinite linear;
    margin-right: 0.5rem;
    vertical-align: middle;
}

@keyframes loader-dots {
    33% {
        background-size: calc(100%/3) 0%, calc(100%/3) 100%, calc(100%/3) 100%;
    }

    50% {
        background-size: calc(100%/3) 100%, calc(100%/3) 0%, calc(100%/3) 100%;
    }

    66% {
        background-size: calc(100%/3) 100%, calc(100%/3) 100%, calc(100%/3) 0%;
    }
}

.loader-pulse {
    width: 60px;
    height: 60px;
    background: rgba(86, 156, 214, 0.5);
    border-radius: 50%;
    animation: pulse-ring 1.5s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
    position: relative;
    box-shadow: 0 0 20px rgba(86, 156, 214, 0.5);
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.33);
        opacity: 0.8;
    }

    80%,
    100% {
        opacity: 0;
        transform: scale(1.5);
    }
}