/*
 * refresh.css — visual skin layered on top of main.css.
 *
 * Direction: editorial / paper. Warm cream backgrounds, single accent
 * (terracotta), serif display type (Source Serif 4), sans body (Inter).
 * No frosted glass, minimal shadows. Article body sits on its own paper
 * surface so it never reads as pure white-on-white or black-on-black.
 *
 * Loaded after main.css; only colors/typography/shadows/radii — no
 * positioning. Disable by removing the <link> in import.ejs to revert.
 */

/* ─── Tokens ──────────────────────────────────────────────────── */
:root {
    /* Page surface — warm paper, not stark white. */
    --bg:            #f5efe1;          /* page background, warm cream */
    --bg-elev:       #fbf6e9;          /* card / panel — slightly lighter */
    --bg-paper:      #fbf6e9;          /* article reading surface */
    --bg-muted:      #ece4d3;          /* code blocks, blockquote */

    /* Ink. Stone-900-ish for body, lighter tones for hierarchy. */
    --text:          #1c1917;
    --text-soft:     #44403c;
    --text-muted:    #78716c;
    --text-faint:    #a8a29e;

    --border:        #e7dfca;
    --border-strong: #d6cdb1;

    /* Single accent: terracotta. Quiet but distinctive. */
    --accent:        #b45309;          /* amber-700 */
    --accent-hover:  #92400e;          /* amber-800 */
    --accent-bg:     rgba(180, 83, 9, 0.08);

    /* Soft secondary used only for emphasis / pagination "current". */
    --rose:          #be123c;          /* rose-700 */

    --shadow-sm: 0 1px 1px rgba(28, 25, 23, 0.04);
    --shadow-md: 0 2px 8px rgba(28, 25, 23, 0.06);
    --shadow-lg: 0 6px 24px rgba(28, 25, 23, 0.08);

    --menu-bg:       #fbf6e9;
    --menu-border:   #e7dfca;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --font-sans:    "Inter", "Noto Sans SC", -apple-system, BlinkMacSystemFont,
                    "Segoe UI", sans-serif;
    --font-serif:   "Source Serif 4", "Noto Serif SC", "Iowan Old Style",
                    "Apple Garamond", Georgia, serif;
    --font-mono:    "JetBrains Mono", ui-monospace, SFMono-Regular,
                    Menlo, "Cascadia Code", monospace;

    color-scheme: light;
}

/* Dark mode — warm dark, not pure black. Stone-900 / -800. */
[data-theme="dark"] {
    --bg:            #1a1612;          /* very warm dark, paper at night */
    --bg-elev:       #221d17;
    --bg-paper:      #1f1a14;
    --bg-muted:      #2a241c;

    --text:          #f5efe1;
    --text-soft:     #d6cdb1;
    --text-muted:    #a8a29e;
    --text-faint:    #78716c;

    --border:        #2e2820;
    --border-strong: #44403c;

    --accent:        #f59e0b;          /* amber-500 — pops on dark */
    --accent-hover:  #fbbf24;
    --accent-bg:     rgba(245, 158, 11, 0.10);

    --rose:          #fda4af;

    --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

    --menu-bg:       rgba(26, 22, 18, 0.92);
    --menu-border:   #2e2820;

    color-scheme: dark;
}

/* Auto dark unless user picked light explicitly. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:            #1a1612;
        --bg-elev:       #221d17;
        --bg-paper:      #1f1a14;
        --bg-muted:      #2a241c;
        --text:          #f5efe1;
        --text-soft:     #d6cdb1;
        --text-muted:    #a8a29e;
        --text-faint:    #78716c;
        --border:        #2e2820;
        --border-strong: #44403c;
        --accent:        #f59e0b;
        --accent-hover:  #fbbf24;
        --accent-bg:     rgba(245, 158, 11, 0.10);
        --rose:          #fda4af;
        --shadow-sm: 0 1px 1px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 2px 12px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
        --menu-bg:       rgba(26, 22, 18, 0.92);
        --menu-border:   #2e2820;
        color-scheme: dark;
    }
}

/* ─── Base ────────────────────────────────────────────────────── */
html, body { background: var(--bg); color: var(--text); }
body {
    font-family: var(--font-sans);
    font-feature-settings: "ss01", "cv11";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.2s ease, color 0.2s ease;
}

* { scrollbar-color: var(--border-strong) var(--bg-muted); }

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

