/* ==========================================================================
   Xipher Docs - layout & content styles (uses tokens from base.css)
   ========================================================================== */

.docs-body {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---- Top bar (shares a few classes with the app) ------------------------ */

.docs-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px clamp(14px, 4vw, 28px);
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--surface-color) 82%, transparent);
    backdrop-filter: saturate(150%) blur(12px);
    -webkit-backdrop-filter: saturate(150%) blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.app-title-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.app-title-logo img {
    width: 28px;
    height: auto;
}

.app-title-text {
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.04em;
    background: var(--brand-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.docs-topbar-tag {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    padding: 3px 9px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
}

.docs-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.topbar-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.topbar-link:hover {
    background: var(--surface-2);
    color: var(--text-color);
}

.topbar-link-github-icon {
    width: 16px;
    height: 16px;
    filter: brightness(0.4);
    transition: filter 0.3s var(--ease);
}

[data-theme="dark"] .topbar-link-github-icon {
    filter: invert(1) brightness(1.4);
}

.topbar-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    border-radius: var(--radius-pill);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s var(--ease);
}

.topbar-icon-button:hover {
    background: var(--surface-color);
}

/* Theme toggle (same look as the app) */
.theme-toggle {
    position: relative;
    width: 52px;
    height: 28px;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    border-radius: var(--radius-pill);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.theme-toggle-circle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: var(--surface-color);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s var(--ease);
}

[data-theme="dark"] .theme-toggle-circle {
    transform: translateX(24px);
}

.theme-toggle-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    line-height: 1;
    transition: opacity 0.3s var(--ease);
}

.theme-toggle-sun { left: 7px; opacity: 0; }
.theme-toggle-moon { right: 7px; opacity: 1; }
[data-theme="dark"] .theme-toggle-sun { opacity: 1; }
[data-theme="dark"] .theme-toggle-moon { opacity: 0; }

.docs-menu-button {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-color);
}

/* ---- Shell -------------------------------------------------------------- */

.docs-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    max-width: 1180px;
    margin: 0 auto;
}

.docs-sidebar {
    position: sticky;
    top: 65px;
    align-self: start;
    height: calc(100vh - 65px);
    height: calc(100dvh - 65px);
    overflow-y: auto;
    padding: 24px 16px 40px;
    border-right: 1px solid var(--border-color);
}

.docs-nav-group {
    margin-bottom: 22px;
}

.docs-nav-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    margin: 0 0 8px;
    padding: 0 12px;
}

.docs-nav-link {
    display: block;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.docs-nav-link:hover {
    background: var(--surface-2);
    color: var(--text-color);
}

.docs-nav-link.is-active {
    color: var(--button-select-file-bg);
    background: color-mix(in srgb, var(--button-select-file-bg) 10%, transparent);
    border-left-color: var(--button-select-file-bg);
    font-weight: 600;
}

.docs-sidebar-backdrop {
    display: none;
}

/* ---- Content ------------------------------------------------------------ */

.docs-content {
    min-width: 0;
    padding: clamp(20px, 4vw, 48px) clamp(18px, 4vw, 56px) 80px;
}

.docs-article {
    max-width: 760px;
}

.docs-article h1 {
    font-size: clamp(28px, 6vw, 38px);
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 14px;
}

.docs-article h2 {
    font-size: clamp(22px, 4vw, 27px);
    font-weight: 800;
    letter-spacing: -0.01em;
    margin: 8px 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    scroll-margin-top: 80px;
}

.docs-article h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 4px 0 12px;
    scroll-margin-top: 80px;
}

.docs-article p,
.docs-article li {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-color);
}

.docs-article a {
    color: var(--button-select-file-bg);
    text-decoration: none;
    font-weight: 500;
}

.docs-article a:hover {
    text-decoration: underline;
}

.docs-article ul,
.docs-article ol {
    padding-left: 22px;
    margin: 12px 0;
}

.docs-article li {
    margin-bottom: 6px;
}

.docs-article code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    padding: 1px 6px;
    border-radius: 5px;
}

.docs-section {
    margin-bottom: 40px;
    scroll-margin-top: 76px;
}

/* ---- Hero --------------------------------------------------------------- */

.docs-hero {
    margin-bottom: 48px;
}

.docs-lead {
    font-size: 17px !important;
    color: var(--text-muted) !important;
    line-height: 1.65 !important;
    margin: 0 0 28px;
}

