/* =========================================
   1. GLOBAL RESET & VARS
   ========================================= */
:root {
    
    /* Deep Space Gray Base */
    --bg-base: #0d0d12; 
    --bg-panel: rgba(255, 255, 255, 0.02); 
    --border-subtle: rgba(255, 255, 255, 0.06);
    
    /* StudioOne Brand Accents */
    --accent-purple: #8b5cf6; 
    --accent-teal: #2dd4bf;   
    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    /* Harmonized Alert Colors */
    --online-green: #10b981;
    --warning-orange: #fbbf24; /* Soft Amber */
    --app-red: #fb7185; /* Vibrant Coral */
    
    /* Layout Variables */
    --nav-height: 70px;
}

/* Replace your '*' block with this */
* { box-sizing: border-box; }

a { 
    color: inherit; 
    text-decoration: none; 
    transition: all 0.2s ease;
}

body { 
    margin: 0; 
    background-color: var(--bg-base); 
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.20) 0%, transparent 45%),
        radial-gradient(circle at 90% 80%, rgba(45, 212, 191, 0.15) 0%, transparent 45%);
    background-attachment: fixed;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    color: var(--text-main);
    overflow-x: hidden;
}

/* Must sit on <html>, not <body> - the document element is the scroller,
   so on <body> this never took effect and anchor jumps snapped instantly. */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* Custom Scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* =========================================
   2. TOP NAVIGATION (Global Anchor)
   ========================================= */
.top-nav {
    position: fixed; top: 0; left: 0; width: 100%; height: var(--nav-height);
    background: rgba(13, 13, 18, 0.8); 
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 40px; z-index: 100;
}

.nav-logo img { height: 35px; opacity: 0.9; transition: opacity 0.2s; }
.nav-logo:hover img { opacity: 1; }

/* The Search Container in the Nav Bar */
.nav-search { position: relative; width: 300px; }
.nav-search input {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-main);
    padding: 10px 16px 10px 40px;
    border-radius: 20px; 
    font-size: 15px; /* Bumped up */
    outline: none;
}
.nav-search input:focus {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(139, 92, 246, 0.5); 
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.15);
}
.nav-search i { position: absolute; left: 14px; top: 12px; color: var(--text-muted); font-size: 14px; }

.shortcut-badge {
    position: absolute; right: 10px; top: 8px;
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted); font-size: 11px; font-weight: 600;
    padding: 2px 6px; border-radius: 4px; pointer-events: none;
}

.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-link { 
    color: var(--text-muted) !important; 
    font-size: 15px; /* Bumped up */
    font-weight: 500; 
}
.nav-link:hover { color: var(--text-main); }
.nav-btn { 
    background: rgba(139, 92, 246, 0.15); 
    color: #c4b5fd !important; 
    padding: 10px 20px; 
    border-radius: 30px; 
    font-size: 15px; /* Bumped up */
    font-weight: 600; 
    border: 1px solid rgba(139, 92, 246, 0.3); 
}
.nav-btn:hover { background: var(--accent-purple); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3); }

/* =========================================
   3. SEARCH RESULTS DROPDOWN (Live Search)
   ========================================= */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: rgba(20, 20, 25, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 15px;
    margin-top: 10px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none; /* Controlled by JS */
}

.result-item {
    padding: 15px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    text-decoration: none;
    transition: background 0.2s;
}

.result-item:last-child { border-bottom: none; }

.result-item:hover, .result-item.selected {
    background: rgba(139, 92, 246, 0.1);
}

.result-title {
    color: var(--text-main);
    font-size: 15px;
    font-weight: 600;
}

.result-cat {
    color: var(--accent-teal);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Group heading inside the dropdown: "On this page" vs "Products" */
.result-group {
    padding: 12px 20px 6px 20px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-muted);
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

/* A line of page text with the matched term inside it */
.result-snippet {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
}
.result-snippet mark {
    background: rgba(45, 212, 191, 0.22);
    color: var(--text-main);
    font-weight: 700;
    padding: 1px 3px;
}

.result-empty {
    padding: 18px 20px;
    font-size: 14px;
    color: var(--text-muted);
}

/* The temporary flash on the word you jumped to */
mark.search-hit {
    background: var(--warning-orange);
    color: #0d0d12;
    font-weight: 700;
    border-radius: 4px;
    padding: 2px 4px;
    animation: hitFlash 2.4s ease-out forwards;
}
@keyframes hitFlash {
    0%, 55% { box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.35); }
    100%    { box-shadow: 0 0 0 4px rgba(251, 191, 36, 0); }
}

