/* KnowSpace — Documentation Theme */

:root {
    --ks-bg: #ffffff;
    --ks-bg-secondary: #f5f6fa;
    --ks-text: #2c3e50;
    --ks-text-light: #6c7a89;
    --ks-accent: #3498db;
    --ks-accent-hover: #2980b9;
    --ks-border: #e1e4e8;
    --ks-header-bg: #2c3e50;
    --ks-header-text: #ffffff;
    --ks-note-tip: #27ae60;
    --ks-note-warning: #e67e22;
    --ks-note-note: #3498db;
    --ks-note-important: #e74c3c;
    --ks-code-bg: #f8f9fa;
    --ks-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --ks-font-mono: "SF Mono", "Fira Code", "JetBrains Mono", monospace;
    --ks-line-height: 1.6;
    --ks-radius: 6px;
    --ks-max-width: 800px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--ks-text);
    line-height: 1.6;
    background: var(--ks-bg);
}

/* Header */
.ks-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 24px;
    background: #2c3e50;
    color: #ffffff;
    font-size: 0.9em;
    position: sticky;
    top: 0;
    z-index: 100;
}

.ks-home {
    display: flex;
    align-items: center;
    color: #ffffff;
    text-decoration: none;
    line-height: 1;
    flex-shrink: 0;
}

.ks-home:hover {
    opacity: 0.85;
}

.ks-logo {
    display: block;
    height: 28px;
    width: auto;
    max-height: 28px;
}

.ks-logo-text {
    font-weight: 600;
    font-size: 0.95em;
    white-space: nowrap;
}

/* Breadcrumb */
.ks-breadcrumb {
    display: flex;
    align-items: center;
    overflow: hidden;
    flex-shrink: 1;
    min-width: 0;
}

.ks-breadcrumb-item {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85em;
    white-space: nowrap;
}

.ks-breadcrumb-sep {
    color: rgba(255, 255, 255, 0.35);
    margin: 0 6px;
    font-size: 0.85em;
    flex-shrink: 0;
}

.ks-breadcrumb-current {
    color: #ffffff;
    font-size: 0.85em;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ks-nav-link {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.8em;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    transition: background 0.15s;
}

.ks-nav-link:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ks-lang-selector {
    display: none;
}

.ks-lang-selector a,
.ks-lang-selector span {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.85em;
    text-transform: uppercase;
}

.ks-lang-selector a {
    color: #bdc3c7;
}

.ks-lang-selector a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

.ks-lang-current {
    color: #ffffff;
    background: var(--ks-accent);
    font-weight: 600;
}

/* Search */
.ks-search {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.ks-search input {
    width: 100%;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--ks-radius);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 0.9em;
    outline: none;
}

.ks-search input::placeholder {
    color: #95a5a6;
}

.ks-search input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: var(--ks-accent);
}

#ks-search-results {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--ks-bg);
    border: 1px solid var(--ks-border);
    border-radius: var(--ks-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    min-width: 300px;
}

#ks-search-results.ks-search-visible {
    display: block;
}

.ks-search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    color: var(--ks-text);
    text-decoration: none;
    border-bottom: 1px solid var(--ks-border);
}

.ks-search-item:last-child {
    border-bottom: none;
}

.ks-search-item:hover {
    background: var(--ks-sidebar-bg);
}

.ks-search-title {
    font-size: 0.9em;
}

.ks-search-score {
    font-size: 0.75em;
    color: var(--ks-text-light);
    background: var(--ks-sidebar-bg);
    padding: 1px 6px;
    border-radius: 3px;
}

.ks-search-empty {
    padding: 12px;
    text-align: center;
    color: var(--ks-text-light);
    font-size: 0.9em;
}

.ks-layout {
    display: flex;
    min-height: calc(100vh - 40px);
}

/* Sidebar — visible on desktop, offcanvas on mobile/tablet */
.ks-sidebar {
    display: none;
}

