@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;700&family=Inter:wght@300;400;500;600;700&family=Orbitron:wght@500;700;900&display=swap');

/* ==========================================================================
   CSS Variables & Design Tokens
   ========================================================================== */
:root {
    --bg-base: #020204;
    --bg-surface: #0a0a0e;
    --bg-surface-elevated: #121218;
    
    --primary: #9d4edd;
    --primary-light: #c77dff;
    --primary-dark: #7b2cbf;
    --primary-glow: rgba(157, 78, 221, 0.12);
    --primary-glow-strong: rgba(157, 78, 221, 0.35);
    
    --text-primary: #ffffff;
    --text-secondary: #a1a1aa;
    --text-muted: #61616c;
    
    --border-subtle: rgba(157, 78, 221, 0.12);
    --border-medium: rgba(157, 78, 221, 0.22);
    --border-strong: rgba(157, 78, 221, 0.45);
    
    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'Fira Code', monospace;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-quick: all 0.15s ease-out;
    
    --sidebar-width: 300px;
    --toc-width: 240px;
    --header-height: 70px;
}

/* ==========================================================================
   Global Reset & Scrollbar Styles
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-dark) var(--bg-base);
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-height) + 20px);
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    overflow-x: hidden;
    position: relative;
}

/* Ambient glow blobs in background */
body::before {
    content: '';
    position: fixed;
    top: -15%;
    left: -15%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(0,0,0,0) 70%);
    z-index: -2;
    pointer-events: none;
    filter: blur(100px);
}

body::after {
    content: '';
    position: fixed;
    bottom: -15%;
    right: -15%;
    width: 45vw;
    height: 45vw;
    background: radial-gradient(circle, rgba(123, 44, 191, 0.06) 0%, rgba(0,0,0,0) 70%);
    z-index: -2;
    pointer-events: none;
    filter: blur(100px);
}

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

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

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

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

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition-quick);
}

code, pre {
    font-family: var(--font-mono);
}

/* ==========================================================================
   Header Navbar (Matches try.ricochet.today)
   ========================================================================== */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1000;
    background: rgba(10, 10, 14, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 24px;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    height: 32px;
    width: auto;
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    background: linear-gradient(135deg, var(--text-primary) 30%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    color: var(--primary-light);
    border: 1px solid var(--border-medium);
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(157, 78, 221, 0.05);
    letter-spacing: 0.1em;
    margin-left: 8px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 24px;
    list-style: none;
}

.nav-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    padding: 8px 0;
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary);
    transition: var(--transition-quick);
}

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

.nav-link:hover::after {
    width: 100%;
}

.nav-cta {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    border: 1px solid var(--primary-light);
    color: var(--text-primary);
    padding: 8px 16px;
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--primary-glow);
    transition: var(--transition-smooth);
}

.nav-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 18px var(--primary-glow-strong);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

/* ==========================================================================
   Documentation Main Layout Structure
   ========================================================================== */
.layout {
    display: flex;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    width: 100%;
    max-width: 1550px;
    margin-left: auto;
    margin-right: auto;
}

/* ==========================================================================
   Left Navigation Sidebar
   ========================================================================== */
#sidebar-nav {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: 24px;
    overflow-y: auto;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    scrollbar-gutter: stable;
}

/* Title on top of nav */
#sidebar-nav h1 {
    display: none; /* Already in top navbar */
}

/* Search bar in sidebar */
.search-container {
    margin-bottom: 24px;
    position: relative;
}

.search-input {
    width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 14px 10px 36px;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-quick);
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

/* Sidebar lists */
#sidebar-nav h2 {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: var(--primary-light);
    margin-top: 24px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

#sidebar-nav h2:first-of-type {
    margin-top: 0;
}

#sidebar-nav ul {
    list-style: none;
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#sidebar-nav ul li a {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 4px;
    border-left: 2px solid transparent;
}

#sidebar-nav ul li a:hover {
    color: var(--text-primary);
    background: rgba(157, 78, 221, 0.04);
    border-left-color: var(--border-medium);
}

#sidebar-nav ul li a[aria-current="page"],
#sidebar-nav ul li a.active {
    color: var(--text-primary);
    font-weight: 600;
    background: rgba(157, 78, 221, 0.08);
    border-left-color: var(--primary);
    box-shadow: inset 0 0 10px rgba(157, 78, 221, 0.03);
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
main {
    flex-grow: 1;
    min-width: 0; /* Prevents flex items from overflowing */
    padding: 48px 48px 80px 48px;
    max-width: 900px;
    margin: 0 auto;
}

/* ==========================================================================
   Table of Contents Sidebar (Right)
   ========================================================================== */
.toc-container {
    width: var(--toc-width);
    flex-shrink: 0;
    padding: 48px 24px 80px 0;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
}

.toc-title {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 700;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-left: 1px solid var(--border-subtle);
    padding-left: 16px;
}

.toc-link {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    line-height: 1.4;
}

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

