/* Ruzit docs — base styles. Single sheet shared by every page so adding
   a new tab is a one-file copy + a sidebar entry, no per-page CSS.
   Light theme by default; <html data-theme="dark"> swaps the palette
   without changing layout. */

:root {
    --bg: #ffffff;
    --bg-alt: #f5f7fb;
    --bg-code: #1e2128;
    --bg-inline: #e9edf5;
    --fg: #1a1d22;
    --fg-soft: #4f5763;
    --fg-muted: #8893a0;
    --accent: #7289da;
    --accent-hover: #5b6eae;
    --accent-soft: rgba(114, 137, 218, 0.10);
    --accent-tint: rgba(114, 137, 218, 0.06);
    --border: #dfe3eb;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.04);
    --sidebar-w: 260px;

    /* Code block colors are shared across themes — the code block has its
       own dark background so the highlighter colors look the same in
       either theme. */
    --code-fg: #e8eaed;
    --code-comment: #8a93a0;
    --code-keyword: #8aa4ff;
    --code-string: #b8e98a;
    --code-num: #f4c969;
    --code-fn: #c39bff;
}

:root[data-theme="dark"] {
    --bg: #14171c;
    --bg-alt: #1c2027;
    --bg-code: #0c0e12;
    --bg-inline: #262a32;
    --fg: #e8eaed;
    --fg-soft: #b0b8c4;
    --fg-muted: #6f7682;
    --accent: #8c9ee5;
    --accent-hover: #7289da;
    --accent-soft: rgba(140, 158, 229, 0.14);
    --accent-tint: rgba(140, 158, 229, 0.08);
    --border: #2a2f38;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background 160ms ease, color 160ms ease;
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 120ms ease, color 120ms ease;
}
a:hover { border-color: var(--accent); }

/* ─── Sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-alt);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 20px 0 40px 0;
    transition: background 160ms ease, border-color 160ms ease;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px 20px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar .brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--bg);
    padding: 2px;
    border: 1px solid var(--border);
}

.sidebar .brand .name {
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.5px;
    color: var(--fg);
    border-bottom: none;
}

.sidebar .brand .version {
    font-size: 11px;
    color: var(--fg-muted);
    font-family: "JetBrains Mono", "SF Mono", "Consolas", monospace;
    margin-left: auto;
}

.sidebar h3 {
    font-size: 11px;
    font-weight: 600;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 16px 24px 8px 24px;
    margin: 0;
}

.discord-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 16px 8px 16px;
    padding: 9px 14px;
    background: var(--accent);
    color: #fff;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    border-bottom: none;
    transition: background 100ms ease;
}

.discord-button:hover {
    background: var(--accent-hover);
    border-bottom: none;
    color: #fff;
}

.discord-button svg { flex-shrink: 0; }

/* Theme toggle button — sits below the discord button. */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 16px 8px 16px;
    padding: 8px 14px;
    background: transparent;
    color: var(--fg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 100ms ease, color 100ms ease, background 100ms ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.theme-toggle svg { flex-shrink: 0; width: 14px; height: 14px; }

/* Each icon shows in only one theme — CSS swaps which one is visible.
   Default (light) shows the moon (action: switch to dark); dark shows
   the sun (action: switch to light). */
.theme-toggle .icon-moon { display: inline-block; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
.theme-toggle .label-light { display: none; }
.theme-toggle .label-dark { display: inline; }
:root[data-theme="dark"] .theme-toggle .label-light { display: inline; }
:root[data-theme="dark"] .theme-toggle .label-dark { display: none; }

.sidebar-foot {
    margin: 24px 24px 0 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12.5px;
    color: var(--fg-muted);
}

.sidebar-foot a {
    color: var(--fg-soft);
    border-bottom: none;
}

.sidebar-foot a:hover { color: var(--accent); }

.sidebar nav a {
    display: block;
    padding: 7px 24px;
    color: var(--fg-soft);
    border-bottom: none;
    border-left: 2px solid transparent;
    font-size: 14px;
    transition: all 100ms ease;
}

.sidebar nav a:hover {
    color: var(--fg);
    background: var(--accent-tint);
}

.sidebar nav a.active {
    color: var(--accent);
    border-left-color: var(--accent);
    background: var(--accent-soft);
    font-weight: 500;
}

.sidebar nav a.coming-soon {
    color: var(--fg-muted);
    cursor: not-allowed;
}

.sidebar nav a.coming-soon::after {
    content: "soon";
    margin-left: 8px;
    font-size: 10px;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 1px 5px;
    text-transform: uppercase;
}

/* ─── Main content area ──────────────────────────────────────────────── */

main {
    margin-left: var(--sidebar-w);
    padding: 56px 64px 96px 64px;
    max-width: 920px;
}

main h1 {
    font-size: 40px;
    font-weight: 700;
    letter-spacing: -1px;
    margin: 0 0 16px 0;
    line-height: 1.1;
}

main h2 {
    font-size: 26px;
    font-weight: 600;
    margin: 56px 0 16px 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    letter-spacing: -0.4px;
}

main h2:first-of-type {
    border-top: none;
    padding-top: 0;
}

main h3 {
    font-size: 19px;
    font-weight: 600;
    margin: 32px 0 12px 0;
    letter-spacing: -0.2px;
}

main h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 0 8px 0;
    color: var(--fg-soft);
}

main p { margin: 0 0 16px 0; }

main .lede {
    font-size: 19px;
    line-height: 1.5;
    color: var(--fg-soft);
    margin: 0 0 32px 0;
}

main ul, main ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
}

