/* ============================================
   Chloe Engine Documentation - styles.css
   Colors from DESIGN.md
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg: #0f1117;
    --surface: #161922;
    --border: #2a2d38;
    --accent: #ff2d7b;
    --accent-hover: #ff5a9e;
    --text-primary: #e1e4ea;
    --text-secondary: #8b8fa4;
    --code-keyword: #ff7b72;
    --code-string: #a5d6ff;
    --code-function: #d2a8ff;
    --success: #3fb950;

    --sidebar-width: 260px;
    --toc-width: 200px;
    --content-max: 800px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg);
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
    gap: 0;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: var(--accent-hover);
}

::selection {
    background: rgba(255, 45, 123, 0.25);
    color: var(--text-primary);
}

/* --- Mobile Sidebar Toggle --- */
#sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 1001;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 0;
}

#sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#sidebar-toggle.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

#sidebar-toggle.active span:nth-child(2) {
    opacity: 0;
}

#sidebar-toggle.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

/* --- Left Sidebar --- */
#sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0;
    z-index: 999;
}

#sidebar::-webkit-scrollbar {
    width: 4px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.logo-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.logo-text {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.sidebar-search {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

#sidebar-search {
    width: 100%;
    padding: 8px 12px 8px 34px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    outline: none;
    transition: border-color 0.15s ease;
}

#sidebar-search::placeholder {
    color: var(--text-secondary);
}

#sidebar-search:focus {
    border-color: var(--accent);
}

/* --- Sidebar Navigation --- */
.sidebar-nav {
    padding: 12px 0;
}

.nav-tree {
    list-style: none;
}

.nav-section {
    margin-bottom: 4px;
}

.nav-section details {
    border: none;
}

.nav-section summary {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: color 0.15s ease;
}

.nav-section summary::-webkit-details-marker {
    display: none;
}

.nav-section summary::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid var(--text-secondary);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-right: 8px;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

.nav-section details[open] > summary::before {
    transform: rotate(90deg);
}

.nav-section summary:hover {
    color: var(--text-primary);
}

.nav-section ul {
    list-style: none;
    padding: 0 0 4px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 6px 16px 6px 28px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.nav-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: transparent;
    margin-right: 10px;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

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

.nav-link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: rgba(255, 45, 123, 0.05);
}

.nav-link.active .nav-dot {
    background: var(--accent);
}

.nav-dot.new-indicator {
    background: var(--accent);
    width: 8px;
    height: 8px;
    box-shadow: 0 0 6px rgba(255, 45, 123, 0.4);
}

/* Sidebar search highlight */
.nav-link mark {
    background: rgba(255, 45, 123, 0.25);
    color: var(--accent);
    border-radius: 2px;
    padding: 0 1px;
}

.nav-link.hidden {
    display: none;
}

.nav-section.hidden {
    display: none;
}

/* --- Main Content --- */
#main-content {
    min-width: 0;
    padding: 0;
}

/* --- Hero / Welcome Banner --- */
#hero {
    height: 40vh;
    min-height: 280px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--bg) 0%, rgba(22, 25, 34, 0.6) 100%);
    border-bottom: 1px solid var(--border);
    padding: 40px;
}

.hero-inner {
    text-align: center;
    max-width: 600px;
}

.hero-title {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.hero-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

.hero-tagline {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}

.hero-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 22px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.hero-version {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.8125rem;
}

.hero-version-note {
    color: var(--text-secondary);
}

/* --- Version Badge --- */
.version-badge {
    display: inline-block;
    padding: 2px 10px;
    border: 1px solid var(--accent);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--accent);
    background: transparent;
    line-height: 1.5;
}

/* --- Breadcrumbs --- */
.breadcrumbs {
    padding: 16px 48px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.breadcrumbs a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.breadcrumbs a:hover {
    color: var(--text-primary);
}

.breadcrumb-sep {
    margin: 0 8px;
    opacity: 0.4;
}

.breadcrumb-current {
    color: var(--accent);
}

/* --- Documentation Content --- */
#doc-content {
    max-width: var(--content-max);
    padding: 40px 48px 80px;
}

#doc-content h2 {
    font-family: 'Inter', sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3vw, 2.5rem);
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

#doc-content h3 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-top: 48px;
    margin-bottom: 16px;
}

#doc-content h4 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 6px;
}

