:root {
  --paper: #faf9f6;
  --paper-warm: #f8f6f1;
  --paper-edge: #f2efe8;
  --ink: #3a352d;
  --ink-light: #6b6560;
  --ink-faded: #9a958e;
  --accent: #8b6b4a;
  --accent-soft: rgba(139, 107, 74, 0.1);
  --rule: #ddd9d0;
  --rule-light: #eae7e0;
  --rule-faint: #f0ede6;
  --width: 40rem;
  --shadow-subtle: 0 1px 4px rgba(0,0,0,0.04), 0 6px 20px rgba(0,0,0,0.05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c1a17;
    --paper-warm: #201e1a;
    --paper-edge: #16140f;
    --ink: #e0dbd2;
    --ink-light: #b8b3aa;
    --ink-faded: #8a857c;
    --accent: #c4a07a;
    --accent-soft: rgba(196, 160, 122, 0.12);
    --rule: #3d3830;
    --rule-light: #2d2a24;
    --rule-faint: #252320;
    --shadow-subtle: 0 1px 4px rgba(0,0,0,0.12), 0 6px 20px rgba(0,0,0,0.18);
  }
}

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

html {
  background:
    linear-gradient(to bottom, var(--paper-edge) 0%, var(--paper) 8%, var(--paper) 92%, var(--paper-edge) 100%);
  background-attachment: fixed;
  min-height: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  main { animation: none; }
}

::selection {
  background: var(--accent);
  color: var(--paper);
}

body {
  font: 1.0625rem/1.8 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  font-weight: 400;
  color: var(--ink);
  background: var(--paper-warm);
  max-width: var(--width);
  margin: 3rem auto;
  padding: 3.5rem 4rem;
  font-feature-settings: "onum" 1, "pnum" 1;
  font-variant-numeric: oldstyle-nums proportional-nums;
  letter-spacing: 0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  box-shadow: var(--shadow-subtle);
  border: 1px solid var(--rule-faint);
}

/* Links */
a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(139, 107, 74, 0.25);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s ease, color 0.2s ease;
}
a:hover {
  text-decoration-color: var(--accent);
}

@media (prefers-color-scheme: dark) {
  a { text-decoration-color: rgba(196, 160, 122, 0.3); }
}

/* Header */
.site-header {
  margin-bottom: 3rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule-light);
}

.site-header nav {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-title {
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}
.site-title:hover { color: var(--accent); }

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.75rem;
}

.nav-links a {
  color: var(--ink-faded);
  font-size: 0.85rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  transition: color 0.2s ease;
}

.nav-links a:hover,
.nav-links a.active { color: var(--ink-light); }

/* Typography */
main {
  min-height: 50vh;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3 {
  font-weight: 400;
  line-height: 1.3;
  color: var(--ink);
}

h1 {
  font-size: 1.875rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.015em;
  font-weight: 400;
}

h2 {
  font-size: 1.125rem;
  margin: 3rem 0 1.25rem;
  letter-spacing: 0.01em;
  font-weight: 400;
  font-style: italic;
  color: var(--ink-light);
}

h3 {
  font-size: 1rem;
  margin: 2.25rem 0 0.875rem;
  font-style: italic;
  font-weight: 400;
  color: var(--ink-light);
}

p {
  margin-bottom: 1.5rem;
  text-align: left;
}

ul, ol { margin-bottom: 1.5rem; padding-left: 1.5rem; }
li { margin-bottom: 0.5rem; line-height: 1.7; }

/* Homepage */
.tagline {
  font-size: 1.125rem;
  font-style: italic;
  color: var(--ink-light);
  text-align: center;
  margin: 0 0 3.5rem;
  line-height: 1.7;
  font-weight: 400;
}

p.home-intro {
  font-size: 0.95rem;
  color: var(--ink-light);
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--rule-light);
  text-align: center;
  line-height: 1.8;
}

.home h2 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-weight: 400;
  color: var(--ink-faded);
  margin: 0 0 0.75rem;
  border-bottom: none;
  padding-bottom: 0;
}

.home h2::after {
  content: none;
}

/* Post list */
.post-list { list-style: none; padding: 0; margin-top: 1.75rem; }

.post-list li {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--rule-light);
}

.post-list li:last-child { border-bottom: none; padding-bottom: 0; }

