@import url("https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,700;1,9..144,400;1,9..144,700&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=DM+Mono:ital,wght@0,400;0,500;1,400&display=swap");

:root {
  --paper:        #131316;
  --paper-card:   #1C1C20;
  --paper-alt:    #22222A;
  --ink:          #EAE6E0;
  --ink-muted:    #8E8A85;
  --rust:         #C17A3E;
  --rust-dim:     rgba(193, 122, 62, 0.12);
  --forest:       #5A9E77;
  --border:       rgba(255, 255, 255, 0.09);
  --border-light: rgba(255, 255, 255, 0.05);
  --tag-bg:       #242429;
  --tag-text:     #ADA8A2;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 80% 50% at 100% 0%,  rgba(100, 70, 30, 0.18)  0%, transparent 55%),
    radial-gradient(ellipse 65% 55% at 0%  100%, rgba(30,  75, 55, 0.14)  0%, transparent 55%);
  color: var(--ink);
  font-family: "Source Serif 4", Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  line-height: 1.65;
  overflow-x: hidden;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--forest);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: 1rem;
  z-index: 1000;
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: var(--paper);
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: 3px;
  transform: translateY(-140%);
  transition: transform 0.18s ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ─── Header ──────────────────────────────────────── */

.site-header {
  width: min(1100px, 92vw);
  margin: 2rem auto 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: "DM Mono", "Courier New", monospace;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
}

.nav-link {
  font-family: "DM Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.18s;
}

.nav-link:hover {
  color: var(--rust);
}

/* ─── Container ───────────────────────────────────── */

.container {
  width: min(1100px, 92vw);
  margin: 0 auto 5rem;
}

/* ─── Hero ────────────────────────────────────────── */

.hero {
  padding: clamp(2.5rem, 5vw, 4.5rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
  margin-bottom: clamp(1.75rem, 3.5vw, 2.75rem);
  animation: fadeUp 0.65s ease both;
}

.eyebrow {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--rust);
  margin: 0 0 1rem;
}

h1,
h2,
h3 {
  margin-top: 0;
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.1;
}

.hero h1 {
  font-size: clamp(2.6rem, 6.5vw, 4.6rem);
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
  max-width: 22ch;
  text-wrap: balance;
}

.lead {
  font-size: clamp(1rem, 2vw, 1.12rem);
  color: var(--ink-muted);
  max-width: 58ch;
  line-height: 1.72;
  margin: 0;
}

/* ─── Cards ───────────────────────────────────────── */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.1rem;
}

.card {
  background: var(--paper-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--rust);
  border-radius: 3px;
  padding: 1.3rem 1.5rem 1.25rem;
  opacity: 0;
  transform: translateY(14px);
  animation: fadeUp 0.52s ease both;
  transition: border-left-color 0.22s, box-shadow 0.22s, transform 0.22s;
}

.card:nth-child(2) { animation-delay: 0.1s; }
.card:nth-child(3) { animation-delay: 0.2s; }
.card:nth-child(4) { animation-delay: 0.3s; }
.card:nth-child(5) { animation-delay: 0.4s; }
.card:nth-child(6) { animation-delay: 0.5s; }

.card:hover {
  border-left-color: var(--forest);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
  transform: translateY(-2px);
}

.card .eyebrow {
  margin-bottom: 0.55rem;
}

.card h2 {
  font-size: clamp(1.18rem, 2.2vw, 1.4rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1.18;
  margin: 0 0 0.65rem;
}

.card h2 a {
  color: var(--ink);
  text-decoration: none;
  transition: color 0.16s;
}

.card h2 a:hover {
  color: var(--rust);
}

.card > p {
  color: var(--ink-muted);
  font-size: 0.94rem;
  line-height: 1.62;
  margin: 0;
}

/* ─── Tags ────────────────────────────────────────── */

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-top: 0.9rem;
}

