/* ===== Tokens ===== */
/* Light: "paper" (default) */
:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --panel: #e7e1d7;
  --border: #c9c0b2;
  --text: #2a2a2a;
  --muted: #5e5a54;
  --accent: #b5542a;
  --accent-hover: #93421f;
  --tint: rgba(0, 0, 0, .04);
  --tint-strong: rgba(0, 0, 0, .08);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* Dark: "midnight". Only when the visitor picks it with the toggle. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171f;
  --panel: #1f2430;
  --border: #343b4c;
  --text: #e6e8ee;
  --muted: #9aa3b5;
  --accent: #4f86c6;
  --accent-hover: #6fa0da;
  --tint: rgba(255, 255, 255, .03);
  --tint-strong: rgba(255, 255, 255, .07);
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 var(--sans);
  overflow-wrap: break-word;
}
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 1.5rem; margin: 1.25rem 0 .5rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
a { color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
code, pre { font-family: var(--mono); font-size: .9em; }
code { background: var(--tint-strong); padding: .1em .35em; }
pre { background: var(--tint-strong); padding: 1rem; overflow-x: auto; }
pre code { background: none; padding: 0; }
blockquote { margin: 1.5rem 0; padding: .25rem 0 .25rem 1rem; border-left: 3px solid var(--accent); color: var(--muted); font-style: italic; }
img { max-width: 100%; height: auto; }
time { color: var(--muted); font-family: var(--mono); font-size: .85rem; }

/* ===== Header + menu ===== */
.top { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; padding: 1rem 16px .5rem; }
.site-name { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; text-decoration: none; }
.tagline { color: var(--muted); font-size: .9rem; }
.menu {
  display: flex; flex-wrap: wrap; gap: 0 1.25rem;
  padding: .35rem 16px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: .95rem;
}
.menu a { font-weight: 600; text-decoration: none; }
.menu a:hover, .menu a[aria-current] { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent); }

/* ===== Theme toggle ===== */
.theme-toggle {
  margin-left: auto;
  font: 600 .95rem var(--sans);
  color: var(--text);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--accent-hover); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Content ===== */
.main { padding: .5rem 16px 2rem; max-width: 85ch; }
.meta { margin-top: 0; }
.post-list { padding-left: 1.5rem; }
.post-list li { margin: .2rem 0; }

/* ===== Footer ===== */
.foot { padding: .5rem 16px; border-top: 1px solid var(--panel); color: var(--muted); font-size: .85rem; }

/* ===== Posts page: large previews ===== */
.previews { display: grid; gap: 1.25rem; margin-top: 1rem; }
.preview { padding: 1.25rem 1.5rem; background: var(--tint); border-left: 4px solid var(--accent); }
.preview h2 { font-size: 1.5rem; margin: .25rem 0 .4rem; }
.preview h2 a { text-decoration: none; }
.preview h2 a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.preview .summary { font-size: 1.1rem; font-weight: 600; margin: 0 0 .5rem; }
.preview .excerpt { color: var(--muted); margin: 0 0 .75rem; }
.preview .more { font-weight: 600; }

/* ===== Projects: selectable tiles ===== */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 1rem; margin-top: 1.25rem; }
.project {
  display: flex; flex-direction: column; gap: .4rem;
  padding: 1.25rem;
  background: var(--tint);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: border-color .15s, background-color .15s, transform .15s;
}
.project:hover, .project:focus-visible { border-color: var(--accent); background: var(--tint-strong); color: var(--text); transform: translateY(-2px); }
.project:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.project h2 { font-size: 1.15rem; margin: 0; }
.project p { margin: 0; color: var(--muted); }
.project .tech { margin-top: auto; font-family: var(--mono); font-size: .8rem; color: var(--accent-hover); }

/* ===== Drafts (only ever seen in local preview) ===== */
.draft {
  font: 600 .7rem var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .1em .45em;
  vertical-align: middle;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.draft-banner {
  margin: 1rem 0 0;
  padding: .4rem .75rem;
  font: .85rem var(--mono);
  color: var(--accent);
  border: 1px dashed var(--accent);
}
