/* SynthDoc Explainer - Core Design System */
:root {
    --bg-main: #020617;
    --bg-card: rgba(15, 23, 42, 0.85);
    --border-color: rgba(56, 189, 248, 0.15);
    --border-color-glow: rgba(56, 189, 248, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --color-sky: #38bdf8;
    --color-cyan: #06b6d4;
    --color-emerald: #10b981;
    --color-rose: #f43f5e;
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Header bar with neon typography */
header {
    width: 100%;
    backdrop-filter: blur(12px);
    background: rgba(2, 6, 23, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.05em;
    color: #ffffff;
    text-transform: uppercase;
}

.logo span {
    color: var(--color-sky);
    text-shadow: 0 0 15px rgba(56, 189, 248, 0.5);
}

/* Main Layout */
main {
    flex-grow: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.explainer-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Viewports - 2D and 3D */
#view-2d-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
}

.viewport-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 0.5rem;
}

@media (max-width: 480px) {
    .viewport-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }
}

.reset-zoom-btn {
    background: none;
    border: none;
    color: var(--color-sky);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s;
}

.reset-zoom-btn:hover {
    color: #ffffff;
}

#view-2d-container {
    width: 100%;
    max-width: 512px;
    aspect-ratio: 1 / 1;
    position: relative;
    overflow: hidden;
    background: #0b1329;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    cursor: grab;
    touch-action: none;
    margin: 0 auto;
}

#view-2d-container.grabbing {
    cursor: grabbing;
}

#stage-2d-content {
    width: 100%;
    height: 100%;
    position: relative;
    transform-origin: 0 0;
}

.layer-2d {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: auto;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

.zoom-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(2, 6, 23, 0.85);
    color: var(--color-sky);
    border: 1px solid var(--border-color-glow);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-family: var(--font-mono);
    pointer-events: none;
    z-index: 10;
    letter-spacing: 0.05em;
}

/* 3D Visualizer & Dashboard Wrapper */
#stage-final-wrapper {
    display: none;
    width: 100%;
    height: auto;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    #stage-final-wrapper {
        flex-direction: column;
        height: auto;
    }
    #canvas-container {
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
        min-height: auto;
        flex: none;
    }
    #final-result-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1104 / 720;
        flex: none;
    }
}

#canvas-container {
    flex: 1.2;
    aspect-ratio: 4 / 3;
    min-height: 350px;
    position: relative;
    background: #0b1329;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

#canvas-container canvas {
    width: 100% !important;
    height: 100% !important;
    outline: none;
}

.expand-control {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px 16px;
    border-radius: 8px;
    z-index: 10;
}

.expand-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-secondary);
    letter-spacing: 0.1em;
}

input[type=range] {
    -webkit-appearance: none;
    flex-grow: 1;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    background: rgba(56, 189, 248, 0.2);
    border-radius: 2px;
    cursor: pointer;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 14px;
    width: 14px;
    border-radius: 50%;
    background: var(--color-sky);
    box-shadow: 0 0 8px var(--color-sky);
    cursor: pointer;
    margin-top: -5px;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#final-result-container {
    flex: 1.5;
    aspect-ratio: 1104 / 720;
    background: #0b1329;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem;
}

#final-result-container img,
#final-result-container video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* Sidebar and Details Panel */
.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .content-grid {
        grid-template-columns: repeat(12, 1fr);
    }
}

.step-navigation-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (max-width: 768px) {
    .step-navigation-panel {
        flex-direction: row;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 0.75rem;
        margin-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbars */
        scrollbar-width: none; /* Firefox */
    }
    .step-navigation-panel::-webkit-scrollbar {
        display: none; /* Chrome, Safari, Opera */
    }
}

@media (min-width: 768px) {
    .step-navigation-panel {
        grid-column: span 4;
    }
}

.step-btn {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    padding: 1rem;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 768px) {
    .step-btn {
        flex: 0 0 auto;
        scroll-snap-align: start;
        white-space: nowrap;
        padding: 0.65rem 0.9rem;
        font-size: 0.75rem;
    }
}

.step-btn:hover {
    background: rgba(56, 189, 248, 0.05);
    border-color: rgba(56, 189, 248, 0.3);
    color: #ffffff;
    transform: translateX(4px);
}

.step-btn.active {
    background: var(--color-sky);
    border-color: var(--color-sky);
    color: #020617;
    font-weight: 700;
    box-shadow: 0 0 15px rgba(56, 189, 248, 0.35);
}

.step-details-panel {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 280px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
}

@media (max-width: 768px) {
    .step-details-panel {
        padding: 1.25rem;
        min-height: auto;
    }
}

@media (min-width: 768px) {
    .step-details-panel {
        grid-column: span 8;
    }
}

.details-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}

.step-tag {
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    color: var(--color-sky);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.details-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
}

.details-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.details-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1.25rem;
}

.nav-arrow-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 4px 8px;
}

@media (max-width: 480px) {
    .nav-arrow-btn {
        font-size: 0.7rem;
        padding: 4px;
    }
    .dots-indicator {
        gap: 5px;
    }
    .dot {
        width: 5px;
        height: 5px;
    }
    .action-next-btn {
        font-size: 0.75rem;
        padding: 6px 12px;
    }
}

.nav-arrow-btn:hover:not(:disabled) {
    color: #ffffff;
}

.nav-arrow-btn:disabled {
    opacity: 0.25;
    cursor: not-allowed;
}

.dots-indicator {
    display: flex;
    gap: 8px;
}

.dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #334155;
    transition: all 0.3s;
}

.dot.active {
    background: var(--color-sky);
    box-shadow: 0 0 8px var(--color-sky);
    transform: scale(1.2);
}

.action-next-btn {
    background: var(--color-sky);
    color: #020617;
    font-weight: 800;
    font-size: 0.8rem;
    padding: 8px 20px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.action-next-btn:hover {
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.4);
    transform: translateY(-1px);
}

.action-next-btn:active {
    transform: translateY(0);
}

/* Loading overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #0f172a;
    color: var(--color-sky);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    z-index: 5;
    animation: pulse 1.5s infinite;
    transition: opacity 0.3s ease;
}

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

/* Architecture Rationale Section */
.architecture-panel {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    width: 100%;
}

.arch-section-title {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-sky);
    letter-spacing: 0.1em;
    margin-bottom: 1.5rem;
}

.arch-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 992px) {
    .arch-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.arch-card {
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.arch-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.arch-number {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-sky);
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.arch-card h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
}

.arch-card p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.6;
}

.arch-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
    margin: 0;
}

.arch-card li {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
}

.arch-card li strong {
    color: var(--color-sky);
}

@media (max-width: 768px) {
    .architecture-panel {
        padding: 1.25rem;
    }
    .arch-card {
        padding: 1.25rem;
    }
}

