/* ══════════════════════════════════════════════
   VexRay — Premium Theme Stylesheet
   ══════════════════════════════════════════════ */

/* ── Reset & Variables ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Dark Theme (Default) ── */
:root,
[data-theme="dark"] {
    /* Core palette */
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-card: rgba(18, 18, 28, 0.75);
    --bg-card-hover: rgba(25, 25, 40, 0.85);
    --border-subtle: rgba(108, 99, 255, 0.12);
    --border-glow: rgba(108, 99, 255, 0.3);

    /* Accent colors */
    --accent-primary: #6C63FF;
    --accent-secondary: #a78bfa;
    --accent-pink: #FF6584;
    --accent-green: #34d399;
    --accent-yellow: #fbbf24;

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;

    /* Component-specific */
    --code-bg: #1a1a2e;
    --graph-bg: rgba(0, 0, 0, 0.2);
    --math-bg: rgba(108, 99, 255, 0.04);
    --math-bg-hover: rgba(108, 99, 255, 0.07);
    --math-border: rgba(108, 99, 255, 0.1);
    --math-border-hover: rgba(108, 99, 255, 0.25);
    --list-bg: rgba(108, 99, 255, 0.03);
    --list-bg-hover: rgba(108, 99, 255, 0.06);
    --glow-color: rgba(108, 99, 255, 0.12);
    --card-shadow: rgba(108, 99, 255, 0.06);
    --scrollbar-thumb: rgba(108, 99, 255, 0.25);
    --scrollbar-hover: rgba(108, 99, 255, 0.45);
    --plotly-template: "plotly_dark";

    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Layout */
    --sidebar-width: 260px;
    --content-max-width: 880px;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Light Theme ── */
[data-theme="light"] {
    --bg-primary: #f5f5fa;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --border-subtle: rgba(108, 99, 255, 0.15);
    --border-glow: rgba(108, 99, 255, 0.35);

    --accent-primary: #5046e5;
    --accent-secondary: #7c3aed;
    --accent-pink: #e63970;
    --accent-green: #059669;
    --accent-yellow: #d97706;

    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #8888a0;

    --code-bg: #f1f0fb;
    --graph-bg: rgba(245, 245, 250, 0.6);
    --math-bg: rgba(108, 99, 255, 0.05);
    --math-bg-hover: rgba(108, 99, 255, 0.09);
    --math-border: rgba(108, 99, 255, 0.12);
    --math-border-hover: rgba(108, 99, 255, 0.3);
    --list-bg: rgba(108, 99, 255, 0.04);
    --list-bg-hover: rgba(108, 99, 255, 0.08);
    --glow-color: rgba(108, 99, 255, 0.08);
    --card-shadow: rgba(108, 99, 255, 0.08);
    --scrollbar-thumb: rgba(108, 99, 255, 0.2);
    --scrollbar-hover: rgba(108, 99, 255, 0.4);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    overflow-x: hidden;
    min-height: 100vh;
    transition: background 0.4s ease, color 0.4s ease;
}

/* ── Theme Toggle ── */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    margin: 0 16px 12px;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(108, 99, 255, 0.06);
    border: 1px solid var(--border-subtle);
    transition: var(--transition-fast);
    user-select: none;
}

.theme-toggle:hover {
    background: rgba(108, 99, 255, 0.12);
    border-color: var(--border-glow);
}

.theme-toggle-icon {
    font-size: 18px;
    transition: transform 0.3s ease;
}

.theme-toggle:hover .theme-toggle-icon {
    transform: rotate(30deg);
}

.theme-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── Sidebar ── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    padding: 28px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(108, 99, 255, 0.5));
}

.brand-text {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 16px;
    overflow-y: auto;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 0 8px;
}

.nav-link {
    display: block;
    padding: 10px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
    margin-bottom: 4px;
}

.nav-link:hover {
    background: rgba(108, 99, 255, 0.08);
    color: var(--text-primary);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.15), rgba(255, 101, 132, 0.08));
    color: var(--accent-primary);
    border: 1px solid var(--border-glow);
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
}