/* =========================================
   4. THE HOLY GRAIL 3-COLUMN GRID
   ========================================= */
.layout-wrapper {
    display: grid;
    /* Slimmed Sidebar (250px) and maximized center (1.2fr) */
    grid-template-columns: 250px minmax(0, 1.2fr) 240px; 
    gap: 30px;
    max-width: 1800px;
    margin: var(--nav-height) auto 0 auto; 
    padding: 0 20px;
}

.left-sidebar {
    position: sticky; top: var(--nav-height); height: calc(100vh - var(--nav-height));
    overflow-y: auto; padding: 40px 15px 40px 0;
    border-right: 1px solid var(--border-subtle);
}

.category-title { 
    font-size: 13px; /* Bumped up */
    text-transform: uppercase; 
    letter-spacing: 1px; 
    color: var(--text-muted); 
    margin: 30px 0 12px 0; 
    font-weight: 700; 
}

/* Force Sidebar links to stay gray/teal and ignore browser defaults */
.dir-link { 
    display: block; 
    color: var(--text-muted) !important; 
    font-size: 15px; /* Bumped up */
    padding: 10px 14px; 
    border-radius: 8px; 
    margin-bottom: 4px; 
}
.dir-link:hover { background: rgba(255,255,255,0.03); color: var(--text-main) !important; }
.dir-link.active { background: rgba(139, 92, 246, 0.1); color: #c4b5fd !important; border-left: 2px solid var(--accent-purple); }

.main-content {
    padding: 80px 40px 100px 40px; 
    animation: fadeIn 0.6s ease-out;
}

.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.breadcrumb a { color: var(--text-muted) !important; }
.breadcrumb a:hover { color: var(--text-main) !important; }
.breadcrumb span { color: var(--accent-teal); }

.right-sidebar {
    position: sticky; top: var(--nav-height); height: calc(100vh - var(--nav-height));
    padding: 80px 0 40px 20px;
}
.toc-title { 
    font-size: 13px; /* Bumped up */
    font-weight: 700; 
    color: var(--text-main); 
    margin-bottom: 20px; 
    letter-spacing: 1px; 
}

.toc-link { 
    display: block; 
    color: var(--text-muted) !important; 
    font-size: 14px; /* Bumped up */
    padding: 8px 0; 
    border-left: 1px solid var(--border-subtle); 
    padding-left: 16px; 
    margin-left: 4px; 
}
.toc-link:hover, .toc-link.active { color: var(--accent-teal) !important; border-left-color: var(--accent-teal); }

/* =========================================
   5. TYPOGRAPHY & COMPONENTS
   ========================================= */

/* 5a. Layout Spacing */
.doc-section {
    margin-bottom: 100px;
}

/* The top nav is fixed, so a plain #anchor jump parks the heading underneath
   it. Push every jump target clear of the nav, plus breathing room above. */
.doc-section,
.main-content section[id],
.main-content [id] {
    scroll-margin-top: calc(var(--nav-height) + 30px);
}

/* 5b. Header Lockups (Eyebrow + Title) */
.gradText { 
    display: block; /* Forces it to its own line */
    margin-bottom: 0px; 
    background: linear-gradient(90deg, var(--accent-purple), var(--accent-teal)); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    font-weight: 900;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 1px;
}

h1 { 
    font-size: 52px; 
    font-weight: 800; 
    margin: 5px 0 25px 0; /* Hugs the eyebrow text */
    letter-spacing: -1.5px; 
    color: var(--text-main); 
}

h2 { 
    font-size: 28px; 
    font-weight: 600; 
    padding-bottom: 12px; 
    border-bottom: 1px solid var(--border-subtle); 
    margin: 5px 0 24px 0; /* Hugs the eyebrow text */
    color: var(--text-main); 
}

h3 { font-size: 20px; font-weight: 600; color: var(--text-main); margin-top: 0; }

/* 5c. Body Text & Inline Elements */
p, li { color: var(--text-muted); line-height: 1.8; font-size: 16px; }

code { 
    background: rgba(255,255,255,0.06); 
    padding: 3px 8px; 
    border-radius: 6px; 
    font-family: monospace; 
    font-size: 0.85em; 
    color: var(--text-main); 
}

mark { 
    background: rgba(139, 92, 246, 0.2); 
    color: #c4b5fd; 
    border-radius: 6px; 
    padding: 2px 6px; 
}

/* 5d. Cards & Alerts */
.spec-card, .faq-item {
    background: var(--bg-panel);
    padding: 30px; 
    border-radius: 20px;
    border: 1px solid var(--border-subtle);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transition: transform 0.3s ease, background 0.3s ease;
    margin-bottom: 24px;
}
.spec-card:hover, .faq-item:hover { background: rgba(255, 255, 255, 0.03); }

.alert-box {
    background: rgba(251, 191, 36, 0.05); 
    padding: 24px; 
    border-radius: 16px; 
    margin: 30px 0;
    border-left: 4px solid var(--warning-orange);
}

.pro-tip {
    background: rgba(16, 185, 129, 0.05);
    border: 1px solid rgba(16, 185, 129, 0.1);
    padding: 24px; 
    border-radius: 20px; 
    margin: 30px 0;
}

/* 5e. Images & Media */
.hero-img { 
    max-width: 90%; 
    display: block; 
    margin: 0 auto; 
    filter: drop-shadow(0 20px 30px rgba(0,0,0,0.4)); 
}

.diagram-img { 
    max-width: 100%; 
    border-radius: 12px; 
    border: 1px solid var(--border-subtle); 
    box-shadow: 0 10px 40px rgba(0,0,0,0.3); 
}

/* Product Card Image Handling (4:3 Ratio) */
.card-img-wrapper {
    width: 100%;
    aspect-ratio: 4 / 3; /* Perfect lock for 700x525px */
    overflow: hidden;
    background: #000;
}

.card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    transition: transform 0.5s ease, opacity 0.3s ease;
}

