/* ==========================================================================
   Pingi Docs — /docs
   Reuses the --pg-* design tokens defined in pingi-theme.css (colors,
   radii, shadows, sidebar width) so the docs feel like part of Pingi rather
   than a generic docs template.
   ========================================================================== */

html, body.hb-body {
    margin: 0;
    background: var(--pg-page-bg);
    color: var(--pg-text);
    font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.hb-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.hb-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    background-image: linear-gradient(180deg, var(--pg-surface) 0%, var(--pg-surface-2) 100%);
    border-right: 1px solid var(--pg-border);
    display: flex;
    flex-direction: column;
    z-index: 150;
    overflow-y: auto;
}
.hb-brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.1rem 1.2rem;
    border-bottom: 1px solid var(--pg-border);
    text-decoration: none;
    flex-shrink: 0;
}
.hb-brand-mark { width: 38px; height: 38px; flex-shrink: 0; display: flex; }
.hb-brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.hb-brand-text { display: flex; flex-direction: column; min-width: 0; }
.hb-brand-name { font-weight: 800; font-size: 1.02rem; color: var(--pg-text); line-height: 1.15; }
.hb-brand-name span { color: var(--pg-brand-600); }
.hb-brand-tagline { font-size: .66rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--pg-text-muted); }

.hb-sidebar-search { position: relative; margin: .9rem 1rem; flex-shrink: 0; }
.hb-sidebar-search > i {
    position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
    color: var(--pg-text-muted); font-size: .85rem; pointer-events: none;
}
.hb-sidebar-search input, .hb-topbar-search input {
    font-family: inherit;
    border: 1px solid var(--pg-border);
    background: var(--pg-surface-2);
    color: var(--pg-text);
    border-radius: 999px;
    outline: none;
}
.hb-sidebar-search input { width: 100%; padding: .5rem .9rem .5rem 2.1rem; font-size: .82rem; box-sizing: border-box; }
.hb-sidebar-search input:focus, .hb-topbar-search input:focus { border-color: var(--pg-brand-400); }

.hb-search-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px);
    background: var(--pg-surface);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-sm);
    box-shadow: var(--pg-shadow-md);
    z-index: 200;
    max-height: 340px;
    overflow-y: auto;
    display: none;
}
.hb-search-results.show { display: block; }
.hb-search-result-item { display: block; padding: .6rem .8rem; text-decoration: none; border-bottom: 1px solid var(--pg-border); }
.hb-search-result-item:last-child { border-bottom: none; }
.hb-search-result-item:hover, .hb-search-result-item.is-active { background: var(--pg-brand-50); }
.hb-search-result-item .hb-sr-group { font-size: .65rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pg-brand-700); }
.hb-search-result-item .hb-sr-title { font-size: .86rem; font-weight: 700; color: var(--pg-text); margin: .1rem 0; }
.hb-search-result-item .hb-sr-snippet { font-size: .76rem; color: var(--pg-text-muted); line-height: 1.4; }
.hb-search-empty { padding: .8rem; font-size: .8rem; color: var(--pg-text-muted); }

.hb-nav { flex: 1 1 auto; padding: .4rem .85rem 1.5rem; overflow-y: auto; }
.hb-nav-group { margin-bottom: .2rem; }
.hb-nav-group-toggle {
    width: 100%;
    display: flex; align-items: center; gap: .6rem;
    background: none; border: none; cursor: pointer;
    padding: .55rem .6rem;
    border-radius: var(--pg-radius-sm);
    color: var(--pg-text);
    font-family: inherit;
    font-weight: 700;
    font-size: .76rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
}
.hb-nav-group-toggle:hover { background: var(--pg-brand-50); }
.hb-nav-group-toggle > i:first-child { color: var(--pg-brand-600); font-size: .95rem; }
.hb-nav-chevron { margin-left: auto !important; font-size: .68rem !important; color: var(--pg-ink-400); transition: transform .2s ease; }
.hb-nav-group.is-open .hb-nav-chevron { transform: rotate(180deg); }
.hb-nav-sublist { max-height: 0; overflow: hidden; transition: max-height .25s ease; padding-left: 1.85rem; }
.hb-nav-group.is-open .hb-nav-sublist { max-height: 800px; }
.hb-nav-link {
    display: block;
    padding: .38rem .6rem;
    margin: .05rem 0;
    border-radius: 8px;
    font-size: .84rem;
    font-weight: 500;
    color: var(--pg-ink-600);
    text-decoration: none;
}
.hb-nav-link:hover { background: var(--pg-brand-50); color: var(--pg-ink-900); }
.hb-nav-link.active {
    background-image: linear-gradient(120deg, var(--pg-surface) 0%, var(--pg-brand-100) 100%);
    color: var(--pg-ink-900);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--pg-brand-500);
}