#doc-content p {
    margin-bottom: 16px;
    color: var(--text-primary);
}

#doc-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    background: var(--surface);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--code-function);
}

/* --- Info Callout --- */
.info-callout {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(165, 214, 255, 0.05);
    border: 1px solid rgba(165, 214, 255, 0.15);
    border-radius: 8px;
    margin-bottom: 24px;
}

.callout-icon {
    flex-shrink: 0;
    margin-top: 2px;
}

.callout-content {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

.callout-content strong {
    color: var(--text-primary);
}

.callout-content a {
    color: var(--code-string);
}

/* --- Code Blocks --- */
.code-block {
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border);
    min-height: 42px;
}

.code-tabs {
    display: flex;
    gap: 0;
}

.code-tab {
    background: none;
    border: none;
    padding: 10px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
    margin-bottom: -1px;
}

.code-tab:hover {
    color: var(--text-primary);
}

.code-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: color 0.15s ease, background 0.15s ease;
}

.copy-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.copy-btn.copied {
    color: var(--success);
}

.copy-btn.copied svg rect,
.copy-btn.copied svg path {
    stroke: var(--success);
}

.code-panels {
    position: relative;
}

.code-panel {
    display: none;
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface);
}

.code-panel.active {
    display: block;
}

.code-panel code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    background: none;
    padding: 0;
    color: inherit;
}

/* Syntax Highlighting */
.syn-keyword {
    color: var(--code-keyword);
}

.syn-string {
    color: var(--code-string);
}

.syn-function {
    color: var(--code-function);
}

.syn-comment {
    color: var(--text-secondary);
    font-style: italic;
}

/* --- Features Grid --- */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.feature-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: border-color 0.2s ease;
}

.feature-card:hover {
    border-color: var(--accent);
}

.feature-icon {
    margin-bottom: 12px;
}

.feature-card h4 {
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.6;
}

/* --- API Table --- */
.api-table-wrapper {
    overflow-x: auto;
    margin-bottom: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.api-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.api-table thead {
    background: rgba(255, 255, 255, 0.03);
}

.api-table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.api-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
}

.api-table tr:last-child td {
    border-bottom: none;
}

.api-table code {
    font-size: 0.8125rem;
    padding: 1px 5px;
}

/* --- Document List --- */
.doc-list {
    list-style: none;
    margin-bottom: 24px;
}

.doc-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(42, 45, 56, 0.5);
}

.doc-list li:last-child {
    border-bottom: none;
}

.list-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
    margin-top: 8px;
}

.list-dot.new-indicator {
    box-shadow: 0 0 6px rgba(255, 45, 123, 0.4);
}

/* --- Next Steps Grid --- */
.next-steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 8px;
}

.next-step-card {
    display: block;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    transition: border-color 0.2s ease, transform 0.2s ease;
}

.next-step-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    color: inherit;
}

.next-step-arrow {
    font-size: 1.2rem;
    color: var(--accent);
    display: block;
    margin-bottom: 8px;
}

.next-step-card strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
    font-size: 0.9375rem;
}

.next-step-card p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.5;
}

/* --- Right TOC Sidebar --- */
#toc {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    padding: 0;
}

.toc-inner {
    padding: 24px 16px;
}

.toc-heading {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.toc-list {
    list-style: none;
}

.toc-list li {
    margin-bottom: 2px;
}

.toc-link {
    display: block;
    padding: 4px 0 4px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.toc-link:hover {
    color: var(--text-primary);
}

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

/* --- Responsive --- */
@media (max-width: 1024px) {
    body {
        grid-template-columns: 1fr;
    }

    #sidebar-toggle {
        display: flex;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: var(--sidebar-width);
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 999;
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebar-overlay.active {
        display: block;
    }

    #toc {
        display: none;
    }

    #main-content {
        padding-top: 56px;
    }

    .breadcrumbs {
        padding: 16px 24px;
    }

    #doc-content {
        padding: 24px 24px 60px;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .next-steps-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .hero-actions {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        justify-content: center;
        max-width: 260px;
    }

    .hero-version {
        flex-direction: column;
        gap: 4px;
    }

    #doc-content {
        padding: 20px 16px 60px;
    }

    .breadcrumbs {
        padding: 12px 16px;
    }

    .code-header {
        flex-wrap: wrap;
        gap: 8px;
    }
}
