/* ========================================
   AnimateLab - Dark Minimal Theme
   ======================================== */

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #09090b;
    color: #e4e4e7;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Back Link ── */
.back-link {
    position: absolute;
    top: 24px;
    left: 24px;
    color: #a1a1aa;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 6px 14px;
    border: 1px solid #27272a;
    border-radius: 6px;
    z-index: 2;
    transition: color 0.2s, border-color 0.2s;
}

.back-link:hover {
    color: #e4e4e7;
    border-color: #a78bfa;
}

/* ── Stats Toggle Button ── */
.stats-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1001;
    background: #111114;
    border: 1px solid #27272a;
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: #71717a;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 10px 8px;
    cursor: pointer;
    writing-mode: vertical-lr;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    transition: color 0.2s, border-color 0.2s, left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-toggle:hover {
    color: #a78bfa;
    border-color: #a78bfa;
}

.stats-toggle.active {
    left: 220px;
}

/* ── Stats Side Panel ── */
.stats-panel {
    position: fixed;
    left: -220px;
    top: 0;
    width: 220px;
    height: 100vh;
    background: #0c0c0f;
    border-right: 1px solid #1e1e24;
    z-index: 1000;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 0.78rem;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-panel.open {
    left: 0;
}

.stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stats-title {
    color: #e4e4e7;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.stats-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a78bfa;
    box-shadow: 0 0 6px rgba(167, 139, 250, 0.4);
    animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.stats-divider {
    height: 1px;
    background: #1e1e24;
}

.stat-block {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}

.stat-tag {
    color: #a78bfa;
    font-weight: 700;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    min-width: 26px;
}

.stat-label {
    color: #52525b;
    font-weight: 500;
    flex: 1;
    font-size: 0.76rem;
}

.stat-value {
    color: #e4e4e7;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: right;
    min-width: 22px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.stat-big {
    font-size: 1.5rem;
    color: #a78bfa;
}

.stat-bar {
    height: 2px;
    background: #1e1e24;
    border-radius: 1px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #a78bfa, #7c3aed);
    border-radius: 1px;
    transition: width 1.5s ease-out;
}

.stat-status {
    color: #3f3f46;
    font-size: 0.7rem;
    margin-top: auto;
    padding-top: 10px;
}

@media (max-width: 500px) {
    .stats-panel {
        width: 190px;
        left: -190px;
    }

    .stats-toggle.active {
        left: 190px;
    }
}

/* ── Header ── */
.header {
    position: relative;
    text-align: center;
    padding: 80px 20px 60px;
    overflow: hidden;
    background: #09090b;
    border-bottom: 1px solid #1e1e24;
}

#header-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.header h1 {
    font-size: 3.5rem;
    font-weight: 900;
    letter-spacing: -1px;
    color: #e4e4e7;
    position: relative;
    z-index: 1;
    display: inline-flex;
}

.title-letter {
    display: inline-block;
    animation: letterWave 2.5s ease-in-out infinite;
    transition: color 0.3s, transform 0.3s;
}

.title-letter:nth-child(1) {
    animation-delay: 0s;
}

.title-letter:nth-child(2) {
    animation-delay: 0.08s;
}

.title-letter:nth-child(3) {
    animation-delay: 0.16s;
}

.title-letter:nth-child(4) {
    animation-delay: 0.24s;
}

.title-letter:nth-child(5) {
    animation-delay: 0.32s;
}

.title-letter:nth-child(6) {
    animation-delay: 0.4s;
}

.title-letter:nth-child(7) {
    animation-delay: 0.48s;
}

.title-letter:nth-child(8) {
    animation-delay: 0.56s;
}

.title-letter:nth-child(9) {
    animation-delay: 0.64s;
}

.title-letter:nth-child(10) {
    animation-delay: 0.72s;
}

.title-letter:hover {
    transform: scale(1.3) rotate(-8deg);
    color: #a78bfa;
}

.title-accent {
    color: #a78bfa;
}

@keyframes letterWave {

    0%,
    100% {
        transform: translateY(0);
    }

    20% {
        transform: translateY(-10px);
    }

    40% {
        transform: translateY(0);
    }
}

.header p {
    font-size: 1.1rem;
    color: #71717a;
    margin-top: 12px;
    font-weight: 500;
    position: relative;
    z-index: 1;
}

/* ── Main Content ── */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 60px;
}

/* ── Category Headings ── */
.category-heading {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: #52525b;
    padding: 48px 0 16px;
    border-bottom: 1px solid #1e1e24;
    margin-bottom: 0;
}

/* ── Animation Sections ── */
.anim-section {
    border-bottom: 1px solid #1e1e24;
    padding: 0;
}

.section-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0 0;
}

