/* Motion Studio - Advanced Playground Styles */

/* --- Layout & Grid --- */
html,
body {
    height: 100%;
    overflow: hidden;
    /* Prevent scroll on body, handle in panels */
}

.studio-container {
    display: grid;
    grid-template-columns: 300px 1fr 350px;
    /* Sidebar | Stage | Code */
    height: 100vh;
    width: 100%;
    padding-top: 70px;
    /* Navbar height */
    background: var(--bg-surface);
    transition: background-color 0.3s ease;
}

/* --- Entrance Animations --- */
@keyframes slideInLeft {
    from {
        transform: translateX(-50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(50px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.studio-sidebar {
    animation: slideInLeft 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.studio-stage {
    animation: zoomIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s forwards;
    opacity: 0;
    /* Start hidden for delay */
}

.studio-code {
    animation: slideInRight 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s forwards;
    opacity: 0;
}

/* --- Sidebar (Controls) --- */
.studio-sidebar {
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.control-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-group {
    margin-bottom: 16px;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 8px;
}

.value-badge {
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
}

/* Premium Inputs */
select,
input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-body);
    color: var(--text-main);
    font-family: inherit;
    transition: all 0.2s;
    cursor: pointer;
}

select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* Sidebar Range Slider (Fix for visibility) */
.studio-sidebar input[type="range"] {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    /* Light mode track */
    border-radius: 3px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.dark-mode .studio-sidebar input[type="range"] {
    background: #334155;
    /* Dark mode track */
}

.studio-sidebar input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.studio-sidebar input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* --- Stage (Center) --- */
.studio-stage {
    background: var(--bg-body);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    perspective: 1000px;
    /* Enable 3D space */
}

/* Animated Aurora Background */
.studio-stage::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(239, 68, 68, 0.1), transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(59, 130, 246, 0.1), transparent 50%);
    animation: aurora 20s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes aurora {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Grid Background Pattern (3D Floor) */
.stage-grid {
    position: absolute;
    inset: -100%;
    width: 300%;
    height: 300%;
    background-image:
        linear-gradient(rgba(148, 163, 184, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.1) 1px, transparent 1px);
    background-size: 50px 50px;
    transform: rotateX(90deg) translateZ(-100px);
    transform-style: preserve-3d;
    pointer-events: none;
    /* Camera Rotation Variables */
    transform: rotateX(var(--cam-rotate-x, 20deg)) rotateZ(var(--cam-rotate-y, 0deg)) scale(1.5);
    transition: transform 0.1s ease-out;
}

/* Content Wrapper for 3D */
.stage-content-wrapper {
    transform-style: preserve-3d;
    transform: rotateX(var(--cam-rotate-x, 20deg)) rotateY(var(--cam-rotate-y, 0deg));
    transition: transform 0.1s ease-out;
    z-index: 1;
}

/* Camera Controls */
.camera-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 20;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    width: 160px;
}

.dark-mode .camera-controls {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(255, 255, 255, 0.05);
}

.cam-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cam-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cam-group input[type="range"] {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
}

.cam-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* Preview Objects */
.preview-object {
    transition: all 0.3s ease;
    transform-style: preserve-3d;
    /* Crucial for 3D children */
}

/* --- 3D Cube --- */
.cube {
    width: 100px;
    height: 100px;
    position: relative;
    transform-style: preserve-3d;
}

.cube-face {
    position: absolute;
    width: 100px;
    height: 100px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 1.2rem;
    background: rgba(239, 68, 68, 0.6);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.2);
}

.cube-face.front {
    transform: translateZ(50px);
}

.cube-face.back {
    transform: rotateY(180deg) translateZ(50px);
}

.cube-face.right {
    transform: rotateY(90deg) translateZ(50px);
}

.cube-face.left {
    transform: rotateY(-90deg) translateZ(50px);
}

.cube-face.top {
    transform: rotateX(90deg) translateZ(50px);
}

.cube-face.bottom {
    transform: rotateX(-90deg) translateZ(50px);
}

/* --- 3D Card --- */
.card-3d {
    width: 200px;
    height: 120px;
    position: relative;
    transform-style: preserve-3d;
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.card-face.front {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    font-weight: bold;
    gap: 8px;
}

.card-face.back {
    background: #1e293b;
    color: white;
    transform: rotateY(180deg);
    border: 2px solid #3b82f6;
}

/* --- 3D Text --- */
.preview-object.text-3d {
    font-size: 4rem;
    font-weight: 900;
    color: #e2e8f0;
    text-transform: uppercase;
    transform: rotateX(10deg) rotateY(-10deg);
    text-shadow:
        1px 1px 0 #94a3b8,
        2px 2px 0 #94a3b8,
        3px 3px 0 #94a3b8,
        4px 4px 0 #94a3b8,
        5px 5px 0 #94a3b8,
        6px 6px 0 #94a3b8,
        7px 7px 0 #94a3b8,
        8px 8px 0 #94a3b8,
        20px 20px 30px rgba(0, 0, 0, 0.5);
}

/* Standard Objects */
.preview-object.box {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(220, 38, 38, 0.9));
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(239, 68, 68, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Add depth to box */
.preview-object.box::after {
    content: '';
    position: absolute;
    inset: 0;
    background: inherit;
    transform: translateZ(-20px);
    border-radius: inherit;
    opacity: 0.5;
}

.preview-object.circle {
    width: 100px;
    height: 100px;
    background: var(--gradient);
    border-radius: 50%;
    box-shadow: var(--shadow-lg);
}

.preview-object.button {
    padding: 12px 32px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.preview-object.text {
    font-size: 3rem;
    font-weight: 800;
    background: var(--gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.preview-object.card {
    width: 200px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.preview-object.notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--card-bg);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    font-weight: 500;
}

/* Playback Controls */
.playback-controls {
    position: absolute;
    bottom: 30px;
    display: flex;
    gap: 12px;
    background: var(--bg-surface);
    padding: 8px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    z-index: 10;
    align-items: center;
}

.control-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-main);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.control-btn:hover {
    background: var(--bg-body);
    color: var(--primary);
}

.control-btn.primary {
    background: var(--primary);
    color: white;
}

.control-btn.primary:hover {
    background: var(--primary-hover);
}

.control-btn.active {
    animation: pulse 1.5s infinite;
}

.divider-vertical {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}



@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* --- Code Panel (Right) --- */
.studio-code {
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.code-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.code-mode-select {
    padding: 4px 8px;
    font-size: 0.8rem;
    border-radius: 6px;
    width: auto;
    background: var(--bg-body);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: var(--primary);
}

.code-editor {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-main);
    background: var(--bg-body);
}

.code-block {
    margin-bottom: 24px;
    position: relative;
    display: block !important;
}

.code-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Enforce high contrast for code blocks */
.studio-code pre,
.studio-code code {
    background: #f8fafc;
    /* Slate-50 - Solid light background */
    color: #0f172a !important;
    /* Slate-900 - Dark text for light mode */
    font-family: 'JetBrains Mono', monospace;
}

.studio-code pre {
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* Dark mode overrides */
.dark-mode .studio-code pre,
.dark-mode .studio-code code {
    background: rgba(255, 255, 255, 0.05);
    /* Transparent in dark mode */
    color: #e2e8f0 !important;
    /* Slate-200 - Light text for dark mode */
}

.dark-mode .studio-code pre {
    border-color: rgba(255, 255, 255, 0.1);
}

/* Responsive */
@media (max-width: 1024px) {
    .studio-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 400px auto;
        height: auto;
        overflow-y: auto;
    }

    .studio-sidebar,
    .studio-stage,
    .studio-code {
        border: none;
        border-bottom: 1px solid var(--border);
        animation: none;
        /* Disable entrance on mobile for performance/layout stability */
        opacity: 1;
    }

    .studio-stage {
        height: 400px;
    }
}