.tag {
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 2px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.tag:hover {
  background: var(--rust);
  color: var(--paper);
  border-color: var(--rust);
}

/* ─── Post Page ───────────────────────────────────── */

.post {
  max-width: 700px;
  margin: clamp(1.5rem, 3.5vw, 2.75rem) auto 0;
  animation: fadeUp 0.55s ease both;
}

.post h1 {
  font-size: clamp(2rem, 5.5vw, 3.4rem);
  font-weight: 700;
  font-style: italic;
  letter-spacing: -0.022em;
  margin-bottom: 0.65rem;
  text-wrap: balance;
}

.post .lead {
  font-size: 1.07rem;
  margin-bottom: 0.75rem;
}

.post-body {
  margin-top: 1.75rem;
  border-top: 1px solid var(--border);
  padding-top: 1.75rem;
}

.post-body p,
.post-body li {
  line-height: 1.88;
}

.post-body h2 {
  font-size: 1.55rem;
  font-style: italic;
  font-weight: 700;
  margin-top: 2.25rem;
  margin-bottom: 0.65rem;
}

.post-body h3 {
  font-size: 1.15rem;
  font-style: normal;
  font-weight: 600;
  margin-top: 1.8rem;
  margin-bottom: 0.5rem;
  letter-spacing: 0.01em;
}

.post-body a {
  color: var(--forest);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.16s;
}

.post-body a:hover {
  color: var(--rust);
}

.post-body code {
  font-family: "DM Mono", monospace;
  font-size: 0.86em;
  background: var(--paper-alt);
  border: 1px solid var(--border);
  color: var(--ink);
  padding: 0.08rem 0.3rem;
  border-radius: 2px;
}

.post-body pre {
  overflow-x: auto;
  background: var(--paper-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rust);
  border-radius: 3px;
  padding: 1.05rem 1.2rem;
  margin: 1.25rem 0;
}

.post-body pre code {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.84rem;
}

.post-body blockquote {
  margin: 1.5rem 0;
  padding: 0.85rem 1.2rem;
  border-left: 3px solid var(--rust);
  background: var(--rust-dim);
  border-radius: 0 3px 3px 0;
}

.post-body blockquote p {
  margin: 0;
  font-style: italic;
  color: var(--ink);
}

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.25rem 0;
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
}

.post-body li + li {
  margin-top: 0.25rem;
}

/* ─── Button ──────────────────────────────────────── */

.button {
  display: inline-block;
  text-decoration: none;
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--ink);
  border-radius: 2px;
  padding: 0.65rem 1.15rem;
  transition: background 0.2s;
}

.button:hover {
  background: var(--rust);
}

/* ─── Post Nav ────────────────────────────────────── */

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.post-nav a {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  text-decoration: none;
  max-width: 40ch;
  transition: color 0.18s;
}

.post-nav a:hover {
  color: var(--rust);
}

.post-nav .prev::before { content: "← "; }
.post-nav .next {
  text-align: right;
}
.post-nav .next::after  { content: " →"; }

/* ─── Tags Index ───────────────────────────────────── */

.tags-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.tag-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  background: var(--paper-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--rust);
  border-radius: 3px;
  padding: 0.85rem 1rem;
  text-decoration: none;
  transition: border-left-color 0.22s, transform 0.22s, box-shadow 0.22s;
}