.post-list a {
  font-weight: 500;
  font-size: 1.05rem;
  display: block;
  margin-bottom: 0.375rem;
  text-decoration: none;
}
.post-list a:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(139, 107, 74, 0.35);
  text-underline-offset: 0.15em;
}

.post-list .post-meta {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.post-list time {
  color: var(--ink-faded);
  font-size: 0.85rem;
  font-style: italic;
  font-feature-settings: "tnum" 1;
}

.post-list .reading-time {
  color: var(--ink-faded);
  font-size: 0.8rem;
  font-style: italic;
}

.post-list .reading-time::before {
  content: "·";
  margin-right: 0.5rem;
  color: var(--rule);
}

.post-list .post-desc {
  color: var(--ink-light);
  font-size: 0.9rem;
  margin: 0.625rem 0 0;
  text-align: left;
  line-height: 1.6;
}

/* Single post */
.post header {
  margin-bottom: 3rem;
  padding-bottom: 2.5rem;
  border-bottom: none;
  text-align: center;
}
.post header::after {
  content: "§";
  display: block;
  margin-top: 2rem;
  color: var(--rule);
  font-size: 0.875rem;
  font-family: Georgia, serif;
}
.post header time {
  display: block;
  margin-top: 0.625rem;
  color: var(--ink-faded);
  font-size: 0.85rem;
  font-style: italic;
  letter-spacing: 0.05em;
}
.post .content { margin-top: 2.5rem; }


/* Tags */
.tags { margin-top: 1rem; display: flex; gap: 0.625rem; flex-wrap: wrap; justify-content: center; }

.tag {
  font-size: 0.65rem;
  padding: 0.25rem 0.625rem;
  border: 1px solid var(--rule-light);
  border-radius: 3px;
  color: var(--ink-faded);
  text-decoration: none;
  letter-spacing: 0.06em;
  text-transform: lowercase;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.tag:hover {
  border-color: var(--rule);
  color: var(--ink-light);
}

/* Code */
code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.03);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

@media (prefers-color-scheme: dark) { code { background: rgba(255,255,255,0.05); } }

pre {
  background: var(--paper);
  padding: 1.5rem 1.75rem;
  overflow-x: auto;
  border: 1px solid var(--rule-light);
  margin: 2rem 0;
}

@media (prefers-color-scheme: dark) { pre { background: rgba(255,255,255,0.02); } }

pre code { background: none; padding: 0; font-size: 0.85rem; line-height: 1.6; }

/* Blockquote */
blockquote {
  margin: 2.5rem 0;
  padding: 0.75rem 0 0.75rem 1.75rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-light);
  font-style: italic;
}

blockquote p { margin-bottom: 0.75rem; }
blockquote p:last-child { margin-bottom: 0; }

/* Horizontal rule */
hr {
  border: none;
  text-align: center;
  margin: 3rem 0;
}
hr::before {
  content: "—";
  color: var(--rule);
  font-size: 1rem;
  letter-spacing: 0;
}

/* Images & Figures */
img { max-width: 100%; height: auto; }

figure {
  margin: 2.5rem 0;
}

figure img {
  display: block;
  margin: 0 auto;
}

figcaption {
  margin-top: 1rem;
  font-size: 0.85rem;
  color: var(--ink-faded);
  text-align: center;
  font-style: italic;
  line-height: 1.5;
}

/* Text emphasis */
strong {
  font-weight: 500;
  color: var(--ink);
}

em {
  font-style: italic;
}

/* Footer */
.site-footer {
  margin-top: 4.5rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--rule-light);
  color: var(--ink-faded);
  font-size: 0.8rem;
  text-align: center;
  font-style: italic;
}
.site-footer::before {
  content: none;
}

.footer-links {
  margin-top: 0.875rem;
  font-style: normal;
}
.footer-links a {
  color: var(--ink-faded);
  margin: 0 0.625rem;
  text-decoration: none;
  letter-spacing: 0.04em;
  text-transform: lowercase;
  transition: color 0.2s ease;
}
.footer-links a:hover { color: var(--ink-light); }

/* ================================
   RESPONSIVE DESIGN
   ================================ */

/* Large tablets and small desktops (1024px and below) */
@media (max-width: 1024px) {
  :root {
    --width: 40rem;
  }
  body {
    margin: 2.5rem auto;
    padding: 3rem 3.5rem;
  }
}

