/* ============================================================
   LOW SIGNAL // reading-first theme
   Purple / gray. Serif display headings, humanist sans body,
   monospace for code. Light + dark. No external requests.
   ============================================================ */

/* ---------- design tokens ---------- */
:root {
    --paper:      #f6f5f8;   /* cool off-white gray */
    --paper-2:    #ecebf1;   /* raised gray surface */
    --ink:        #201d29;   /* near-black, faint purple */
    --ink-soft:   #494455;
    --ink-faint:  #7a7488;
    --rule:       #ddd9e6;   /* hairline rules */
    --accent:     #7c3aed;   /* violet */
    --accent-2:   #5b21b6;   /* deep violet (links hover) */
    --link:       #6d28d9;
    --danger:     #b4232a;
    --ok:         #3f7a63;
    --max:        44rem;     /* reading measure */
    --wide:       64rem;     /* header/footer/grids */
    --radius:     6px;
    --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono:  ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
    --paper:      #141220;   /* near-black gray, purple tint */
    --paper-2:    #1e1b2b;
    --ink:        #e8e5f0;
    --ink-soft:   #c0bad0;
    --ink-faint:  #857f97;
    --rule:       #2d2940;
    --accent:     #a78bfa;   /* light violet */
    --accent-2:   #c4b5fd;
    --link:       #b7a2f6;
    --danger:     #e0715f;
    --ok:         #7fb8a0;
}

/* ---------- reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 1.075rem;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background .25s ease, color .25s ease;
}

.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 1.25rem; }
main.wrap { max-width: var(--max); padding-top: 2.5rem; padding-bottom: 4rem; }

img { max-width: 100%; height: auto; }
hr { border: none; border-top: 1px solid var(--rule); margin: 2.5rem 0; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-2); }

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------- headings ---------- */
h1, h2, h3, h4 { font-family: var(--serif); line-height: 1.2; color: var(--ink); font-weight: 600; }

/* ---------- header ---------- */
.site-header {
    border-bottom: 1px solid var(--rule);
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(1.2) blur(6px);
}
.header-inner {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; padding-top: 1rem; padding-bottom: 1rem; flex-wrap: wrap;
}
.brand { text-decoration: none; color: var(--ink); display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-family: var(--serif); font-size: 1.4rem; font-weight: 700; letter-spacing: .01em; }
.brand-tag  { font-size: .78rem; color: var(--ink-faint); margin-top: .15rem; }
.site-nav { display: flex; align-items: center; gap: 1.4rem; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-size: .95rem; }
.site-nav a:hover { color: var(--accent); }
.site-nav a[aria-current="page"] { color: var(--accent); border-bottom: 2px solid var(--accent); }
.theme-toggle {
    background: none; border: 1px solid var(--rule); color: var(--ink-soft);
    border-radius: 50%; width: 2rem; height: 2rem; cursor: pointer; font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- flashes ---------- */
.flashes { margin-top: 1.25rem; }
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: .5rem; font-size: .95rem;
         border: 1px solid var(--rule); background: var(--paper-2); }
.flash-error   { border-color: color-mix(in srgb, var(--danger) 45%, var(--rule)); }
.flash-success { border-color: color-mix(in srgb, var(--ok) 45%, var(--rule)); }

/* ---------- home / hero ---------- */
.hero { padding: 1rem 0 2rem; border-bottom: 1px solid var(--rule); margin-bottom: 2.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.1rem); margin: 0 0 1rem; letter-spacing: -0.01em; }
.hero .lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 38rem; }
.hero .cta { margin-top: 1.75rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.btn {
    display: inline-block; text-decoration: none; font-size: .95rem;
    padding: .6rem 1.1rem; border-radius: var(--radius); border: 1px solid var(--ink);
    color: var(--ink); background: transparent; cursor: pointer;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }

.home-cards { display: grid; gap: 1.25rem; grid-template-columns: 1fr; margin: 2.5rem 0; }
@media (min-width: 40rem) { .home-cards { grid-template-columns: 1fr 1fr; } }
.home-card { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.4rem; background: var(--paper-2); }
.home-card h3 { margin: .1rem 0 .5rem; font-size: 1.15rem; }
.home-card p { margin: 0; color: var(--ink-soft); font-size: .98rem; }
.home-card .kicker { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-family: var(--mono); }

/* ---------- page headings ---------- */
.page-head { margin-bottom: 2rem; }
.page-head h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); margin: 0 0 .35rem; }
.page-head .sub { color: var(--ink-faint); font-family: var(--mono); font-size: .85rem; }

