/* ==========================================================================
   docs.css — Developer documentation
   --------------------------------------------------------------------------
   Standalone. Deliberately does NOT use stylesheet.css: no dot grid, no
   Space Mono, no uppercase headings, red only as a link accent. Used by
   developers.html and the reference pages linked from it.
   ========================================================================== */

:root {
    --doc-bg: #ffffff;
    --doc-surface: #f7f8f9;
    --doc-surface-2: #f1f2f4;
    --doc-ink: #15171c;
    --doc-muted: #565d69;
    --doc-faint: #878e9a;
    --doc-line: #e4e6ea;
    --doc-line-strong: #cdd1d8;
    --doc-accent: #c8102e;
    --doc-accent-soft: rgba(200, 16, 46, 0.08);
    --doc-radius: 6px;

    --doc-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --doc-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --doc-bg: #0f1116;
        --doc-surface: #171a21;
        --doc-surface-2: #1d212a;
        --doc-ink: #e7e9ed;
        --doc-muted: #9aa1ae;
        --doc-faint: #6d7480;
        --doc-line: #252a34;
        --doc-line-strong: #39404c;
        --doc-accent: #ff7a85;
        --doc-accent-soft: rgba(255, 122, 133, 0.12);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background-color: var(--doc-bg);
    color: var(--doc-ink);
    font-family: var(--doc-sans);
    font-size: 16px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Top bar ------------------------------------------------------------ */

.doc-topbar {
    border-bottom: 1px solid var(--doc-line);
    background-color: var(--doc-bg);
    position: sticky;
    top: 0;
    z-index: 20;
}

.doc-topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.doc-brand {
    display: inline-flex;
    align-items: baseline;
    gap: 0.55rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--doc-ink);
    text-decoration: none;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.doc-brand span {
    font-weight: 400;
    color: var(--doc-faint);
}

.doc-topnav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    font-size: 0.875rem;
    overflow-x: auto;
    scrollbar-width: none;
}

.doc-topnav::-webkit-scrollbar {
    display: none;
}

.doc-topnav a {
    color: var(--doc-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s ease;
}

.doc-topnav a:hover,
.doc-topnav a[aria-current='page'] {
    color: var(--doc-ink);
}

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

.doc-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: 4rem;
    align-items: start;
}

.doc-shell.single {
    grid-template-columns: minmax(0, 1fr);
    max-width: 900px;
}

.doc-main {
    min-width: 0;
    padding: 3.5rem 0 6rem;
    max-width: 780px;
}

/* --- Sidebar ------------------------------------------------------------ */

.doc-side {
    position: sticky;
    top: 56px;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    padding: 3.5rem 0 3rem;
    font-size: 0.875rem;
}

.doc-side h2 {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--doc-faint);
    font-weight: 600;
    margin: 0 0 0.85rem;
}

.doc-side h2 + ol,
.doc-side h2 + ul {
    margin: 0 0 2.25rem;
}

.doc-side ol,
.doc-side ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.doc-side li {
    margin: 0;
}

.doc-side a {
    display: block;
    padding: 0.3rem 0 0.3rem 0.85rem;
    margin-left: -1px;
    border-left: 2px solid var(--doc-line);
    color: var(--doc-muted);
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.doc-side a:hover {
    color: var(--doc-ink);
    border-left-color: var(--doc-line-strong);
}

.doc-side a.active {
    color: var(--doc-ink);
    border-left-color: var(--doc-accent);
    font-weight: 500;
}

.doc-side .num {
    display: inline-block;
    width: 1.5rem;
    color: var(--doc-faint);
    font-variant-numeric: tabular-nums;
}

/* --- Headings & prose --------------------------------------------------- */

.doc-eyebrow {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--doc-faint);
    margin-bottom: 0.75rem;
}

.doc-main h1 {
    font-size: 2.5rem;
    line-height: 1.15;
    letter-spacing: -0.025em;
    font-weight: 600;
    margin: 0 0 1rem;
}

.doc-lead {
    font-size: 1.125rem;
    line-height: 1.6;
    color: var(--doc-muted);
    margin: 0 0 2rem;
}