main li { margin-bottom: 6px; }

/* ─── Code blocks ────────────────────────────────────────────────────── */

code, pre {
    font-family: "JetBrains Mono", "SF Mono", "Consolas", "Menlo", monospace;
}

/* Inline code — direct-child selectors so inline `<code>` inside `<pre>`
   never picks up the inline pill background. The previous version used
   descendant selectors which leaked through into the deprecated-section
   side-by-side comparison tables. */
main p > code,
main li > code,
main td > code,
main h2 > code,
main h3 > code,
main h4 > code,
main .member-desc > code,
main .callout > code,
main .callout strong > code {
    background: var(--bg-inline);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 13.5px;
    color: var(--fg);
}

pre {
    background: var(--bg-code);
    color: var(--code-fg);
    padding: 18px 22px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13.5px;
    line-height: 1.55;
    margin: 0 0 20px 0;
}

main pre,
main td pre {
    background: var(--bg-code);
}
main pre code,
main td pre code {
    background: none;
    padding: 0;
    color: inherit;
    border-radius: 0;
}

/* Tiny syntax highlighter — bare-bones spans we apply by hand. */
.hl-kw { color: var(--code-keyword); }
.hl-str { color: var(--code-string); }
.hl-num { color: var(--code-num); }
.hl-fn { color: var(--code-fn); }
.hl-com { color: var(--code-comment); font-style: italic; }

/* ─── Reference cards / signature blocks ─────────────────────────────── */

.sig {
    background: var(--bg-alt);
    border-left: 3px solid var(--accent);
    padding: 14px 20px;
    border-radius: 0 6px 6px 0;
    font-family: "JetBrains Mono", "SF Mono", "Consolas", monospace;
    font-size: 13.5px;
    margin: 16px 0 12px 0;
    overflow-x: auto;
}

.member-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    margin: 16px 0 24px 0;
}