/* ---------- blog controls ---------- */
.blog-controls { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 2rem; }
.search-input {
    flex: 1 1 14rem; min-width: 0; padding: .55rem .8rem; font: inherit; font-size: .95rem;
    background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); color: var(--ink);
}
.search-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tag-filters { display: flex; flex-wrap: wrap; gap: .4rem; }
.tag-chip {
    font: inherit; font-size: .8rem; padding: .25rem .7rem; border-radius: 999px;
    border: 1px solid var(--rule); background: transparent; color: var(--ink-soft);
    text-decoration: none; cursor: pointer; font-family: var(--mono);
}
.tag-chip:hover { border-color: var(--accent); color: var(--accent); }
.tag-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- post list ---------- */
.post-list { list-style: none; margin: 0; padding: 0; }
.post-item { padding: 1.5rem 0; border-bottom: 1px solid var(--rule); }
.post-item:first-child { padding-top: 0; }
.post-item .meta { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); display: flex; gap: .8rem; flex-wrap: wrap; margin-bottom: .4rem; }
.post-item h2 { font-size: 1.5rem; margin: 0 0 .4rem; }
.post-item h2 a { color: var(--ink); text-decoration: none; }
.post-item h2 a:hover { color: var(--accent); }
.post-item .excerpt { margin: 0; color: var(--ink-soft); }
.post-item .tags { margin-top: .55rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.post-tag { font-family: var(--mono); font-size: .72rem; color: var(--ink-faint); }
.post-tag::before { content: "#"; opacity: .6; }
.empty { color: var(--ink-faint); font-style: italic; padding: 2rem 0; }

/* ---------- single post ---------- */
.back-link { font-family: var(--mono); font-size: .85rem; display: inline-block; margin-bottom: 1.5rem; text-decoration: none; }
.article-head { margin-bottom: 2rem; }
.article-head h1 { font-size: clamp(2rem, 5.5vw, 3rem); margin: 0 0 .6rem; letter-spacing: -0.01em; }
.article-head .meta { font-family: var(--mono); font-size: .82rem; color: var(--ink-faint); display: flex; gap: .9rem; flex-wrap: wrap; }
.article-draft-badge { color: #fff; background: var(--danger); padding: .05rem .5rem; border-radius: 4px; font-size: .72rem; }

.prose { font-size: 1.12rem; line-height: 1.75; }
.prose > * + * { margin-top: 1.25rem; }
.prose h2 { font-size: 1.6rem; margin-top: 2.5rem; }
.prose h3 { font-size: 1.3rem; margin-top: 2rem; }
.prose a { color: var(--link); }
.prose blockquote {
    margin: 1.5rem 0; padding: .3rem 0 .3rem 1.25rem; border-left: 3px solid var(--accent);
    color: var(--ink-soft); font-style: italic;
}
.prose code { font-family: var(--mono); font-size: .9em; background: var(--paper-2); padding: .12em .38em; border-radius: 4px; }
.prose pre {
    font-family: var(--mono); font-size: .88rem; line-height: 1.5; overflow-x: auto;
    background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1rem 1.15rem;
}
.prose pre code { background: none; padding: 0; }
.prose img { border-radius: var(--radius); display: block; margin: 1.5rem auto; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .35rem; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--rule); padding: .5rem .7rem; text-align: left; }
.prose figure { margin: 1.5rem 0; }
.prose figcaption { font-size: .85rem; color: var(--ink-faint); text-align: center; margin-top: .4rem; }
.source-credit { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); margin-top: 2rem; }

.post-tags-footer { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); display: flex; gap: .5rem; flex-wrap: wrap; }
.post-tags-footer a { font-family: var(--mono); font-size: .8rem; text-decoration: none; color: var(--ink-faint); }
.post-tags-footer a:hover { color: var(--accent); }

/* ---------- comments ---------- */
.comments { margin-top: 3.5rem; padding-top: 2rem; border-top: 2px solid var(--rule); }
.comments h2 { font-size: 1.5rem; margin: 0 0 1.5rem; }
.comment-list { list-style: none; margin: 0 0 2.5rem; padding: 0; }
.comment { padding: 1.1rem 0; border-bottom: 1px solid var(--rule); }
.comment .who { font-weight: 600; }
.comment .when { font-family: var(--mono); font-size: .75rem; color: var(--ink-faint); margin-left: .5rem; }
.comment .body { margin: .4rem 0 0; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: break-word; }
.no-comments { color: var(--ink-faint); font-style: italic; margin-bottom: 2rem; }

.comment-form { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.4rem; }
.comment-form h3 { margin: 0 0 1rem; font-size: 1.2rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .85rem; color: var(--ink-soft); margin-bottom: .3rem; font-family: var(--mono); }
.field input, .field textarea {
    width: 100%; font: inherit; font-size: .98rem; padding: .55rem .7rem; color: var(--ink);
    background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
}
.field textarea { min-height: 8rem; resize: vertical; }
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-note { font-size: .8rem; color: var(--ink-faint); }

/* ---------- watch ---------- */
.watch-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 48rem) { .watch-grid { grid-template-columns: 1fr 1fr; } }
.watch-panel { border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem 1.4rem; background: var(--paper-2); }
.watch-panel.foes { grid-column: 1 / -1; }
.watch-panel h3 { margin: 0 0 1rem; font-size: 1.2rem; display: flex; align-items: center; gap: .5rem; }
.watch-panel.foes h3 { color: var(--danger); }
.watch-list { list-style: none; margin: 0; padding: 0; }
.watch-item { padding: .7rem 0; border-bottom: 1px solid var(--rule); }
.watch-item:last-child { border-bottom: none; }
.watch-item .name { font-weight: 600; }
.watch-item .desc { color: var(--ink-soft); font-size: .93rem; }
.watch-item .desc a { font-size: .85rem; }
.watch-item a.ext { font-family: var(--mono); font-size: .82rem; text-decoration: none; }
.watch-item a.ext:hover { text-decoration: underline; }

/* ---------- contact ---------- */
.contact-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
@media (min-width: 44rem) { .contact-grid { grid-template-columns: 1fr; } }
.contact-list { list-style: none; margin: 0; padding: 0; }
.contact-list li { padding: .8rem 0; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.contact-list .label { font-family: var(--mono); font-size: .82rem; color: var(--ink-faint); }
.contact-list .value a { text-decoration: none; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--rule); margin-top: 4rem; padding: 2rem 0; color: var(--ink-faint); font-size: .88rem; }
.site-footer p { margin: .3rem 0; }
.footer-links a { text-decoration: none; color: var(--ink-faint); }
.footer-links a:hover { color: var(--accent); }

/* ---------- 404 ---------- */
.notfound { text-align: center; padding: 4rem 0; }
.notfound .code { font-family: var(--mono); font-size: 4rem; color: var(--accent); }
