/* =====================================================
   CSS Animation Playground — styles.css
   Purple/Cyan dark mode, premium glassmorphism
   ===================================================== */

:root {
    --primary: #A855F7;
    --secondary: #C084FC;
    --accent: #22D3EE;
    --bg: #0F1219;
    --surface: #161C27;
    --surface2: #1C2436;
    --border: rgba(168, 85, 247, 0.15);
    --text: #E2E8F0;
    --text-muted: #6B7B99;
    --green: #4ADE80;
    --red: #F87171;
    --radius: 12px;
    --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.55;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 80% 0%, rgba(168, 85, 247, 0.06) 0%, transparent 55%),
        radial-gradient(ellipse at 20% 100%, rgba(34, 211, 238, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* ── Glass ─────────────────────────────────────────── */
.glass-card {
    background: rgba(22, 28, 39, 0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ── Header ────────────────────────────────────────── */
.header {
    position: sticky;
    top: 0;
    z-index: 200;
    background: rgba(15, 18, 25, 0.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
}

.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 10px;
}

.logo-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.logo-sub {
    font-size: 0.65rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Buttons ───────────────────────────────────────── */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.84rem;
    font-weight: 600;
    padding: 8px 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.btn-primary:hover {
    box-shadow: 0 0 18px rgba(168, 85, 247, 0.45);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 8px 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 7px;
    transition: all var(--transition);
}

.btn-ghost:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-ghost-sm {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 5px 10px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost-sm:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.hidden {
    display: none !important;
}

/* ── Main Layout ───────────────────────────────────── */
.main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: 280px 1fr 360px;
    gap: 18px;
    align-items: start;
    position: relative;
    z-index: 1;
    min-height: calc(100vh - 64px);
}

/* ── Config Panel ──────────────────────────────────── */
.config-panel {
    padding: 0;
    overflow: hidden;
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

.panel-section {
    padding: 16px 16px 14px;
    border-bottom: 1px solid var(--border);
}

.section-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

/* Presets */
.presets-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.preset-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text-muted);
    font-size: 0.72rem;
    padding: 4px 11px;
    cursor: pointer;
    transition: all var(--transition);
}

.preset-chip:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.preset-chip.active {
    background: rgba(168, 85, 247, 0.15);
    color: var(--primary);
    border-color: var(--primary);
}

/* Form controls */
.prop-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.prop-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 70px;
    flex-shrink: 0;
}

.val-label {
    color: var(--primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
}

.range-field {
    flex: 1;
    min-width: 80px;
    cursor: pointer;
    -webkit-appearance: none;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    outline: none;
}

.range-field::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.select-field,
.input-field {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 0.8rem;
    padding: 7px 10px;
    outline: none;
    transition: border-color var(--transition);
}

.select-field:focus,
.input-field:focus {
    border-color: var(--primary);
}

.input-field.mono {
    font-family: 'JetBrains Mono', monospace;
}

input[type="color"] {
    width: 36px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

/* Easing presets */
.easing-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.ease-chip {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text-muted);
    font-size: 0.68rem;
    padding: 3px 9px;
    cursor: pointer;
    transition: all var(--transition);
}

.ease-chip:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.ease-chip.active {
    background: rgba(34, 211, 238, 0.1);
    color: var(--accent);
    border-color: var(--accent);
}

.bezier-canvas {
    width: 100%;
    height: 90px;
    display: block;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 10px;
}

/* ── Preview Area ──────────────────────────────────── */
.preview-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.device-controls {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.device-btn {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
    padding: 7px 14px;
    cursor: pointer;
    transition: all var(--transition);
}

.device-btn[aria-pressed="true"] {
    color: var(--primary);
    border-color: var(--primary);
    background: rgba(168, 85, 247, 0.1);
}

.preview-wrapper {
    overflow: hidden;
    transition: max-width var(--transition);
    margin: 0 auto;
    width: 100%;
}

.preview-wrapper.tablet {
    max-width: 768px;
}

.preview-wrapper.phone {
    max-width: 375px;
}

.preview-wrapper.desktop {
    max-width: 100%;
}

.preview-screen {
    min-height: 380px;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.anim-target {
    width: 60px;
    height: 60px;
    background: var(--primary);
    border-radius: 12px;
    transition: background var(--transition), border-radius var(--transition), width var(--transition), height var(--transition);
}

.anim-target.circle {
    border-radius: 50%;
}

.anim-target.text {
    width: auto;
    height: auto;
    background: transparent;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.anim-target.card {
    width: 160px;
    height: 100px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(168, 85, 247, 0.3);
}

/* Playback */
.playback-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
}

.play-btn {
    width: 34px;
    height: 34px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 8px;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.play-btn:hover {
    background: rgba(168, 85, 247, 0.25);
}

.playback-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-left: 4px;
}

/* ── Editor Area ───────────────────────────────────── */
.editor-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Timeline */
.timeline-panel {
    overflow: hidden;
    padding: 0;
}

.timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
}

.timeline-ruler {
    display: flex;
    padding: 6px 16px;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface2);
}

.ruler-mark {
    flex: 1;
    font-size: 0.62rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    text-align: left;
    border-left: 1px solid var(--border);
    padding-left: 3px;
}

.keyframe-tracks {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kf-track {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 12px;
    position: relative;
}

.kf-track-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 60px;
}

.kf-track-bar {
    flex: 1;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
}

.kf-dot {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--primary);
    border: 2px solid var(--surface);
    border-radius: 50%;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
    transition: background var(--transition), transform var(--transition);
}

.kf-dot:hover {
    background: var(--secondary);
    transform: translateY(-50%) scale(1.3);
}

.kf-dot.selected {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

/* Keyframe property editor */
.kf-editor {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    background: rgba(168, 85, 247, 0.04);
}

.kf-editor-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
}

.kf-props {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kf-prop-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.kf-prop-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    min-width: 80px;
}

.kf-prop-input {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    padding: 5px 8px;
    outline: none;
    transition: border-color var(--transition);
}

.kf-prop-input:focus {
    border-color: var(--primary);
}

/* Code panel */
.code-panel {
    overflow: hidden;
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.code-output {
    background: var(--surface2);
    padding: 14px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.76rem;
    color: var(--text);
    line-height: 1.7;
    white-space: pre;
    overflow-x: auto;
    max-height: 220px;
}

/* ── Export Modal ──────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 400;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(5px);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow);
    animation: modal-in 0.22s ease;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: 1rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.export-code {
    max-height: 320px;
    overflow-y: auto;
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 1200px) {
    .main {
        grid-template-columns: 240px 1fr 320px;
    }
}

@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }

    .config-panel {
        position: static;
        max-height: none;
    }
}

@media (max-width: 640px) {
    .main {
        padding: 12px;
    }

    .preview-screen {
        min-height: 240px;
    }
}