.member {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.member:last-child { border-bottom: none; }

.member-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.member-name {
    font-family: "JetBrains Mono", "SF Mono", "Consolas", monospace;
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
}

.member-type {
    font-family: "JetBrains Mono", "SF Mono", "Consolas", monospace;
    font-size: 13px;
    color: var(--fg-muted);
}

.tag {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    background: var(--bg-inline);
    color: var(--fg-soft);
}

.tag-readonly { background: rgba(231, 169, 30, 0.18); color: #b88204; }
.tag-static { background: var(--accent-soft); color: var(--accent); }
.tag-method { background: var(--accent-soft); color: var(--accent); }
.tag-new { background: rgba(56, 178, 76, 0.18); color: #237b39; }
.tag-deprecated, .deprecated-tag { background: rgba(213, 76, 76, 0.18); color: #a13a3a; }

:root[data-theme="dark"] .tag-readonly { color: #f3c25c; }
:root[data-theme="dark"] .tag-new { color: #6cd082; }
:root[data-theme="dark"] .tag-deprecated,
:root[data-theme="dark"] .deprecated-tag { color: #ef6f6f; }

.deprecated-tag {
    display: inline-block;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    margin-left: 6px;
    border-radius: 3px;
    font-weight: 600;
}

.deprecation-banner {
    margin: 8px 0 20px 0;
    padding: 14px 16px;
    border-radius: 6px;
    background: rgba(213, 76, 76, 0.10);
    border-left: 4px solid #d54c4c;
    font-size: 14px;
    color: var(--fg-strong);
}
.deprecation-banner strong { color: #d54c4c; }

.member-desc { color: var(--fg-soft); font-size: 14px; margin: 6px 0 0 0; }

/* ─── Hero (landing page) ────────────────────────────────────────────── */

.hero {
    padding: 24px 0 48px 0;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 48px;
    align-items: center;
}

.hero-text { min-width: 0; }

.hero-icon {
    width: 200px;
    height: 200px;
    border-radius: 24px;
    background: var(--bg-alt);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.hero-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.hero .eyebrow {
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
}

.hero h1 {
    font-size: 56px;
    line-height: 1.05;
    letter-spacing: -1.5px;
    margin: 0 0 20px 0;
}

.hero p {
    font-size: 19px;
    line-height: 1.5;
    color: var(--fg-soft);
    max-width: 660px;
    margin: 0 0 24px 0;
}

.hero .cta-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14.5px;
    border: 1px solid transparent;
    transition: all 120ms ease;
}

.btn-primary {
    background: var(--accent);
    color: white;
    border-bottom: none;
}
.btn-primary:hover {
    background: var(--accent-hover);
    border-bottom: none;
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--fg);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    border-color: var(--accent);
    border-bottom-color: var(--accent);
    color: var(--accent);
}

/* ─── Feature grid ───────────────────────────────────────────────────── */

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin: 24px 0 32px 0;
}

.feature {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    background: var(--bg-alt);
}

.feature h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
}

.feature p {
    margin: 0;
    font-size: 14px;
    color: var(--fg-soft);
}

/* ─── Tables ─────────────────────────────────────────────────────────── */

table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0 24px 0;
    font-size: 14px;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

th {
    font-weight: 600;
    background: var(--bg-alt);
    font-size: 13px;
}

td > pre { margin: 0; }

/* ─── Callouts ───────────────────────────────────────────────────────── */

.callout {
    border-left: 3px solid var(--fg-muted);
    background: var(--bg-alt);
    padding: 14px 18px;
    border-radius: 0 6px 6px 0;
    margin: 16px 0 20px 0;
    font-size: 14.5px;
}

.callout.note { border-left-color: var(--accent); }
.callout.warn { border-left-color: #e7a91e; }

.callout strong { color: var(--fg); }

/* ─── Responsive ────────────────────────────────────────────────────── */

@media (max-width: 860px) {
    :root { --sidebar-w: 220px; }
    main { padding: 40px 28px 80px 28px; }
    .hero {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .hero h1 { font-size: 38px; }
    .hero p { font-size: 17px; }
    .hero-icon { width: 140px; height: 140px; }
    main h1 { font-size: 30px; }
    main h2 { font-size: 22px; }
}

@media (max-width: 640px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 16px 0 16px 0;
    }
    main { margin-left: 0; padding: 32px 20px 64px 20px; }
}

/* ─── Right rail "On this page" ─────────────────────────────────────── */

:root {
    --right-toc-w: 260px;
    --kind-property: #4dabf7;
    --kind-method:   #d563a6;
    --kind-event:    #f4c969;
    --kind-section:  var(--accent);
}

aside.right-toc {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--right-toc-w);
    height: 100vh;
    padding: 28px 20px 40px 20px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
    background: var(--bg);
    font-size: 13px;
    z-index: 5;
}

.right-toc-heading {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--fg-muted);
    margin: 0 0 12px 0;
    font-weight: 600;
}

.right-toc nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.right-toc-section {
    display: block;
    margin: 14px 0 4px 0;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--fg);
    border-bottom: none;
    line-height: 1.4;
}
.right-toc-section:first-child { margin-top: 0; }
.right-toc-section:hover { color: var(--accent); }

.right-toc-member {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    margin-left: -8px;
    border-radius: 4px;
    color: var(--fg-soft);
    font-family: "JetBrains Mono", "SF Mono", "Consolas", monospace;
    font-size: 12px;
    line-height: 1.4;
    border-bottom: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.right-toc-member:hover {
    background: var(--accent-soft);
    color: var(--accent);
}
.right-toc-member.active {
    background: var(--accent-tint);
    color: var(--accent);
}
.right-toc-member[data-deprecated="true"] {
    opacity: 0.55;
}
.right-toc-member[data-deprecated="true"] .right-toc-member-name {
    text-decoration: line-through;
}

.right-toc-member-icon {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    background: var(--kind-section);
}
.right-toc-member[data-kind="property"] .right-toc-member-icon { background: var(--kind-property); border-radius: 3px; }
.right-toc-member[data-kind="method"]   .right-toc-member-icon { background: var(--kind-method);   border-radius: 50%; }
.right-toc-member[data-kind="event"]    .right-toc-member-icon { background: var(--kind-event);    border-radius: 50%; }

.right-toc-member-name {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Inline kind chip on each member-list entry, for the Roblox-style look. */
.member { position: relative; }
.member-header::before {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 8px;
    flex-shrink: 0;
    background: var(--kind-property);
    transform: translateY(2px);
}
.member[data-kind="method"] .member-header::before {
    background: var(--kind-method);
    border-radius: 50%;
}
.member[data-kind="event"] .member-header::before {
    background: var(--kind-event);
    border-radius: 50%;
}
.member[data-kind="section"] .member-header::before {
    display: none;
}

/* Make room for the right rail on wide screens. */
@media (min-width: 1280px) {
    main {
        margin-right: var(--right-toc-w);
        max-width: none;
        padding-right: 64px;
    }
    main > * { max-width: 920px; }
}

@media (max-width: 1279px) {
    aside.right-toc { display: none; }
}

/* Floating "On this page" toggle for medium screens (and the icon next to
   the heading in the Roblox screenshot). */
.right-toc-toggle {
    display: none;
}

@media (min-width: 901px) and (max-width: 1279px) {
    .right-toc-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 20px;
        right: 20px;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: var(--bg-alt);
        border: 1px solid var(--border);
        color: var(--fg);
        cursor: pointer;
        z-index: 6;
        box-shadow: var(--shadow);
    }
    aside.right-toc.is-open {
        display: block;
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.18);
    }
}
