/* Documentation pages (docs.html, docs-app.html) on the shared "Clarté" shell
   (styles.css + site.css): sidebar, long-form content, code blocks and callouts. */

.docs-page {
    --nav-h: 64px;
    --sidebar-w: 264px;
    line-height: 1.7;
}

/* ---------- Layout ---------- */
.docs-container {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    max-width: 1280px;
    min-height: calc(100vh - var(--nav-h));
    margin: 0 auto;
}

.docs-sidebar {
    position: sticky;
    top: var(--nav-h);
    align-self: start;
    height: calc(100vh - var(--nav-h));
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: #fff;
    scrollbar-width: thin;
}

.sidebar-content {
    padding: 28px 20px 40px 24px;
}

.sidebar-search {
    margin-bottom: 24px;
}

.search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--ice);
    color: var(--night);
    font: inherit;
    font-size: 14px;
    transition:
        border-color 0.15s ease,
        background 0.15s ease;
}

.search-input::placeholder {
    color: #7b8b96;
}

.search-input:focus {
    border-color: var(--teal);
    background: #fff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(56, 151, 152, 0.15);
}

.sidebar-nav {
    display: grid;
    gap: 22px;
}

.nav-section {
    display: flex;
    flex-direction: column;
}

.nav-section-title {
    margin: 0 0 6px;
    padding: 0 10px;
    color: var(--teal);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.nav-list {
    display: grid;
    gap: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.nav-item {
    position: relative;
    display: block;
    padding: 6px 10px;
    border-radius: 8px;
    color: var(--grey);
    font-size: 14px;
    line-height: 1.45;
    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.nav-item:hover {
    background: var(--ice);
    color: var(--night);
}

.nav-item.active {
    background: var(--mint-soft);
    color: var(--petrol);
    font-weight: 600;
}

.nav-list-sub {
    margin: 2px 0 4px 12px;
    padding-left: 8px;
    border-left: 1px solid var(--line);
}

.nav-item-sub {
    font-size: 13px;
}

.nav-section[hidden],
.nav-list li[hidden] {
    display: none;
}

/* Mobile: the sidebar becomes a drawer opened by .docs-sidebar-toggle */
.docs-sidebar-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 0 0 20px;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--night);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* ---------- Main column ---------- */
.docs-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    min-width: 0;
}

.docs-content {
    width: 100%;
    max-width: 860px;
    padding: 48px 48px 96px;
}

/* "On this page" (docs-app.html), large screens only */
.docs-toc {
    display: none;
    position: sticky;
    top: calc(var(--nav-h) + 32px);
    max-height: calc(100vh - var(--nav-h) - 64px);
    padding: 48px 24px 0 0;
    overflow-y: auto;
}

.toc-title {
    margin: 0 0 10px;
    color: var(--teal);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.toc-nav {
    display: grid;
    border-left: 1px solid var(--line);
}

.toc-link {
    display: block;
    margin-left: -1px;
    padding: 4px 12px;
    border-left: 2px solid transparent;
    color: var(--grey);
    font-size: 13px;
}

.toc-link:hover,
.toc-link.active {
    border-left-color: var(--teal);
    color: var(--night);
}

.toc-link.is-sub {
    padding-left: 24px;
    font-size: 12.5px;
}

@media (min-width: 1400px) {
    .docs-main:has(.docs-toc) {
        grid-template-columns: minmax(0, 1fr) 220px;
    }

    .docs-toc {
        display: block;
    }
}

/* ---------- Content typography ---------- */
.doc-section {
    padding-top: 0; /* styles.css pads every <section> */
    padding-bottom: 56px;
    margin-bottom: 56px;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: calc(var(--nav-h) + 24px);
}

.doc-section:last-child {
    margin-bottom: 0;
    border-bottom: 0;
}

.doc-section [id] {
    scroll-margin-top: calc(var(--nav-h) + 24px);
}

.section-title {
    margin: 0 0 14px;
    color: var(--night);
    font-size: clamp(30px, 3.4vw, 40px);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.section-lead {
    max-width: 680px;
    margin: 0 0 28px;
    color: var(--grey);
    font-size: 18px;
    line-height: 1.6;
}

.doc-section h2 {
    margin: 44px 0 12px;
    color: var(--night);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.doc-section h3 {
    margin: 28px 0 8px;
    color: var(--night);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
}

.doc-section h4 {
    margin: 22px 0 6px;
    color: var(--night);
    font-size: 16px;
    font-weight: 700;
}

.doc-section p,
.doc-section ul,
.doc-section ol {
    margin: 0 0 16px;
    color: #33415a;
    font-size: 16px;
}

.doc-section ul,
.doc-section ol {
    padding-left: 22px;
}

.doc-section li {
    margin: 6px 0;
}

.doc-section li::marker {
    color: var(--teal);
}

.doc-section strong {
    color: var(--night);
    font-weight: 600;
}

.doc-section a:not([class]) {
    color: var(--petrol);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-color: rgba(41, 118, 142, 0.35);
    text-underline-offset: 3px;
}

.doc-section :not(pre) > code {
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--ice);
    color: var(--petrol);
    font-family: var(--mono);
    font-size: 0.86em;
    font-variant-ligatures: none;
    overflow-wrap: anywhere;
}

.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 8px;
    border-radius: 50%;
    vertical-align: 0.05em;
}

.status-dot.is-amber {
    background: #f5c04f;
}

.status-dot.is-green {
    background: #4cc38a;
}

.status-dot.is-red {
    background: #e0634f;
}

/* ---------- Callouts ---------- */
.alert {
    display: flex;
    gap: 12px;
    margin: 20px 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--ice);
    color: #33415a;
    font-size: 15px;
}

.alert::before {
    content: '';
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    background: currentColor;
    -webkit-mask: var(--alert-icon) center / contain no-repeat;
    mask: var(--alert-icon) center / contain no-repeat;
}

.alert-content {
    flex: 1;
    min-width: 0;
    color: #33415a;
}

.alert-content strong {
    color: var(--night);
    font-weight: 600;
}

.alert-info {
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 11v5M12 7.5v.5'/%3E%3C/svg%3E");
    border-color: #cfe3e6;
    background: #f1f8f9;
    color: var(--petrol);
}

.alert-success {
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='m8 12 3 3 5-6'/%3E%3C/svg%3E");
    border-color: #bfe6da;
    background: var(--mint-soft);
    color: #1f7a5c;
}

.alert-warning {
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3 2 20h20Z'/%3E%3Cpath d='M12 10v4M12 17v.5'/%3E%3C/svg%3E");
    border-color: #f1d9a6;
    background: #fff8e8;
    color: #9a6a0c;
}

.alert-danger {
    --alert-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v6M12 16v.5'/%3E%3C/svg%3E");
    border-color: #f3c9c0;
    background: #fdf0ed;
    color: #b8432f;
}

/* ---------- Cards ---------- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 20px 0 28px;
}

.doc-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.doc-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 40px -20px rgba(21, 30, 54, 0.3);
}

.card-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    margin-bottom: 14px;
    border-radius: 11px;
    background: var(--mint-soft);
    color: var(--petrol);
}

.doc-section .doc-card h3 {
    margin: 0 0 4px;
    font-size: 16px;
}

.doc-section .doc-card p {
    margin: 0;
    color: var(--grey);
    font-size: 14px;
    line-height: 1.55;
}

/* ---------- Text + media ---------- */
.content-with-media {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 340px);
    align-items: start;
    gap: 36px;
    margin: 24px 0;
}

