/* Documentation homepage — editorial product experience */

.docs-shell--home .docs-main {
    display: block;
    justify-content: stretch;
    max-width: none;
}

.dh-page {
    --dh-pad: clamp(1.25rem, 4vw, 3rem);
    --dh-max: 1240px;
    overflow-x: hidden;
}

/* ── Hero ── */
.dh-hero {
    border-bottom: 1px solid var(--border);
    background:
        linear-gradient(180deg, var(--bg) 0%, var(--bg-subtle) 100%);
}
.dh-hero-grid {
    max-width: var(--dh-max);
    margin: 0 auto;
    padding: clamp(2.5rem, 6vw, 4.5rem) var(--dh-pad) clamp(2rem, 5vw, 3.5rem);
    display: grid;
    grid-template-columns: 1fr minmax(240px, 320px);
    gap: clamp(2rem, 5vw, 4rem);
    align-items: start;
}
.dh-eyebrow {
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 1rem;
}
.dh-headline {
    font-size: clamp(1.85rem, 4.5vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.12;
    margin: 0 0 1rem;
    max-width: 18ch;
}
.dh-lines {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    margin: 0 0 1.25rem;
}
.dh-lines span {
    font-size: clamp(1.05rem, 2.2vw, 1.35rem);
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: -0.02em;
}
.dh-lede {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-muted);
    margin: 0 0 1.75rem;
    max-width: 58ch;
}
.dh-search {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 440px;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color var(--duration), box-shadow var(--duration);
    text-align: left;
}
.dh-search:hover,
.dh-search:focus-visible {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.dh-search span { flex: 1; color: var(--text-secondary); }
.dh-search kbd {
    padding: 0.2rem 0.45rem;
    border-radius: 5px;
    border: 1px solid var(--border);
    font-size: 0.68rem;
    background: var(--bg-subtle);
    color: var(--text-muted);
}
.dh-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dh-hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.dh-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1.15rem 1.25rem;
    background: var(--surface);
}
.dh-stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.dh-stat-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
}
.dh-stat-detail {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ── Sections ── */
.dh-section {
    max-width: var(--dh-max);
    margin: 0 auto;
    padding: clamp(2.5rem, 6vw, 4rem) var(--dh-pad);
    border-bottom: 1px solid var(--border);
}
.dh-section-head { margin-bottom: clamp(1.5rem, 4vw, 2.25rem); max-width: 640px; }
.dh-section-tag {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}
.dh-section-title {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 750;
    letter-spacing: -0.03em;
    margin: 0 0 0.65rem;
    line-height: 1.2;
}
.dh-section-desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--text-muted);
}

/* ── System map ── */
.dh-system {
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}
.dh-system .dh-section-head {
    max-width: var(--dh-max);
    margin-left: auto;
    margin-right: auto;
    padding: 0 var(--dh-pad);
}

.sys-map {
    position: relative;
    max-width: var(--dh-max);
    margin: 0 auto;
    padding: 0 var(--dh-pad) 1rem;
    display: grid;
    grid-template-columns: 1fr minmax(260px, 300px);
    gap: clamp(1rem, 3vw, 2rem);
    align-items: start;
}
.sys-map-canvas {
    position: relative;
    min-height: 340px;
}
.sys-map-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}
.sys-map-lines path {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 1.5;
    transition: stroke var(--duration), opacity var(--duration);
}
.sys-map-lines path.active {
    stroke: var(--primary);
    opacity: 1;
}
.sys-map-lines path.flow {
    stroke-dasharray: 6 8;
    animation: sys-flow 1.2s linear infinite;
}
@keyframes sys-flow {
    to { stroke-dashoffset: -14; }
}
.sys-map-nodes {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: auto;
    grid-template-areas:
        ". clients clients clients ."
        ". . api . ."
        "auth . services . events"
        ". orders billing dispatch ."
        ". database . finix .";
    gap: 0.65rem 0.5rem;
    min-height: 340px;
    padding: 1rem 0;
}
.sys-node {
    grid-area: var(--area);
    justify-self: center;
    align-self: center;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--duration), background var(--duration), transform var(--duration), box-shadow var(--duration);
    white-space: nowrap;
}
.sys-node--core {
    font-size: 0.8125rem;
    padding: 0.65rem 1rem;
    border-color: var(--border-strong);
}
.sys-node--entry { --area: clients; }
.sys-node--core:nth-of-type(2) { --area: api; }
.sys-node[data-node-id="auth"] { --area: auth; }
.sys-node[data-node-id="services"] { --area: services; }
.sys-node[data-node-id="events"] { --area: events; }
.sys-node[data-node-id="orders"] { --area: orders; }
.sys-node[data-node-id="billing"] { --area: billing; }
.sys-node[data-node-id="dispatch"] { --area: dispatch; }
.sys-node[data-node-id="database"] { --area: database; }
.sys-node[data-node-id="finix"] { --area: finix; }
.sys-node[data-node-id="clients"] { --area: clients; }
.sys-node[data-node-id="api"] { --area: api; }