.hb-sidebar-footer { flex-shrink: 0; border-top: 1px solid var(--pg-border); padding: .75rem .85rem; display: flex; flex-direction: column; gap: .15rem; }
.hb-footer-link {
    display: flex; align-items: center; gap: .55rem;
    padding: .5rem .6rem; border-radius: var(--pg-radius-sm);
    color: var(--pg-text-muted); text-decoration: none;
    font-size: .82rem; font-weight: 600;
}
.hb-footer-link:hover { background: var(--pg-brand-50); color: var(--pg-ink-800); }
.hb-footer-link i { color: var(--pg-brand-600); }

.hb-mobile-toggle {
    display: none;
    position: fixed; top: .9rem; left: .9rem; z-index: 160;
    width: 40px; height: 40px; border-radius: 50%;
    align-items: center; justify-content: center;
    background: var(--pg-surface); border: 1px solid var(--pg-border);
    box-shadow: var(--pg-shadow-sm);
    color: var(--pg-text); font-size: 1.1rem;
}
.hb-sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(var(--pg-ink-rgb),.45); z-index: 140; }

/* ---- Main column ---- */
.hb-main { margin-left: 280px; flex: 1 1 auto; min-width: 0; }
.hb-topbar {
    position: sticky; top: 0; z-index: 80;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .85rem 2.2rem;
    background: var(--pg-surface);
    border-bottom: 1px solid var(--pg-border);
}
.hb-topbar-search {
    position: relative;
    flex: 1 1 auto; max-width: 420px;
    display: flex; align-items: center; gap: .55rem;
    background: var(--pg-surface-2);
    border: 1px solid var(--pg-border);
    border-radius: 999px;
    padding: .45rem .5rem .45rem 1rem;
    color: var(--pg-text-muted);
}
.hb-topbar-search input { flex: 1 1 auto; border: none; background: transparent; padding: 0; font-size: .85rem; }
.hb-topbar-search kbd {
    font-family: inherit; font-size: .68rem; color: var(--pg-text-muted);
    background: var(--pg-surface); border: 1px solid var(--pg-border);
    border-radius: 6px; padding: .1rem .4rem;
}
.hb-topbar-search .hb-search-results { top: calc(100% + 10px); }

.hb-content { padding: 2rem 2.2rem 4rem; max-width: 1180px; }

/* ---- Homepage ---- */
.hb-hero { max-width: 720px; margin-bottom: 2.2rem; }
.hb-eyebrow { font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--pg-brand-700); margin-bottom: .4rem; }
.hb-hero h1 { font-size: 2.2rem; font-weight: 800; margin: 0 0 .6rem; color: var(--pg-text); }
.hb-hero p { font-size: 1.05rem; color: var(--pg-text-muted); line-height: 1.6; margin: 0; }

.hb-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.hb-card {
    display: flex; flex-direction: column;
    background: var(--pg-surface);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius);
    padding: 1.3rem;
    text-decoration: none;
    box-shadow: var(--pg-shadow-xs);
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.hb-card:hover { box-shadow: var(--pg-shadow-md); transform: translateY(-2px); border-color: var(--pg-brand-300); }
.hb-card-icon {
    width: 42px; height: 42px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background-image: linear-gradient(135deg, var(--pg-brand-400), var(--pg-brand-600));
    color: var(--pg-ink-950); font-size: 1.15rem;
    margin-bottom: .9rem;
    box-shadow: var(--pg-shadow-brand);
}
.hb-card h3 { margin: 0 0 .4rem; font-size: 1.02rem; font-weight: 800; color: var(--pg-text); }
.hb-card p { margin: 0; font-size: .86rem; color: var(--pg-text-muted); line-height: 1.5; flex: 1 1 auto; }
.hb-card-cta { margin-top: .9rem; font-size: .8rem; font-weight: 700; color: var(--pg-brand-700); }
.hb-card-accent { background-image: linear-gradient(160deg, var(--pg-brand-50) 0%, var(--pg-surface) 65%); border-color: var(--pg-brand-200); }

