:root {
  --bg: #0e0f11;
  --surface: #16181b;
  --surface-2: #1d2024;
  --border: #2a2d32;
  --text: #f3f3f1;
  --text-2: #b9bbbe;
  --text-3: #8a8d92;
  --accent: #ff7a45;
  --link: #ffa47e;
  --radius: 14px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.wrap-narrow { width: min(700px, 100% - 32px); margin-inline: auto; }

/* ---------- header / footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-weight: 800; font-size: 17px; letter-spacing: -0.01em; text-decoration: none; }
nav { display: flex; gap: 22px; }
nav a { color: var(--text-2); text-decoration: none; font-size: 15px; font-weight: 500; }
nav a:hover { color: var(--text); }

.site-footer { border-top: 1px solid var(--border); margin-top: 96px; }
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between;
  padding: 28px 0 40px; color: var(--text-3); font-size: 14px;
}
.footer-links { display: flex; gap: 18px; }
.footer-links a { color: var(--text-3); text-decoration: none; }
.footer-links a:hover { color: var(--text); }

/* ---------- home ---------- */
.intro { padding: 64px 0 32px; }
.intro h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.05; letter-spacing: -0.03em; margin: 0 0 14px; font-weight: 800; }
.intro p { font-size: clamp(17px, 2.2vw, 20px); color: var(--text-2); max-width: 600px; margin: 0; }

.essay-list { display: flex; flex-direction: column; gap: 28px; }

.card-link {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  transition: border-color .2s, transform .2s, background .2s;
}
.card-link:hover { border-color: #3d4148; background: var(--surface-2); transform: translateY(-2px); }
.card-image { aspect-ratio: 3 / 2; overflow: hidden; background: var(--surface-2); }
.card-image img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
.card-link:hover .card-image img { transform: scale(1.03); }
.card-body { padding: clamp(22px, 3.5vw, 40px); display: flex; flex-direction: column; justify-content: center; }
.card-title { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; margin: 0 0 12px; }
.card-subtitle { color: var(--text-2); font-size: 16px; margin: 0 0 20px; }
.read-more { margin-top: 22px; color: var(--accent); font-weight: 600; font-size: 15px; }
.read-more span { display: inline-block; transition: transform .2s; }
.card-link:hover .read-more span { transform: translateX(4px); }

/* alternate image side for rhythm */
.card:nth-child(even) .card-link { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); }
.card:nth-child(even) .card-image { order: 2; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.dot { opacity: .6; }
.badge {
  margin-left: 4px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
  color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .06em;
}

@media (max-width: 760px) {
  .card-link, .card:nth-child(even) .card-link { grid-template-columns: 1fr; }
  .card:nth-child(even) .card-image { order: 0; }
  .intro { padding: 48px 0 28px; }
}

/* ---------- essay page ---------- */
.essay-header { padding: 64px 0 32px; }
.essay-header h1 { font-size: clamp(32px, 5.5vw, 50px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 16px; font-weight: 800; }
.essay-subtitle { font-size: clamp(18px, 2.4vw, 21px); color: var(--text-2); margin: 0 0 24px; line-height: 1.45; }
.essay-cover { margin-block: 0 48px; }
.essay-cover img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.draft-note {
  font-size: 15px; color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 12px 16px; border-radius: 8px; margin: 0 0 32px;
}

.prose { font-family: var(--serif); font-size: 20px; line-height: 1.7; color: #e8e8e5; }
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote { margin: 0 0 1.3em; }
.prose h2, .prose h3 { font-family: var(--sans); color: var(--text); letter-spacing: -0.02em; line-height: 1.2; }
.prose h2 { font-size: 28px; margin: 2.2em 0 .7em; font-weight: 700; }
.prose h3 { font-size: 21px; margin: 1.8em 0 .6em; font-weight: 650; }
.prose a { color: var(--link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--link) 45%, transparent); }
.prose a:hover { text-decoration-color: var(--link); }
.prose strong { color: var(--text); font-weight: 600; }
.prose li { margin-bottom: .45em; }
.prose li > ul { margin-top: .45em; margin-bottom: 0; }
.prose blockquote {
  border-left: 3px solid var(--accent); margin-left: 0; padding: 4px 0 4px 22px;
  font-style: italic; color: var(--text);
}
.prose blockquote p { margin: 0; }
.prose .footnote-ref a { text-decoration: none; font-family: var(--sans); font-size: .7em; font-weight: 600; }

.prose figure.diagram { margin: 2em 0 2.2em; }
.prose figure.diagram img {
  width: 100%; background: #fff; border-radius: 12px; padding: clamp(6px, 1.5vw, 14px);
}
.prose figcaption { font-family: var(--sans); font-size: 14px; color: var(--text-3); text-align: center; margin-top: 10px; }

.prose aside.note { font-size: 17px; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 1.4em; margin-top: 2.4em; }

.prose .footnotes { font-family: var(--sans); font-size: 14.5px; line-height: 1.6; color: var(--text-2); border-top: 1px solid var(--border); margin-top: 3em; padding-top: 1em; }
.prose .footnotes h2 { font-size: 18px; margin: .8em 0 1em; }
.prose .footnotes ol { padding-left: 1.4em; }
.prose .footnotes li { margin-bottom: .7em; overflow-wrap: anywhere; }
.prose .footnotes p { margin: 0; display: inline; }
.prose .footnote-backref { text-decoration: none; margin-left: 4px; }
.prose hr.footnotes-sep { display: none; }

.essay-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 64px; padding-top: 28px; border-top: 1px solid var(--border); }
.essay-nav a { text-decoration: none; font-weight: 600; font-size: 16px; line-height: 1.3; padding: 16px 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.essay-nav a:hover { border-color: #3d4148; }
.essay-nav a.next { text-align: right; }
.essay-nav small { display: block; color: var(--text-3); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }

@media (max-width: 600px) {
  .prose { font-size: 18px; }
  .prose h2 { font-size: 24px; }
  .essay-header { padding-top: 40px; }
  .essay-nav { grid-template-columns: 1fr; }
  .essay-nav a.next { text-align: left; }
}