.sys-node:hover,
.sys-node:focus-visible,
.sys-node.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    outline: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 20px color-mix(in srgb, var(--primary) 15%, transparent);
}
.sys-node-label { pointer-events: none; }

.sys-map-panel {
    position: sticky;
    top: calc(var(--header-h) + 1.5rem);
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    min-height: 180px;
}
.sys-map-panel-hint {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.sys-map-panel-body.hidden { display: none; }
.sys-map-panel-hint.hidden { display: none; }
.sys-map-panel-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 650;
}
.sys-map-panel-summary {
    margin: 0 0 1rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: var(--text-secondary);
}
.sys-map-panel-meta {
    margin: 0 0 1rem;
    font-size: 0.75rem;
}
.sys-map-panel-meta dt {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.62rem;
    margin-bottom: 0.15rem;
}
.sys-map-panel-meta dd { margin: 0; color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.72rem; }
.sys-map-panel-link {
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
}
.sys-map-panel-link:hover { text-decoration: underline; }

/* ── Domain entities ── */
.dh-entity-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.dh-entity {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1.15rem 1.25rem;
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    transition: background var(--duration);
}
.dh-entity:hover {
    background: var(--bg-subtle);
}
.dh-entity-name {
    font-size: 0.875rem;
    font-weight: 650;
    color: var(--text);
}
.dh-entity-desc {
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--text-muted);
}

/* ── Workflow explorer ── */
.wf-explorer {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: clamp(1rem, 3vw, 2rem);
    align-items: start;
}
.wf-rail {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-left: 1px solid var(--border);
    padding-left: 0;
}
.wf-step-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 0 0.75rem 1rem;
    margin-left: -1px;
    border: none;
    border-left: 2px solid transparent;
    background: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color var(--duration), background var(--duration);
}
.wf-step-btn:hover,
.wf-step-btn:focus-visible {
    outline: none;
    background: var(--bg-subtle);
}
.wf-step-btn.active {
    border-left-color: var(--primary);
    background: var(--primary-soft);
}
.wf-step-num {
    font-size: 0.68rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    min-width: 1.5rem;
}
.wf-step-btn.active .wf-step-num { color: var(--primary); }
.wf-step-title {
    font-size: 0.8125rem;
    font-weight: 550;
    color: var(--text-secondary);
    line-height: 1.35;
}
.wf-step-btn.active .wf-step-title {
    color: var(--text);
    font-weight: 600;
}
.wf-connector { display: none; }

.wf-detail {
    position: relative;
    min-height: 220px;
}
.wf-panel {
    display: none;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    animation: wf-in 0.25s var(--ease);
}
.wf-panel.active { display: block; }
@keyframes wf-in {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.wf-panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}
.wf-panel-num {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.wf-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 650;
}
.wf-panel-summary {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--text-secondary);
}
.wf-panel-meta {
    display: grid;
    gap: 0.85rem;
    margin: 0 0 1.25rem;
    font-size: 0.8125rem;
}
.wf-panel-meta dt {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}
.wf-panel-meta dd {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}
.wf-panel-link {
    font-size: 0.8125rem;
    font-weight: 600;
}

/* ── Explore layout ── */
.dh-explore-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    grid-template-rows: auto auto;
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.dh-explore-featured,
.dh-explore-secondary,
.dh-explore-link {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.5rem 1.65rem;
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    transition: background var(--duration);
}
.dh-explore-featured {
    grid-row: span 2;
    justify-content: flex-end;
    min-height: 280px;
    border-right: 1px solid var(--border);
}
.dh-explore-featured:hover,
.dh-explore-secondary:hover,
.dh-explore-link:hover {
    background: var(--bg-subtle);
}
.dh-explore-tag {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--primary);
}
.dh-explore-featured h3,
.dh-explore-secondary h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.dh-explore-featured p,
.dh-explore-secondary p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-muted);
    flex: 1;
}
.dh-explore-meta {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}
.dh-explore-compact {
    grid-column: 2;
    display: flex;
    flex-direction: column;
}
.dh-explore-link {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}
.dh-explore-link-title {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}
.dh-explore-link-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: right;
}

