/* ==========================================================================
   Guide: Dedicated Styles
   Prefixed with guide- to avoid collisions with styles.css
   ========================================================================== */

:root {
    --guide-bg: #f7f9fc;
    --guide-surface: #ffffff;
    --guide-text: #333333;
    --guide-title: #2c3e50;
    --guide-accent: #4a90e2;
    --guide-accent-hover: #357abd;
    --guide-border: #e5e7eb;
}

html {
    scroll-behavior: smooth;
}

/* Layout: TOC + Content two-column */
.guide-layout {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    width: 83%;
    max-width: 2000px;
    margin-left: var(--content-offset-desktop, 210px);
    margin-right: auto;
    margin-top: 20px;
    padding-bottom: 60px;
    min-height: calc(100vh - 80px);
}

/* ---- Table of Contents (sticky sidebar) ---- */
.guide-toc {
    order: 2;
    position: sticky;
    top: 80px;
    align-self: flex-start;
    width: 170px;
    min-width: 170px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    padding: 12px 0;
    background: var(--guide-surface);
    border: 1px solid var(--guide-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.guide-toc-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--guide-border);
    margin-bottom: 6px;
}

.guide-toc ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.guide-toc li {
    margin: 0;
}

.guide-toc a {
    display: block;
    padding: 5px 12px;
    font-size: 11.5px;
    color: #475569;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.guide-toc a:hover {
    color: var(--guide-accent);
    background: #eef4ff;
}

.guide-toc a.active {
    color: var(--guide-accent);
    font-weight: 600;
    border-left-color: var(--guide-accent);
    background: #eef4ff;
}

/* Sub-items (downstream modules, etc.) */
.guide-toc .toc-sub a {
    padding-left: 24px;
    font-size: 10.8px;
}

/* Mobile TOC toggle */
.guide-toc-toggle {
    display: none;
    width: 100%;
    padding: 12px 14px;
    background: var(--guide-accent);
    color: #fff;
    border: none;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    border-radius: 8px;
}

.guide-toc-toggle i {
    margin-right: 8px;
    transition: transform 0.2s;
}

.guide-toc-toggle.open i {
    transform: rotate(90deg);
}

/* ---- Main Content Area ---- */
.guide-content {
    order: 1;
    flex: 1;
    min-width: 0;
}

/* Sections */
.guide-section {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    margin-top: 0;
    padding: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    scroll-margin-top: 80px;
    margin-bottom: 40px;
}

.guide-section-title {
    font-size: 26px;
    font-weight: 600;
    color: var(--guide-title);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--guide-accent);
}

