/* ── bySince — Documentation stylesheet ──────────────────────────────────── */

:root {
    --terracotta:       #DC5C3B;
    --dark-terracotta:  #892E1F;
    --navy:             #142136;
    --cream:            #f2fafa;
    --cream-dark:       #e0eeee;
    --warm-grey:        #7b8e9a;
    --text:             #142136;
    --text-light:       #5a6e7e;
    --white:            #FFFFFF;
    --border:           #cfdce2;
}

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

body {
    font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
    background: var(--cream);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────────── */
.header {
    background: var(--navy);
    padding: 2rem 2rem 1.8rem;
    position: relative;
}
.header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 4px;
    background: var(--terracotta);
}
.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.brand {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    color: var(--white);
    letter-spacing: 0.12em;
    line-height: 1;
}
.brand span { color: var(--terracotta); }
.header-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 400;
    color: var(--warm-grey);
    letter-spacing: 0.08em;
}

/* ── Two-column layout ───────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 3rem;
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

/* ── Sidebar (sticky wrapper) ────────────────────────── */
.sidebar {
    position: sticky;
    top: 1.5rem;
    width: 280px;
    flex-shrink: 0;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.doc-main {
    flex: 1;
    min-width: 0;
}

.doc-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-light);
}
.doc-meta .doc-date { margin-left: auto; }

.doc-body {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2.5rem 2.5rem 2rem;
    line-height: 1.75;
    font-size: 0.95rem;
    color: var(--text);
    overflow-x: auto;
}

/* ── Document navigation (inter-documents) ───────────── */
.doc-nav {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.2rem 1.2rem 0.8rem;
}
.doc-nav-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.15rem;
    color: var(--navy);
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--terracotta);
}
.doc-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.doc-nav-list li {
    border-bottom: 1px solid var(--border);
}
.doc-nav-list li:last-child {
    border-bottom: none;
}
.doc-nav-list a {
    display: block;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--text);
    text-decoration: none;
    border-left: 3px solid transparent;
    border-radius: 0 4px 4px 0;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.doc-nav-list a:hover {
    color: var(--terracotta);
    background: var(--cream);
    border-left-color: var(--terracotta);
}
.doc-nav-active a {
    color: var(--terracotta);
    font-weight: 600;
    border-left-color: var(--terracotta);
    background: var(--cream);
}

/* ── Home link in sidebar ────────────────────────────── */
.doc-nav-home {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.6rem;
    margin-bottom: 0.5rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--cream);
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.doc-nav-home svg {
    flex-shrink: 0;
    color: var(--terracotta);
}
.doc-nav-home:hover {
    color: var(--terracotta);
    background: var(--cream-dark);
    border-color: var(--terracotta);
}
.doc-nav-home-active {
    color: var(--white);
    background: var(--terracotta);
    border-color: var(--terracotta);
    font-weight: 600;
}
.doc-nav-home-active svg {
    color: var(--white);
}
.doc-nav-home-active:hover {
    color: var(--white);
    background: var(--dark-terracotta);
    border-color: var(--dark-terracotta);
}

/* ── Table of contents (page headings) ───────────────── */
.toc {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.4rem 1.2rem;
    scroll-margin-top: 1rem;
}
.toc-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.15rem;
    color: var(--navy);
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--terracotta);
}

/* ── H1 top-level entry ── */
.toc-h1-entry {
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--border);
}
.toc-h1-entry a {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--navy);
    text-decoration: none;
    letter-spacing: 0.04em;
}
.toc-h1-entry a:hover { color: var(--terracotta); }