.version-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid var(--border-subtle);
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

/* ── Hero ── */
.hero {
    position: relative;
    padding: 80px 60px 60px;
    overflow: hidden;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 40px;
}

.hero-glow {
    position: absolute;
    top: -120px;
    left: -60px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--glow-color) 0%, transparent 70%);
    pointer-events: none;
    animation: heroGlowPulse 6s ease-in-out infinite;
}

@keyframes heroGlowPulse {

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

    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.hero-content {
    flex: 1;
    position: relative;
    z-index: 1;
}

.hero-icon {
    font-size: 56px;
    display: block;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 20px rgba(108, 99, 255, 0.4));
    animation: iconFloat 4s ease-in-out infinite;
}

@keyframes iconFloat {

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

    50% {
        transform: translateY(-8px);
    }
}

.hero-title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -1.5px;
    line-height: 1.1;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-secondary) 60%, var(--accent-pink) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 400;
    max-width: 500px;
}

/* Table of Contents */
.toc {
    position: relative;
    z-index: 1;
    min-width: 220px;
    max-width: 280px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    backdrop-filter: blur(16px);
    max-height: 400px;
    overflow-y: auto;
}

.toc-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.toc-link {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 0;
    border-left: 2px solid transparent;
    padding-left: 12px;
    transition: var(--transition-fast);
}

.toc-link:hover {
    color: var(--accent-primary);
    border-left-color: var(--accent-primary);
}

/* ── Sections Container ── */
.sections-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 40px 40px 80px;
}

/* ── Section Card ── */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 18px;
    padding: 40px;
    margin-bottom: 32px;
    backdrop-filter: blur(16px);
    transition: var(--transition-smooth);
    position: relative;
    overflow: hidden;

    /* Scroll animation */
    opacity: 0;
    transform: translateY(30px);
}

.section-card.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.section-card:hover {
    border-color: var(--border-glow);
    background: var(--bg-card-hover);
    box-shadow: 0 0 40px var(--card-shadow);
}

.section-number {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 1px;
    margin-bottom: 8px;
    opacity: 0.7;
}

.section-heading {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Text Sections ── */
.section-text {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-secondary);
}

.section-text strong {
    color: var(--accent-primary);
    font-weight: 600;
}