/* ── Popular list ── */
.dh-popular-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--border);
}
.dh-popular-item {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.25rem 1rem;
    padding: 1.15rem 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    transition: background var(--duration);
}
.dh-popular-item:hover {
    background: var(--bg-subtle);
    margin: 0 calc(var(--dh-pad) * -0.5);
    padding-left: calc(var(--dh-pad) * 0.5);
    padding-right: calc(var(--dh-pad) * 0.5);
}
.dh-popular-title {
    grid-column: 1;
    font-size: 0.9375rem;
    font-weight: 650;
    color: var(--text);
}
.dh-popular-desc {
    grid-column: 1;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}
.dh-popular-arrow {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    color: var(--text-muted);
    transition: transform var(--duration), color var(--duration);
}
.dh-popular-item:hover .dh-popular-arrow {
    transform: translateX(4px);
    color: var(--primary);
}

/* ── Developer path ── */
.dh-path-track {
    display: flex;
    align-items: stretch;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.dh-path-step {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.15rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--duration), background var(--duration);
}
.dh-path-step:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.dh-path-num {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.dh-path-label {
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--text-secondary);
}
.dh-path-step:hover .dh-path-label { color: var(--text); }
.dh-path-connector {
    flex-shrink: 0;
    width: 24px;
    align-self: center;
    height: 1px;
    background: var(--border-strong);
    position: relative;
}
.dh-path-connector::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    border: 4px solid transparent;
    border-left-color: var(--border-strong);
}

/* ── Resources ── */
.dh-resources-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.dh-resource {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 1rem 1.15rem;
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    transition: background var(--duration);
}
.dh-resource:hover { background: var(--bg-subtle); }
.dh-resource-label { font-size: 0.875rem; font-weight: 600; }
.dh-resource-desc { font-size: 0.75rem; color: var(--text-muted); }

/* ── Mobile ── */
@media (max-width: 900px) {
    .dh-hero-grid {
        grid-template-columns: 1fr;
    }
    .dh-hero-stats {
        grid-template-columns: repeat(4, 1fr);
    }
    .dh-stat { padding: 0.85rem; }
    .dh-stat-detail { display: none; }
    .sys-map {
        grid-template-columns: 1fr;
    }
    .sys-map-panel {
        position: static;
        order: -1;
    }
    .sys-map-nodes {
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "clients clients"
            "api api"
            "auth services"
            "events events"
            "orders billing"
            "dispatch dispatch"
            "database finix";
        min-height: auto;
    }
    .dh-entity-grid { grid-template-columns: 1fr 1fr; }
    .wf-explorer { grid-template-columns: 1fr; }
    .wf-rail {
        flex-direction: row;
        overflow-x: auto;
        border-left: none;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0.5rem;
        gap: 0.35rem;
        -webkit-overflow-scrolling: touch;
    }
    .wf-step-btn {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
        padding: 0.65rem 0.85rem;
        margin-left: 0;
        border-left: none;
        border-bottom: 2px solid transparent;
        min-width: 100px;
        flex-shrink: 0;
    }
    .wf-step-btn.active { border-bottom-color: var(--primary); border-left-color: transparent; }
    .dh-explore-layout {
        grid-template-columns: 1fr;
    }
    .dh-explore-featured {
        grid-row: auto;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .dh-explore-compact { grid-column: 1; }
    .dh-explore-link {
        flex-direction: column;
        align-items: flex-start;
    }
    .dh-explore-link-desc { text-align: left; }
    .dh-resources-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .dh-hero-stats { grid-template-columns: 1fr 1fr; }
    .dh-entity-grid { grid-template-columns: 1fr; }
    .dh-path-track { flex-direction: column; overflow-x: visible; }
    .dh-path-connector {
        width: 1px;
        height: 16px;
        margin: 0 auto;
    }
    .dh-path-connector::after {
        top: auto;
        bottom: 0;
        left: -3px;
        right: auto;
        border: 4px solid transparent;
        border-top-color: var(--border-strong);
        border-left-color: transparent;
    }
    .dh-path-step { min-width: 0; }
    .dh-hero-actions .btn { flex: 1 1 100%; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
    .sys-map-lines path.flow { animation: none; }
    .wf-panel { animation: none; }
}