.content-text > :first-child {
    margin-top: 0;
}

.content-media {
    position: sticky;
    top: calc(var(--nav-h) + 24px);
}

.media-container {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 30px 60px -30px rgba(21, 30, 54, 0.3);
}

.media-container img,
.media-container video {
    display: block;
    width: 100%;
    height: auto;
}

.media-container video {
    background: var(--night);
}

.media-container img[hidden],
.media-container video[hidden] {
    display: none;
}

.media-caption {
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    color: var(--grey);
    font-size: 13px;
    text-align: center;
}

/* ---------- Code ---------- */
.code-block {
    margin: 18px 0 24px;
    overflow: hidden;
    border: 1px solid var(--ink);
    border-radius: 14px;
    background: var(--ink);
}

.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: #1e2a44;
}

.code-lang {
    color: #a9b6c8;
    font-family: var(--mono);
    font-size: 12px;
    text-transform: lowercase;
}

.code-copy {
    margin-left: auto;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: transparent;
    color: #dbe4ef;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition:
        background 0.15s ease,
        border-color 0.15s ease;
}

.code-copy:hover {
    border-color: var(--mint);
    background: rgba(161, 234, 212, 0.08);
}

.code-copy.copied {
    border-color: var(--mint);
    color: var(--mint);
}