.docs-hero-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.docs-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--surface-color);
    text-decoration: none !important;
    transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s var(--ease);
}

.docs-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
}

.docs-card-icon {
    font-size: 22px;
}

.docs-card-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-color);
}

.docs-card-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ---- Code blocks -------------------------------------------------------- */

.code-block {
    position: relative;
    background: var(--input-bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin: 14px 0;
    overflow-x: auto;
}

.code-block code {
    background: transparent;
    border: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-color);
    white-space: pre;
}

.code-block::before {
    content: attr(data-lang);
    position: absolute;
    top: 8px;
    right: 52px;
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-faint);
}

.code-copy-button {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    border: 1px solid var(--border-color);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s var(--ease), color 0.2s var(--ease),
        border-color 0.2s var(--ease), transform 0.12s var(--ease),
        box-shadow 0.2s var(--ease);
}

.code-copy-button svg {
    width: 15px;
    height: 15px;
    display: block;
}

.code-copy-button:hover {
    background: var(--surface-color);
    color: var(--text-color);
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.code-copy-button:active {
    transform: translateY(0) scale(0.94);
    box-shadow: none;
}

.code-copy-button:focus-visible {
    outline: none;
    border-color: var(--button-select-file-bg);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--button-select-file-bg) 22%, transparent);
}

.code-copy-button.copied {
    color: var(--success-color);
    background: color-mix(in srgb, var(--success-color) 16%, var(--surface-2));
    border-color: color-mix(in srgb, var(--success-color) 50%, var(--border-color));
}

/* ---- Tables ------------------------------------------------------------- */

.docs-table-wrap {
    overflow-x: auto;
    margin: 16px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

.docs-table th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

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

.docs-table code {
    font-size: 12.5px;
}

/* ---- Callouts ----------------------------------------------------------- */

.docs-callout {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    margin: 18px 0;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--button-select-file-bg) 8%, var(--surface-color));
    border: 1px solid color-mix(in srgb, var(--button-select-file-bg) 30%, var(--border-color));
}

.docs-callout-warn {
    background: color-mix(in srgb, var(--button-decrypt-bg) 10%, var(--surface-color));
    border-color: color-mix(in srgb, var(--button-decrypt-bg) 35%, var(--border-color));
}

.docs-callout-icon {
    font-size: 18px;
    line-height: 1.5;
}

.docs-callout p {
    margin: 0;
    font-size: 14px !important;
}

/* ---- UI chips & FAQ ----------------------------------------------------- */

.ui-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 13px;
    vertical-align: middle;
}

.ui-chip svg {
    width: 14px;
    height: 14px;
    display: block;
}

.docs-faq {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0;
    margin: 10px 0;
    overflow: hidden;
}

.docs-faq summary {
    cursor: pointer;
    padding: 14px 16px;
    font-weight: 600;
    font-size: 15px;
    list-style: none;
    transition: background 0.2s var(--ease);
}

.docs-faq summary::-webkit-details-marker {
    display: none;
}

.docs-faq summary::after {
    content: "+";
    float: right;
    color: var(--text-faint);
    font-weight: 400;
}

.docs-faq[open] summary::after {
    content: "−";
}

.docs-faq summary:hover {
    background: var(--surface-2);
}

.docs-faq p {
    padding: 0 16px 16px;
    margin: 0;
    color: var(--text-muted);
}

.docs-footer {
    margin-top: 56px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.docs-footer p {
    font-size: 13px !important;
    color: var(--text-muted) !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 880px) {
    .docs-shell {
        grid-template-columns: 1fr;
    }

    .docs-menu-button {
        display: inline-flex;
    }

    .docs-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: auto;
        width: 280px;
        max-width: 84vw;
        z-index: 200;
        background: var(--surface-color);
        border-right: 1px solid var(--border-color);
        padding-top: 24px;
        transform: translateX(-102%);
        transition: transform 0.28s var(--ease);
    }

    .docs-sidebar.is-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .docs-sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 150;
        background: rgba(8, 12, 20, 0.5);
    }

    .docs-sidebar-backdrop[hidden] {
        display: none;
    }
}

@media (max-width: 420px) {
    .topbar-link-label {
        display: none;
    }

    .docs-topbar-tag {
        display: none;
    }
}
