/* 4SHTF — self-contained, no CDN, no webfonts. Minimal: white, black, red. */

:root {
    --ink: #111111;
    --muted: #6b6b6b;
    --paper: #ffffff;
    --line: #e6e6e6;
    --accent: #ab0000;       /* sampled from the logo's "4" */
    --accent-dark: #7a0000;
    --max: 1160px;
    --narrow: 720px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 16px/1.65 var(--font);
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

h1, h2, h3 { font-weight: 700; }

/* Header: logo top-left, nav top-right */
.site-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--line);
}

.brand { display: block; line-height: 0; }
.brand img { height: 64px; width: auto; display: block; }

.site-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-left: auto;
    font-size: 0.95rem;
    font-weight: 700;
}

.site-nav a { color: var(--ink); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }
.site-nav .nav-account { color: var(--accent); }
.site-nav .nav-account:hover { color: var(--accent-dark); }

/* Logged-in nav: avatar + name + dropdown */
.nav-user { position: relative; }
.nav-user-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: none;
    border: 0;
    font: inherit;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    padding: 0;
}
.nav-user-toggle:hover { color: var(--accent); }
.nav-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex: 0 0 auto;
}
.nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    min-width: 170px;
    padding: 0.4rem;
    z-index: 50;
}
.nav-user.is-open .nav-dropdown { display: block; }
.nav-dropdown a, .nav-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.55rem 0.6rem;
    border-radius: 4px;
    background: none;
    border: 0;
    font: inherit;
    font-weight: 400;
    color: var(--ink);
    cursor: pointer;
    text-decoration: none;
}
.nav-dropdown a:hover, .nav-dropdown button:hover { background: #f5f5f5; color: var(--accent); }

.site-main {
    max-width: var(--max);
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.narrow { max-width: var(--narrow); margin: 0 auto; }

/* Homepage: 70/30 — full latest article, tiny thumbs of the rest */
.home-layout {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
}

.home-main { flex: 0 0 70%; max-width: 70%; min-width: 0; }
.home-sidebar { flex: 1 1 30%; min-width: 0; }
.home-sidebar .search-form { margin-top: 0; }

.sidebar-heading {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding-bottom: 0.6rem;
    margin: 0 0 1.1rem;
}

.sidebar-list { display: flex; flex-direction: column; gap: 1.1rem; list-style: none; margin: 0; padding: 0; }

.sidebar-card { display: flex; gap: 0.75rem; }
.sidebar-thumb { flex: 0 0 60px; }
.sidebar-thumb img { width: 60px; height: 60px; object-fit: cover; border-radius: 4px; }
.sidebar-card h3 { font-size: 1.06rem; line-height: 1.3; margin: 0; font-weight: 600; }
.sidebar-card h3 a { color: var(--ink); text-decoration: none; }
.sidebar-card h3 a:hover { color: var(--accent); }
.sidebar-card .byline { font-size: 0.72rem; margin: 0.25rem 0 0; }

@media (max-width: 860px) {
    .home-layout { flex-direction: column; }
    .home-main, .home-sidebar { max-width: 100%; flex-basis: auto; }
}

/* Hero / full article (shared: homepage hero and standalone article page) */
.article-full h1, .hero h1 { font-size: 1.9rem; line-height: 1.25; margin: 0.6rem 0 0.2rem; }
.article-full .featured, .hero-image { width: 100%; height: auto; border-radius: 6px; margin: 0 0 0.6rem; }
.article-full h1 a, .hero h1 a { color: var(--ink); text-decoration: none; }
.article-full h1 a:hover, .hero h1 a:hover { color: var(--accent); }

.byline { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0 0.6rem; }

.article-body, .hero .article-body { font-size: 1.05rem; }
.article-body img { max-width: 100%; height: auto; border-radius: 4px; }
.article-body h2, .article-body h3 { line-height: 1.3; margin-top: 1.8em; }
.article-body blockquote {
    margin: 1.2em 0;
    padding: 0.1em 1.2em;
    border-left: 4px solid var(--accent);
    background: #f7f7f7;
    font-style: italic;
}
.article-body pre { overflow-x: auto; background: #141414; color: #eee; padding: 1em; border-radius: 6px; }

.read-more { font-weight: 700; text-decoration: none; }

/* Article cards — search results */
.article-list { display: flex; flex-direction: column; gap: 1.6rem; }

.article-card {
    display: flex;
    gap: 1rem;
    padding-bottom: 1.6rem;
    border-bottom: 1px solid var(--line);
}

.card-thumb { flex: 0 0 180px; }
.card-thumb img { width: 180px; height: 120px; object-fit: cover; border-radius: 4px; }
.card-body h2 { font-size: 1.5rem; line-height: 1.3; margin: 0 0 0.1rem; }
.card-body h2 a { color: var(--ink); text-decoration: none; }
.card-body h2 a:hover { color: var(--accent); }
.card-body p { margin: 0.3rem 0 0; }

@media (max-width: 560px) {
    .article-card { flex-direction: column; }
    .card-thumb, .card-thumb img { width: 100%; height: auto; }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    margin-top: 2rem;
    font-weight: 700;
}
.pagination a { text-decoration: none; }

/* Search */
.page-title { font-size: 1.6rem; }
.search-form { display: flex; gap: 0.5rem; margin: 1rem 0 1.5rem; }
.search-form input { flex: 1; padding: 0.6rem 0.8rem; border: 1px solid var(--line); border-radius: 4px; font-size: 1rem; font-family: var(--font); }
.search-form button {
    padding: 0.6rem 1.2rem;
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.search-form button:hover { background: var(--accent-dark); }
.result-count { color: var(--muted); font-size: 0.9rem; }

/* Members / account stubs + footer */
.members-stub h1, .account-stub h1 { font-size: 1.8rem; }
.empty-note { color: var(--muted); }

.account-form { display: flex; flex-direction: column; gap: 1rem; max-width: 360px; margin-top: 1.5rem; }
.account-form label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.9rem; }
.account-form input {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.6rem 0.7rem;
    font-size: 1rem;
    font-family: var(--font);
    font-weight: 400;
}
.account-form button {
    padding: 0.65rem 1.2rem;
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    align-self: flex-start;
}
.account-form button:hover { background: var(--accent-dark); }
.form-error { color: var(--accent); font-weight: 600; font-size: 0.9rem; margin-top: 1rem; }

/* Members feed (foundation slice — two-column for now, not the full
   three-column blueprint in docs/05) */
.members-layout { display: flex; gap: 3rem; align-items: flex-start; }
.members-main { flex: 0 0 70%; max-width: 70%; min-width: 0; }
.members-sidebar { flex: 1 1 30%; min-width: 0; }

@media (max-width: 860px) {
    .members-layout { flex-direction: column; }
    .members-main, .members-sidebar { max-width: 100%; flex-basis: auto; }
}

.post-composer { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }
.post-composer textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
    font-size: 1rem;
    font-family: var(--font);
    resize: vertical;
}
.post-composer button {
    align-self: flex-start;
    padding: 0.6rem 1.3rem;
    border: 0;
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}
.post-composer button:hover { background: var(--accent-dark); }

.post-list { display: flex; flex-direction: column; gap: 1.5rem; }
.post-card { padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
.post-meta { display: flex; gap: 0.6rem; align-items: baseline; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.4rem; }
.post-author { font-weight: 700; color: var(--ink); }
.post-group { padding: 0.1rem 0.5rem; background: #f5f5f5; border-radius: 3px; }
.post-body { white-space: pre-wrap; margin: 0; }

.load-more {
    display: block;
    margin: 1.5rem auto 0;
    padding: 0.6rem 1.4rem;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    font-weight: 700;
    cursor: pointer;
}
.load-more:hover { border-color: var(--accent); color: var(--accent); }

.group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.group-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.group-name { font-weight: 600; font-size: 0.92rem; }
.group-join, .group-leave {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 4px;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}
.group-join { color: var(--accent); border-color: var(--accent); }
.group-join:hover { background: var(--accent); color: #fff; }
.group-leave { color: var(--muted); }
.group-leave:hover { border-color: var(--accent); color: var(--accent); }

.site-footer {
    max-width: var(--max);
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2.5rem;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.6rem;
}
.site-footer a { color: var(--muted); background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.site-footer a:hover { color: var(--accent); }
.footer-links { display: flex; gap: 1rem; flex-wrap: wrap; }

/* Legal modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 100;
}
.modal-overlay.is-open { display: flex; }
.modal-panel {
    background: #fff;
    max-width: 640px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    border-radius: 6px;
    position: relative;
    border-top: 4px solid var(--accent);
}
.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: none;
    border: 0;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: var(--ink);
    padding: 0.25rem 0.5rem;
}
.modal-panel h2 { margin-top: 0; }
