/* ============================================================
   FireflyProtector Docs — modern developer-docs layout
   Design philosophy: clean, minimal, transparent surfaces with
   subtle borders. No heavy grey card fills — matches the dark/
   light theme backgrounds instead. Generous spacing, wide layout.
   ============================================================ */

/* On the docs page, drop default main-content padding so the shell
   controls its own full-width layout. */
.main-content.docs-main-shell {
    padding-top: 0;
    padding-bottom: 0;
}

/* ---------- Shell: full-bleed three-column grid ---------- */
.docs-shell {
    display: grid;
    grid-template-columns:
        260px
        minmax(0, 1fr)
        240px;
    align-items: start;
    width: 100%;
    max-width: 1640px;
    margin: 0 auto;
    padding-top: var(--spacing-xl);
}

/* ============================================================
   LEFT — fixed sidebar
   ============================================================ */
.docs-sidebar {
    position: sticky;
    top: 72px; /* navbar (sticky, ~64px) + small gap */
    height: calc(100vh - 72px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-xxl) var(--spacing-lg);
    border-right: 1px solid var(--outline-color);
    scrollbar-width: thin;
    scrollbar-color: var(--outline-color) transparent;
}
.docs-sidebar::-webkit-scrollbar { width: 6px; }
.docs-sidebar::-webkit-scrollbar-thumb {
    background: var(--outline-color);
    border-radius: 3px;
}

.docs-brand { margin-bottom: var(--spacing-lg); }
.docs-brand-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--secondary-text);
}

.docs-nav-group { margin-bottom: var(--spacing-lg); }
.docs-nav-heading {
    display: block;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary-text);
    margin-bottom: var(--spacing-sm);
    padding: 0 var(--spacing-sm);
}

.docs-nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px var(--spacing-sm);
    border-radius: 9px;
    font-size: 0.875rem;
    color: var(--secondary-text);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1.3;
    margin-bottom: 2px;
    border: 1px solid transparent;
}
.docs-nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--on-surface-text);
}
.docs-nav-link.is-active {
    /* dark blue active background, per the design brief */
    background: #1d4ed8;
    color: #fff;
    font-weight: 500;
}
.docs-nav-icon {
    font-size: 18px;
    flex-shrink: 0;
    opacity: 0.85;
}
.docs-nav-link.is-active .docs-nav-icon { opacity: 1; }

/* ============================================================
   MAIN — breadcrumb, title, article
   ============================================================ */
.docs-main {
    min-width: 0; /* prevent grid blowout from long <pre>/<code> */
    padding: var(--spacing-sm) var(--spacing-xxl) var(--spacing-xxl) var(--spacing-xxl);
}

.docs-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--secondary-text);
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
}
.docs-breadcrumb a {
    color: var(--secondary-text);
    text-decoration: none;
    transition: color 0.15s ease;
}
.docs-breadcrumb a:hover { color: var(--primary-accent); }
.docs-breadcrumb-sep { opacity: 0.5; }
.docs-breadcrumb-current { color: var(--on-surface-text); font-weight: 500; }

.docs-title {
    font-size: clamp(2rem, 1.3rem + 2.6vw, 2.9rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--on-surface-text);
    margin: 0 0 var(--spacing-md);
    line-height: 1.08;
}

.docs-lead {
    font-size: 1.08rem;
    line-height: 1.7;
    color: var(--secondary-text);
    max-width: 78ch;
    margin: 0;
}
.docs-lead a {
    color: var(--primary-accent);
    text-decoration: none;
    font-weight: 500;
}
.docs-lead a:hover { text-decoration: underline; }

.docs-divider {
    border: none;
    border-top: 1px solid var(--outline-color);
    margin: var(--spacing-xxl) 0;
}

/* ---------- Section blocks ---------- */
.docs-section-block {
    margin-bottom: var(--spacing-xxl);
    scroll-margin-top: 88px; /* offset for sticky navbar on anchor jumps */
}
.docs-section-block > h2 {
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--on-surface-text);
    margin: 0 0 var(--spacing-lg);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--outline-color);
}
.docs-section-block > p {
    color: var(--secondary-text);
    line-height: 1.7;
    margin: 0 0 var(--spacing-md);
    max-width: 80ch;
    font-size: 0.98rem;
}
.docs-section-block h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--on-surface-text);
    margin: var(--spacing-xl) 0 var(--spacing-sm);
}
.docs-section-block h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--on-surface-text);
    margin: var(--spacing-lg) 0 var(--spacing-sm);
}
.docs-section-block ul,
.docs-section-block ol {
    margin: 0 0 var(--spacing-md);
    padding-left: 1.4rem;
    color: var(--secondary-text);
    line-height: 1.75;
    max-width: 80ch;
    font-size: 0.95rem;
}
.docs-section-block li { margin-bottom: 7px; }
.docs-section-block a {
    color: var(--primary-accent);
    text-decoration: none;
    font-weight: 500;
}
.docs-section-block a:hover { text-decoration: underline; }
.docs-section-block code,
.docs-product-body code,
.docs-callout code,
.docs-tags code,
.docs-table code {
    background: var(--bg-tertiary);
    border: 1px solid var(--outline-color);
    padding: 1.5px 6px;
    border-radius: 6px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85em;
    color: var(--on-surface-text);
}

