/* aniicrite.dev — hand-rolled editorial theme. Dark default + light toggle. */

:root {
  --font-serif: "Iowan Old Style", "Charter", "Palatino", Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --measure: 66ch;
  --gap: 1.5rem;
  --radius: 6px;
}

/* Dark (default) */
:root, [data-theme="dark"] {
  --bg: #14161a;
  --bg-soft: #1c1f25;
  --border: #2a2e37;
  --fg: #e6e8ec;
  --fg-muted: #9aa2ad;
  --accent: #e0895b;
  --accent-fg: #14161a;
  --mark: #4a3b1e;
}

[data-theme="light"] {
  --bg: #fbfaf7;
  --bg-soft: #f2f0ea;
  --border: #e2ddd2;
  --fg: #23252a;
  --fg-muted: #6b7079;
  --accent: #b8541f;
  --accent-fg: #fbfaf7;
  --mark: #f6e6b8;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Kill theme-flip flash: toggled off after first paint. */
.notransition * { transition: none !important; }
body, a, .tag, button, input, textarea { transition: background-color .2s, color .2s, border-color .2s; }

.wrap { max-width: 46rem; margin: 0 auto; padding: 0 1.25rem; }

/* ---- Header / nav ---- */
.site-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}
.nav {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 1.25rem 0;
  font-family: var(--font-sans);
}
.nav .brand {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}
.nav a { color: var(--fg); text-decoration: none; }
.nav .links { display: flex; gap: 1rem; margin-left: auto; align-items: baseline; }
.nav .links a { color: var(--fg-muted); font-size: 0.95rem; }
.nav .links a:hover, .nav .links a.active { color: var(--accent); }

#theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--fg-muted);
  border-radius: var(--radius); cursor: pointer; padding: 0.25rem 0.55rem;
  font-family: var(--font-sans); font-size: 0.85rem;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---- Typography ---- */
h1, h2, h3, h4 { font-family: var(--font-sans); line-height: 1.25; letter-spacing: -0.02em; }
h1 { font-size: 2.1rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.5rem; margin: 2.5rem 0 0.75rem; }
h3 { font-size: 1.2rem; margin: 2rem 0 0.5rem; }
a { color: var(--accent); text-underline-offset: 2px; }
p, ul, ol { margin: 0 0 1.25rem; }

.muted { color: var(--fg-muted); }
.meta { font-family: var(--font-sans); font-size: 0.85rem; color: var(--fg-muted); }

/* ---- Home intro ---- */
.intro { display: flex; gap: 1.25rem; align-items: center; margin-bottom: 3rem; }
.intro img { width: 84px; height: 84px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border); }
.intro h1 { margin: 0 0 0.25rem; font-size: 1.6rem; }
.intro p { margin: 0; color: var(--fg-muted); font-size: 1rem; }

/* ---- Post lists ---- */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li { padding: 1rem 0; border-bottom: 1px solid var(--border); }
.post-list a { color: var(--fg); text-decoration: none; font-family: var(--font-sans); font-weight: 600; font-size: 1.15rem; }
.post-list a:hover { color: var(--accent); }
.post-list .summary { color: var(--fg-muted); font-size: 0.98rem; margin: 0.35rem 0 0; }
.section-label { font-family: var(--font-sans); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--fg-muted); margin: 0 0 0.5rem; }

/* ---- Tags ---- */
.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.5rem 0; }
.tag {
  font-family: var(--font-sans); font-size: 0.75rem; color: var(--fg-muted);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 0.1rem 0.5rem; border-radius: 999px;
}

