/* ── Tokens ──────────────────────────────────────────── */

:root {
  --ink:       #1a1a1a;
  --ink-2:     #3d3d3d;
  --muted:     #6b6b6b;
  --faint:     #d8d4ce;
  --accent:    #355c7d;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --bg:        #faf8f5;
  --bg-2:      #f2efe9;
  --max:       680px;
  --sans:      "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial;
  --serif:     "Playfair Display", ui-serif, Georgia, "Times New Roman", Times, serif;
  --transition: 200ms ease;
  color-scheme: light;
}

[data-theme="dark"] {
  --ink:    #e8e4dc;
  --ink-2:  #bfb9ae;
  --muted:  #8a8480;
  --faint:  #2e2c29;
  --accent: #88a9c5;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --bg:     #161513;
  --bg-2:   #1e1c19;
  color-scheme: dark;
}


/* ── Reset ───────────────────────────────────────────── */

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 18px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
}

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.wrap {
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 24px;
}

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

header {
  padding: 48px 0 0;
}

.header-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.site-name {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(34px, 6vw, 52px);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1;
}

.site-name a {
  text-decoration: none;
}

.home-page .header-top {
  margin-bottom: 14px;
}

.home-page .site-name {
  font-size: clamp(40px, 7vw, 62px);
  letter-spacing: 0;
}

.site-tagline {
  margin: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  max-width: 420px;
}

.home-page .site-tagline {
  max-width: 460px;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.rule {
  margin: 24px 0 0;
  border: none;
  border-top: 1px solid var(--faint);
  transition: border-color var(--transition);
}

.home-page .site-tagline + .rule {
  margin-top: 30px;
}

nav {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 6px 28px;
  padding: 16px 0;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.home-page nav {
  gap: 8px 24px;
  padding: 14px 0 18px;
  font-size: 11px;
  letter-spacing: 0.1em;
}

.home-page nav a {
  position: relative;
  transition: color var(--transition);
}

.home-page nav a:hover {
  color: color-mix(in srgb, var(--accent) 72%, var(--muted));
}

.home-page nav + .rule {
  margin-top: 0;
}

nav a:hover {
  color: var(--ink);
  text-decoration: none;
}

/* ── Dark mode toggle ───────────────────────────────── */

.theme-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--faint);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  padding: 0;
}

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

[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none;  }
.icon-sun  { display: none;  }
.icon-moon { display: block; }

/* ── Main ────────────────────────────────────────────── */

main {
  padding: 52px 0 80px;
}

.about-intro {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  align-items: center;
  gap: 44px;
  margin: 6px 0 0;
  padding-bottom: 44px;
  border-bottom: 1px solid var(--faint);
}

.about-portrait {
  margin: 0;
}

.about-portrait img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  height: auto;
  object-fit: cover;
  object-position: center 22%;
  border-radius: 14px;
  border: 1px solid var(--faint);
  filter: saturate(0.98) contrast(1.02);
}

.about-intro-copy {
  min-width: 0;
  max-width: 34rem;
  padding-top: 0;
}

.about-intro-copy p {
  color: var(--ink-2);
}

.about-intro-copy p:last-child {
  margin-bottom: 0;
}

.about-title {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-size: clamp(28px, 4.4vw, 38px);
  font-weight: 400;
  line-height: 1.15;
}

.about-section {
  max-width: 40rem;
  padding-top: 24px;
  margin-top: 28px;
  border-top: 1px solid var(--faint);
}

.about-section h2 {
  margin: 0 0 14px;
  color: color-mix(in srgb, var(--accent) 56%, var(--muted));
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.about-section p {
  margin: 0;
}

.about-links ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.about-links li {
  padding: 12px 0;
  border-top: 1px solid color-mix(in srgb, var(--faint) 82%, transparent);
}

.about-links li:first-child {
  padding-top: 0;
  border-top: 0;
}

.about-links li:last-child {
  padding-bottom: 0;
}

/* Featured essay ---------------------------------------- */

.featured {
  margin-bottom: 60px;
  padding-bottom: 48px;
  border-bottom: 1px solid var(--faint);
}

.home-page .featured {
  padding-bottom: 52px;
}

.label {
  display: block;
  margin-bottom: 16px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.home-page .label,
.home-page .posts-label {
  color: color-mix(in srgb, var(--accent) 56%, var(--muted));
  letter-spacing: 0.12em;
}

.featured h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 400;
  line-height: 1.2;
}

.featured h2 a:hover {
  text-decoration: none;
  opacity: 0.7;
}

.featured .lede {
  margin: 14px 0 0;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.7;
}

.featured .meta {
  margin-top: 18px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.home-page .featured .meta {
  color: color-mix(in srgb, var(--accent) 42%, var(--muted));
}

/* Post list --------------------------------------------- */

.posts-label {
  margin: 0 0 20px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.post-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 16px;
  padding: 18px 0;
  border-top: 1px solid var(--faint);
  transition: border-color var(--transition);
}

.home-page .post-list li {
  transition: border-color var(--transition), transform var(--transition);
}

.home-page .post-list li:hover {
  border-top-color: color-mix(in srgb, var(--accent) 18%, var(--faint));
  transform: translateX(1px);
}

.post-list li:last-child {
  border-bottom: 1px solid var(--faint);
}

.post-title {
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.3;
}

.home-page .post-title {
  transition: color var(--transition);
}

.home-page .post-list li:hover .post-title {
  color: color-mix(in srgb, var(--accent) 68%, var(--ink));
}

.post-title:hover {
  text-decoration: none;
  opacity: 0.7;
}

.post-title .sub {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  opacity: 1;
}

.post-date {
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
}

.home-page .post-date {
  letter-spacing: 0.03em;
}

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

.archive-header {
  margin-bottom: 44px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--faint);
}

.archive-header h1 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(28px, 4.8vw, 42px);
  font-weight: 400;
  line-height: 1.15;
}