/* ---- Breadcrumb ---- */
.hb-breadcrumb { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--pg-text-muted); margin-bottom: 1.4rem; }
.hb-breadcrumb a { color: var(--pg-text-muted); text-decoration: none; }
.hb-breadcrumb a:hover { color: var(--pg-brand-700); }
.hb-breadcrumb i { font-size: .65rem; }
.hb-breadcrumb span:last-child { color: var(--pg-text); font-weight: 600; }

/* ---- Page layout: prose + on-this-page toc ---- */
.hb-page-layout { display: grid; grid-template-columns: 1fr 220px; gap: 3rem; align-items: start; }
.hb-toc { position: sticky; top: 5.5rem; font-size: .8rem; }
.hb-toc-label { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .68rem; color: var(--pg-text-muted); margin-bottom: .6rem; }
.hb-toc ul { list-style: none; margin: 0; padding: 0; border-left: 2px solid var(--pg-border); }
.hb-toc li { margin: 0; }
.hb-toc a { display: block; padding: .3rem 0 .3rem .8rem; color: var(--pg-text-muted); text-decoration: none; }
.hb-toc a:hover { color: var(--pg-brand-700); }
.hb-toc-level-3 a { padding-left: 1.6rem; font-size: .78rem; }

/* ---- Prose (rendered Markdown) ---- */
.hb-prose { max-width: 780px; }
.hb-prose h1 { font-size: 1.9rem; font-weight: 800; color: var(--pg-text); margin: 0 0 .5rem; }
.hb-lead { font-size: 1.02rem; color: var(--pg-text-muted); line-height: 1.6; margin: 0 0 1.6rem; }
.hb-prose h2 { font-size: 1.35rem; font-weight: 800; color: var(--pg-text); margin: 2.2rem 0 .8rem; scroll-margin-top: 5.5rem; }
.hb-prose h3 { font-size: 1.08rem; font-weight: 700; color: var(--pg-text); margin: 1.6rem 0 .6rem; scroll-margin-top: 5.5rem; }
.hb-prose p { line-height: 1.7; color: var(--pg-text); margin: 0 0 1rem; }
.hb-prose ul, .hb-prose ol { line-height: 1.7; color: var(--pg-text); margin: 0 0 1rem; padding-left: 1.4rem; }
.hb-prose li { margin-bottom: .3rem; }
.hb-prose a { color: var(--pg-brand-700); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--pg-brand-300); }
.hb-prose a:hover { color: var(--pg-brand-600); border-color: var(--pg-brand-500); }
.hb-prose strong { color: var(--pg-text); }
.hb-prose hr { border: none; border-top: 1px solid var(--pg-border); margin: 2rem 0; }

.hb-prose code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: .84em;
    background: var(--pg-surface-tint);
    border: 1px solid var(--pg-border);
    border-radius: 5px;
    padding: .1em .35em;
    color: var(--pg-brand-700);
}
.hb-prose pre {
    background: var(--pg-ink-950);
    color: var(--pg-code-text);
    border-radius: var(--pg-radius-sm);
    padding: 1rem 1.2rem;
    overflow-x: auto;
    margin: 0 0 1.3rem;
    box-shadow: var(--pg-shadow-sm);
}
.hb-prose pre code { background: none; border: none; color: inherit; padding: 0; font-size: .82rem; line-height: 1.6; }

.hb-prose table { width: 100%; border-collapse: collapse; margin: 0 0 1.5rem; font-size: .86rem; }
.hb-prose th, .hb-prose td { text-align: left; padding: .55rem .8rem; border-bottom: 1px solid var(--pg-border); }
.hb-prose thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--pg-text-muted); border-bottom: 2px solid var(--pg-border-strong); }
.hb-prose tbody tr:hover { background: var(--pg-surface-tint); }

.hb-prose blockquote {
    margin: 0 0 1.3rem;
    padding: .1rem 0 .1rem 1rem;
    border-left: 3px solid var(--pg-brand-400);
    color: var(--pg-text-muted);
}