.doc-main h2 {
    font-size: 1.5rem;
    line-height: 1.3;
    letter-spacing: -0.015em;
    font-weight: 600;
    margin: 0 0 1rem;
    scroll-margin-top: 5rem;
}

.doc-main h3 {
    font-size: 1.0625rem;
    line-height: 1.4;
    font-weight: 600;
    margin: 2.5rem 0 0.85rem;
    scroll-margin-top: 5rem;
}

.doc-main h4 {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--doc-faint);
    margin: 1.75rem 0 0.75rem;
}

.doc-main p {
    margin: 0 0 1.15rem;
}

.doc-main a {
    color: var(--doc-accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.doc-main a:hover {
    border-bottom-color: currentColor;
}

.doc-main strong {
    font-weight: 600;
    color: var(--doc-ink);
}

.doc-section {
    padding-top: 3.5rem;
    margin-top: 3.5rem;
    border-top: 1px solid var(--doc-line);
}

.doc-section:first-of-type {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

.doc-section > .doc-eyebrow {
    font-size: 0.6875rem;
}

/* Anker-Link, per JS eingefügt */
.doc-anchor {
    margin-left: 0.4em;
    color: var(--doc-faint);
    border: none !important;
    opacity: 0;
    font-weight: 400;
    transition: opacity 0.15s ease;
}

h2:hover > .doc-anchor,
h3:hover > .doc-anchor,
.doc-anchor:focus {
    opacity: 1;
}

/* --- Lists -------------------------------------------------------------- */

.doc-main ul,
.doc-main ol {
    margin: 0 0 1.15rem;
    padding-left: 1.35rem;
}

.doc-main li {
    margin-bottom: 0.55rem;
}

.doc-main li::marker {
    color: var(--doc-faint);
}

.doc-main li > ul,
.doc-main li > ol {
    margin-top: 0.55rem;
}

/* --- Facts strip -------------------------------------------------------- */

.doc-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border: 1px solid var(--doc-line);
    border-radius: var(--doc-radius);
    overflow: hidden;
    margin: 0 0 2.5rem;
}

.doc-facts div {
    flex: 1 1 160px;
    padding: 0.85rem 1.1rem;
    border-right: 1px solid var(--doc-line);
}

.doc-facts div:last-child {
    border-right: none;
}

.doc-facts dt {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--doc-faint);
    margin-bottom: 0.2rem;
}

.doc-facts dd {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

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

code {
    font-family: var(--doc-mono);
    font-size: 0.875em;
    background-color: var(--doc-surface-2);
    border-radius: 3px;
    padding: 0.12em 0.35em;
    overflow-wrap: anywhere;
}

pre {
    font-family: var(--doc-mono);
    font-size: 0.8125rem;
    line-height: 1.7;
    background-color: var(--doc-surface);
    border: 1px solid var(--doc-line);
    border-radius: var(--doc-radius);
    padding: 1.1rem 1.25rem;
    margin: 0 0 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    color: var(--doc-ink);
    tab-size: 2;
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

pre .c {
    color: var(--doc-faint);
}

pre .k {
    color: var(--doc-accent);
}

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

.doc-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--doc-line);
    border-radius: var(--doc-radius);
    margin: 0 0 1.5rem;
}

.doc-table table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

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

.doc-table thead th {
    background-color: var(--doc-surface);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 600;
    color: var(--doc-muted);
    white-space: nowrap;
}

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

.doc-table td {
    color: var(--doc-muted);
}

.doc-table td:first-child {
    color: var(--doc-ink);
    font-weight: 500;
    white-space: nowrap;
}

.doc-table td code,
.doc-table th code {
    background: none;
    padding: 0;
    white-space: nowrap;
}

/* --- Pills -------------------------------------------------------------- */

.pill {
    display: inline-block;
    font-size: 0.6875rem;
    font-family: var(--doc-sans);
    font-weight: 500;
    letter-spacing: 0.02em;
    padding: 0.1rem 0.45rem;
    border-radius: 3px;
    background-color: var(--doc-surface-2);
    color: var(--doc-muted);
    white-space: nowrap;
}

.pill.required {
    background-color: var(--doc-accent-soft);
    color: var(--doc-accent);
}

/* --- Notes & callouts --------------------------------------------------- */

.note {
    border-left: 3px solid var(--doc-line-strong);
    background-color: var(--doc-surface);
    border-radius: 0 var(--doc-radius) var(--doc-radius) 0;
    padding: 1.15rem 1.35rem;
    margin: 0 0 1.5rem;
}

.note.accent {
    border-left-color: var(--doc-accent);
}

.note > :last-child {
    margin-bottom: 0;
}

.note h3 {
    margin: 0 0 0.6rem !important;
    font-size: 0.9375rem;
}

.principle {
    border-left: 3px solid var(--doc-line-strong);
    padding: 0.15rem 0 0.15rem 1.35rem;
    margin: 2rem 0;
    color: var(--doc-muted);
    font-size: 1.0625rem;
}

.principle > :last-child {
    margin-bottom: 0;
}

/* --- Level cards (chapter 4) -------------------------------------------- */

.level {
    border: 1px solid var(--doc-line);
    border-radius: var(--doc-radius);
    padding: 1.5rem 1.75rem;
    margin: 0 0 1.25rem;
}

.level > h3 {
    margin-top: 0 !important;
    font-size: 1.125rem;
}

.level-tag {
    display: inline-block;
    font-size: 0.75rem;
    color: var(--doc-faint);
    margin-bottom: 1rem;
}

.level > :last-child {
    margin-bottom: 0;
}

/* --- LED grid figure ---------------------------------------------------- */

.grid-figure {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2.5rem;
    border: 1px solid var(--doc-line);
    border-radius: var(--doc-radius);
    padding: 1.75rem;
    margin: 0 0 1.5rem;
}

.led-grid {
    width: 208px;
    height: 208px;
    flex-shrink: 0;
}

.led-grid .on {
    fill: var(--doc-ink);
}

.led-grid .off {
    fill: var(--doc-line-strong);
}

.grid-legend {
    margin: 0;
    flex: 1 1 180px;
}

.grid-legend dt {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.grid-legend dd {
    margin: 0 0 1.25rem;
    font-size: 0.8125rem;
    color: var(--doc-muted);
}

.grid-legend dd:last-child {
    margin-bottom: 0;
}

/* --- Link cards (developers.html) --------------------------------------- */

.doc-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin: 0 0 2.5rem;
}

.doc-card {
    display: block;
    border: 1px solid var(--doc-line);
    border-radius: var(--doc-radius);
    padding: 1.5rem;
    text-decoration: none;
    color: inherit !important;
    border-bottom: 1px solid var(--doc-line) !important;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.doc-card:hover {
    border-color: var(--doc-line-strong) !important;
    background-color: var(--doc-surface);
}

.doc-card h3 {
    margin: 0 0 0.5rem !important;
    font-size: 1.0625rem;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}

.doc-card h3 .ext {
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--doc-faint);
}

.doc-card p {
    margin: 0 !important;
    font-size: 0.875rem;
    color: var(--doc-muted);
}

/* --- Footer ------------------------------------------------------------- */

.doc-footer {
    border-top: 1px solid var(--doc-line);
    margin-top: 2rem;
}

.doc-footer-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.75rem;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--doc-faint);
}

.doc-footer-inner a {
    color: var(--doc-muted);
    text-decoration: none;
}

.doc-footer-inner a:hover {
    color: var(--doc-ink);
}

.doc-footer-inner p {
    margin: 0;
    margin-right: auto;
}

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 900px) {
    .doc-shell {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .doc-side {
        position: static;
        max-height: none;
        overflow: visible;
        padding: 2rem 0 0;
        border-bottom: 1px solid var(--doc-line);
        padding-bottom: 1.5rem;
    }

    .doc-side h2 + ol,
    .doc-side h2 + ul {
        margin-bottom: 1.5rem;
    }

    .doc-main {
        padding-top: 2.5rem;
    }
}

@media (max-width: 640px) {
    .doc-topbar-inner,
    .doc-shell,
    .doc-footer-inner {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .doc-main h1 {
        font-size: 1.875rem;
    }

    .doc-lead {
        font-size: 1rem;
    }

    .level,
    .grid-figure {
        padding: 1.25rem;
    }

    .grid-figure {
        gap: 1.5rem;
    }

    .led-grid {
        width: 168px;
        height: 168px;
    }
}
