/* ============================================================
   t15n — stylesheet
   Confirmed: Warm paper · Uniform compact header · 680px · 17px body
   Charter for headings + body. Inter for UI.
   IBM Plex Mono for kickers, wordmark, code, meta.
   ============================================================ */

/* --- Charter — self-hosted (1992 Bitstream X Consortium) --- */
@font-face { font-family: 'Charter'; src: url('/fonts/charter/charter_regular.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap }
@font-face { font-family: 'Charter'; src: url('/fonts/charter/charter_italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap }
@font-face { font-family: 'Charter'; src: url('/fonts/charter/charter_bold.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap }
@font-face { font-family: 'Charter'; src: url('/fonts/charter/charter_bold_italic.woff2') format('woff2'); font-weight: 700; font-style: italic; font-display: swap }

/* --- Inter — self-hosted variable font (SIL OFL 1.1) --- */
@font-face { font-family: 'Inter'; src: url('/fonts/inter/inter-variable.woff2') format('woff2'); font-weight: 100 900; font-style: normal; font-display: swap }

/* --- IBM Plex Mono — self-hosted (SIL OFL 1.1) --- */
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono/ibm-plex-mono-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono/ibm-plex-mono-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap }
@font-face { font-family: 'IBM Plex Mono'; src: url('/fonts/ibm-plex-mono/ibm-plex-mono-600.woff2') format('woff2'); font-weight: 600; font-style: normal; font-display: swap }

/* --- Design tokens: light (warm paper) --- */
:root {
  --bg:      #faf9f7;
  --bg2:     #f2f0ed;
  --bg3:     #e8e5e0;
  --fg:      #1c1b19;
  --fg2:     #3d3a36;
  --fg3:     #726e69;
  --fg4:     #a09c96;
  --border:  #ddd9d3;
  --border2: #b8b3ac;

  --font-serif: 'Charter', Georgia, 'Times New Roman', serif;
  --font-ui:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'IBM Plex Mono', ui-monospace, 'SF Mono', Consolas, 'Courier New', monospace;

  --reading-width: 680px;
  --body-size: 17px;

  /* Header: uniform — matches page temperature */
  --hdr-bg:       var(--bg);
  --hdr-border:   var(--border);
  --hdr-fg:       var(--fg);
  --hdr-dim:      var(--fg3);
  --hdr-hover:    var(--fg);
  --hdr-navhover: rgba(28,27,25,0.06);
}

/* --- Design tokens: dark --- */
[data-theme="dark"] {
  --bg:      #161513;
  --bg2:     #1f1d1a;
  --bg3:     #272420;
  --fg:      #e8e5e0;
  --fg2:     #a09c96;
  --fg3:     #6a6660;
  --fg4:     #3f3c39;
  --border:  #2e2b28;
  --border2: #454240;
  --hdr-dim: #908b85;
  --hdr-navhover: rgba(232,229,224,0.07);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:      #161513;
    --bg2:     #1f1d1a;
    --bg3:     #272420;
    --fg:      #e8e5e0;
    --fg2:     #a09c96;
    --fg3:     #6a6660;
    --fg4:     #3f3c39;
    --border:  #2e2b28;
    --border2: #454240;
    --hdr-dim: #908b85;
    --hdr-navhover: rgba(232,229,224,0.07);
  }
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* --- Base --- */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  font-size: var(--body-size);
  line-height: 1.85;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.22s, color 0.18s;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.page { flex: 1; }
::selection { background: var(--fg); color: var(--bg); }

/* ================================================================
   HEADER — uniform, compact (42px)
================================================================ */
header {
  background: var(--hdr-bg);
  border-bottom: 1px solid var(--hdr-border);
  padding: 0 44px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color 0.22s, border-color 0.18s;
}

.header-left { display: flex; align-items: baseline; gap: 9px; }

.wordmark {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--hdr-fg);
  text-decoration: none;
  border-bottom: none;
  letter-spacing: 0.03em;
  line-height: 1;
  transition: opacity 0.14s;
}
.wordmark:hover { opacity: 0.75; border-bottom: none; }

.header-sep { color: var(--hdr-dim); font-size: 11px; user-select: none; line-height: 1; }

.header-name {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--hdr-dim);
  letter-spacing: 0.02em;
}

.header-nav { display: flex; align-items: center; gap: 2px; }

.header-nav a {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--hdr-dim);
  text-decoration: none;
  border-bottom: none;
  padding: 4px 7px;
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  letter-spacing: 0.04em;
}
.header-nav a:hover { color: var(--hdr-hover); background: var(--hdr-navhover); border-bottom: none; }

.theme-btn {
  background: none;
  border: 1px solid var(--hdr-border);
  border-radius: 5px;
  color: var(--hdr-dim);
  cursor: pointer;
  padding: 4px 5px;
  margin-left: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}
.theme-btn:hover { color: var(--hdr-hover); background: var(--hdr-navhover); }
.theme-btn svg { width: 11px; height: 11px; display: block; }

/* ================================================================
   PAGE SHELL
================================================================ */
.page {
  max-width: calc(var(--reading-width) + 80px);
  margin: 0 auto;
  padding: 72px 40px 120px;
}

/* ================================================================
   LINKS
================================================================ */
a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid var(--border2);
  transition: border-color 0.12s, color 0.12s;
}
a:hover { border-bottom-color: var(--fg); }
p a, li a { border-bottom-color: var(--fg); }
p a:hover, li a:hover { opacity: 0.75; }

/* ================================================================
   ARTICLE + TYPOGRAPHY
================================================================ */
article { max-width: var(--reading-width); }

.kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--fg3);
  margin-bottom: 24px;
}