.ks-nav-section h3 {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ks-text);
    margin: 20px 0 6px;
    padding: 6px 10px;
    background: var(--ks-border);
    border-radius: var(--ks-radius);
}

.ks-nav-section ul {
    list-style: none;
}

.ks-nav-section li {
    margin: 2px 0;
}

.ks-nav-section a {
    display: block;
    padding: 4px 12px;
    color: var(--ks-text);
    text-decoration: none;
    border-radius: var(--ks-radius);
    font-size: 0.9em;
}

.ks-nav-section a:hover {
    background: var(--ks-accent);
    color: white;
}

/* Content */
.ks-content {
    flex: 1;
    max-width: 800px;
    padding: 40px 48px;
}

.ks-content-breadcrumb {
    font-size: 0.85em;
    color: var(--ks-text-light);
    margin-bottom: 8px;
}

.ks-content h1 {
    font-size: 2em;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--ks-border);
    padding-bottom: 12px;
}

.ks-content h2 {
    font-size: 1.5em;
    margin: 32px 0 16px;
}

.ks-content h3 {
    font-size: 1.2em;
    margin: 24px 0 12px;
}

.ks-content p {
    margin: 12px 0;
}

/* Images */
.ks-figure {
    margin: 20px 0;
}

.ks-figure img {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--ks-border);
    border-radius: var(--ks-radius);
}

/* Notes */
.ks-note {
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: var(--ks-radius);
    border-left: 4px solid;
}

.ks-note strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85em;
    text-transform: uppercase;
}

.ks-note--tip {
    background: #eafaf1;
    border-color: var(--ks-note-tip);
}

.ks-note--warning {
    background: #fef5e7;
    border-color: var(--ks-note-warning);
}

.ks-note--note {
    background: #eaf2f8;
    border-color: var(--ks-note-note);
}

.ks-note--important {
    background: #fdedec;
    border-color: var(--ks-note-important);
}

/* Steps */
.ks-steps {
    margin: 16px 0;
    padding-left: 24px;
}

.ks-steps li {
    margin: 8px 0;
    padding-left: 8px;
}

/* Tables */
.ks-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.ks-table th,
.ks-table td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid var(--ks-border);
}

.ks-table th {
    background: var(--ks-sidebar-bg);
    font-weight: 600;
}

.ks-table tr:hover {
    background: #f8f9fa;
}

/* Code */
.ks-code {
    background: var(--ks-code-bg);
    border: 1px solid var(--ks-border);
    border-radius: var(--ks-radius);
    padding: 16px;
    margin: 16px 0;
    overflow-x: auto;
    font-family: "SF Mono", "Fira Code", monospace;
    font-size: 0.9em;
    line-height: 1.5;
}

/* Links */
.ks-link {
    margin: 12px 0;
}

.ks-link a {
    color: var(--ks-accent);
    text-decoration: none;
}

.ks-link a:hover {
    text-decoration: underline;
}

/* Index page */
.ks-index {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.ks-index-logo {
    display: block;
    margin: 0 auto 24px;
    height: 100px;
    width: auto;
}

.ks-toc {
    text-align: left;
    margin-top: 32px;
}

.ks-toc-section {
    margin: 24px 0;
}

.ks-toc-section h2 {
    font-size: 1.2em;
    border-bottom: none;
}

.ks-toc-section ul {
    list-style: none;
    padding: 0;
}

.ks-toc-section li {
    margin: 4px 0;
}

.ks-toc-section a {
    color: var(--ks-accent);
    text-decoration: none;
}

.ks-toc-section a:hover {
    text-decoration: underline;
}

/* Menu buttons */
.ks-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

#ks-lang-btn {
    margin-left: auto;
}

/* Hamburger icon (3 bars → X) */
.ks-hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 20px;
    height: 20px;
}

.ks-hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: #ffffff;
    border-radius: 1px;
    transition: transform 0.3s, opacity 0.3s;
    transform-origin: center;
}

.ks-menu-btn.ks-active .ks-hamburger span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.ks-menu-btn.ks-active .ks-hamburger span:nth-child(2) {
    opacity: 0;
}