.archive-header .lede {
  margin: 0;
  max-width: 38rem;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.7;
}

.archive-year + .archive-year {
  margin-top: 44px;
}

.archive-year h2 {
  margin: 0 0 18px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.archive-month + .archive-month {
  margin-top: 28px;
}

.archive-month h3 {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.2;
}

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

.archive-list li {
  border-top: 1px solid var(--faint);
}

.archive-list li:last-child {
  border-bottom: 1px solid var(--faint);
}

.archive-link {
  display: block;
  padding: 16px 0 18px;
  text-decoration: none;
}

.archive-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 16px;
}

.archive-title {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.3;
}

.archive-date {
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.archive-lede {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
}

.archive-link:hover .archive-title {
  color: color-mix(in srgb, var(--accent) 68%, var(--ink));
}

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

.search-header {
  margin-bottom: 44px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--faint);
}

.search-header h2 {
  margin: 0 0 14px;
  font-family: var(--serif);
  font-size: clamp(28px, 4.8vw, 42px);
  font-weight: 400;
  line-height: 1.15;
}

.search-header .lede {
  margin: 0;
  max-width: 38rem;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.7;
}

.search-shell {
  display: grid;
  gap: 0;
}

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

.search-form {
  margin-bottom: 32px;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--faint);
  border-radius: 8px;
  background: var(--bg-2);
  transition: border-color var(--transition), background var(--transition);
}

.search-input-row:focus-within {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--faint));
  background: color-mix(in srgb, var(--bg-2) 60%, var(--bg));
}

.search-icon {
  flex-shrink: 0;
  color: var(--muted);
  transition: color var(--transition);
}

.search-input-row:focus-within .search-icon {
  color: var(--accent);
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  appearance: none;
  -webkit-appearance: none;
}

.search-input::placeholder {
  color: var(--muted);
  font-weight: 400;
  opacity: 1;
}

.search-input::-webkit-search-cancel-button,
.search-input::-webkit-search-decoration {
  -webkit-appearance: none;
}

.search-input:-webkit-autofill,
.search-input:-webkit-autofill:hover,
.search-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-2) inset;
  transition: background-color 5000s ease-in-out 0s;
}

.search-input:focus {
  outline: none;
}

.search-clear {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--faint);
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.search-clear:hover {
  background: color-mix(in srgb, var(--faint) 60%, var(--ink));
  color: var(--bg);
}

.search-count {
  margin: 0 0 8px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

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

.search-results-list li {
  border-top: 1px solid var(--faint);
}

.search-results-list li:last-child {
  border-bottom: 1px solid var(--faint);
}

.search-result-link {
  display: block;
  padding: 16px 0 18px;
  text-decoration: none;
}

.search-result-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 16px;
}

.search-result-title {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.3;
}

.search-result-date {
  white-space: nowrap;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.search-result-link:hover .search-result-title {
  color: color-mix(in srgb, var(--accent) 68%, var(--ink));
}

.search-result-link:hover {
  text-decoration: none;
}

.search-empty {
  padding: 18px 0;
  border-top: 1px solid var(--faint);
  border-bottom: 1px solid var(--faint);
}

.search-empty p {
  margin: 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
}

/* ── Article page ───────────────────────────────────── */

.article-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.article-back:hover {
  color: var(--ink);
  text-decoration: none;
}

.article-header {
  margin-bottom: 36px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--faint);
}

.article-end-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--faint);
}