.hb-prose details {
    background: var(--pg-surface-2);
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-sm);
    padding: .8rem 1rem;
    margin: 0 0 1.3rem;
}
.hb-prose details summary { cursor: pointer; font-weight: 700; color: var(--pg-text); }
.hb-prose details[open] summary { margin-bottom: .6rem; }
.hb-prose details p:last-child { margin-bottom: 0; }

.hb-callout {
    display: flex; gap: .75rem;
    border-radius: var(--pg-radius-sm);
    padding: .9rem 1.1rem;
    margin: 0 0 1.3rem;
    border: 1px solid var(--pg-border);
    background: var(--pg-surface-2);
}
.hb-callout::before { font-weight: 800; flex-shrink: 0; }
.hb-callout p:last-child { margin-bottom: 0; }
.hb-callout-note { border-color: var(--pg-info); background: var(--pg-info-bg); }
.hb-callout-note::before { content: "\F431"; font-family: "bootstrap-icons"; color: var(--pg-info); }
.hb-callout-tip { border-color: var(--pg-success); background: var(--pg-success-bg); }
.hb-callout-tip::before { content: "\F615"; font-family: "bootstrap-icons"; color: var(--pg-success); }
.hb-callout-warning { border-color: var(--pg-warning); background: var(--pg-warning-bg); }
.hb-callout-warning::before { content: "\F33A"; font-family: "bootstrap-icons"; color: var(--pg-warning); }

/* ---- Prev/next ---- */
.hb-pagenav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--pg-border); }
.hb-pagenav-link {
    display: flex; flex-direction: column; gap: .25rem;
    padding: .9rem 1.1rem;
    border: 1px solid var(--pg-border);
    border-radius: var(--pg-radius-sm);
    text-decoration: none;
}
.hb-pagenav-link:hover { border-color: var(--pg-brand-300); background: var(--pg-brand-50); }
.hb-pagenav-next { text-align: right; align-items: flex-end; grid-column: 2; }
.hb-pagenav-label { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--pg-text-muted); }
.hb-pagenav-title { font-size: .92rem; font-weight: 700; color: var(--pg-text); }

/* ---- Search page ---- */
.hb-search-page { max-width: 780px; }
.hb-search-form { position: relative; display: flex; align-items: center; margin-bottom: 1.6rem; }
.hb-search-form i { position: absolute; left: 1rem; color: var(--pg-text-muted); }
.hb-search-form input {
    width: 100%; box-sizing: border-box;
    padding: .8rem 1.1rem .8rem 2.6rem;
    border-radius: 999px;
    border: 1px solid var(--pg-border);
    background: var(--pg-surface-2);
    color: var(--pg-text);
    font-size: .95rem;
}
.hb-search-list { display: flex; flex-direction: column; gap: .8rem; }
.hb-search-result {
    display: block; padding: 1rem 1.2rem;
    border: 1px solid var(--pg-border); border-radius: var(--pg-radius-sm);
    text-decoration: none;
}
.hb-search-result:hover { border-color: var(--pg-brand-300); background: var(--pg-brand-50); }
.hb-search-result-group { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--pg-brand-700); margin-bottom: .3rem; }
.hb-search-result h3 { margin: 0 0 .3rem; font-size: 1rem; font-weight: 800; color: var(--pg-text); }
.hb-search-result p { margin: 0; font-size: .85rem; color: var(--pg-text-muted); line-height: 1.5; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1100px) {
    .hb-page-layout { grid-template-columns: 1fr; }
    .hb-toc { display: none; }
}

@media (max-width: 991.98px) {
    .hb-sidebar { left: -100%; transition: left .25s ease; }
    .hb-sidebar.show { left: 0; }
    .hb-main { margin-left: 0; }
    .hb-mobile-toggle { display: flex; }
    .hb-sidebar-backdrop.show { display: block; }
    .hb-topbar { padding-left: 4rem; }
}

@media (max-width: 600px) {
    .hb-content { padding: 1.4rem 1.1rem 3rem; }
    .hb-topbar { padding: .8rem 1rem .8rem 4rem; }
    .hb-topbar-search kbd { display: none; }
    .hb-hero h1 { font-size: 1.6rem; }
    .hb-pagenav { grid-template-columns: 1fr; }
    .hb-pagenav-next { grid-column: 1; text-align: left; align-items: flex-start; }
}