.ks-menu-btn.ks-active .ks-hamburger span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Language button icon */
.ks-lang-icon {
    width: 20px;
    height: 20px;
    stroke: #ffffff;
    fill: none;
    stroke-width: 1.5;
}

/* Offcanvas overlay */
.ks-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 150;
    opacity: 0;
    transition: opacity 0.3s;
}

.ks-overlay.ks-visible {
    display: block;
}

.ks-overlay.ks-shown {
    opacity: 1;
}

/* Offcanvas panel */
.ks-offcanvas {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 85vw;
    background: var(--ks-bg);
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ks-offcanvas--left {
    left: 0;
}

.ks-offcanvas--right {
    right: 0;
    transform: translateX(100%);
}

.ks-offcanvas.ks-open {
    transform: translateX(0);
}

/* Offcanvas header */
.ks-offcanvas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #2c3e50;
    color: #ffffff;
    flex-shrink: 0;
}

.ks-offcanvas-title {
    font-weight: 600;
    font-size: 0.95em;
}

.ks-offcanvas-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.4em;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.ks-offcanvas-close:hover {
    opacity: 0.7;
}

/* Offcanvas body */
.ks-offcanvas-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Nav menu items inside offcanvas */
.ks-offcanvas-body .ks-nav-section h3 {
    font-size: 0.8em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ks-text);
    margin: 20px 0 6px;
    padding: 6px 10px;
    background: var(--ks-border);
    border-radius: var(--ks-radius);
}

.ks-offcanvas-body .ks-nav-section:first-child h3 {
    margin-top: 0;
}

.ks-offcanvas-body .ks-nav-section ul {
    list-style: none;
}

.ks-offcanvas-body .ks-nav-section li {
    margin: 2px 0;
}

.ks-offcanvas-body .ks-nav-section a {
    display: block;
    padding: 10px 12px;
    color: var(--ks-text);
    text-decoration: none;
    border-radius: var(--ks-radius);
    font-size: 0.95em;
    border-left: 3px solid transparent;
    transition: background 0.15s, border-color 0.15s;
}

.ks-offcanvas-body .ks-nav-section a:hover {
    background: var(--ks-sidebar-bg);
    border-left-color: var(--ks-accent);
    color: var(--ks-text);
}

/* Language list in offcanvas */
.ks-lang-list {
    list-style: none;
    padding: 0;
}

.ks-lang-list li {
    margin: 2px 0;
}

.ks-lang-list a,
.ks-lang-list .ks-lang-list-current {
    display: block;
    padding: 12px 16px;
    border-radius: var(--ks-radius);
    text-decoration: none;
    font-size: 0.95em;
    transition: background 0.15s;
}

.ks-lang-list a {
    color: var(--ks-text);
}

.ks-lang-list a:hover {
    background: var(--ks-sidebar-bg);
}

.ks-lang-list .ks-lang-list-current {
    background: var(--ks-accent);
    color: #ffffff;
    font-weight: 600;
}

/* Footer */
.ks-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.8em;
    color: var(--ks-text-light);
    border-top: 1px solid var(--ks-border);
}

.ks-footer a {
    color: var(--ks-accent);
    text-decoration: none;
}

.ks-footer a:hover {
    text-decoration: underline;
}

/* Desktop: sidebar visible, hamburger hidden */
@media (min-width: 1024px) {
    .ks-sidebar {
        display: block;
        width: 280px;
        flex-shrink: 0;
        padding: 24px 16px;
        background: var(--ks-sidebar-bg);
        border-right: 1px solid var(--ks-border);
        overflow-y: auto;
        max-height: calc(100vh - 40px);
        position: sticky;
        top: 40px;
    }

    #ks-nav-btn {
        display: none;
    }
}

/* Tablet/mobile: compact content */
@media (max-width: 768px) {
    .ks-content {
        padding: 24px 16px;
    }

    .ks-breadcrumb {
        display: none;
    }
}
