/* ============================================================
   chloe.cx -- Game Engine Editor UI
   Colors: #121820 #1a2233 #0d1117 #4a5568 #e2e8f0 #9ca3af
           #6ee7b7 #818cf8 #c084fc #fbbf24 #3b82f6 #4ade80 #f59e0b
   Fonts: Chakra Petch, Inter, JetBrains Mono
   ============================================================ */

:root {
    --bg-deep: #121820;
    --bg-panel: #1a2233;
    --bg-console: #0d1117;
    --border-steel: #4a5568;
    --text-primary: #e2e8f0;
    --text-secondary: #9ca3af;
    --accent-green: #6ee7b7;
    --accent-indigo: #818cf8;
    --accent-violet: #c084fc;
    --accent-gold: #fbbf24;
    --focus-blue: #3b82f6;
    --log-green: #4ade80;
    --signal-amber: #f59e0b;
    --titlebar-bg: #1e293b;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-deep);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.65;
    overflow-x: hidden;
}

/* ===== Panel Chrome ===== */
.panel-chrome {
    border: 1px solid var(--border-steel);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    background: var(--bg-panel);
    overflow: hidden;
}

.panel-titlebar {
    background: var(--titlebar-bg);
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid var(--border-steel);
}

.window-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.dot-red { background: #ef4444; }
.dot-yellow { background: var(--accent-gold); }
.dot-green { background: var(--accent-green); }

.panel-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 8px;
    letter-spacing: 0.02em;
}

/* ===== Hero Viewport ===== */
#viewport-hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: var(--bg-deep);
}

.grid-plane {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(rgba(74, 85, 104, 0.1) 1px, transparent 1px),
        linear-gradient(90deg, rgba(74, 85, 104, 0.1) 1px, transparent 1px);
    background-size: 40px 40px;
    transform: perspective(600px) rotateX(30deg) scale(2);
    transform-origin: center 70%;
    opacity: 0;
    transition: opacity 1s ease, transform 1s ease;
}

.grid-plane.visible {
    opacity: 1;
}

#crystal-container {
    width: 280px;
    height: 280px;
    position: relative;
    z-index: 2;
}

#wireframe-crystal {
    width: 100%;
    height: 100%;
    animation: crystalRotate 120s linear infinite;
    animation-play-state: paused;
}

#wireframe-crystal.spinning {
    animation-play-state: running;
}

@keyframes crystalRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.crystal-edge {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 2s ease;
}

.crystal-edge.drawn {
    stroke-dashoffset: 0;
}

#crystal-faces polygon {
    transition: opacity 1s ease;
}

#engine-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: var(--accent-green);
    margin-top: 32px;
    position: relative;
    z-index: 2;
    letter-spacing: 0.02em;
    min-height: 1.5em;
}

/* ===== Inspector Panel ===== */
#inspector-panel {
    max-width: 720px;
    margin: 0 auto;
    padding: 80px 24px;
    opacity: 0;
    transform: translateX(80px);
    transition: opacity 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#inspector-panel.visible {
    opacity: 1;
    transform: translateX(0);
}

.inspector-content {
    padding: 16px;
}

.property-group {
    border-bottom: 1px solid rgba(74, 85, 104, 0.3);
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.property-group.visible {
    opacity: 1;
    transform: translateY(0);
}

.property-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.property-header:hover {
    background: rgba(59, 130, 246, 0.08);
}

.disclosure-triangle {
    width: 12px;
    height: 12px;
    fill: var(--text-secondary);
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.property-group[data-expanded="true"] .disclosure-triangle {
    transform: rotate(90deg);
}

.group-label {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    text-transform: uppercase;
}

.property-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                padding 0.3s ease;
    padding: 0 8px;
}

.property-group[data-expanded="true"] .property-body {
    max-height: 300px;
    padding: 0 8px 16px;
}

.prop-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid rgba(74, 85, 104, 0.1);
}

.prop-key {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: var(--text-secondary);
}

.prop-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--accent-indigo);
    text-align: right;
}

/* ===== Timeline Section ===== */
#timeline-section {
    padding: 80px 24px;
}

#timeline-section .panel-chrome {
    max-width: 1200px;
    margin: 0 auto;
}

.timeline-track-container {
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 48px 24px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-steel) var(--bg-panel);
}

.timeline-track {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: max-content;
    position: relative;
    padding: 40px 60px;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 40px;
    right: 40px;
    height: 1px;
    background: var(--border-steel);
    transform: translateY(-50%);
}

.keyframe {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
    scroll-snap-align: center;
    z-index: 2;
    cursor: pointer;
}

.diamond {
    width: 16px;
    height: 16px;
    background: var(--accent-gold);
    transform: rotate(45deg) scale(0);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 0 8px rgba(251, 191, 36, 0.3);
}

.keyframe.visible .diamond {
    transform: rotate(45deg) scale(1);
}

.kf-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 16px;
    letter-spacing: 0.04em;
}

.kf-tooltip {
    position: absolute;
    bottom: calc(100% + 16px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--titlebar-bg);
    border: 1px solid var(--border-steel);
    border-radius: 4px;
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.keyframe:hover .kf-tooltip {
    opacity: 1;
}

/* ===== Console Section ===== */
#console-section {
    padding: 80px 24px;
    max-width: 900px;
    margin: 0 auto;
}

.console-chrome {
    background: var(--bg-console);
}

#console-output {
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-secondary);
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
}

.console-line {
    white-space: pre-wrap;
    word-break: break-all;
    min-height: 1.8em;
}

.log-green {
    color: var(--log-green);
}

.log-amber {
    color: var(--signal-amber);
}

.console-cursor-line {
    padding: 0 16px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--accent-green);
}

.blink-cursor {
    animation: blink 1.06s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.console-prompt {
    color: var(--accent-green);
}

/* ===== Scene Graph (Footer) ===== */
#scene-graph {
    padding: 80px 24px;
    max-width: 500px;
    margin: 0 auto;
}

.tree-view {
    padding: 16px;
}

.tree-node {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.2s ease;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
}

.tree-node.visible {
    opacity: 1;
    transform: translateY(0);
}

.tree-node:hover {
    background: rgba(59, 130, 246, 0.12);
}

.tree-node[data-level="1"] {
    padding-left: 28px;
}

.tree-node[data-level="2"] {
    padding-left: 48px;
}

.tree-root {
    color: var(--accent-green);
    font-weight: 500;
}

.tree-icon {
    font-size: 8px;
    margin-right: 6px;
    color: var(--text-secondary);
}

.tree-node a {
    color: inherit;
    text-decoration: none;
}

.tree-node a:hover {
    color: var(--focus-blue);
}

/* ===== Mobile ===== */
@media (max-width: 768px) {
    #crystal-container {
        width: 200px;
        height: 200px;
    }

    #inspector-panel {
        padding: 40px 16px;
    }

    #timeline-section {
        padding: 40px 16px;
    }

    .timeline-track {
        padding: 40px 20px;
    }

    .keyframe {
        min-width: 100px;
    }

    #console-section {
        padding: 40px 16px;
    }

    #scene-graph {
        padding: 40px 16px;
    }

    .section-heading {
        font-size: 28px;
    }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    #wireframe-crystal {
        animation: none;
    }

    .crystal-edge {
        stroke-dashoffset: 0;
        transition: none;
    }

    .blink-cursor {
        animation: none;
        opacity: 1;
    }

    .grid-plane {
        opacity: 1;
        transition: none;
    }

    .property-group,
    .tree-node,
    #inspector-panel {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .diamond {
        transform: rotate(45deg) scale(1);
        transition: none;
    }
}