.guide-section-title .step-badge {
    display: inline-block;
    background: var(--guide-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    margin-right: 10px;
    vertical-align: middle;
}

/* Cards */
.guide-card {
    background: var(--guide-surface);
    border: 1px solid var(--guide-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 24px;
    overflow: hidden;
}

.guide-card-header {
    background: #111111;
    color: #fff;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.guide-card-header i {
    font-size: 18px;
    opacity: 0.9;
}

.guide-card-body {
    padding: 24px;
    line-height: 1.75;
    color: #374151;
    font-size: 15px;
}

.guide-card-body h4 {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin: 20px 0 10px;
}

.guide-card-body h4:first-child {
    margin-top: 0;
}

.guide-card-body p {
    margin-bottom: 14px;
}

.guide-card-body ul, .guide-card-body ol {
    margin-bottom: 14px;
    padding-left: 24px;
}

.guide-card-body li {
    margin-bottom: 6px;
}

/* ---- Callouts ---- */
.guide-callout {
    border-radius: 6px;
    padding: 16px 20px;
    margin: 16px 0;
    font-size: 14px;
    line-height: 1.65;
}

.guide-callout-title {
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.guide-callout.note {
    background: #eef4ff;
    border-left: 4px solid var(--guide-accent);
}

.guide-callout.note .guide-callout-title {
    color: var(--guide-accent);
}

.guide-callout.warning {
    background: #fff8e6;
    border-left: 4px solid #e6a817;
}

.guide-callout.warning .guide-callout-title {
    color: #c9940f;
}

.guide-callout.reference {
    background: #f8fbff;
    border-left: 4px solid var(--guide-accent);
}

.guide-callout.reference .guide-callout-title {
    color: var(--guide-accent);
}

.guide-reference-list {
    margin: 8px 0 0;
    padding-left: 18px;
}

.guide-reference-list li {
    margin-bottom: 8px;
}

.guide-reference-list a {
    color: #1e40af;
    text-decoration: none;
}

.guide-reference-list a:hover {
    text-decoration: underline;
}

/* ---- Parameter Tables ---- */
.guide-params-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}

.guide-params-table thead th {
    background: #f5f7fa;
    color: #2c3e50;
    font-weight: 600;
    text-align: left;
    padding: 10px 14px;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.guide-params-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    vertical-align: top;
}

.guide-params-table tbody tr:hover {
    background: #f9fbfe;
}

.guide-params-table code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    color: #c0392b;
}

/* Scrollable table wrapper */
.guide-table-wrap {
    overflow-x: auto;
    margin: 16px 0;
    -webkit-overflow-scrolling: touch;
}

/* ---- Figures ---- */
.guide-figure {
    margin: 24px 0;
    text-align: center;
}

.guide-figure svg {
    max-width: 100%;
    height: auto;
}

.guide-figure figcaption {
    font-size: 13px;
    color: #777;
    margin-top: 10px;
    font-style: italic;
}

/* ---- Back to Top ---- */
.guide-back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 44px;
    height: 44px;
    background: var(--guide-accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(74, 144, 226, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.guide-back-to-top:hover {
    transform: translateY(-3px);
    background: var(--guide-accent-hover);
}

.guide-back-to-top i {
    margin-right: 0;
    line-height: 1;
}

/* ---- Inline code ---- */
.guide-card-body code {
    background: #f0f2f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
    color: #c0392b;
}

/* ---- Header banner ---- */
.guide-header {
    background: var(--guide-surface);
    color: var(--guide-title);
    border: 1px solid var(--guide-border);
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.guide-header h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--guide-title);
}

.guide-header p {
    font-size: 15px;
    color: #475569;
    max-width: 700px;
    line-height: 1.6;
}

/* ---- Glossary ---- */
.guide-glossary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.guide-glossary-item {
    padding: 12px 16px;
    background: #f9fbfe;
    border-radius: 6px;
    border-left: 3px solid #4a90e2;
}

.guide-glossary-item dt {
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    margin-bottom: 4px;
}

.guide-glossary-item dd {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin: 0;
}

.glossary-icon {
    color: var(--guide-accent);
    font-size: 12px;
    margin-right: 4px;
    opacity: 0.7;
}

/* Glossary target highlight when navigated from tooltip */
.guide-glossary-item:target {
    animation: glossaryHighlight 1.5s ease;
    border-left-color: #e74c3c;
}
@keyframes glossaryHighlight {
    0%   { background: #fff3cd; }
    100% { background: #f9fbfe; }
}

/* ---- Inline glossary tooltips ---- */
.glossary-tooltip {
    position: relative;
    border-bottom: 1px dotted var(--guide-accent);
    cursor: help;
}

.glossary-tooltip .glossary-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    background: #2c3e50;
    color: #fff;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    padding: 10px 14px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.glossary-tooltip .glossary-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2c3e50;
}

.glossary-tooltip:hover .glossary-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Ensure tooltips near edges don't overflow */
@media (max-width: 768px) {
    .glossary-tooltip .glossary-tooltip-text {
        width: 220px;
        left: 0;
        transform: none;
    }
    .glossary-tooltip .glossary-tooltip-text::after {
        left: 20px;
    }
}

/* ---- FAQ ---- */
.guide-faq-item {
    margin-bottom: 16px;
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
}

.guide-faq-q {
    font-weight: 600;
    padding: 14px 20px;
    background: #f9fbfe;
    color: #2c3e50;
    font-size: 14px;
    cursor: default;
}

.guide-faq-a {
    padding: 14px 20px;
    font-size: 14px;
    line-height: 1.65;
    color: #444;
}

/* ---- Responsive ---- */

/* Sidebar toggle adjustments for guide layout */
.sidebar.hidden ~ .guide-layout {
    margin-left: 20px;
    margin-right: 20px;
    width: auto;
}

@media (max-width: 768px) {
    .guide-layout {
        flex-direction: column;
        margin: 12px 10px 0 !important;
        width: auto !important;
        max-width: none;
        gap: 14px;
        min-height: auto;
        padding-bottom: 24px;
    }

    .guide-toc {
        order: 0;
        position: static;
        width: 100%;
        min-width: 0;
        max-height: none;
        overflow: visible;
        border-radius: 10px;
    }

    .guide-content {
        order: 1;
        width: 100%;
    }

    .guide-content .guide-section {
        width: 100% !important;
        max-width: none !important;
        margin: 0 0 28px 0 !important;
        padding: 0 !important;
    }

    .guide-toc-toggle {
        display: block;
    }

    .guide-toc ul {
        display: none;
        padding: 10px 0;
    }

    .guide-toc.open ul {
        display: block;
    }

    .guide-header {
        padding: 18px 16px;
        margin-bottom: 20px;
    }

    .guide-header h1 {
        font-size: 20px;
        line-height: 1.3;
    }

    .guide-header p {
        max-width: none;
        font-size: 14px;
    }

    .guide-section-title {
        font-size: 18px;
        margin-bottom: 16px;
    }

    .guide-card-header {
        padding: 12px 16px;
        font-size: 15px;
    }

    .guide-card-body {
        padding: 14px;
        font-size: 14px;
        line-height: 1.7;
    }

    .guide-card-body ul,
    .guide-card-body ol {
        padding-left: 20px;
    }

    .guide-callout {
        padding: 14px 16px;
    }

    .guide-faq-q,
    .guide-faq-a {
        padding: 12px 14px;
    }

    .guide-back-to-top {
        width: 40px;
        height: 40px;
        right: 16px;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    .guide-layout {
        margin: 10px 8px 0 !important;
        gap: 12px;
    }

    .guide-toc-toggle {
        padding: 10px 12px;
        font-size: 13px;
    }

    .guide-toc-title {
        padding: 8px 12px 6px;
    }

    .guide-toc a {
        font-size: 11.5px;
        padding: 7px 10px;
    }

    .guide-toc .toc-sub a {
        padding-left: 18px;
    }

    .guide-section-title {
        font-size: 17px;
    }

    .guide-section-title .step-badge {
        font-size: 12px;
        padding: 2px 8px;
        margin-right: 8px;
    }

    .guide-card-header {
        padding: 11px 14px;
        font-size: 14px;
    }

    .guide-card-body {
        padding: 12px;
        font-size: 13.5px;
    }

    .guide-params-table {
        font-size: 12px;
    }

    .guide-params-table thead th,
    .guide-params-table tbody td {
        padding: 8px;
    }

    .guide-glossary-grid {
        grid-template-columns: 1fr;
    }
}

/* ---- Figure cross-reference links ---- */
a.figure-ref {
    color: var(--guide-accent);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px dashed var(--guide-accent);
    transition: color 0.2s, border-color 0.2s;
}
a.figure-ref:hover {
    color: var(--guide-accent-hover);
    border-bottom-style: solid;
}

/* Smooth scroll target highlight */
.guide-figure:target {
    animation: figureHighlight 1.5s ease;
}
@keyframes figureHighlight {
    0%   { outline: 3px solid var(--guide-accent); outline-offset: 6px; }
    100% { outline: 3px solid transparent; outline-offset: 6px; }
}