/* This creates the zoom effect when you hover over the product card */
.spec-card:hover .card-img {
    transform: scale(1.05);
    opacity: 1;
}

/* 5f. Buttons & Pills */
.home-btn {
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 10px;
    padding: 14px; 
    background: var(--accent-purple); 
    border: none;
    border-radius: 30px; 
    color: #ffffff !important; 
    text-decoration: none !important;
    font-size: 15px; 
    font-weight: 600; 
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}
.home-btn:hover { background: #7c3aed; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4); }

.social-pill {
    border: 1px solid var(--border-subtle); 
    background: transparent; 
    color: var(--text-main) !important; 
    padding: 12px 24px; 
    border-radius: 30px; 
    text-decoration: none !important; 
    font-size: 14px; 
    font-weight: 500; 
    display: inline-flex; 
    align-items: center; 
    gap: 10px; 
    transition: all 0.2s ease;
}
.social-pill:hover { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.15); }

/* 5g. Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Update Log Timeline */
.timeline-container {
    position: relative;
    padding-left: 20px;
    margin-top: 20px;
}

/* The vertical stem */
.timeline-container::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: var(--border-subtle);
}

.log-item {
    position: relative;
    margin-bottom: 25px;
}

/* The glowing dot */
.log-dot {
    position: absolute;
    left: -21px;
    top: 4px;
    width: 10px;
    height: 10px;
    background: var(--accent-purple);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent-purple);
    border: 2px solid var(--bg-base);
    z-index: 2;
}

/* Style for the "Latest" update dot (like the red one in your image) */
.log-item:first-child .log-dot {
    background: var(--app-red);
    box-shadow: 0 0 10px var(--app-red);
}

.log-version {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-main);
    display: block;
}

.log-date {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 8px;
}

.log-notes {
    margin: 0;
    padding-left: 15px;
    font-size: 13px;
    color: var(--text-muted);
}

.log-notes li {
    margin-bottom: 4px;
    line-height: 1.4;
}

/* =========================================
   6. SIDEBAR CATEGORY GROUPS
   Collapsible <details> groups. The category you are currently
   reading in is rendered open; the rest start collapsed.
   ========================================= */
.cat-group { margin-bottom: 6px; }