/* ---------- Quick-start steps ---------- */
.docs-steps {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}
.docs-step {
    display: flex;
    gap: var(--spacing-md);
    align-items: flex-start;
    padding: var(--spacing-md) var(--spacing-lg);
    border: 1px solid var(--outline-color);
    border-radius: var(--radius-md);
    background: transparent;
}
.docs-step-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.92rem;
}
.docs-step h3 { margin: 0 0 5px; font-size: 1.02rem; }
.docs-step p { margin: 0; font-size: 0.92rem; max-width: none; color: var(--secondary-text); line-height: 1.65; }

/* ---------- Mini cards (transparent, border-only) ---------- */
.docs-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}
.docs-mini-card {
    background: transparent;
    border: 1px solid var(--outline-color);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.docs-mini-link {
    text-decoration: none;
    display: block;
    color: inherit;
}
.docs-mini-link:hover {
    border-color: var(--primary-accent);
    transform: translateY(-2px);
    background: var(--bg-tertiary);
}
.docs-mini-icon {
    font-size: 26px;
    color: var(--primary-accent);
    margin-bottom: var(--spacing-sm);
}
.docs-mini-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--on-surface-text);
    margin: 0 0 7px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.docs-mini-card p {
    font-size: 0.9rem;
    color: var(--secondary-text);
    margin: 0;
    line-height: 1.6;
}

/* ---------- Pills / badges ---------- */
.docs-pill {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--bg-tertiary);
    color: var(--secondary-text);
    border: 1px solid var(--outline-color);
    text-transform: capitalize;
    vertical-align: middle;
    line-height: 1.4;
}
.docs-pill-stable { background: rgba(48, 209, 88, 0.14); color: #30d158; border-color: transparent; }
.docs-pill-alpha  { background: rgba(255, 159, 10, 0.16); color: #ffb340; border-color: transparent; }
.docs-pill-maint  { background: rgba(255, 69, 58, 0.14); color: #ff6961; border-color: transparent; }
.docs-pill-soon   { background: rgba(41, 151, 255, 0.16); color: #5ab0ff; border-color: transparent; }

/* ---------- Product blocks (no grey box — divider separated) ---------- */
.docs-product {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-xl);
    border-top: 1px solid var(--outline-color);
    scroll-margin-top: 88px;
}
.docs-product:first-of-type { border-top: none; padding-top: 0; }
.docs-product-head {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
}
.docs-product-head > .material-symbols-outlined {
    font-size: 30px;
    color: var(--primary-accent);
    flex-shrink: 0;
}
.docs-product-head > .docs-head-text { flex: 1; min-width: 0; }
.docs-product-head h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--on-surface-text);
    letter-spacing: -0.01em;
}
.docs-product-head .docs-head-sub {
    margin: 3px 0 0;
    font-size: 0.88rem;
    color: var(--secondary-text);
}
.docs-product-body > p {
    color: var(--secondary-text);
    line-height: 1.7;
    margin: 0 0 var(--spacing-md);
    max-width: 80ch;
    font-size: 0.95rem;
}
.docs-product-body h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--on-surface-text);
    margin: var(--spacing-lg) 0 var(--spacing-sm);
}
.docs-product-body ul,
.docs-product-body ol {
    margin: 0 0 var(--spacing-md);
    padding-left: 1.4rem;
    color: var(--secondary-text);
    line-height: 1.75;
    max-width: 80ch;
    font-size: 0.93rem;
}
.docs-product-body li { margin-bottom: 6px; }
.docs-product-body a {
    color: var(--primary-accent);
    text-decoration: none;
    font-weight: 500;
}
.docs-product-body a:hover { text-decoration: underline; }

/* ---------- Tables ---------- */
.docs-table-wrap {
    overflow-x: auto;
    margin: var(--spacing-md) 0;
    border: 1px solid var(--outline-color);
    border-radius: var(--radius-sm);
}
.docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 480px;
}
.docs-table th,
.docs-table td {
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--outline-color);
    color: var(--secondary-text);
    vertical-align: top;
    line-height: 1.5;
}
.docs-table th {
    background: var(--bg-tertiary);
    color: var(--on-surface-text);
    font-weight: 600;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}
.docs-table tr:last-child td { border-bottom: none; }

