/* =====================================================================
   A New Error — stylesheet
   Direction B "Ledger": monospace date gutter + hanging entries.
   Serif (Spectral) body, Helvetica UI, IBM Plex Mono dates.
   Auto light/dark via prefers-color-scheme + manual [data-theme] override.
   ===================================================================== */

:root {
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* fixed content measure (the site never goes full-bleed) */
  --measure: 760px;   /* ledger pages: date gutter + entry */
  --read: 680px;      /* reading column for posts */
  --pad: 34px;
  --gutter: 104px;    /* width of the date column */
}

/* ---- Light (default) ---- */
:root, :root[data-theme="light"] {
  --bg:     #FAFBFC;  /* cool near-white */
  --ink:    #1B2027;  /* cool near-black */
  --muted:  #69717C;  /* secondary text */
  --faint:  #99A1AC;  /* dates, labels */
  --rule:   #E6E9EF;  /* hairlines */
  --rule-2: #b6b9be;
  --accent: #1463C7;  /* AA blue on --bg */
  --accent-hover: #0F4FA3;
  --field:  #F1F3F6;  /* subtle fill (toggle, code) */
}

/* ---- Dark ---- */
:root[data-theme="dark"] {
  --bg:     #14171C;
  --ink:    #E2E6EC;
  --muted:  #9AA2AD;
  --faint:  #69717C;
  --rule:   #262B32;
  --rule-2: #5e6670;
  --accent: #6FA9F2;  /* AA blue on dark --bg */
  --accent-hover: #97C1F8;
  --field:  #1D2128;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:     #14171C;
    --ink:    #E2E6EC;
    --muted:  #9AA2AD;
    --faint:  #69717C;
    --rule:   #262B32;
    --rule-2: #5e6670;
    --accent: #6FA9F2;
    --accent-hover: #97C1F8;
    --field:  #1D2128;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

::selection { background: color-mix(in oklab, var(--accent) 22%, transparent); }

a { color: inherit; }

/* ---------- shell / responsive width ---------- */
.shell {
  width: 100%;
  max-width: var(--measure);
  margin-inline: auto;
  padding-inline: var(--pad);
}
.page { min-height: 100vh; display: flex; flex-direction: column; }
.page > main { flex: 1 0 auto; }

/* =====================================================================
   Top navigation
   ===================================================================== */
.nav {
  font-family: var(--sans);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 38px 0 18px;
  border-bottom: 1px solid var(--rule);
}
.nav.minimal { border-bottom: none; padding-bottom: 0; }

.mast {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.005em;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.mast:hover { color: var(--accent); }

.nav-links {
  display: flex;
  align-items: baseline;
  gap: 26px;
}
.nav-links a, .iconbtn {
  font-family: var(--sans);
  font-size: 13.5px;
  letter-spacing: 0.01em;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.nav-links a:hover, .iconbtn:hover { color: var(--accent); }
.nav-links a.active { color: var(--ink); }

.nav-tools { display: flex; align-items: center; gap: 18px; }

.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  color: var(--muted);
}
.iconbtn:hover { color: var(--accent); background: var(--field); }
.iconbtn svg { width: 15px; height: 15px; display: block; }

/* hamburger — hidden on desktop */
.hamburger { display: none; }
.mobile-menu { display: none; }

/* =====================================================================
   About
   ===================================================================== */
.about { padding: 56px 0 80px; max-width: var(--read); }
.about h1 {
  font-family: var(--serif); font-size: 32px; font-weight: 600;
  letter-spacing: -0.012em; color: var(--ink); margin: 0 0 28px;
}
.about p { font-size: 19px; line-height: 1.66; margin: 0 0 1.2em; color: var(--ink); }
.about p .muted { color: var(--muted); }
.about .meta {
  font-family: var(--sans); font-size: 13px; color: var(--faint);
  margin-top: 36px; padding-top: 20px; border-top: 1px solid var(--rule);
  display: flex; gap: 22px; flex-wrap: wrap;
}
.about .meta a { color: var(--muted); text-decoration: none; }
.about .meta a:hover { color: var(--accent); }

/* =====================================================================
   Footer
   ===================================================================== */
.foot {
  font-family: var(--sans);
  border-top: 1px solid var(--rule);
  margin-top: 20px;
  padding: 22px 0 40px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  font-size: 12.5px;
  color: var(--faint);
  flex: 0 0 auto;
}
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--accent); }
.foot .rss-link { display: inline-flex; align-items: center; gap: 7px; }

/* =====================================================================
   Mobile
   ===================================================================== */
@media (max-width: 640px) {
  :root { --pad: 22px; --gutter: 74px; }
  body { font-size: 17px; }

  .nav-links { display: none; }
  .hamburger { display: inline-flex; }

  .mobile-menu {
    display: none;
    font-family: var(--sans);
  }
  .mobile-menu.open {
    display: flex; flex-direction: column;
    gap: 2px;
    padding: 8px 0 14px;
    border-bottom: 1px solid var(--rule);
  }
  .mobile-menu a, .mobile-menu button {
    font-family: var(--sans);
    text-align: left;
    background: none; border: none; cursor: pointer;
    color: var(--ink);
    font-size: 16px;
    padding: 12px 4px;
    text-decoration: none;
    border-radius: 6px;
  }
  .mobile-menu a:hover, .mobile-menu button:hover { color: var(--accent); }
  .mobile-menu .row { display: flex; align-items: center; gap: 10px; }
}

/* =====================================================================
   Icon swaps — handled in CSS here (React did this with component state)
   ===================================================================== */
/* theme toggle: moon in light, sun in dark */
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: block; }
}

/* hamburger: bars when closed, X when open */
.hamburger .ico-close { display: none; }
.hamburger.is-open .ico-bars { display: none; }
.hamburger.is-open .ico-close { display: block; }

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