/* ----------------------------------------------------------------
   Aside tooltip — date reveal. No visible cue on the anchor itself;
   the styled card is the only signal. Desktop: hover. Touch: tap to
   toggle (a small script in chrome.ts manages the `.is-revealed` class).
---------------------------------------------------------------- */
.aside-anchor {
  position: relative;
}

.aside-anchor::after {
  content: attr(data-aside);
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 50;
  width: max-content;
  max-width: 320px;
  padding: 10px 14px;
  background: var(--bg2);
  color: var(--fg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  white-space: pre-line;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

@media (hover: hover) {
  .aside-anchor:hover::after {
    opacity: 1;
    transition-delay: 0.05s;
  }
}

@media (hover: none) {
  .aside-anchor.is-revealed::after {
    opacity: 1;
    transition-delay: 0.05s;
  }
}

@media (max-width: 480px) and (hover: none) {
  .aside-anchor::after {
    position: fixed;
    top: var(--aside-top, 100%);
    left: 20px;
    right: 20px;
    width: auto;
    max-width: none;
  }
}

h1 {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.016em;
  color: var(--fg);
  margin-bottom: 28px;
  max-width: var(--reading-width);
  text-wrap: pretty;
}

h2 {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.24;
  letter-spacing: -0.007em;
  color: var(--fg);
  margin: 64px 0 16px;
  max-width: var(--reading-width);
  scroll-margin-top: 56px;
}

h3 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--fg);
  margin: 40px 0 10px;
}

p {
  font-family: var(--font-serif);
  color: var(--fg);
  margin-bottom: 1.6em;
  max-width: var(--reading-width);
  text-wrap: pretty;
}

ul, ol {
  font-family: var(--font-serif);
  color: var(--fg);
  margin: 0 0 1.6em 1.5em;
  max-width: var(--reading-width);
}
li { margin-bottom: 6px; line-height: 1.75; }

strong { font-weight: 700; }
em { font-style: italic; }

blockquote {
  border-left: 2px solid var(--border2);
  margin: 36px 0;
  padding: 3px 0 3px 24px;
}
blockquote p { font-style: italic; color: var(--fg2); margin-bottom: 0; }

code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--bg2);
  color: var(--fg2);
  padding: 1px 5px;
  border-radius: 3px;
}

pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 22px;
  overflow-x: auto;
  margin: 28px 0;
  max-width: var(--reading-width);
}
pre code { background: none; padding: 0; font-size: 13px; line-height: 1.65; }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 60px 0;
  max-width: var(--reading-width);
}