/* ── H2 without children ── */
.toc-h2-entry {
    padding: 0.35rem 0.5rem 0.35rem calc(0.5rem + 5px + 0.4rem);
    border-bottom: 1px solid var(--border);
}
.toc-h2-entry:last-child { border-bottom: none; }
.toc-h2-entry a {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.toc-h2-entry a:hover { color: var(--terracotta); }

/* ── Collapsible H2 groups ── */
.toc-group {
    border-bottom: 1px solid var(--border);
}
.toc-group:last-child {
    border-bottom: none;
}
.toc-h2 {
    list-style: none;
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s;
    border-radius: 6px;
}
.toc-h2:hover {
    background: var(--cream);
}
.toc-h2::before {
    content: '';
    display: inline-block;
    width: 0; height: 0;
    border-left: 5px solid var(--terracotta);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.toc-group[open] > .toc-h2::before {
    transform: rotate(90deg);
}
.toc-h2::-webkit-details-marker { display: none; }
.toc-h2 a {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}
.toc-h2 a:hover {
    color: var(--terracotta);
}

.toc-list {
    list-style: none;
    padding: 0 0 0.3rem 0.8rem;
    margin: 0;
}
.toc-item {
    line-height: 1.35;
}
.toc-item a {
    display: block;
    padding: 0.2rem 0;
    color: var(--text);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 400;
    border-left: 2px solid transparent;
    padding-left: 0.6rem;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc-item a:hover {
    color: var(--terracotta);
    border-left-color: var(--terracotta);
    background: var(--cream);
}
.toc-level-2 a { padding-left: 0.6rem; }
.toc-level-3 a { padding-left: 1.2rem; font-size: 0.76rem; color: var(--text-light); }
.toc-level-4 a { padding-left: 1.8rem; font-size: 0.74rem; color: var(--text-light); }

/* ── Back-to-TOC button (hidden when sidebar visible) ── */
.btn-back-toc {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    vertical-align: middle;
    margin-left: 0.5rem;
    color: var(--warm-grey);
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 50%;
    text-decoration: none !important;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.btn-back-toc:hover {
    color: var(--white);
    background: var(--terracotta);
    border-color: var(--terracotta);
}

/* ── Document body content ───────────────────────────── */
.doc-body h1, .doc-body h2, .doc-body h3,
.doc-body h4, .doc-body h5, .doc-body h6 {
    font-family: 'Bebas Neue', sans-serif;
    color: var(--navy);
    letter-spacing: 0.04em;
    margin: 1.8rem 0 0.6rem;
    line-height: 1.2;
    scroll-margin-top: 1.5rem;
}
.doc-body h1 { font-size: 2rem; border-bottom: 2px solid var(--terracotta); padding-bottom: 0.3rem; }
.doc-body h2 { font-size: 1.6rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2rem; }
.doc-body h3 { font-size: 1.3rem; }
.doc-body h1:first-child, .doc-body h2:first-child, .doc-body h3:first-child { margin-top: 0; }
.doc-body p { margin: 0.8rem 0; }
.doc-body a { color: var(--terracotta); text-decoration: underline; text-underline-offset: 2px; }
.doc-body a:hover { color: var(--dark-terracotta); }
.doc-body strong { font-weight: 600; color: var(--navy); }
.doc-body em { font-style: italic; }
.doc-body blockquote {
    border-left: 4px solid var(--terracotta);
    margin: 1rem 0;
    padding: 0.6rem 1.2rem;
    background: var(--cream);
    border-radius: 0 6px 6px 0;
    color: var(--text-light);
}
.doc-body code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85em;
    background: var(--cream-dark);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    color: var(--dark-terracotta);
}
.doc-body pre {
    background: var(--navy);
    color: var(--cream);
    padding: 1.2rem 1.4rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1rem 0;
    line-height: 1.5;
}
.doc-body pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.88rem;
}
.doc-body ul, .doc-body ol { margin: 0.8rem 0; padding-left: 1.6rem; }
.doc-body li { margin: 0.3rem 0; }
.doc-body li::marker { color: var(--terracotta); }
.doc-body img { max-width: 100%; height: auto; border-radius: 6px; margin: 1rem 0; }
.doc-body table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.doc-body th, .doc-body td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.8rem;
    text-align: left;
    font-size: 0.88rem;
}
.doc-body th {
    background: var(--cream-dark);
    font-weight: 600;
    color: var(--navy);
}
.doc-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

/* ── Footer ──────────────────────────────────────────── */
.footer {
    text-align: center;
    padding: 2rem;
    font-size: 0.72rem;
    color: var(--warm-grey);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ── Print ────────────────────────────────────────────── */
@media print {
    .header { padding: 1rem; }
    .container { display: block; padding: 1rem; }
    .sidebar { position: static; width: auto; max-height: none; }
    .toc { break-after: page; }
    .toc-group { border: none; }
    .toc-group[open] > .toc-h2::before, .toc-h2::before { display: none; }
    .btn-back-toc { display: none !important; }
    .doc-nav { display: none; }
    .doc-body { border: none; padding: 0; box-shadow: none; }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
    }
    .sidebar {
        position: static;
        width: auto;
        max-height: none;
    }
    .btn-back-toc {
        display: inline-flex;
    }
}

@media (max-width: 700px) {
    .header { padding: 1.5rem 1.2rem; }
    .container { padding: 1rem 1rem 2rem; }
    .doc-body { padding: 1.5rem 1.2rem; }
}
