/* ==========================================================================
   Keep It Simple Stupid — a quiet, readable serif theme.
   Optimized for long-form reading: comfortable measure, generous rhythm.
   ========================================================================== */

:root {
  /* A high-quality serif stack. Falls back gracefully across every OS. */
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", "Palatino",
           "Book Antiqua", Georgia, "Times New Roman", serif;
  --mono: "SF Mono", "JetBrains Mono", "Menlo", "Consolas",
          "Liberation Mono", monospace;

  /* Soft e-ink grey palette — easy on the eyes, gentle contrast */
  --bg: #e9e8e3;          /* warm light grey, like an e-ink screen */
  --fg: #3a3832;          /* soft grey-ink, gentle on the eyes */
  --muted: #6f6c63;
  --rule: #d2d0c8;
  --accent: #6a3a2a;      /* muted sepia-brown — restrained, intellectual */
  --accent-soft: #8a5241;
  --code-bg: #dedcd4;

  --measure: 58rem;       /* wider, more spacious measure */
  --leading: 1.72;
}

/* --- Reset-ish --- */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  color-scheme: light;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--serif);
  /* Fluid type: smoothly scales between small and large viewports — increased for better readability */
  font-size: clamp(1.25rem, 1.18rem + 0.38vw, 1.4rem);
  line-height: var(--leading);
  font-kerning: normal;
  font-feature-settings: "kern" 1, "liga" 1, "onum" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first last;
}

.wrap {
  max-width: var(--measure);
  margin-inline: auto;
  padding-block: 3.5rem 5rem;
  padding-inline: 1.4rem;
}

/* --- Skip link (visually hidden until focused) --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--fg);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 0 0 4px 0;
  z-index: 10;
}
.skip-link:focus {
  left: 0;
  text-decoration: none;
}

/* --- Header --- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 1.6rem;
  margin-bottom: 3rem;
  border-bottom: 1px solid var(--rule);
}
.site-title {
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: 0.01em;
  color: var(--fg);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.site-logo {
  height: 50px;
  width: auto;
  display: block;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 1.15rem;
  margin-inline-start: 1.1rem;
}
.site-nav a:hover { color: var(--accent); }

/* --- Links --- */
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-soft); text-decoration: underline; text-underline-offset: 2px; }

/* --- Focus states (keyboard accessibility) --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

/* --- Headings --- */
h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  margin: 2.4em 0 0.7em;
  letter-spacing: -0.01em;
  text-wrap: balance;
}
h1 { font-size: 2.6rem; }
h2 { font-size: 1.95rem; }
h3 { font-size: 1.55rem; }
h4 { font-size: 1.3rem; }

p { text-wrap: pretty; }
p, ul, ol, blockquote, pre, table { margin: 0 0 1.4rem; }

/* --- Home / post list --- */
.year-group { margin-bottom: 1rem; }
.post-list { margin: 0; }
.post-card { margin-bottom: 2.4rem; }
.post-card .entry-title {
  font-size: 1.7rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
  line-height: 1.3;
}
.post-card .entry-title a { color: var(--fg); }
.post-card .entry-title a:hover { color: var(--accent); text-decoration: none; }
.post-card .entry-meta { color: var(--muted); font-size: 0.95rem; margin: 0 0 0.4rem; }
.post-card .entry-excerpt { color: var(--fg); margin: 0; }
.year-heading {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin: 2.6rem 0 1.2rem;
  font-weight: 700;
}

/* --- Post --- */
.post-title { margin-top: 0; font-size: 2.9rem; }
.post-meta { color: var(--muted); font-size: 0.95rem; margin-top: -0.4rem; }
.post-meta .tag { font-style: italic; }

.post-content { margin-top: 2rem; }
.post-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.8rem auto;
  border-radius: 2px;
}
.post-content blockquote {
  margin-inline: 0;
  padding-inline-start: 1.2rem;
  border-inline-start: 3px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}
