/* ============================================================================
   blogfor.net — "literary field notes for engineers"
   Editorial essay aesthetic: warm paper, oxblood accent, Fraunces + Newsreader
   display/body serifs, IBM Plex Mono for technical signals.
   Theme vars (--bg/--fg/--muted/--accent/--border/--code-bg) are also consumed
   by annotate.css, so keep them defined in every theme.
   ========================================================================== */

:root {
  --bg: #f6f1e6;          /* warm ivory paper */
  --fg: #211c15;          /* warm near-black ink */
  --muted: #7c7163;       /* warm taupe */
  --accent: #9d2933;      /* oxblood */
  --accent-soft: rgba(157, 41, 51, 0.12);
  --border: #e2d9c8;      /* warm hairline */
  --code-bg: #241f18;     /* dark code island */

  --serif-display: "Fraunces", Georgia, "Times New Roman", serif;
  --serif-body: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 40rem;       /* reading column */
  --gutter: 1.5rem;
}
:root[data-theme="dark"] {
  --bg: #15110b;
  --fg: #ece3d3;
  --muted: #9b8f7e;
  --accent: #e6857d;
  --accent-soft: rgba(230, 133, 125, 0.14);
  --border: #322a1f;
  --code-bg: #0f0c07;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #15110b;
    --fg: #ece3d3;
    --muted: #9b8f7e;
    --accent: #e6857d;
    --accent-soft: rgba(230, 133, 125, 0.14);
    --border: #322a1f;
    --code-bg: #0f0c07;
  }
}

* { box-sizing: border-box; }

html { border-top: 3px solid var(--accent); }   /* signature accent rule */

body {
  margin: 0;
  font-family: var(--serif-body);
  font-optical-sizing: auto;
  font-size: clamp(1.06rem, 1rem + 0.3vw, 1.2rem);
  line-height: 1.72;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
main a { text-decoration-color: var(--border); transition: text-decoration-color .15s ease; }
main a:hover { text-decoration-color: var(--accent); }

/* ---- shared horizontal frame ---- */
.masthead, main, .colophon {
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--gutter);
}
main { padding-block: 1.5rem 5rem; }

/* ---- masthead ---- */
.masthead {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: 1.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.wordmark {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
  color: var(--fg);
  text-decoration: none;
}
.wordmark::after {
  content: ""; display: inline-block;
  width: 0.4rem; height: 0.4rem; margin-left: 0.18rem;
  background: var(--accent); border-radius: 1px;
  vertical-align: 0.05em;
}
#theme-toggle {
  font-family: var(--mono); font-size: 0.95rem; line-height: 1;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: none; border: 1px solid var(--border); color: var(--muted);
  cursor: pointer; transition: color .15s ease, border-color .15s ease;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

/* ---- shared editorial bits ---- */
.eyebrow, .section-label {
  font-family: var(--mono);
  font-size: 0.72rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--accent);
  margin: 0;
}
.post-date {
  font-family: var(--mono);
  font-size: 0.74rem; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0.5rem 0 0;
}
.post-title {
  font-family: var(--serif-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.018em;
  margin: 0.4rem 0 0;
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.7rem);
}

/* ---- featured essay ---- */
.featured { padding-top: 0.5rem; }
.featured .post-title { font-size: clamp(2.2rem, 1.6rem + 3vw, 3.3rem); }
.post-body { margin-top: 1.75rem; }
.post-body p { margin: 0 0 1.25rem; }
.post-body img { max-width: 100%; height: auto; border-radius: 2px; }
.post-body h2, .post-body h3 {
  font-family: var(--serif-display); font-weight: 600;
  letter-spacing: -0.01em; line-height: 1.2;
  margin: 2.25rem 0 0.6rem;
}
.post-body h2 { font-size: 1.5rem; }
.post-body h3 { font-size: 1.2rem; }
.post-body blockquote {
  margin: 1.5rem 0; padding-left: 1.1rem;
  border-left: 2px solid var(--accent);
  color: var(--muted); font-style: italic;
}

