/* ==========================================================================
   Beacon Bulletin Board — default theme
   ==========================================================================
   Design tokens live on :root as CSS custom properties; dark mode swaps
   the same tokens via [data-theme="dark"] or, absent an explicit choice,
   prefers-color-scheme. Components only ever reference tokens.

   This file is the shipped "Master" stylesheet; the theme engine (M4)
   compiles per-theme SCSS overrides down to the same token contract.
   ========================================================================== */

/* ------------------------------ tokens: light ------------------------- */
:root {
    color-scheme: light dark;

    --color-bg: #f6f5f2;
    --color-bg-raised: #ffffff;
    --color-bg-sunken: #eceae5;
    --color-text: #1f2430;
    --color-text-muted: #676f7d;
    --color-line: #d9d5cc;

    --color-accent: #b45309;
    --color-accent-contrast: #ffffff;
    --color-accent-soft: #b4530917;

    --color-danger: #b3403a;
    --color-success: #2f7a4d;

    --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

    --radius-s: 5px;
    --radius-m: 8px;
    --radius-l: 12px;

    --shadow-1: 0 1px 2px #0000000f, 0 1px 6px #0000000a;
    --shadow-2: 0 4px 16px #00000014;

    --content-width: 62rem;
    --transition: 140ms ease;
}

/* ------------------------------ tokens: dark -------------------------- */
[data-theme="dark"] {
    --color-bg: #14161c;
    --color-bg-raised: #1d2028;
    --color-bg-sunken: #0f1116;
    --color-text: #e6e4df;
    --color-text-muted: #9299a5;
    --color-line: #2e323d;

    --color-accent: #f0a548;
    --color-accent-contrast: #1a1206;
    --color-accent-soft: #f0a54821;

    --color-danger: #e07570;
    --color-success: #6fbd8f;

    --shadow-1: 0 1px 2px #00000059, 0 1px 6px #0000003d;
    --shadow-2: 0 4px 18px #00000073;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-bg: #14161c;
        --color-bg-raised: #1d2028;
        --color-bg-sunken: #0f1116;
        --color-text: #e6e4df;
        --color-text-muted: #9299a5;
        --color-line: #2e323d;

        --color-accent: #f0a548;
        --color-accent-contrast: #1a1206;
        --color-accent-soft: #f0a54821;

        --color-danger: #e07570;
        --color-success: #6fbd8f;

        --shadow-1: 0 1px 2px #00000059, 0 1px 6px #0000003d;
        --shadow-2: 0 4px 18px #00000073;
    }
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--color-text);
    background: var(--color-bg);
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }

pre, code { font-family: var(--font-mono); font-size: 0.9em; }

:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    border-radius: var(--radius-s);
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

.muted { color: var(--color-text-muted); font-size: 0.9rem; }

.container {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 0 1.1rem;
}

/* ------------------------------- header -------------------------------- */
.site-header {
    background: var(--color-bg-raised);
    border-bottom: 1px solid var(--color-line);
    box-shadow: var(--shadow-1);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 1.1rem;
    min-height: 3.4rem;
    flex-wrap: wrap;
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.12rem;
    color: var(--color-text);
}
.brand:hover { text-decoration: none; color: var(--color-accent); }
.brand__mark { color: var(--color-accent); }

.site-nav { display: flex; align-items: center; gap: 0.9rem; margin-right: auto; }
.site-nav a { color: var(--color-text-muted); font-size: 0.95rem; }
.site-nav a:hover { color: var(--color-accent); text-decoration: none; }

.user-area { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.user-area form { margin: 0; }
.user-name { font-weight: 600; font-size: 0.95rem; }

/* ------------------------------- buttons ------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.42rem 0.95rem;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-m);
    background: var(--color-bg-raised);
    color: var(--color-text);
    font: inherit;
    font-size: 0.92rem;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.btn:hover { border-color: var(--color-accent); color: var(--color-accent); text-decoration: none; }

.btn--primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-contrast);
}
.btn--primary:hover { filter: brightness(1.06); color: var(--color-accent-contrast); }

.btn--ghost { background: transparent; }

.link-button {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: inherit;
    color: var(--color-accent);
    cursor: pointer;
}
.link-button:hover { text-decoration: underline; }
.link-button--danger { color: var(--color-danger); }

.inline-form { display: inline; margin: 0; }

/* -------------------------------- page --------------------------------- */
main.page { flex: 1; width: 100%; padding: 1.6rem 0 2.5rem; }

.site-footer {
    border-top: 1px solid var(--color-line);
    padding: 1rem 0 1.4rem;
    background: var(--color-bg-sunken);
}
.site-footer .container {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* ------------------------------- notices -------------------------------- */
.notice {
    max-width: var(--content-width);
    margin: 1rem auto 0;
    padding: 0.65rem 1.1rem;
    border: 1px solid var(--color-accent);
    background: var(--color-accent-soft);
    border-radius: var(--radius-m);
    width: calc(100% - 2.2rem);
}

/* ----------------------------- breadcrumbs ------------------------------ */
.breadcrumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: var(--color-text-muted);
}
.breadcrumbs a { color: var(--color-text-muted); }
.breadcrumbs a:hover { color: var(--color-accent); }

/* ------------------------------ node lists ------------------------------ */
.node-section { margin-bottom: 2rem; }

.node-section__title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    padding-bottom: 0.45rem;
    margin-bottom: 0;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.6rem;
}
.section-head .node-section__title { padding-bottom: 0; }

