/* Default = dark, matching darioamodei.com */
:root {
  --bg: #1f1e1d;
  --text: #f0eee6;
  --muted: #9d9a90;
  --rule: #3a3835;
  --toggle-border: #3f3d39;
  --switch-track: #46433d;
  --switch-knob: #f0eee6;
  --switch-icon: #1f1e1d;
  --heading: #e08a3e;
  --maxw: 620px;
}

/* Light = warm, book-paper cream */
:root[data-theme="light"] {
  --bg: #f5efe1;
  --text: #2c2822;
  --muted: #7c7461;
  --rule: #e2d9c5;
  --toggle-border: #d7cdb8;
  --switch-track: #ded4bf;
  --switch-knob: #fffdf7;
  --switch-icon: #bf862b;
  --heading: #2f66c9;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-optical-sizing: auto;
  font-size: 20px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Old-newspaper headings, readable rather than blackletter */
.article h1 {
  font-family: "IM Fell English SC", "Newsreader", Georgia, serif;
  font-weight: 400;
  letter-spacing: 0.025em;
}

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

/* Links */
a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text);
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover { opacity: 0.7; }

/* Top bar: name + archive + toggle */
.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 34px;
}
.topbar h1 {
  font-size: 48px;
  font-weight: 400;
  line-height: 1.1;
  margin: 0;
}
.topbar h1 a { text-decoration: none; }

/* Text masthead */
.topbar h1 {
  flex: none;
  font-family: "Cormorant Garamond", "Newsreader", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.topbar h1 a { display: block; color: var(--heading); }

.topbar .nav a { text-decoration: none; }
.topbar .nav a:hover { text-decoration: underline; }
.spacer { flex: 1; }

/* Apple-style theme switch */
.theme-switch {
  position: relative;
  width: 52px;
  height: 30px;
  flex: none;
  align-self: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--switch-track);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s ease;
}
.theme-switch:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--switch-knob);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--switch-icon);
  transition: transform 0.3s cubic-bezier(0.4, 0.1, 0.2, 1.2), background-color 0.3s ease;
}
:root[data-theme="light"] .switch-knob { transform: translateX(22px); }
.switch-knob svg { width: 13px; height: 13px; display: block; }
.switch-knob .icon-sun { display: none; }
:root[data-theme="light"] .switch-knob .icon-sun { display: block; }
:root[data-theme="light"] .switch-knob .icon-moon { display: none; }

/* Intro */
.intro { margin: 0; }
.intro p { margin: 0 0 22px; }

/* Sections */
.section { margin-top: 40px; }
.section h2 {
  font-family: "IM Fell English SC", "Newsreader", Georgia, serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 0 0 10px;
  color: var(--heading);
}
.entry {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 0;
}
.entry .date {
  font-size: 16px;
  color: var(--muted);
  white-space: nowrap;
  text-decoration: none;
}

/* Article */
.back {
  display: inline-block;
  font-size: 17px;
  color: var(--muted);
  text-decoration: none;
  margin-bottom: 40px;
}
.back:hover { color: var(--text); }
.article h1 {
  font-size: 44px;
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: 0.01em;
  margin: 0 0 10px;
  color: var(--heading);
}
.article .meta {
  font-size: 16px;
  color: var(--muted);
  margin: 0 0 40px;
}
.article p { margin: 0 0 24px; }
.article h2 {
  font-family: "IM Fell English SC", "Newsreader", Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  letter-spacing: 0.02em;
  margin: 42px 0 14px;
  color: var(--heading);
}
.article blockquote {
  margin: 30px 0;
  padding-left: 22px;
  border-left: 3px solid var(--rule);
  color: var(--muted);
  font-style: italic;
}
.article ul, .article ol { padding-left: 24px; margin: 0 0 24px; }
.article li { margin-bottom: 8px; }

.footer {
  margin-top: 90px;
  padding-top: 22px;
  border-top: 1px solid var(--rule);
  font-size: 16px;
  color: var(--muted);
}

@media (max-width: 600px) {
  body { font-size: 19px; }
  .wrap { padding: 44px 20px 90px; }
  .topbar { gap: 14px; }
  .topbar h1 { font-size: 38px; }
  .article h1 { font-size: 31px; }
  .entry { flex-direction: column; gap: 2px; }
}

@media (max-width: 430px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .topbar h1 {
    flex-basis: 100%;
    font-size: 42px;
  }
  .spacer { flex: 1; }
}
