/* === style.css === */

/* --- CSS Variables for Consistent Color Scheme --- */
:root {
    --bg-body: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-header: #343a40;
    --bg-code: #f4f6f8;
    --bg-code-inline: #f4f6f8;
    --bg-index-hover: #e9ecef;

    --text-main: #333333;
    --text-muted: #495057;
    --text-header: #ffffff;
    --text-code: #212529;
    --text-code-inline: #212529;
    --text-code-constant: #902000;

    --border-light: #e9ecef;
    --border-medium: #dee2e6;
    --border-dark: #ced4da;

    --accent-primary: #007bff;
    --accent-hover: #0056b3;
}

/* --- Basic Reset & Body Styling --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-main);
    background-color: var(--bg-body);
    padding: 1rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

hr {
    margin-top: 3rem;
    margin-bottom: 2rem;
    color: var(--accent-primary);
}

/* --- Header Styling --- */
.main-header {
    background-color: var(--bg-header);
    color: var(--text-header);
    padding: 1rem 2rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.main-header h1 {
    font-size: 1.75rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

/* Groups title + section nav together on the left */
.main-header .header-left {
    display: flex;
    align-items: center;
    gap: 1.8rem;
    flex-wrap: wrap;
}

/* Page-section links — left-aligned next to the title */
.main-header .main-nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.main-header .main-nav a {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.3rem 0.65rem;
    border-radius: 5px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.main-header .main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--text-header);
    text-decoration: none;
}

.main-header a.current-main-nav {
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--text-header);
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.3rem 0.65rem;
    border-radius: 5px;
    text-decoration: none;
}

.main-header .breadcrumb-nav {
    display: flex;
}

/* Breadcrumb link — right-aligned */
.main-header .breadcrumb-nav a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    transition: color 0.2s ease;
    margin-left: 1.5rem;
}

.main-header .breadcrumb-nav nav a:first-child {
    margin-left: 0;
}

.main-header .breadcrumb-nav a:hover {
    color: var(--text-header);
    text-decoration: none;
}

/* --- Layout Systems --- */
.content-columns {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
    align-items: start;
}

.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.content-info {
    margin-top: 1rem;
}

.content-info p,
ul {
    max-width: 148ch;
}

/* Fix for wide content potentially distorting grid column widths */
.content-columns>.content-single-column,
.content-columns>.overview-column {
    min-width: 0;
}

/* --- Main Content Areas (Command Pages & Overview) --- */
.content-single-column,
.overview-column {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    padding: 2rem 2.5rem;
}

.overview-column {
    min-height: calc(100vh - 150px);
}

/* Typography inside content */
.content-single-column h2,
.overview-column h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--bg-header);
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
}

.content-single-column h2:first-of-type,
.overview-column h2:first-of-type {
    margin-top: 0;
}

.content-single-column h3,
.overview-column h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
}

