@import url('https://fonts.googleapis.com/css2?family=Newsreader:ital,wght@0,400;0,500;0,600;1,400&display=swap');

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

:root, [data-theme="dark"] {
  --bg:            #0f1117;
  --fg:            #e8e6e1;
  --muted:         #8a8a8a;
  --accent:        #c9a84c;
  --accent-dim:    rgba(201, 168, 76, 0.12);
  --border:        rgba(201, 168, 76, 0.22);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --toggle-bg:     rgba(255, 255, 255, 0.06);
  --toggle-hover:  rgba(255, 255, 255, 0.1);
}

[data-theme="light"] {
  --bg:            #f7f5f0;
  --fg:            #1a1714;
  --muted:         #7a7268;
  --accent:        #9a6f2a;
  --accent-dim:    rgba(154, 111, 42, 0.1);
  --border:        rgba(154, 111, 42, 0.25);
  --border-subtle: rgba(0, 0, 0, 0.08);
  --toggle-bg:     rgba(0, 0, 0, 0.05);
  --toggle-hover:  rgba(0, 0, 0, 0.09);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 2rem 6rem;
  min-height: 100vh;
  transition: background 0.3s ease, color 0.3s ease;
}

main { width: 100%; max-width: 680px; }

a { color: var(--fg); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 3rem;
}

.back-link {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.back-link:hover { color: var(--accent); }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--toggle-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-family: inherit;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
  user-select: none;
}
.theme-toggle:hover { background: var(--toggle-hover); color: var(--fg); border-color: var(--border); }

.toggle-track {
  width: 32px; height: 18px;
  border-radius: 999px;
  background: var(--border-subtle);
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.25s, border-color 0.25s;
  flex-shrink: 0;
}
[data-theme="light"] .toggle-track { background: var(--accent-dim); border-color: var(--border); }

.toggle-knob {
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.25s;
}
[data-theme="light"] .toggle-knob { transform: translateX(14px); background: var(--accent); }

.toggle-icon { font-size: 0.9rem; line-height: 1; }

article h1 {
  font-family: 'Newsreader', Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 3.2rem);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--fg);
  margin-bottom: 1rem;
}

.subtitle {
  font-size: 1.1rem;
  color: var(--muted);
  line-height: 1.6;
  font-style: italic;
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-subtle);
}

.essay-body h2 {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 500;
  color: var(--fg);
  margin: 2.5rem 0 0.75rem;
  line-height: 1.2;
}

.essay-body p { margin-bottom: 1.4rem; }
.essay-body p:last-child { margin-bottom: 0; }
.essay-body strong { font-weight: 600; }
.essay-body em { font-style: italic; }

.essay-body img {
  width: 100%; height: auto;
  border-radius: 6px;
  margin: 1.5rem 0;
  display: block;
}

.essay-body ul, .essay-body ol { margin: 0.5rem 0 1.4rem 1.5rem; }
.essay-body li { margin-bottom: 0.5rem; line-height: 1.7; }

.essay-body blockquote {
  border-left: 2px solid var(--border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--muted);
}

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

.essay-body a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 2px; }
.essay-body a:hover { text-decoration-color: var(--accent); }

.footnote { font-size: 0.95rem; color: var(--muted); font-style: italic; }

@media (max-width: 600px) {
  body { padding: 2rem 1.25rem 4rem; }
  article h1 { font-size: 2rem; }
}