/* ─── Menu — solid, simple, with hairline border ─────────────── */
#menu {
    background: var(--menu-bg);
    border-bottom: 1px solid var(--menu-border);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
#menu.menu-color {
    background: var(--menu-bg);
}
#menu #desktop-menu .title,
#menu #desktop-menu a,
#menu #mobile-menu .title,
#menu #mobile-menu a,
#menu.menu-color #desktop-menu a,
#menu.menu-color #mobile-menu a,
#menu.menu-color #mobile-menu .title {
    color: var(--text);
    font-weight: 500;
}
#menu #desktop-menu .title { font-family: var(--font-serif); font-weight: 600; letter-spacing: 0.02em; }
#menu #desktop-menu a:hover, #menu #mobile-menu a:hover { color: var(--accent); }
#menu-curtain { background: rgba(0, 0, 0, 0.4); }

/* Theme toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    height: 32px;
    line-height: 1;
    margin-left: 16px;
    padding: 0 12px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.theme-toggle .fa-sun { display: none; }
[data-theme="dark"] .theme-toggle .fa-sun  { display: inline-block; }
[data-theme="dark"] .theme-toggle .fa-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .fa-sun  { display: inline-block; }
    :root:not([data-theme="light"]) .theme-toggle .fa-moon { display: none; }
}

/* ─── Hero ──────────────────────────────────────────────────── */
#home-head #home-info .loop:nth-child(1),
#home-head #home-info .loop:nth-child(3) { opacity: 0.16; }
#home-head #home-info .loop:nth-child(2),
#home-head #home-info .loop:nth-child(4) { opacity: 0.24; }

#home-head::after {
    background: linear-gradient(180deg, rgba(0,0,0,0.10) 0%, rgba(0,0,0,0.18) 60%, rgba(0,0,0,0.40) 100%);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 0;
}
#home-head #home-info { z-index: 1; }
#home-head #home-info .info { color: #fff; text-shadow: 0 2px 24px rgba(0, 0, 0, 0.4); }
#home-head #home-info .info .wrap h1 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em; }
#home-head #home-info .info .wrap h3 { font-weight: 400; opacity: 0.9; }
#home-head #home-info .info .wrap h5 { opacity: 0.75; font-weight: 400; }

/* ─── Post cards ────────────────────────────────────────────── */
#home-posts .post {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: none;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
#home-posts .post:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
#home-posts .post-title {
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 600;
    letter-spacing: -0.015em;
}
#home-posts .post .category-and-date { color: var(--text-muted); font-size: 13px; }
#home-posts .post .category-and-date .category a { color: var(--text-muted); }
#home-posts .post .category-and-date .category a:hover { color: var(--accent); }
#home-posts .post .description { color: var(--text-soft); }
#home-posts .post .description::after {
    background: linear-gradient(to bottom, rgba(0,0,0,0), var(--bg-elev));
}

/* "Read more" — solid accent, no gradient, less plastic. */
#home-posts .post .go-post {
    background: var(--accent);
    border-radius: var(--radius-md) 0;
    box-shadow: none;
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.02em;
}
#home-posts .post .go-post:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
    right: -5px;
}

#home-posts .post .post-tags .tag a { color: var(--accent); font-weight: 500; }

/* ─── Sidebar card ────────────────────────────────────────── */
#home-card #card-style,
#post-card #card-style {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: none;
}
#home-card #card-div .name,
#post-card #card-div .name {
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 600;
}
#home-card #card-div .description,
#post-card #card-div .description,
#home-card #card-div .latest-list a,
#post-card #card-div .latest-list a,
#home-card #card-div .friend-links a,
#post-card #card-div .friend-links a,
#home-card #card-div .icon-links a,
#post-card #card-div .icon-links a {
    color: var(--text-soft);
}
#home-card #card-div .latest-title,
#post-card #card-div .latest-title {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}
#home-card #card-div .latest-posts,
#post-card #card-div .latest-posts,
#home-card #card-div .icon-links,
#post-card #card-div .icon-links,
#home-card #card-div .friend-links,
#post-card #card-div .friend-links {
    border-top-color: var(--border);
}
#home-card #card-div .icon-links a:hover,
#home-card #card-div .friend-links a:hover,
#post-card #card-div .icon-links a:hover,
#post-card #card-div .friend-links a:hover {
    background: var(--accent-bg);
    color: var(--accent);
}
#home-card #card-div .avatar { border-color: var(--border); }

/* ─── Article reading surface ─────────────────────────────── */
/*
 * Give the article its own paper layer so reading isn't on the bare page
 * background. This is what makes long reads comfortable in both modes.
 */