.toc-link.active {
    color: var(--primary-light);
    font-weight: 500;
}

/* ==========================================================================
   Typography & Elements Styling
   ========================================================================== */
main h1 {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 900;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    margin-bottom: 24px;
    line-height: 1.25;
    background: linear-gradient(135deg, #ffffff 40%, var(--primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

main h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-primary);
    margin-top: 48px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

main h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 32px;
    margin-bottom: 12px;
}

main p {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 1rem;
}

main a {
    color: var(--primary-light);
    border-bottom: 1px solid transparent;
}

main a:hover {
    border-bottom-color: var(--primary-light);
}

/* Lists styling */
main ul, main ol {
    margin-bottom: 24px;
    padding-left: 24px;
}

main li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

main li strong {
    color: var(--text-primary);
}

/* Inline Code Elements */
main code {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--primary-light);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    word-break: break-all;
}

/* Blockquotes / Tips / Callouts */
main blockquote,
main .callout {
    background: rgba(157, 78, 221, 0.04);
    border: 1px solid var(--border-medium);
    border-left: 4px solid var(--primary);
    padding: 16px 20px;
    border-radius: 6px;
    margin: 24px 0;
}

main blockquote p,
main .callout p {
    margin-bottom: 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Warnings and special callouts */
main .callout.warning {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.04);
    border-color: rgba(239, 68, 68, 0.15);
}

/* Table Design */
main table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    font-size: 0.9rem;
    text-align: left;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow: hidden;
}

main th {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    font-weight: 600;
    padding: 14px 18px;
    border-bottom: 2px solid var(--border-subtle);
    font-family: var(--font-heading);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

main td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

main tr:last-child td {
    border-bottom: none;
}

main tr:hover td {
    background: rgba(157, 78, 221, 0.02);
}

/* Code Blocks (pre + code) */
main pre {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    margin: 24px 0;
    overflow: hidden;
    position: relative;
}

/* Code blocks window simulation */
main pre::before {
    content: '';
    display: block;
    height: 38px;
    background: #0d0d12;
    border-bottom: 1px solid var(--border-subtle);
    position: relative;
    z-index: 1;
}

/* Fake window dots */
.code-dots {
    position: absolute;
    top: 14px;
    left: 16px;
    display: flex;
    gap: 6px;
    z-index: 5;
}

.code-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--border-medium);
}
.code-dot.red { background-color: #ef4444; }
.code-dot.yellow { background-color: #f59e0b; }
.code-dot.green { background-color: #10b981; }

.code-lang-tag {
    position: absolute;
    top: 8px;
    right: 16px;
    font-family: var(--font-heading);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    z-index: 5;
}

main pre code {
    display: block;
    padding: 16px 20px;
    background: transparent;
    border: none;
    color: #e4e4e7;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.6;
    word-break: normal;
}

/* Code comments inside code blocks */
main pre code span.comment, 
main pre code .comment {
    color: var(--text-muted);
}

main pre code span.keyword,
main pre code .keyword {
    color: var(--primary-light);
}

/* Previous / Next Navigation */
.prev-next-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 60px;
    border-top: 1px solid var(--border-subtle);
    padding-top: 32px;
}

.nav-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    transition: var(--transition-smooth);
}

.nav-card.next {
    align-items: flex-end;
    text-align: right;
}

.nav-card:hover {
    border-color: var(--border-strong);
    background: rgba(157, 78, 221, 0.03);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(157, 78, 221, 0.05);
}

.nav-card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.nav-card-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Footer Section */
.footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    padding: 40px 24px;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-logo img {
    height: 24px;
}

.footer-brand {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.1rem;
    letter-spacing: 0.1em;
}

.footer-copyright {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ==========================================================================
   Responsive & Adaptive Media Queries
   ========================================================================== */
@media (max-width: 1200px) {
    .toc-container {
        display: none;
    }
}

@media (max-width: 900px) {
    .navbar {
        justify-content: space-between;
    }
    
    .nav-links, .nav-cta {
        display: none; /* Hide top links on tablet/mobile */
    }
    
    .mobile-menu-btn {
        display: block; /* Show hamburger button */
    }
    
    .layout {
        position: relative;
    }
    
    #sidebar-nav {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        width: var(--sidebar-width);
        z-index: 900;
        transition: var(--transition-smooth);
        background: #060609;
        box-shadow: 20px 0 40px rgba(0,0,0,0.8);
    }
    
    #sidebar-nav.open {
        left: 0;
    }
    
    /* Backdrop for sidebar drawer */
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        top: var(--header-height);
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(4px);
        z-index: 850;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    main {
        padding: 32px 24px;
    }
}

@media (max-width: 600px) {
    main h1 {
        font-size: 1.8rem;
    }
    main h2 {
        font-size: 1.2rem;
    }
    .prev-next-nav {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .nav-card.next {
        align-items: flex-start;
        text-align: left;
    }
}