.content-single-column p,
.overview-column p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Lists */
.content-single-column ul,
.overview-column ul {
    margin-left: 1.5rem;
    margin-top: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.content-single-column li,
.overview-column li {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

/* API Constant Lists specific styling */
.content-single-column ul.api-list {
    list-style: none;
    margin-left: 0;
}

.content-single-column ul.api-list li {
    border-bottom: 1px solid var(--border-light);
    padding: 0.8rem 0;
    margin-bottom: 0;
}

.content-single-column ul.api-list li:last-child {
    border-bottom: none;
}

/* --- Inline Code & Code Blocks --- */
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

p code,
li code {
    color: var(--text-code-inline);
    background-color: var(--bg-code-inline);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid var(--border-medium);
    white-space: nowrap;
}

.constant {
    color: var(--text-code-constant);
}

/* Syntax Block Styling */
.code-wrapper {
    position: relative;
}

/* "Select code-wrapper if it is followed by a paragraph" */
.code-wrapper:has(+ p) {
    margin-bottom: 1rem;
}

pre {
    background-color: var(--bg-code);
    color: var(--text-code);
    padding: 1.25rem;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.5;
}

div.sourceCode {
    margin: 0;
}

/* Targets .sourceCode only if the NEXT sibling is another .sourceCode */
.sourceCode:has(+ .sourceCode) {
    margin-bottom: 1rem;
}

/* The Copy Button */
.copy-code-button {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    background: var(--bg-surface);
    border: 1px solid var(--border-dark);
    color: var(--text-muted);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.copy-code-button:hover {
    background: var(--bg-code-inline);
    color: var(--text-code);
    border-color: var(--text-muted);
}

/* --- Parameters Section --- */
.parameters-section p {
    margin-bottom: 1rem;
    padding-left: 1rem;
    border-left: 3px solid var(--border-light);
}

.parameters-section strong {
    font-weight: 600;
    color: var(--accent-hover);
    display: inline-block;
    margin-bottom: 0.3em;
}

.parameters-section pre {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    margin-left: 1rem;
    padding: 1rem;
}

.parameters-section ol {
    margin-left: 3rem;
    margin-bottom: 1rem;
}

/* --- Index (Sidebar) Styles --- */
.index-column {
    background-color: var(--bg-body);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    position: sticky;
    top: 1rem;
    overflow-y: auto;
    /* Custom thin scrollbar for a cleaner look */
    scrollbar-width: thin;
    scrollbar-color: var(--border-dark) var(--bg-body);
}

.index-column::-webkit-scrollbar {
    width: 6px;
}

.index-column::-webkit-scrollbar-track {
    background: transparent;
}

.index-column::-webkit-scrollbar-thumb {
    background-color: var(--border-dark);
    border-radius: 10px;
}

.index-column h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-dark);
    padding-bottom: 0.5rem;
    color: var(--bg-header);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.index-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
    margin-bottom: 1.5rem;
}

/* Select any UL that does NOT have a header anywhere after it in the same parent */
.index-column ul:not(:has(~ h1, ~ h2, ~ h3, ~ h4, ~ h5, ~ h6)) {
    margin-bottom: 0;
}

.index-column li {
    margin-bottom: 0.3rem;
}

/* Add indentation back to nested lists */
.index-column ul ul {
    padding-left: 1.5rem;
    margin-top: 0.3rem;
    /* Optional: aligns it better under the parent link */
}

/* Bullet point for sub-items only */
.index-column ul ul li {
    list-style: disc;
}

.index-column ul ul li::marker {
    color: var(--accent-primary);
    content: "▸ ";
    /* Changes the disc to a triangle pointer */
}

.index-column a {
    text-decoration: none;
    color: var(--accent-primary);
    font-weight: 500;
    font-size: 0.9rem;
    display: block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.index-column a:hover {
    background-color: var(--bg-index-hover);
    color: var(--accent-hover);
    text-decoration: none;
}

/* Active command in the sidebar */
.index-column a.current-command {
    font-weight: 600;
    color: var(--text-code);
    background-color: #e2e6ea;
    border-left: 3px solid var(--accent-primary);
    border-radius: 0 4px 4px 0;
    padding-left: .7rem;
}

/* --- Feature Grid (Home Page) --- */
.feature-section {
    position: relative;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    padding: 1.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.feature-section:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.08);
    border-color: var(--border-dark);
}

.feature-header {
    margin-bottom: 0.75rem;
}

.feature-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
}

.feature-header h2 a {
    color: var(--accent-primary);
    text-decoration: none;
}

.feature-section p {
    font-size: 0.95rem;
    color: var(--text-muted);
    flex-grow: 1;
    margin: 0;
}

/* Makes the entire feature card clickable */
.feature-section h2 a.main-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* --- Footer --- */
.main-footer {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding-top: 1.5rem;
    padding-bottom: 1rem;
    border-top: 1px solid var(--border-medium);
}

/* --- Global Link Styling --- */
a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

/* --- Responsive Adjustments --- */
@media (max-width: 900px) {
    .content-columns {
        grid-template-columns: 1fr;
    }

    .index-column {
        order: -1;
        margin-bottom: 1rem;
        position: static;
        max-height: 300px;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem 1.5rem;
        gap: 0.5rem;
    }

    .main-header .header-left {
        width: 100%;
        gap: 0.5rem;
    }

    .main-header .main-nav a {
        font-size: 0.825rem;
        padding: 0.3rem 0.5rem;
    }

    .main-header .breadcrumb-nav {
        width: 100%;
    }

    .content-single-column,
    .overview-column {
        padding: 1.5rem;
    }
}

@media screen {
    .sourceCode {
        overflow: auto;
    }
}