.article-end-link {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

.article-end-link:hover {
  color: var(--ink);
  text-decoration: none;
}

.article-header h1 {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 400;
  line-height: 1.15;
}

.article-header .lede {
  margin: 0 0 20px;
  color: var(--ink-2);
  font-size: 17px;
  line-height: 1.65;
}

.article-header .meta {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.03em;
}

.article-body {
  font-size: 18px;
  line-height: 1.8;
}

.article-body p {
  margin: 0 0 1.5em;
}

.article-body > * {
  max-width: 40rem;
}

.article-body > figure,
.article-body > pre {
  max-width: none;
}

.article-body h2 {
  margin: 2.3em 0 0.6em;
  font-family: var(--serif);
  font-size: 1.5em;
  font-weight: 400;
  line-height: 1.25;
}

.article-body h3 {
  margin: 2em 0 0.55em;
  font-family: var(--sans);
  font-size: 0.85em;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.article-body a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, currentColor);
  text-underline-offset: 3px;
}

.article-body a:hover {
  color: color-mix(in srgb, var(--accent) 72%, var(--ink));
}

.article-body strong {
  font-weight: 600;
}

.article-body em {
  font-style: italic;
}

.article-body code {
  font-size: 0.875em;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-2));
  padding: 2px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 10%, var(--faint));
  border-radius: 999px;
  font-family: ui-monospace, "Cascadia Code", "Fira Code", monospace;
  transition: background var(--transition), border-color var(--transition);
}

.article-body pre {
  position: relative;
  background: color-mix(in srgb, var(--bg-2) 92%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--faint) 86%, transparent);
  border-radius: 16px;
  padding: 44px 22px 22px;
  overflow-x: auto;
  margin: 1.9em 0;
  box-shadow: 0 12px 24px rgba(26, 26, 26, 0.05);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.article-body pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 14px;
  left: 18px;
  color: color-mix(in srgb, var(--accent) 54%, var(--muted));
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.article-body pre:not([data-lang])::before,
.article-body pre[data-lang=""]::before {
  content: "Snippet";
}

.article-body pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: 14px;
  border-radius: 0;
  color: inherit;
}

.article-body blockquote {
  margin: 2em 0;
  padding: 2px 0 2px 24px;
  border-left: 2px solid color-mix(in srgb, var(--accent) 32%, var(--faint));
  color: var(--ink-2);
  font-style: italic;
  position: relative;
}

.article-body blockquote::before {
  content: "“";
  position: absolute;
  left: -2px;
  top: -10px;
  color: color-mix(in srgb, var(--accent) 34%, var(--muted));
  font-family: var(--serif);
  font-size: 50px;
  line-height: 1;
}

.article-body blockquote p {
  margin: 0;
}

.article-body ul,
.article-body ol {
  margin: 0 0 1.7em;
  padding-left: 1.35em;
}

.article-body li + li {
  margin-top: 0.55em;
}

.article-body figure {
  margin: 2.4em 0;
}

.article-body figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 18px 34px rgba(26, 26, 26, 0.08);
}

.article-body figcaption {
  margin-top: 12px;
  color: color-mix(in srgb, var(--muted) 84%, var(--accent));
  font-family: var(--serif);
  font-size: 14px;
  font-style: italic;
  line-height: 1.5;
  text-align: center;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border-radius: 14px;
}

.about-body ul {
  padding-left: 1.1em;
}

.about-body li + li {
  margin-top: 0.5em;
}

/* ── Copy button ─────────────────────────────────────── */

.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 5px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border: 1px solid color-mix(in srgb, var(--faint) 82%, transparent);
  border-radius: 999px;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  backdrop-filter: blur(10px);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}

.article-body pre:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--bg));
  border-color: color-mix(in srgb, var(--accent) 24%, var(--faint));
  color: var(--ink);
}

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

footer {
  padding: 28px 0 48px;
  border-top: 1px solid var(--faint);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: border-color var(--transition);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

footer a {
  color: var(--muted);
}

footer a:hover {
  color: var(--ink);
  text-decoration: none;
}

/* ── Reading progress bar ───────────────────────────── */

.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--ink);
  z-index: 100;
  transition: width 0.1s linear, background var(--transition);
}

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

@media (max-width: 680px) {
  .about-intro {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-bottom: 36px;
  }

  .about-portrait {
    max-width: 220px;
  }
}

@media (max-width: 520px) {
  header { padding-top: 32px; }

  .about-intro {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-bottom: 32px;
  }

  .about-portrait {
    max-width: 200px;
  }

  .about-portrait img {
    border-radius: 12px;
  }

  .about-intro-copy {
    width: 100%;
    padding-top: 0;
  }

  .post-list li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .archive-title-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .search-result-title-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .article-end-nav {
    gap: 8px 16px;
  }

  .archive-date {
    font-size: 11px;
  }

  .post-date {
    font-size: 11px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}