/* ---- Article ---- */
article.post img { max-width: 100%; height: auto; border-radius: var(--radius); }
article.post .cover { width: 100%; margin: 1.5rem 0; }
.post pre {
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; overflow-x: auto;
  font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.5;
  /* background comes from chroma.css (.chroma), so it follows the theme */
}
article.post code { font-family: var(--font-mono); font-size: 0.88em; }
article.post :not(pre) > code { background: var(--bg-soft); padding: 0.1rem 0.35rem; border-radius: 4px; }
article.post blockquote { border-left: 3px solid var(--accent); margin: 1.25rem 0; padding: 0.25rem 1rem; color: var(--fg-muted); }
article.post table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
article.post th, article.post td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }

/* ---- Search ---- */
.search-box { width: 100%; padding: 0.6rem 0.8rem; font-size: 1rem; font-family: var(--font-sans);
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg); border-radius: var(--radius); }
.search-box:focus { outline: none; border-color: var(--accent); }
.search-results { margin-top: 1rem; }
.search-results mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }
.htmx-indicator { opacity: 0; transition: opacity .2s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---- Comments ---- */
.comments { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 1.5rem; }
.comment { display: flex; gap: 0.75rem; padding: 0.9rem 0; border-bottom: 1px solid var(--border); }
.comment img { width: 36px; height: 36px; border-radius: 50%; }
.comment .who { font-family: var(--font-sans); font-weight: 600; font-size: 0.9rem; }
.comment .body { margin: 0.15rem 0 0; font-size: 0.98rem; }

/* ---- Forms / buttons ---- */
.btn {
  display: inline-block; font-family: var(--font-sans); font-size: 0.9rem; cursor: pointer;
  background: var(--accent); color: var(--accent-fg); border: none;
  padding: 0.5rem 1rem; border-radius: var(--radius); text-decoration: none;
}
.btn.secondary { background: var(--bg-soft); color: var(--fg); border: 1px solid var(--border); }
.btn:hover { opacity: 0.9; }
label { display: block; font-family: var(--font-sans); font-size: 0.85rem; color: var(--fg-muted); margin: 1rem 0 0.3rem; }
input[type=text], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%; padding: 0.55rem 0.7rem; font-size: 1rem; font-family: var(--font-sans);
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg); border-radius: var(--radius);
}
textarea { font-family: var(--font-mono); font-size: 0.9rem; line-height: 1.5; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 1rem; }
.form-row > * { flex: 1; }

/* ---- Admin ---- */
.admin-bar { background: var(--bg-soft); border-bottom: 1px solid var(--border); font-family: var(--font-sans); }
.admin-bar .nav .links a { font-size: 0.9rem; }
.admin-table { width: 100%; border-collapse: collapse; font-family: var(--font-sans); font-size: 0.95rem; }
.admin-table th, .admin-table td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
.admin-table .actions { display: flex; gap: 0.5rem; }
.badge { font-size: 0.7rem; padding: 0.1rem 0.45rem; border-radius: 999px; background: var(--bg-soft); border: 1px solid var(--border); color: var(--fg-muted); }
.badge.published { color: var(--accent); border-color: var(--accent); }
.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.preview { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; background: var(--bg-soft); overflow-y: auto; max-height: 60vh; }
.flash { padding: 0.6rem 0.9rem; border-radius: var(--radius); margin-bottom: 1rem; font-family: var(--font-sans); font-size: 0.9rem; }
.flash.error { background: #3a1f22; color: #f0b4b4; border: 1px solid #6b2f34; }

/* ---- Footer ---- */
.site-footer { border-top: 1px solid var(--border); margin-top: 4rem; padding: 2rem 0; color: var(--fg-muted); font-family: var(--font-sans); font-size: 0.85rem; }
.site-footer .socials { display: flex; gap: 1rem; margin-bottom: 0.75rem; }
.site-footer a { color: var(--fg-muted); }
.site-footer a:hover { color: var(--accent); }

.pagination { display: flex; justify-content: space-between; margin: 2rem 0; font-family: var(--font-sans); }

@media (max-width: 640px) {
  body { font-size: 1.05rem; }
  .editor-grid { grid-template-columns: 1fr; }
  .intro { flex-direction: column; text-align: center; }
}