/* Tablets (768px - 1024px) */
@media (max-width: 900px) {
  body {
    font-size: 1rem;
    padding: 2.5rem 3rem;
  }
  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.0625rem;
    margin: 2.5rem 0 1rem;
  }
  .tagline {
    font-size: 1.0625rem;
  }
  blockquote {
    margin: 2rem 0;
  }
  .site-footer {
    margin-top: 3.5rem;
  }
}

/* Small tablets (768px and below) */
@media (max-width: 768px) {
  html {
    background: var(--paper);
  }
  body {
    font-size: 1rem;
    margin: 0;
    padding: 2.5rem 2rem;
    max-width: 100%;
    border: none;
    box-shadow: none;
  }
  h1 {
    font-size: 1.625rem;
  }
  h2 {
    font-size: 1rem;
    margin: 2.25rem 0 0.875rem;
  }
  h3 {
    font-size: 0.9375rem;
    margin: 1.75rem 0 0.625rem;
  }
  .site-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
  }
  .site-header nav {
    justify-content: center;
    gap: 0.75rem 1.5rem;
  }
  .site-title {
    width: 100%;
    text-align: center;
  }
  .nav-links {
    justify-content: center;
    gap: 1.5rem;
  }
  .tagline {
    font-size: 1rem;
    margin-bottom: 2.5rem;
  }
  p.home-intro {
    font-size: 0.9rem;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
  }
  .post header {
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
  }
  pre {
    padding: 1.25rem 1.5rem;
    margin: 1.5rem -0.5rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  blockquote {
    margin: 2rem 0;
    padding-left: 1.5rem;
  }
  figure {
    margin: 2rem -0.5rem;
  }
  figure img {
    width: 100%;
  }
}

/* Mobile phones (680px and below) */
@media (max-width: 680px) {
  body {
    margin: 0;
    padding: 2rem 1.5rem;
    font-size: 1rem;
    line-height: 1.75;
    max-width: 100%;
  }
  h1 {
    font-size: 1.5rem;
    letter-spacing: -0.01em;
  }
  h2 {
    font-size: 0.9375rem;
    margin: 2rem 0 0.75rem;
  }
  h3 {
    font-size: 0.875rem;
    margin: 1.75rem 0 0.625rem;
  }
  .site-header {
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
  }
  .site-title {
    font-size: 1.1rem;
  }
  .nav-links {
    gap: 1.25rem;
  }
  .nav-links a {
    font-size: 0.8rem;
  }
  .tagline {
    font-size: 0.9375rem;
    margin-bottom: 2rem;
  }
  p.home-intro {
    font-size: 0.85rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }
  .post-list a {
    font-size: 1rem;
  }
  .post-list .post-desc {
    font-size: 0.85rem;
  }
  .post header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }
  .post .content {
    margin-top: 2rem;
  }
  p {
    margin-bottom: 1.25rem;
  }
  .post header::after {
    font-size: 0.625rem;
    margin-top: 1.5rem;
  }
  ul, ol {
    padding-left: 1.25rem;
    margin-bottom: 1.25rem;
  }
  pre {
    padding: 1.25rem;
    margin: 1.5rem -1.5rem;
    font-size: 0.8rem;
  }
  pre code {
    font-size: 0.8rem;
  }
  code {
    font-size: 0.8em;
  }
  blockquote {
    margin: 1.75rem 0;
    padding: 0.5rem 0 0.5rem 1.25rem;
  }
  hr {
    margin: 2.5rem 0;
  }
  figure {
    margin: 1.75rem -1.5rem;
  }
  figcaption {
    padding: 0 1.5rem;
    font-size: 0.8rem;
  }
  .tags {
    gap: 0.5rem;
  }
  .tag {
    font-size: 0.6rem;
    padding: 0.2rem 0.5rem;
  }
  .site-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    font-size: 0.75rem;
  }
  .footer-links a {
    margin: 0 0.5rem;
  }
}

/* Very small phones (375px and below) */
@media (max-width: 375px) {
  body {
    padding: 1.5rem 1.25rem;
  }
  h1 {
    font-size: 1.375rem;
  }
  .site-header nav {
    gap: 0.5rem;
  }
  .nav-links {
    gap: 1rem;
  }
  .nav-links a {
    font-size: 0.75rem;
  }
  pre {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
    padding: 1rem;
  }
  figure {
    margin-left: -1.25rem;
    margin-right: -1.25rem;
  }
  figcaption {
    padding: 0 1.25rem;
  }
}

@media print {
  body { box-shadow: none; border: none; margin: 0; padding: 0; }
  html { background: white; }
}