.tag-item:hover {
  border-left-color: var(--forest);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.tag-item .tag-name {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
}

.tag-item .tag-count {
  font-family: "DM Mono", monospace;
  font-size: 0.63rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ─── Footer ───────────────────────────────────────── */

.site-footer {
  width: min(1100px, 92vw);
  margin: 3rem auto 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1.5rem;
  align-items: center;
  flex-wrap: wrap;
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.site-footer a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.18s;
}

.site-footer a:hover {
  color: var(--rust);
}

/* ─── Animations ──────────────────────────────────── */

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

/* ─── Light Theme ─────────────────────────────────── */

[data-theme="light"] {
  --paper:        #F5F0E8;
  --paper-card:   #FEFAF2;
  --paper-alt:    #EDE6D4;
  --ink:          #1A1510;
  --ink-muted:    #72624F;
  --rust:         #8C3A27;
  --rust-dim:     rgba(140, 58, 39, 0.09);
  --forest:       #2F5E41;
  --border:       #D5CAB2;
  --border-light: #E4DBC6;
  --tag-bg:       #E8E1CE;
  --tag-text:     #3E3024;
}

html[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 90% 45% at 105% 0%,  rgba(175, 110, 65, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 70% 55% at -5%  105%, rgba(70,  120, 85, 0.05) 0%, transparent 60%);
}

/* ─── Site Nav & Theme Toggle ──────────────────────── */

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--ink-muted);
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.28rem 0.58rem;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.theme-toggle:hover {
  color: var(--rust);
  border-color: var(--rust);
}

/* ─── Copy Code Button ─────────────────────────────── */

.pre-wrap {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--paper-alt);
  border: 1px solid var(--border);
  color: var(--ink-muted);
  font-family: "DM Mono", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.45rem;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover,
.copy-btn.copied {
  color: var(--forest);
  border-color: var(--forest);
}

/* ─── Search ───────────────────────────────────────── */

.search-box {
  margin-top: 1.5rem;
}

.search-input {
  width: 100%;
  max-width: 52ch;
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.05rem;
  background: var(--paper-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rust);
  color: var(--ink);
  padding: 0.65rem 0.9rem;
  border-radius: 3px;
  outline: none;
  transition: border-left-color 0.18s;
}

.search-input:focus {
  border-left-color: var(--forest);
}

.search-input::placeholder {
  color: var(--ink-muted);
}

.search-empty {
  font-family: "DM Mono", monospace;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 2rem 0;
}

/* ─── Archive ──────────────────────────────────────── */

.archive {
  margin-top: 0.5rem;
}

.archive-year {
  margin-bottom: 2.25rem;
}

.archive-year-label {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--rust);
  margin: 0 0 0.65rem;
  font-style: normal;
  font-weight: 500;
}

.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.archive-item {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
  padding: 0.48rem 0;
  border-bottom: 1px solid var(--border-light);
}

.archive-item:last-child {
  border-bottom: none;
}

.archive-date {
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  min-width: 5ch;
  white-space: nowrap;
}

.archive-item a {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.16s;
}

.archive-item a:hover {
  color: var(--rust);
}

/* ─── Series Box ───────────────────────────────────── */

.series-box {
  background: var(--paper-card);
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--forest);
  border-radius: 3px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.series-label {
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--forest);
  margin: 0 0 0.35rem;
}

.series-title {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1rem;
  color: var(--ink);
  margin: 0 0 0.75rem;
}

.series-parts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.series-parts li {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
  color: var(--ink-muted);
}

.series-parts li.series-current {
  color: var(--rust);
}

.series-parts a {
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.16s;
}

.series-parts a:hover {
  color: var(--rust);
}

/* ─── Related Posts ────────────────────────────────── */

.related {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-heading {
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.9rem;
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.related-item {
  display: flex;
  align-items: baseline;
  gap: 1.25rem;
}

.related-item a {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
  transition: color 0.16s;
}

.related-item a:hover {
  color: var(--rust);
}

.related-date {
  font-family: "DM Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  white-space: nowrap;
}

/* ─── Images ───────────────────────────────────────── */

.post-body figure {
  margin: 1.75rem 0;
  text-align: center;
}

.post-body figure img {
  max-width: 100%;
  border-radius: 3px;
  display: block;
  margin: 0 auto;
}

.post-body figcaption {
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* ─── Responsive ──────────────────────────────────── */

@media (max-width: 780px) {
  .cards {
    grid-template-columns: 1fr;
  }

  .container {
    margin-bottom: 3rem;
  }
}

@media (max-width: 640px) {
  .hero h1 {
    font-size: clamp(2.2rem, 9vw, 3rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero,
  .card,
  .post {
    animation: none;
    opacity: 1;
    transform: none;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