.node-list {
    background: var(--color-bg-raised);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.node-row {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    padding: 0.85rem 1.1rem;
}
.node-row + .node-row { border-top: 1px solid var(--color-line); }

.node-row__main { flex: 1; min-width: 0; }
.node-row__icon { margin-right: 0.25rem; }
.node-row__title { margin: 0; font-size: 1.02rem; }
.node-row__desc { margin: 0.1rem 0 0; }
.node-row__subs { margin: 0.35rem 0 0; display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.87rem; }

.node-row__stats {
    display: flex;
    flex-direction: column;
    text-align: right;
    font-size: 0.83rem;
    white-space: nowrap;
    color: var(--color-text-muted);
}

.node-row__last {
    width: 14rem;
    min-width: 0;
    font-size: 0.83rem;
    color: var(--color-text-muted);
    display: none;
}
.node-row__last-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
}
@media (min-width: 760px) { .node-row__last { display: block; } }

/* ----------------------------- thread lists ----------------------------- */
.thread-list {
    background: var(--color-bg-raised);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-1);
    overflow: hidden;
}

.thread-row {
    display: flex;
    gap: 1.1rem;
    align-items: center;
    padding: 0.7rem 1.1rem;
}
.thread-row + .thread-row { border-top: 1px solid var(--color-line); }
.thread-row__main { flex: 1; min-width: 0; }
.thread-row__title { margin: 0; font-size: 0.98rem; font-weight: 600; }
.thread-row__meta { margin: 0.12rem 0 0; font-size: 0.83rem; }

.tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--color-line);
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
    border-radius: var(--radius-s);
    padding: 0.08rem 0.4rem;
    vertical-align: 0.1em;
}

/* ------------------------------ pagination ------------------------------ */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.1rem 0;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

/* -------------------------------- posts --------------------------------- */
.post-list { margin-top: 0.4rem; }

.post {
    background: var(--color-bg-raised);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-1);
    padding: 0.95rem 1.2rem;
    margin-bottom: 1rem;
}
.post:target { border-color: var(--color-accent); }

.post__meta {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.55rem;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}
.post__meta strong { color: var(--color-text); font-size: 0.95rem; }

.post__body { overflow-wrap: break-word; }
.post__body p { margin: 0.55rem 0; }
.post__body p:first-child { margin-top: 0; }
.post__body p:last-child { margin-bottom: 0; }
.post__body ul, .post__body ol { margin: 0.55rem 0; padding-left: 1.4rem; }
.post__body blockquote {
    margin: 0.55rem 0;
    padding: 0.45rem 0.95rem;
    border-left: 3px solid var(--color-accent);
    background: var(--color-accent-soft);
    border-radius: 0 var(--radius-s) var(--radius-s) 0;
}
.post__body blockquote p { margin: 0; }
.post__body .post-code {
    background: var(--color-bg-sunken);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-m);
    padding: 0.65rem 0.95rem;
    overflow-x: auto;
}
.post__body code {
    background: var(--color-bg-sunken);
    border-radius: var(--radius-s);
    padding: 0.08rem 0.32rem;
}
.post__body .post-code code { background: none; padding: 0; border: none; }
.post__body a { text-decoration: underline; }

.post__actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.7rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--color-line);
    font-size: 0.85rem;
}

/* -------------------------------- forms --------------------------------- */
.field { margin-bottom: 1rem; }
.field label { display: block; margin-bottom: 0.3rem; font-weight: 600; font-size: 0.93rem; }

.field input,
textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--color-line);
    border-radius: var(--radius-m);
    font: inherit;
    background: var(--color-bg-raised);
    color: inherit;
    transition: border-color var(--transition);
}
.field input:focus, textarea:focus { border-color: var(--color-accent); outline: none; }
textarea { resize: vertical; }

.error { color: var(--color-danger); font-size: 0.88rem; margin: 0.3rem 0 0; }

.auth-card {
    max-width: 26rem;
    margin: 1rem auto 0;
    background: var(--color-bg-raised);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-2);
    padding: 1.6rem 1.7rem;
}
.auth-card h1 { font-size: 1.3rem; }

.form-card {
    background: var(--color-bg-raised);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-l);
    box-shadow: var(--shadow-1);
    padding: 1.3rem 1.4rem;
}

pre.setup-hint {
    background: var(--color-bg-sunken);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-m);
    padding: 0.8rem 1rem;
    overflow-x: auto;
    font-size: 0.85rem;
}

/* --------------------------- theme toggle ------------------------------- */
.theme-toggle { min-width: 2.4rem; padding-inline: 0.55rem; }