.post-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.8rem 0;
}
.post-content ul, .post-content ol { padding-inline-start: 1.4rem; }
.post-content li { margin-bottom: 0.4rem; }

/* --- Code --- */
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: #3c3836;
  padding: 0.12em 0.35em;
  border-radius: 5px;
  color: #fabd2f;
  border: 1px solid #504945;
}
pre {
  background: #282828;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.88em;
  line-height: 1.5;
  color: #fbf1c7;
  border: 1px solid #3c3836;
}
pre code { background: none; padding: 0; font-size: inherit; color: inherit; }

/* --- Syntax Highlighting (Gruvbox Dark theme) --- */
.highlight table td { padding: 5px; border: none; }
.highlight table pre { margin: 0; }
.highlight table { border-collapse: separate; }
/* Remove any borders from all highlighting elements */
.highlight, .highlight *, .highlight pre, .highlight code, .highlight span {
  border: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: none !important;
  border-right: none !important;
}
.highlight, .highlight .w {
  color: #fbf1c7;
  background-color: #282828;
  border-radius: 8px;
}
.highlight .err {
  color: #fb4934;
  background-color: #282828;
  font-weight: bold;
}
.highlight .c, .highlight .ch, .highlight .cd, .highlight .cm, .highlight .cpf, .highlight .c1, .highlight .cs {
  color: #928374;
  font-style: italic;
}
.highlight .cp {
  color: #8ec07c;
}
.highlight .nt {
  color: #fb4934;
}
.highlight .o, .highlight .ow {
  color: #fbf1c7;
}
.highlight .p, .highlight .pi {
  color: #fbf1c7;
}
.highlight .gi {
  color: #b8bb26;
  background-color: #282828;
}
.highlight .gd {
  color: #fb4934;
  background-color: #282828;
}
.highlight .gh {
  color: #b8bb26;
  font-weight: bold;
}
.highlight .ge {
  font-style: italic;
}
.highlight .ges {
  font-weight: bold;
  font-style: italic;
}
.highlight .gs {
  font-weight: bold;
}
.highlight .k, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kv {
  color: #fb4934;
}
.highlight .kc {
  color: #d3869b;
}
.highlight .kt {
  color: #fabd2f;
}
.highlight .kd {
  color: #fe8019;
}
.highlight .s, .highlight .sb, .highlight .sc, .highlight .dl, .highlight .sd, .highlight .s2, .highlight .sh, .highlight .sx, .highlight .s1 {
  color: #b8bb26;
  font-style: italic;
}
.highlight .si {
  color: #b8bb26;
  font-style: italic;
}
.highlight .sr {
  color: #b8bb26;
  font-style: italic;
}
.highlight .sa {
  color: #fb4934;
}
.highlight .se {
  color: #fe8019;
}
.highlight .nn {
  color: #8ec07c;
}
.highlight .nc {
  color: #8ec07c;
}
.highlight .no {
  color: #d3869b;
}
.highlight .na {
  color: #b8bb26;
}
.highlight .m, .highlight .mb, .highlight .mf, .highlight .mh, .highlight .mi, .highlight .il, .highlight .mo, .highlight .mx {
  color: #d3869b;
}
.highlight .ss {
  color: #83a598;
}
.highlight .nf, .highlight .fm {
  color: #8ec07c;
}
.highlight .nb {
  color: #fabd2f;
}
.highlight .bp {
  color: #fabd2f;
}
.highlight .ne {
  color: #fabd2f;
}
.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi, .highlight .vm {
  color: #83a598;
}

/* --- Tables --- */
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--rule); text-align: left; }
/* Override table styling for syntax highlighting tables */
.highlight table, .highlight table th, .highlight table td {
  border: none !important;
  border-collapse: separate !important;
  padding: 0 !important;
}

/* --- Post navigation --- */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  font-size: 0.95rem;
}
.post-nav .next { margin-inline-start: auto; text-align: right; }

/* --- Footer --- */
.site-footer {
  margin-top: 4rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.85rem;
}