.cat-toggle {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    transition: all 0.2s ease;
    user-select: none;
}
.cat-toggle::-webkit-details-marker { display: none; }
.cat-toggle:hover { color: var(--text-main); background: rgba(255,255,255,0.03); }

.cat-icon { font-size: 13px; width: 16px; text-align: center; color: var(--accent-purple); }

.cat-chevron {
    margin-left: auto;
    font-size: 10px;
    opacity: 0.5;
    transition: transform 0.25s ease;
}
.cat-group[open] > .cat-toggle { color: var(--text-main); }
.cat-group[open] > .cat-toggle .cat-chevron { transform: rotate(180deg); }

/* Nudge the product links in under their category heading */
.cat-group .dir-link { margin-left: 10px; }

/* =========================================
   7. PORTED CONTENT COMPONENTS
   Carried over from the previous stylesheet and restyled for v3.
   ========================================= */

/* 7a. Tables */
.main-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    overflow: hidden;
}

.main-content th,
.main-content td {
    padding: 15px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.7;
}

.main-content th {
    background: rgba(255,255,255,0.04);
    color: var(--accent-teal);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
}

.main-content tbody tr:last-child td { border-bottom: none; }
.main-content tbody tr:hover td { background: rgba(255,255,255,0.02); }
.main-content td strong { color: var(--text-main); }

/* 7b. Video embeds (16:9) */
.videoWrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
    background: #000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.videoWrapper iframe {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    border: 0;
}
/* When the wrapper carries a caption bar above the video, the padding
   trick can't be used — this variant lets the iframe size itself. */
.videoWrapper.has-caption { position: static; padding-bottom: 0; height: auto; }
.videoWrapper.has-caption iframe { position: static; display: block; height: 450px; }

/* 7c. Smaller inline diagrams */
.diagram-small {
    max-width: 70%;
    width: auto;
}

/* 7d. Inline label badge */
.code-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    color: #c4b5fd;
}

/* 7e. Keyboard / gesture keys */
.gesture-key {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    border: 1px solid var(--border-subtle);
    border-bottom-width: 2px;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-main);
    white-space: nowrap;
}

/* 7f. Tidy bulleted lists */
.clean-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 14px;
}
.clean-list li {
    position: relative;
    padding-left: 22px;
}
.clean-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-teal);
}
.clean-list li strong { color: var(--text-main); }

/* 7g. Status indicator dot (inline colour is set per-use) */
.status-light {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 10px;
    vertical-align: middle;
}

/* 7h. Hidden-by-default error/notice block */
.err { display: none; }
.err.show {
    display: block;
    padding: 15px;
    border-radius: 12px;
    background: rgba(251, 113, 133, 0.08);
    border: 1px solid rgba(251, 113, 133, 0.25);
    color: var(--text-main);
}

/* 7i. Library card fallback for products with no art yet */
.card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 30% 30%, rgba(139, 92, 246, 0.25) 0%, transparent 60%),
        radial-gradient(circle at 70% 70%, rgba(45, 212, 191, 0.20) 0%, transparent 60%),
        #101018;
}
.card-placeholder i {
    font-size: 46px;
    color: rgba(255,255,255,0.25);
}

/* =========================================
   8. RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 1200px) {
    .layout-wrapper { grid-template-columns: 260px minmax(0, 1fr); gap: 40px; }
    .right-sidebar { display: none; }
}

@media (max-width: 900px) {
    /* minmax(0, 1fr), not 1fr: a plain 1fr track refuses to shrink below its
       content's min-width, so one wide table pushes the whole page sideways. */
    .layout-wrapper { grid-template-columns: minmax(0, 1fr); padding: 0 20px; }
    .left-sidebar { display: none; }
    .nav-search { display: none; }
    .nav-links .nav-link { display: none; }
    .main-content { padding-top: 30px; }
    h1 { font-size: 36px; }

    /* The guides lay their columns out with inline grid styles.
       Collapse every one of them to a single column on small screens. */
    .main-content [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }

    /* Let wide spec tables scroll instead of squashing the page */
    .main-content table { display: block; overflow-x: auto; white-space: nowrap; }

    .diagram-small { max-width: 100%; }
    .videoWrapper.has-caption iframe { height: 240px; }
}