/* ============================================
   DEMO PAGE - Compact Single-Page Layout
   ============================================ */

/* Make navbar solid on demo page and remove border */
body:has(.demo-main) .navbar.scrolled {
    background: #09090b;
    border-bottom: none;
    box-shadow: none;
}

.demo-main {
    padding: 80px 20px 20px;
    min-height: 100vh;
    background: #09090b;
    position: relative;
}

/* Hide the redundant mini footer */
.demo-footer {
    display: none;
}

.demo-header { display: none; }

/* Video Tutorial Banner */
.video-tutorial-banner {
    max-width: 1500px;
    margin: 0 auto 20px;
    background: linear-gradient(145deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.08) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 12px;
    overflow: hidden;
}

.video-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.video-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
}

.video-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    font-size: 12px;
    color: white;
}

.video-text {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
}

.video-arrow {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    transition: transform 0.3s ease;
}

.video-tutorial-banner.expanded .video-arrow {
    transform: rotate(180deg);
}

.video-container {
    display: none;
    padding: 0 20px 20px;
}

.video-tutorial-banner.expanded .video-container {
    display: block;
}

.video-container video {
    width: 100%;
    max-height: 500px;
    border-radius: 8px;
    background: #000;
}

.demo-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 24px;
    max-width: 1500px;
    margin: 0 auto;
    padding-top: var(--space-2xl);
    align-items: start;
}

/* CONTROLS PANEL */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.panel-section {
    background: linear-gradient(165deg, rgba(22,24,30,0.95) 0%, rgba(14,16,22,0.98) 100%);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 18px;
    backdrop-filter: blur(20px);
}

.panel-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.45);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.control-header .panel-title { margin-bottom: 0; }

.control-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    box-shadow: 0 0 10px currentColor;
}

.control-dot.head { background: #3b82f6; color: #3b82f6; }
.control-dot.eye { background: #8b5cf6; color: #8b5cf6; }
.control-dot.expr { background: #ec4899; color: #ec4899; }

/* Gender Toggle */
.gender-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.gender-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.gender-btn:hover {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.8);
}

.gender-btn.active {
    background: linear-gradient(145deg, rgba(99,102,241,0.15), rgba(99,102,241,0.08));
    border-color: rgba(99,102,241,0.4);
    color: #a5b4fc;
}

.gender-icon { font-size: 18px; }

/* Joystick - Horizontal Layout */
.joystick-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
}

.joystick-container { flex-shrink: 0; }

.joystick-pad {
    position: relative;
    width: 130px;
    height: 130px;
    background: linear-gradient(145deg, rgba(0,0,0,0.5), rgba(0,0,0,0.3));
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    cursor: crosshair;
}

.joystick-heatmap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 9px;
    opacity: 0.5;
}

.joystick-grid {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 25% 25%;
    border-radius: 9px;
}

.joystick-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.joystick-axis-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.axis-label {
    position: absolute;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.25);
}

.axis-left { left: 6px; top: 50%; transform: translateY(-50%); }
.axis-right { right: 6px; top: 50%; transform: translateY(-50%); }
.axis-up { top: 6px; left: 50%; transform: translateX(-50%); }
.axis-down { bottom: 6px; left: 50%; transform: translateX(-50%); }

.joystick-marker {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 10;
    pointer-events: none;  /* Allow clicks to pass through to the pad */
}

.joystick-marker:active { cursor: grabbing; }

.joystick-marker.head {
    background: radial-gradient(circle at 30% 30%, #60a5fa, #3b82f6);
    box-shadow: 0 0 12px rgba(59,130,246,0.6);
}

.joystick-marker.eye {
    background: radial-gradient(circle at 30% 30%, #a78bfa, #8b5cf6);
    box-shadow: 0 0 12px rgba(139,92,246,0.6);
}

/* Coord Inputs - Vertical to Right */
.coord-inputs {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.coord-input-group {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,0.25);
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.06);
}

.coord-input-group label {
    font-size: 11px;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    width: 14px;
}

.coord-btn {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    color: rgba(255,255,255,0.5);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.coord-btn:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

.coord-input {
    width: 50px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.85);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    text-align: center;
}

.coord-input:focus { outline: none; }

/* Expression */
.expression-control {
    display: flex;
    align-items: center;
    gap: 14px;
}

.expr-icon { font-size: 18px; opacity: 0.7; }

.expr-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 6px;
    background: linear-gradient(90deg, rgba(239,68,68,0.3) 0%, rgba(255,255,255,0.1) 50%, rgba(34,197,94,0.3) 100%);
    border-radius: 3px;
    cursor: pointer;
}

.expr-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: radial-gradient(circle at 30% 30%, #f472b6, #ec4899);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(236,72,153,0.5);
    cursor: grab;
}

.expr-label {
    font-size: 12px;
    font-weight: 600;
    color: #f472b6;
    padding: 4px 12px;
    background: rgba(236,72,153,0.1);
    border-radius: 12px;
    min-width: 60px;
    text-align: center;
}

.expression-presets { display: none; }

/* Reset Button */
.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
}

.reset-btn svg { width: 14px; height: 14px; opacity: 0.6; }

/* RESULTS PANEL */
.results-panel {
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(165deg, rgba(22,24,30,0.9) 0%, rgba(14,16,22,0.95) 100%);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.results-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.results-count {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.7);
}

