/* ------------------------------
   StayTeam Quick Guide (scoped)
   Theme-aware: respects prefers-color-scheme
   ------------------------------ */

/* Layout tokens that don't depend on theme */
:root {
    /* ~105ch ≈ 100–110 characters per line */
    --qg-body-maxch: 105;
    --qg-toc-width: 260px;
    --qg-toc-right: 24px;
    --qg-toc-top: 120px;
}

/* Theme tokens – LIGHT is default here */
.qg-body {
    /* announce we support both */
    color-scheme: light dark;

    /* light theme */
    --qg-bg: #f6f7fb;
    --qg-fg: #0f141a;
    --qg-muted: #4b5563;
    --qg-panel: #ffffff;
    --qg-border: rgba(17, 24, 39, 0.12);
    --qg-accent: #2b6fff;
}

/* DARK theme overrides */
@media (prefers-color-scheme: dark) {
    .qg-body {
        --qg-bg: #121417;
        --qg-fg: #e8ecf2;
        --qg-muted: #b8c0cc;
        --qg-panel: #1a202a;
        --qg-border: rgba(255, 255, 255, .08);
        --qg-accent: #2b90ff;
    }
}

/* Page background + footer fix (opaque) */
.qg-body {
    background: var(--qg-bg);
    color: var(--qg-fg);
}

.qg-body .content {
    height: auto;
    overflow: visible;
}

.qg-body .footer {
    background: var(--qg-panel);
    border-top: 1px solid var(--qg-border);
}

/* Keep the avatar on the far-right for this page so it won't overlap the logo */
.qg-body .header {
    position: relative;
}

.qg-body #my-name {
    position: absolute;
    right: 16px;
    top: 10px;
}

/* Main container: ~105ch max width, centered */
.qg-container {
    width: min(calc(var(--qg-body-maxch) * 1ch), 90vw);
    margin: 0 auto;
    padding: 16px 0 24px;
}

/* Headline (centered, balanced) */
.qg-hero {
    text-align: center;
    padding: 20px 0 24px;
}

.qg-h1 {
    margin: 0 0 8px;
    font-size: clamp(28px, 3.3vw, 40px);
}

.qg-sub {
    margin: 0;
    color: var(--qg-muted);
}

/* Sections */
.qg-sec {
    padding: 24px 0;
    border-top: 1px solid var(--qg-border);
    scroll-margin-top: 96px;
    /* anchor offset under header */
}

/* Preface */
.qg-h2 {
    margin: 0 0 8px;
    /* small gap per your request */
    font-size: clamp(20px, 2.2vw, 26px);
}

/* justified paragraphs in preface only */
.qg-justify {
    text-align: justify;
    text-justify: inter-word;
}

/* Section titles (other sections) */
.qg-title {
    margin: 0 0 12px;
    font-size: clamp(20px, 2.2vw, 26px);
    font-weight: 700;
}

/* Media/text layout: figure left, text right */
.qg-media {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Figures */
.qg-fig {
    margin: 0;
}

.qg-fig img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 8px;
}

.qg-cap {
    margin-top: 8px;
    font-size: 0.9rem;
    color: var(--qg-muted);
}

/* Two small images side-by-side (2.1, 2.2) */
.qg-duo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 12px;
}

.qg-mini img {
    border-radius: 6px;
}

/* Text block to the right of images */
.qg-text {
    line-height: 1.65;
}

.qg-ol {
    margin: 0;
    padding-left: 20px;
}

.qg-subol {
    margin: 8px 0 0;
    padding-left: 18px;
    font-size: 0.98rem;
}

.qg-note {
    margin: 10px 0 0;
    color: var(--qg-muted);
}

/* Fig3.1 aligned left under its paragraph list */
.qg-left {
    margin-top: 14px;
    max-width: 520px;
}

.qg-left img {
    border-radius: 8px;
}

.qg-left-cap {
    text-align: left;
}

/* Back link */
.qg-back {
    padding: 24px 0 8px;
    border-top: 1px solid var(--qg-border);
    margin-top: 24px;
}

.qg-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 10px;
    background: var(--qg-panel);
    border: 1px solid var(--qg-border);
    color: var(--qg-fg);
    text-decoration: none;
}

.qg-btn:hover {
    border-color: rgba(0, 0, 0, .2);
    /* adjusts fine for both themes */
}

@media (prefers-color-scheme: dark) {
    .qg-btn:hover {
        border-color: rgba(255, 255, 255, .18);
    }
}

/* TOC (independent, fixed right) */
.qg-toc {
    position: fixed;
    top: var(--qg-toc-top);
    right: var(--qg-toc-right);
    width: var(--qg-toc-width);
    z-index: 50;
}

.qg-toc-card {
    background: var(--qg-panel);
    border: 1px solid var(--qg-border);
    border-radius: 14px;
    padding: 14px 14px 10px;
    backdrop-filter: blur(6px);
}

.qg-toc-title {
    font-weight: 700;
    margin: 0 0 10px;
}

.qg-toc-nav {
    display: grid;
    gap: 8px;
}

.qg-toc-nav a {
    color: var(--qg-fg);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 8px;
    display: block;
}

.qg-toc-nav a:hover {
    background: rgba(0, 0, 0, .06);
}

@media (prefers-color-scheme: dark) {
    .qg-toc-nav a:hover {
        background: rgba(255, 255, 255, .06);
    }
}

/* Image zoom (overlay + centered) */
.qg-fig img {
    cursor: zoom-in;
    transition: transform .25s ease;
}

.qg-fig img.zoomed {
    position: fixed;
    top: 50%;
    left: 50%;
    max-width: 92vw;
    max-height: 92vh;
    transform: translate(-50%, -50%);
    z-index: 1001;
    cursor: zoom-out;
    box-shadow: 0 0 18px rgba(0, 0, 0, .8);
    background: #000;
    /* looks good in both themes */
}

.qg-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    z-index: 1000;
}

.qg-overlay.active {
    display: block;
}

/* Responsive tweaks */
@media (max-width: 1100px) {
    :root {
        --qg-toc-right: 12px;
        --qg-toc-top: 100px;
    }

    .qg-toc {
        width: 220px;
    }
}

@media (max-width: 980px) {
    .qg-toc {
        display: none;
    }

    /* hide TOC on narrow screens */
    .qg-media {
        grid-template-columns: 1fr;
    }
}