.code-block pre {
    margin: 0;
    padding: 16px 18px;
    overflow-x: auto;
    color: #e6edf5;
    font-family: var(--mono);
    font-size: 13px;
    font-variant-ligatures: none;
    line-height: 1.65;
}

.code-block code {
    font-family: inherit;
}

/* ---------- Tables ---------- */
.docs-table {
    width: 100%;
    margin: 16px 0 28px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 14px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.docs-table th,
.docs-table td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.docs-table thead th {
    background: #fafcfc;
    color: var(--grey);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.docs-table tbody tr:last-child td {
    border-bottom: 0;
}

.docs-table tbody tr:hover {
    background: #fafcfc;
}

/* ---------- Architecture diagrams ---------- */
.architecture-diagram {
    display: grid;
    gap: 10px;
    margin: 20px 0 28px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--ice);
}

.arch-layer {
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
}

.doc-section .arch-layer h3 {
    margin: 0 0 10px;
    font-size: 14px;
}

.arch-components {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.arch-component {
    padding: 5px 10px;
    border-radius: 8px;
    background: var(--mint-soft);
    color: var(--petrol);
    font-size: 13px;
    font-weight: 600;
}

.arch-arrow {
    position: relative;
    justify-self: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: var(--night);
    color: #fff;
    font-family: var(--mono);
    font-size: 12px;
}

/* ---------- Back to top + reading progress ---------- */
.back-to-top {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 40;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--night);
    box-shadow: 0 12px 24px -10px rgba(21, 30, 54, 0.6);
    color: #fff;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition:
        opacity 0.2s ease,
        transform 0.2s ease,
        visibility 0.2s;
}

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

.back-to-top:hover {
    background: var(--ink);
}

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--teal), var(--mint));
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .content-with-media {
        grid-template-columns: minmax(0, 1fr);
    }

    .content-media {
        position: static;
        max-width: 480px;
    }
}

@media (max-width: 900px) {
    .docs-page {
        --nav-h: 69px;
    }

    .docs-container {
        grid-template-columns: minmax(0, 1fr);
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 70;
        width: min(300px, 86vw);
        height: auto;
        box-shadow: 0 30px 60px -20px rgba(21, 30, 54, 0.45);
        transform: translateX(-105%);
        transition: transform 0.25s ease;
    }

    .docs-sidebar.open {
        transform: none;
    }

    .docs-sidebar-toggle {
        display: inline-flex;
    }

    .docs-content {
        padding: 28px 24px 72px;
    }
}

@media (max-width: 560px) {
    .docs-content {
        padding: 24px 16px 64px;
    }

    .doc-section {
        padding-bottom: 40px;
        margin-bottom: 40px;
    }

    .doc-section h2 {
        margin-top: 36px;
        font-size: 21px;
    }

    .docs-table {
        display: block;
        overflow-x: auto;
    }

    .back-to-top {
        right: 16px;
        bottom: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .doc-card,
    .docs-sidebar,
    .back-to-top,
    .nav-item {
        transition: none;
    }
}

@media print {
    .navbar,
    .docs-sidebar,
    .docs-sidebar-toggle,
    .docs-toc,
    .back-to-top,
    .code-copy,
    .reading-progress,
    .product-footer {
        display: none;
    }

    .docs-container {
        display: block;
    }

    .docs-content {
        max-width: none;
        padding: 0;
    }
}