/* ---------- Tag chips ---------- */
.docs-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: var(--spacing-sm) 0 var(--spacing-md);
}
.docs-tags > span {
    font-size: 0.78rem;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: var(--bg-tertiary);
    border: 1px solid var(--outline-color);
    color: var(--secondary-text);
    font-weight: 500;
}

/* ---------- Callouts ---------- */
.docs-callout {
    display: flex;
    gap: 13px;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--outline-color);
    background: transparent;
    margin: var(--spacing-lg) 0;
    font-size: 0.92rem;
    line-height: 1.65;
    color: var(--on-surface-text);
}
.docs-callout > .material-symbols-outlined {
    flex-shrink: 0;
    font-size: 22px;
    margin-top: 1px;
}
.docs-callout a {
    color: var(--primary-accent);
    text-decoration: none;
    font-weight: 500;
}
.docs-callout a:hover { text-decoration: underline; }
.docs-callout-info {
    border-color: rgba(41, 151, 255, 0.28);
}
[data-theme="dark"] .docs-callout-info { background: rgba(41, 151, 255, 0.06); }
[data-theme="light"] .docs-callout-info { background: rgba(0, 113, 227, 0.05); }
.docs-callout-info > .material-symbols-outlined { color: var(--primary-accent); }
.docs-callout-warn {
    border-color: rgba(255, 159, 10, 0.32);
}
[data-theme="dark"] .docs-callout-warn { background: rgba(255, 159, 10, 0.07); }
[data-theme="light"] .docs-callout-warn { background: rgba(255, 214, 10, 0.08); }
.docs-callout-warn > .material-symbols-outlined { color: #ffb340; }

/* ============================================================
   RIGHT — "On this page" TOC
   ============================================================ */
.docs-toc {
    position: sticky;
    top: 72px;
    height: calc(100vh - 72px);
    overflow-y: auto;
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-xxl) var(--spacing-md);
    border-left: 1px solid var(--outline-color);
}
.docs-toc-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--secondary-text);
    margin-bottom: var(--spacing-md);
}
.docs-toc-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.docs-toc-link {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 0.83rem;
    color: var(--secondary-text);
    text-decoration: none;
    padding: 6px var(--spacing-xs);
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
    line-height: 1.3;
}
.docs-toc-link:hover {
    color: var(--on-surface-text);
    background: var(--bg-tertiary);
}
.docs-toc-link.is-active {
    color: var(--on-surface-text);
    font-weight: 600;
}
.docs-toc-marker {
    width: 2px;
    height: 15px;
    background: transparent;
    border-radius: 2px;
    flex-shrink: 0;
    transition: background 0.15s ease;
}
.docs-toc-link.is-active .docs-toc-marker {
    background: var(--primary-accent);
}

/* ============================================================
   Mobile sidebar toggle (FAB)
   ============================================================ */
.docs-sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 1100;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: var(--primary-accent);
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
}
.docs-sidebar-toggle .material-symbols-outlined { font-size: 24px; }

/* Docs backdrop for mobile drawer */
.docs-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.docs-backdrop.is-open { display: block; opacity: 1; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1280px) {
    /* Collapse the right TOC on medium-wide screens */
    .docs-shell { grid-template-columns: 260px minmax(0, 1fr); }
    .docs-toc { display: none; }
}

@media (max-width: 1024px) {
    .docs-main { padding-left: var(--spacing-xl); padding-right: var(--spacing-xl); }
}

@media (max-width: 860px) {
    /* Single column; sidebar becomes an off-canvas drawer */
    .docs-shell {
        grid-template-columns: minmax(0, 1fr);
        padding-top: var(--spacing-lg);
    }
    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 286px;
        max-width: 86vw;
        background: var(--background-color);
        border-right: 1px solid var(--outline-color);
        z-index: 1050;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
        padding: var(--spacing-lg);
        box-shadow: var(--shadow-lg);
    }
    .docs-sidebar.is-open { transform: translateX(0); }
    .docs-main {
        padding: var(--spacing-sm) var(--spacing-md) var(--spacing-xxl);
    }
    .docs-sidebar-toggle { display: flex; }
    .docs-product-head { gap: var(--spacing-sm); }
    .docs-product-head > .material-symbols-outlined { font-size: 26px; }
}

@media (max-width: 560px) {
    .docs-title { font-size: 1.8rem; }
    .docs-section-block > h2 { font-size: 1.4rem; }
    .docs-step {
        padding: var(--spacing-sm) var(--spacing-md);
        gap: var(--spacing-sm);
    }
    .docs-step-num { width: 28px; height: 28px; font-size: 0.85rem; }
    .docs-breadcrumb { font-size: 0.75rem; }
    .docs-cards { grid-template-columns: 1fr; }
}