/* ================================================================
   POST FOOTNOTES — academic-style notes at the end of a post
================================================================ */
.post-footnotes {
  margin-top: 48px;
  max-width: var(--reading-width);
}
.post-footnotes hr {
  margin: 0 0 24px;
}
.post-footnotes p {
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--fg2);
  margin-bottom: 14px;
  scroll-margin-top: 60px;
}
.post-footnotes p:last-child {
  margin-bottom: 0;
}
.post-footnotes strong {
  color: var(--fg);
}

/* Footnote markers — clickable, no underline, muted color, scroll offset for sticky header */
a.fn-ref, a.fn-back {
  border-bottom: none;
  color: var(--fg3);
  padding: 0 1px;
  scroll-margin-top: 60px;
  transition: color 0.12s;
}
a.fn-ref:hover, a.fn-back:hover {
  color: var(--fg);
  border-bottom: none;
}

/* ================================================================
   POST-END
================================================================ */
.pe-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
  margin: 60px auto 0;
}

.pe-link {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--fg3);
  border-bottom: none;
  transition: color 0.12s;
}
.pe-link:hover { color: var(--fg); border-bottom: none; }

.pe-dot {
  color: var(--border2);
  font-family: var(--font-mono);
  font-size: 10.5px;
}

/* ================================================================
   HOMEPAGE
================================================================ */
.index-intro { max-width: var(--reading-width); margin-bottom: 56px; }
.index-intro p {
  font-family: var(--font-serif);
  font-size: 18px;
  font-style: italic;
  color: var(--fg3);
  line-height: 1.65;
  margin-bottom: 0;
}
.index-intro p + p { margin-top: 24px; }

/* ================================================================
   ABOUT
================================================================ */
.about-top {
  display: flex;
  gap: 32px;
  align-items: flex-start;
  margin-bottom: 18px;
  margin-right: -10px;
}
.about-top-text {
  flex: 1;
  min-width: 0;
}
.about-top-text .kicker { margin-top: 0; }
.about-top-text h1 { margin-top: 0; }
.about-top-text p:last-child { margin-bottom: 0; }

.about-photo {
  flex-shrink: 0;
  width: 240px;
  height: 240px;
  object-fit: cover;
  filter: grayscale(100%) contrast(1.08) brightness(0.98);
  border-radius: 4px;
}

@media (max-width: 560px) {
  .about-top {
    flex-direction: column-reverse;
    gap: 24px;
    align-items: center;
    margin-right: 0;
  }
  .about-top-text { width: 100%; }
  .about-top-text .kicker,
  .about-top-text h1,
  .about-top-text p { text-align: left; }
  .about-photo {
    width: 210px;
    height: 210px;
  }
}

.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }

.post-item {
  padding: 36px 0;
  border-bottom: 1px solid var(--border);
  max-width: var(--reading-width);
}
.post-item:last-child { border-bottom: none; }

.post-item-kicker {
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--fg3);
  margin-bottom: 11px;
}

.post-item-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 10px;
}
.post-item-title a { color: var(--fg); border-bottom: 1px solid transparent; transition: border-color 0.15s, opacity 0.15s; }
.post-item:hover .post-item-title a { border-bottom-color: var(--fg); }
.post-item-title a:hover { opacity: 0.75; }

.post-item-summary {
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--fg2);
  line-height: 1.65;
  text-wrap: pretty;
  margin: 0;
}

/* ================================================================
   FOOTER — centered colophon
================================================================ */
footer {
  border-top: 1px solid var(--border);
  padding: 44px 44px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
}

.ft-mark {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.03em;
}

.ft-byline {
  font-family: var(--font-ui);
  font-size: 11.5px;
  font-weight: 300;
  color: var(--fg2);
  letter-spacing: 0.03em;
}

.ft-note {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 300;
  color: var(--fg3);
  letter-spacing: 0.02em;
}

footer a { color: inherit; border-bottom: none; }
footer a:hover { color: var(--fg2); border-bottom: none; }

/* ================================================================
   404
================================================================ */
.not-found { padding: 80px 0; }
.not-found h1 { font-size: 28px; margin-bottom: 12px; }
.not-found p { color: var(--fg2); }

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 640px) {
  header { padding: 0 20px; height: 50px; }
  .header-name, .header-sep { display: none; }
  .page { padding: 48px 20px 80px; }
  footer { padding: 28px 20px; }
  h1 { font-size: 30px; }
  h2 { font-size: 22px; }
}