/* drop cap on the opening paragraph of any essay */
.featured .post-body > p:first-of-type::first-letter,
.post .post-body > p:first-of-type::first-letter {
  font-family: var(--serif-display);
  font-weight: 600;
  float: left;
  font-size: 3.4em;
  line-height: 0.78;
  padding: 0.05em 0.08em 0 0;
  color: var(--accent);
}

/* ---- single post page ---- */
.post .back {
  margin-top: 3rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.78rem;
  letter-spacing: 0.04em; text-transform: uppercase;
}

/* ---- section dividers (recent / projects / index) ---- */
.recent, .projects, .all-posts {
  margin-top: 3.5rem; padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.section-label { margin-bottom: 1.25rem; }

/* ---- post index: hanging mono dates ---- */
.post-list { list-style: none; padding: 0; margin: 0; }
.post-list li {
  display: grid;
  grid-template-columns: 6rem 1fr;
  column-gap: 1.25rem;
  align-items: baseline;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}
.post-list li:first-child { border-top: 1px solid var(--border); }
.post-list li a {
  grid-column: 2; grid-row: 1;
  font-family: var(--serif-display); font-weight: 600;
  font-size: 1.15rem; letter-spacing: -0.01em;
  color: var(--fg); text-decoration: none;
}
.post-list li a:hover { color: var(--accent); }
.post-list .meta {
  grid-column: 1; grid-row: 1;
  font-family: var(--mono); font-size: 0.7rem;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding-top: 0.18rem;
}
.post-list .blurb {
  grid-column: 2; grid-row: 2;
  color: var(--muted); font-size: 0.95rem; margin: 0.3rem 0 0;
}

/* ---- projects colophon ---- */
.project-list { list-style: none; padding: 0; margin: 0; }
.project-list li { margin: 0 0 0.85rem; line-height: 1.5; }
.project-list li a {
  font-family: var(--serif-display); font-weight: 600;
  color: var(--fg); text-decoration: none;
}
.project-list li a:hover { color: var(--accent); }
.project-list .blurb { color: var(--muted); font-size: 0.95rem; }

/* ---- code ---- */
pre {
  background: var(--code-bg); color: #ece3d3;
  padding: 1.1rem 1.25rem; border-radius: 4px; overflow-x: auto;
  font-size: 0.86rem; line-height: 1.6;
}
code { font-family: var(--mono); font-size: 0.88em; }
:not(pre) > code {
  background: var(--accent-soft); color: var(--fg);
  padding: 0.08em 0.34em; border-radius: 3px;
}

/* ---- display equation ---- */
.eq {
  font-family: var(--mono);
  text-align: center;
  font-size: 1.02rem;
  line-height: 1.7;
  margin: 2rem 0;
  padding: 1.25rem 0.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}
.eq b { color: var(--accent); font-weight: 500; }
.eq i { color: var(--muted); font-style: normal; }

/* ---- colophon / footer ---- */
.colophon {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  margin-top: 4rem; padding-block: 1.5rem 3rem;
  border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.74rem;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
}
.colophon a { color: var(--muted); text-decoration: none; }
.colophon a:hover { color: var(--accent); }
.colophon-mark { color: var(--fg); }

/* ---- staggered load-in ---- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: none; }
  }
  .masthead, .featured > *, .recent, .projects, .all-posts, .post > * {
    animation: rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  }
  .masthead { animation-delay: 0s; }
  .featured .eyebrow { animation-delay: 0.06s; }
  .featured .post-title { animation-delay: 0.12s; }
  .featured .post-date { animation-delay: 0.18s; }
  .featured .post-body { animation-delay: 0.24s; }
  .recent { animation-delay: 0.3s; }
  .projects { animation-delay: 0.36s; }
}

/* ---- narrow screens: stack the hanging date ---- */
@media (max-width: 34rem) {
  .post-list li { grid-template-columns: 1fr; }
  .post-list .meta { grid-column: 1; grid-row: 1; padding-top: 0; }
  .post-list li a { grid-column: 1; grid-row: 2; margin-top: 0.15rem; }
  .post-list .blurb { grid-column: 1; grid-row: 3; }
}