#post-wrap.has-card .article {
    background: var(--bg-paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 56px;
}
@media (max-width: 900px) {
    #post-wrap.has-card .article {
        padding: 28px 22px;
        border-radius: var(--radius-md);
    }
}

.article { color: var(--text); font-size: 17px; line-height: 1.78; }
.article > div > h1 {
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5em;
}
.article .info { color: var(--text-muted); font-size: 14px; }
.article .info a { color: var(--text-muted); }
.article .info a:hover { color: var(--accent); }

.article .content {
    font-family: var(--font-sans);
    color: var(--text);
}
.article .content h1,
.article .content h2,
.article .content h3,
.article .content h4 {
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 700;
    letter-spacing: -0.015em;
    line-height: 1.3;
}
.article .content h2 { font-size: 1.6em; margin: 2.2em 0 0.6em; }
.article .content h3 { font-size: 1.3em; margin: 1.8em 0 0.5em; }
.article .content p { margin: 1em 0; }

.article .content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 30%, transparent);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}
.article .content a:hover {
    text-decoration-color: var(--accent);
}

.article .content code {
    background: var(--bg-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 0.88em;
    padding: 0.1em 0.4em;
}
.article .content pre code { background: transparent; border: 0; padding: 0; }
.article .content pre,
.article .content pre.hljs {
    background: var(--bg-muted) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.article .content blockquote {
    background: var(--bg-muted);
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-soft);
    margin: 1.4em 0;
    padding: 0.6em 1.2em;
}
.article .content hr {
    background: var(--border);
    border: 0;
    height: 1px;
    margin: 2.4em 0;
}

/* ─── Post nav ────────────────────────────────────────────── */
.post-nav-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: none;
}
.post-nav-item .label { color: var(--text-muted); }
.post-nav-item .title { color: var(--accent); font-family: var(--font-serif); font-weight: 600; }
.post-nav-item:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }

/* ─── Pagination ─────────────────────────────────────────── */
#home-posts .page-current .current { color: var(--rose); }
#home-posts .page-current a { color: var(--text-muted); }
#home-posts .page-current .page-num:hover { background: var(--accent); color: #fff; }

/* ─── Footer ─────────────────────────────────────────────── */
#footer #footer-wrap { border-top: 1px solid var(--border); color: var(--text-muted); }
#footer a { color: var(--accent); }

/* ─── ChaosBoard ─────────────────────────────────────────── */
#chaosboard h1, #chaosboard h3 {
    color: var(--text);
    font-family: var(--font-serif);
    font-weight: 600;
}
#chaosboard h1 i,
#chaosboard h3 i,
#chaosboard .form-group label i,
#chaosboard .message-avatar { color: var(--accent); }
#chaosboard .chaosboard-subtitle,
#chaosboard .message-date,
#chaosboard .pagination .page-info { color: var(--text-muted); }
#chaosboard .chaosboard-form,
#chaosboard .message-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    box-shadow: none;
}
#chaosboard .message-card:hover { box-shadow: var(--shadow-sm); }
#chaosboard .form-group input,
#chaosboard .form-group textarea {
    background: var(--bg-paper);
    border-color: var(--border);
    color: var(--text);
    font-family: var(--font-sans);
}
#chaosboard .form-group input::placeholder,
#chaosboard .form-group textarea::placeholder { color: var(--text-faint); }
#chaosboard .form-group input:focus,
#chaosboard .form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-bg);
}
#chaosboard .submit-btn {
    background: var(--accent);
    border-radius: var(--radius-sm);
    box-shadow: none;
}
#chaosboard .submit-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
#chaosboard .pagination button {
    background: var(--bg-elev);
    border-color: var(--border);
    color: var(--text);
}
#chaosboard .pagination button:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
#chaosboard .submit-status.success { background: var(--accent-bg); color: var(--accent-hover); border-color: var(--accent); }
#chaosboard .no-messages.load-error i { color: var(--rose); }
#chaosboard .no-messages.load-error p { color: var(--text-soft); }

/* ─── Tags / categories ──────────────────────────────────── */
#archives .categories-tags span a {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--text);
}
#archives .categories-tags span a:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ─── Generic search input ───────────────────────────────── */
.input {
    background: var(--bg-elev);
    border-color: var(--border);
    color: var(--text);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }

/* ─── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #home-head #home-info .loop { animation: none !important; }
    * { transition: none !important; }
}