.results-count span { 
    font-weight: 700; 
    color: #fff;
    display: inline-block;
    min-width: 5ch;  /* Fixed width for up to 8 digits */
    text-align: right;
}

.results-time {
    font-size: 10px;
    font-weight: 500;
    color: #4ade80;
    padding: 3px 8px;
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.2);
    border-radius: 12px;
    min-width: 55px;
    text-align: center;
}

/* Buttons */
.shuffle-btn, .demo-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.shuffle-btn {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.6);
}

.shuffle-btn:hover {
    background: rgba(99,102,241,0.15);
    border-color: rgba(99,102,241,0.4);
    color: #a5b4fc;
}

.shuffle-btn svg { width: 12px; height: 12px; }

.demo-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    box-shadow: 0 2px 10px rgba(99,102,241,0.3);
}

.demo-btn:hover { box-shadow: 0 4px 16px rgba(99,102,241,0.4); }

.demo-btn.active {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
    box-shadow: 0 2px 10px rgba(239,68,68,0.3);
}

.demo-btn #toggleIcon { font-size: 9px; }

.query-display {
    padding: 6px 12px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
}

.query-display code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(255,255,255,0.4);
}

/* RESULTS GRID - 5x4 */
.results-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.result-card {
    position: relative;
    background: rgba(20,22,28,0.8);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
    overflow: hidden;
    animation: cardFadeIn 0.3s ease forwards;
    opacity: 0;
    transition: all 0.25s ease;
}

.result-card:hover {
    transform: scale(1.04);
    border-color: rgba(99,102,241,0.5);
    box-shadow: 0 12px 32px rgba(0,0,0,0.5), 0 0 20px rgba(99,102,241,0.2);
    z-index: 10;
}

.result-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.result-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.9));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.result-card:hover .result-info { opacity: 1; }

.result-name { display: none; }

.result-distance, .result-info .distance {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 600;
    color: #4ade80;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Placeholder */
.results-placeholder {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    background: rgba(20,22,28,0.5);
    border: 2px dashed rgba(255,255,255,0.08);
    border-radius: 12px;
}

.placeholder-icon svg {
    width: 40px;
    height: 40px;
    color: rgba(255,255,255,0.2);
    margin-bottom: 16px;
}

.results-placeholder h3 {
    font-size: 16px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    margin-bottom: 6px;
}

.results-placeholder p {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    margin-bottom: 12px;
}

.server-command {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 10px 16px;
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: #4ade80;
}

.results-placeholder .hint {
    font-size: 11px;
    color: rgba(255,255,255,0.3);
}

/* Footer */
.demo-footer {
    padding: 16px;
    text-align: center;
    margin-top: 20px;
}

.demo-footer p { font-size: 12px; color: rgba(255,255,255,0.3); }
.demo-footer a { color: rgba(99,102,241,0.7); text-decoration: none; }

/* RESPONSIVE */
@media (max-width: 1100px) {
    .results-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
    .demo-layout { grid-template-columns: 1fr; }
    .controls-panel {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .controls-panel .panel-section:first-child,
    .controls-panel .panel-section:last-child { grid-column: 1 / -1; }
    .results-grid { grid-template-columns: repeat(5, 1fr); }
}

@media (max-width: 768px) {
    /* Demo page navbar - always solid */
    .navbar,
    .navbar.scrolled,
    body:has(.demo-main) .navbar,
    body:has(.demo-main) .navbar.scrolled {
        background: #09090b !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
    }
    
    .demo-main {
        padding: 70px 12px 20px !important;
    }
    
    .demo-layout {
        padding-top: 16px;
    }
    
    /* Touch-friendly joysticks */
    .joystick-area {
        touch-action: none;
        min-height: 100px;
    }
    
    .panel-section {
        padding: 14px;
    }
    
    .panel-title {
        font-size: 11px;
        margin-bottom: 12px;
    }
    
    .results-panel {
        min-height: 280px;
    }
    
    .results-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
}

@media (max-width: 600px) {
    .demo-main { 
        padding: 65px 8px 16px !important;
    }
    
    .demo-layout {
        gap: 12px;
        padding-top: 12px;
    }
    
    .controls-panel { 
        grid-template-columns: 1fr; 
        gap: 8px;
    }
    
    .panel-section {
        padding: 12px;
    }
    
    .results-grid { 
        grid-template-columns: repeat(3, 1fr); 
        gap: 6px;
    }
    
    /* Larger touch targets */
    .joystick-knob {
        width: 36px;
        height: 36px;
    }
    
    .joystick-area {
        min-height: 85px;
    }
    
    /* Smaller expression buttons */
    .expr-btn {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    /* Gender buttons */
    .gender-btn {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .gender-icon {
        font-size: 14px;
    }
    
    /* Results header */
    .results-header {
        flex-wrap: wrap;
        gap: 6px;
        padding-bottom: 10px;
    }
    
    .results-title {
        font-size: 13px;
    }
    
    .query-badge {
        font-size: 9px;
        padding: 3px 6px;
    }
    
    /* Image results */
    .result-item {
        border-radius: 6px;
    }
    
    .result-item img {
        border-radius: 6px;
    }
    
    /* Demo button */
    .demo-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    /* Server status */
    .server-status {
        font-size: 11px;
    }
}

@media (max-width: 400px) {
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .expr-btn {
        padding: 6px 8px;
        font-size: 10px;
    }
}