.section-text em {
    color: var(--accent-pink);
    font-style: normal;
    font-family: var(--font-mono);
    font-size: 14px;
    background: rgba(255, 101, 132, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
}

.section-description {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.section-description strong {
    color: var(--accent-primary);
}

/* ── Math Sections ── */
.math-block {
    padding: 24px;
    margin-bottom: 16px;
    background: var(--math-bg);
    border-radius: 14px;
    border: 1px solid var(--math-border);
    transition: var(--transition-fast);
}

.math-block:hover {
    border-color: var(--math-border-hover);
    background: var(--math-bg-hover);
}

.math-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}

.math-formula {
    font-size: 18px;
    text-align: center;
    padding: 16px 0;
    color: var(--text-primary);
}

.math-explanation {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid rgba(108, 99, 255, 0.08);
}

/* ── Graph Sections ── */
.graph-container {
    width: 100%;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: var(--graph-bg);
    min-height: 400px;
}

.graph-container .plotly {
    border-radius: 14px;
}

/* ── Code Sections ── */
.code-block-wrapper {
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    background: var(--code-bg);
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    background: rgba(108, 99, 255, 0.06);
    border-bottom: 1px solid var(--border-subtle);
}

.code-lang {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 1px;
}

.copy-btn {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: var(--font-body);
}

.copy-btn:hover {
    background: rgba(108, 99, 255, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.copy-btn.copied {
    background: rgba(52, 211, 153, 0.15);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

pre {
    padding: 20px 24px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.7;
}

pre code {
    font-family: var(--font-mono);
    background: none !important;
}

/* ── List Sections ── */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    padding: 20px 24px;
    border-radius: 14px;
    border: 1px solid var(--border-subtle);
    background: var(--list-bg);
    transition: var(--transition-fast);
}

.info-item:hover {
    border-color: var(--border-glow);
    background: var(--list-bg-hover);
    transform: translateX(6px);
}

.info-item-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
    flex-shrink: 0;
}

.info-item-detail {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    padding-left: 18px;
}

/* ── Footer ── */
.footer {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
    border-top: 1px solid var(--border-subtle);
}

.footer strong {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

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

    .toc {
        max-width: 100%;
        min-width: unset;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .hero {
        padding: 40px 24px;
    }

    .hero-title {
        font-size: 32px;
    }

    .sections-container {
        padding: 24px 16px;
    }

    .section-card {
        padding: 24px;
    }
}

/* ══════════════════════════════════════════════
   PLAYGROUND STYLES
   ══════════════════════════════════════════════ */

/* ── Layout ── */
.pg-layout {
    display: flex;
    min-height: 100vh;
}

.pg-panel {
    width: 360px;
    min-width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow-y: auto;
    backdrop-filter: blur(20px);
}

.pg-panel-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 32px 28px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.pg-icon {
    font-size: 40px;
    filter: drop-shadow(0 0 12px rgba(108, 99, 255, 0.4));
    animation: iconFloat 4s ease-in-out infinite;
}

.pg-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.pg-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--accent-pink);
    background: rgba(255, 101, 132, 0.1);
    border: 1px solid rgba(255, 101, 132, 0.2);
    padding: 3px 10px;
    border-radius: 6px;
    margin-top: 4px;
}

.pg-description {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
    padding: 20px 28px;
    border-bottom: 1px solid var(--border-subtle);
}

/* ── Controls ── */
.pg-controls {
    flex: 1;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.pg-control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pg-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pg-value {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-primary);
    background: rgba(108, 99, 255, 0.1);
    padding: 2px 10px;
    border-radius: 6px;
    min-width: 48px;
    text-align: center;
}

/* ── Custom Range Slider ── */
.pg-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(108, 99, 255, 0.15);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.pg-slider:hover {
    background: rgba(108, 99, 255, 0.25);
}

.pg-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
    cursor: pointer;
    border: 3px solid var(--bg-secondary);
    box-shadow: 0 0 10px rgba(108, 99, 255, 0.4);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pg-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 16px rgba(108, 99, 255, 0.6);
}

.pg-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
    cursor: pointer;
    border: 3px solid var(--bg-secondary);
    box-shadow: 0 0 10px rgba(108, 99, 255, 0.4);
}

.pg-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: -2px;
}

/* ── Select Dropdown ── */
.pg-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-primary);
    background: rgba(108, 99, 255, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236C63FF' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.pg-select:hover,
.pg-select:focus {
    border-color: var(--border-glow);
    background-color: rgba(108, 99, 255, 0.1);
}

.pg-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ── Reset Button ── */
.pg-reset-btn {
    margin: 0 28px 20px;
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-body);
    color: var(--text-secondary);
    background: rgba(108, 99, 255, 0.06);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.pg-reset-btn:hover {
    background: rgba(108, 99, 255, 0.12);
    border-color: var(--border-glow);
    color: var(--accent-primary);
}

.pg-panel-footer {
    padding: 16px 28px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Main Graph Area ── */
.pg-main {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 24px;
    min-height: 100vh;
}

.pg-graph-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pg-graph {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 48px);
    border-radius: 18px;
    border: 1px solid var(--border-subtle);
    background: var(--graph-bg);
    overflow: hidden;
}

/* ── Loading Indicator ── */
.pg-loading {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    backdrop-filter: blur(16px);
    z-index: 10;
}

.pg-loading.visible {
    opacity: 1;
    transform: translateY(0);
}

.pg-spinner {
    width: 16px;
    height: 16px;
    border: 2.5px solid rgba(108, 99, 255, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: pgSpin 0.7s linear infinite;
}

@keyframes pgSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Playground Responsive ── */
@media (max-width: 900px) {
    .pg-layout {
        flex-direction: column;
    }

    .pg-panel {
        width: 100%;
        min-width: unset;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .pg-main {
        min-height: 50vh;
    }

    .pg-graph {
        min-height: 50vh;
    }
}