.section-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #e4e4e7;
}

.interaction-hint {
    font-size: 0.75rem;
    font-weight: 500;
    color: #52525b;
    font-style: italic;
}

.section-content {
    display: flex;
    gap: 24px;
    padding: 16px 0 20px;
    align-items: stretch;
}

.preview-col {
    flex: 3;
    min-width: 0;
}

.controls-col {
    flex: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Preview Area ── */
.preview-area {
    height: 220px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111114;
    border: 1px solid #1e1e24;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
}

.preview-area canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* ── Controls Panel ── */
.controls-panel {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #111114;
    border: 1px solid #1e1e24;
    border-radius: 10px;
    flex: 1;
}

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

.control-row label {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 80px;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-row .value-display {
    font-size: 0.78rem;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
    color: #a1a1aa;
    font-family: 'Consolas', 'Courier New', monospace;
}

/* ── Range Sliders ── */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    background: #27272a;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #a78bfa;
    cursor: pointer;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 12px rgba(167, 139, 250, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #a78bfa;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.3);
}

/* ── Select Dropdowns ── */
select {
    background: #18181b;
    color: #a1a1aa;
    border: 1px solid #27272a;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    font-family: inherit;
}

select:focus {
    border-color: #a78bfa;
    color: #e4e4e7;
}

/* ── Color Inputs ── */
input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 24px;
    border: 1px solid #27272a;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    padding: 2px;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* ── Code Toggle Button ── */
.code-toggle-btn {
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 6px;
    color: #52525b;
    font-weight: 600;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: inherit;
}

.code-toggle-btn:hover {
    color: #a78bfa;
    border-color: #a78bfa;
}

/* ── Code Panel ── */
.code-panel {
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.4s ease;
    border-radius: 0 0 10px 10px;
}

.code-panel.open {
    max-height: 500px;
}

.code-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #111114;
    border: 1px solid #1e1e24;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
}

.code-lang {
    color: #52525b;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-actions {
    display: flex;
    gap: 8px;
}

.code-panel-header .btn {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-panel-header .btn:active {
    transform: scale(0.95);
}

.btn-apply {
    background: #a78bfa;
    color: #09090b;
}

.btn-apply:hover {
    background: #8b5cf6;
}

.btn-reset {
    background: #27272a;
    color: #a1a1aa;
}

.btn-reset:hover {
    background: #3f3f46;
}

.code-panel textarea {
    width: 100%;
    min-height: 140px;
    background: #0c0c0f;
    color: #a1a1aa;
    border: 1px solid #1e1e24;
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 14px 16px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    tab-size: 2;
}

.code-panel textarea:focus {
    border-color: #27272a;
}

/* ── Preview Elements ── */
.preview-box {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.preview-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    position: absolute;
}

/* Transition preview */
.transition-box {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
}

.preview-area:hover .transition-box.active {
    transform: scale(1.3) rotate(10deg);
    border-radius: 50%;
    box-shadow: 0 0 30px rgba(167, 139, 250, 0.5);
}

/* Keyframe preview */
.keyframe-box {
    width: 70px;
    height: 70px;
    border-radius: 14px;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
}

.keyframe-box.playing {
    animation: bounce-spin 1s ease-in-out infinite;
}

@keyframes bounce-spin {
    0% {
        transform: translateY(0) rotate(0deg);
    }

    25% {
        transform: translateY(-40px) rotate(90deg);
    }

    50% {
        transform: translateY(0) rotate(180deg);
    }

    75% {
        transform: translateY(-20px) rotate(270deg);
    }

    100% {
        transform: translateY(0) rotate(360deg);
    }
}

/* Transform preview */
.transform-box {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: linear-gradient(135deg, #a78bfa, #6d28d9);
}

/* Hover effects preview */
.hover-demo-box {
    width: 100px;
    height: 80px;
    border-radius: 14px;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

/* CSS Variables preview */
.css-var-preview {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.css-var-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid;
    position: absolute;
    animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.6;
    }
}

.css-var-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

/* Scroll-driven preview */
.scroll-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 16px;
    position: relative;
}

.scroll-container::-webkit-scrollbar {
    width: 4px;
}

.scroll-container::-webkit-scrollbar-track {
    background: #111114;
}

.scroll-container::-webkit-scrollbar-thumb {
    background: #a78bfa;
    border-radius: 2px;
}

.scroll-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #a78bfa, #7c3aed);
    transition: width 0.1s linear;
    z-index: 2;
}

.scroll-reveal-item {
    padding: 12px;
    margin: 8px 0;
    background: #18181b;
    border: 1px solid #27272a;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.82rem;
    color: #71717a;
    opacity: 0.3;
    transform: translateX(-20px);
    transition: all 0.4s ease;
}

.scroll-reveal-item.visible {
    opacity: 1;
    transform: translateX(0);
    color: #a1a1aa;
}

/* Spring physics preview */
.spring-preview {
    width: 100%;
    height: 100%;
    position: relative;
}

.spring-ball {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    position: absolute;
    cursor: grab;
    box-shadow: 0 4px 20px rgba(167, 139, 250, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.spring-ball:active {
    cursor: grabbing;
}

.spring-anchor {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #52525b;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* SVG Morph preview */
.morph-svg {
    width: 140px;
    height: 140px;
}

.morph-svg path {
    transition: d 0.6s ease-in-out;
}

/* Parallax preview */
.parallax-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    border-radius: 50%;
    transition: transform 0.1s ease-out;
}

/* Typing Effect preview */
.typing-preview {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.typing-cursor-line {
    color: #52525b;
}

.typing-text {
    color: #f97316;
}

.typing-cursor {
    animation: cursorBlink 0.6s step-end infinite;
    color: #e4e4e7;
    margin-left: 1px;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Flip Card preview */
.flip-container {
    width: 140px;
    height: 100px;
    perspective: 600px;
}

.flip-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.preview-area:hover .flip-inner.flip-y {
    transform: rotateY(180deg);
}

.preview-area:hover .flip-inner.flip-x {
    transform: rotateX(180deg);
}

.flip-front,
.flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 12px;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.flip-front {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.flip-back {
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    transform: rotateY(180deg);
}

.flip-inner.flip-x .flip-back {
    transform: rotateX(180deg);
}

/* Gradient Animation preview */
.gradient-box {
    width: 160px;
    height: 120px;
    border-radius: 16px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6, #06b6d4, #ec4899);
    background-size: 300% 300%;
    animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ── Footer ── */
footer {
    text-align: center;
    padding: 40px 20px;
    color: #3f3f46;
    font-size: 0.8rem;
    font-weight: 500;
    border-top: 1px solid #1e1e24;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .section-content {
        flex-direction: column;
    }

    .preview-col,
    .controls-col {
        flex: none;
        width: 100%;
    }

    .header h1 {
        font-size: 2.5rem;
    }

    .header {
        padding: 60px 16px 40px;
    }

    .main-content {
        padding: 0 16px 40px;
    }
}

@media (max-width: 500px) {
    .header h1 {
        font-size: 2rem;
    }

    .header p {
        font-size: 0.95rem;
    }

    .category-heading {
        font-size: 0.7rem;
    }

    .preview-area {
        height: 180px;
    }

    .control-row label {
        min-width: 60px;
        font-size: 0.7rem;
    }
}