/* =================================================================
   Theme tokens — warm cream paper (light) / warm deep (dark)
   ================================================================= */

:root, :root[data-theme="light"] {
  --bg:          #f5efe4;   /* warm cream paper */
  --bg-deep:     #ede5d3;
  --text:        #2a241e;   /* warm near-black */
  --text-muted:  #6b6258;
  --text-faint:  #9a9080;
  --rule:        #d8cfb8;
  --accent:      #2a241e;
  --accent-soft: #6b6258;

  --max-width:     680px;
  --reading-width: 38rem;
}

:root[data-theme="dark"] {
  --bg:          #1c1815;
  --bg-deep:     #25201b;
  --text:        #ede5d3;
  --text-muted:  #a09686;
  --text-faint:  #5a5248;
  --rule:        #36302a;
  --accent:      #ede5d3;
  --accent-soft: #a09686;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:          #1c1815;
    --bg-deep:     #25201b;
    --text:        #ede5d3;
    --text-muted:  #a09686;
    --text-faint:  #5a5248;
    --rule:        #36302a;
    --accent:      #ede5d3;
    --accent-soft: #a09686;
  }
}

/* =================================================================
   Reset + base
   ================================================================= */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light dark; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Newsreader", ui-serif, Charter, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 19px;
  line-height: 1.7;
  font-weight: 400;
  font-feature-settings: "kern", "liga", "onum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 4px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 120ms ease;
}
a:hover {
  text-decoration-color: var(--text);
  text-decoration-thickness: 1px;
}

::selection { background: var(--text); color: var(--bg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =================================================================
   Site header
   ================================================================= */

.site-header {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 1.5rem 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
}

.site-brand {
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 500;
  font-style: italic;
  letter-spacing: 0;
  color: var(--text);
  text-decoration: none;
}
.site-brand::before { content: none; }
.site-brand:hover { text-decoration: underline; text-decoration-color: var(--text-muted); }

.site-nav-wrap {
  display: flex;
  align-items: baseline;
  gap: 0.5rem 1.25rem;
  flex-wrap: wrap;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.95rem;
  font-style: italic;
}
.site-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 120ms ease;
}
.site-nav a:hover { color: var(--text); }
.site-nav a.is-active {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-underline-offset: 5px;
}

.theme-toggle {
  background: transparent;
  border: none;
  padding: 0.2rem 0.3rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: inherit;
  transition: color 120ms ease;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle:focus-visible { outline: 1px solid var(--text-muted); outline-offset: 3px; }
.theme-toggle::after { content: none; }
.theme-toggle svg { width: 14px; height: 14px; display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* =================================================================
   Hero
   ================================================================= */

.hero { margin: 2.5rem 0 4rem; }
.hero-name {
  font-size: 2.4rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0 0 1rem;
}
.hero-bio {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.55;
  color: var(--text);
  max-width: var(--reading-width);
}

/* =================================================================
   Section labels — italic serif, no decoration
   ================================================================= */

.section-label {
  font-family: inherit;
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
  display: block;
}
.section-label::before, .section-label::after { content: none; }

.now { margin-bottom: 4rem; }
.now p {
  margin: 0;
  color: var(--text);
  max-width: var(--reading-width);
}
.now em { color: var(--text-muted); font-style: italic; }
.now code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: var(--text-muted);
  background: var(--bg-deep);
  padding: 0.05em 0.3em;
  border-radius: 2px;
}

.elsewhere { margin-top: 5rem; }
.elsewhere p { margin: 0; color: var(--text-muted); font-style: italic; }
.elsewhere a { color: var(--text); text-decoration-color: var(--rule); font-style: normal; }

/* =================================================================
   Category sections (homepage)
   ================================================================= */

.cat { margin-bottom: 4rem; }
.cat-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}
.cat-title {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 500;
  font-style: italic;
  margin: 0;
  letter-spacing: 0;
}
.cat-title::before { content: none; }
.cat-title a { text-decoration: none; }
.cat-title a:hover { text-decoration: underline; text-decoration-color: var(--text-muted); }
.cat-all {
  font-family: inherit;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 120ms ease;
}
.cat-all:hover { color: var(--text); }
.cat-list {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* =================================================================
   Page header (category, about, project, post)
   ================================================================= */

.page-header { margin-bottom: 3rem; }
.page-header::after { content: none; }
.page-title {
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.012em;
  margin: 0 0 0.5rem;
  line-height: 1.2;
}
.page-lede {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
  font-size: 1.1rem;
  max-width: var(--reading-width);
}

.page-body {
  font-size: 1.02rem;
  line-height: 1.75;
  max-width: var(--reading-width);
}
.page-body h1 { font-size: 1.45rem; font-weight: 500; margin-top: 2.5rem; }
.page-body h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 2.5rem 0 0.75rem;
  letter-spacing: -0.005em;
  padding-left: 0;
}
.page-body h2::before { content: none; }
.page-body h3 {
  font-size: 1.05rem;
  font-weight: 500;
  margin: 2rem 0 0.5rem;
}
.page-body p { margin: 0 0 1.25rem; }
.page-body ul, .page-body ol { padding-left: 1.5rem; margin: 0 0 1.25rem; }
.page-body li { margin-bottom: 0.5rem; }
.page-body code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--bg-deep);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
.page-body pre {
  background: var(--bg-deep);
  border-radius: 3px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0 0 1.5rem;
}
.page-body pre code { background: transparent; padding: 0; }
.page-body blockquote {
  margin: 0 0 1.25rem;
  padding-left: 1.25rem;
  border-left: 2px solid var(--rule);
  color: var(--text-muted);
  font-style: italic;
}
.page-body img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
}

/* =================================================================
   Year groups
   ================================================================= */

.year {
  font-family: inherit;
  font-style: italic;
  font-weight: 400;
  font-size: 0.95rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  margin: 3rem 0 1.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  display: block;
}
.year::before, .year::after { content: none; }
.year:first-of-type { margin-top: 0; }
.year-group { display: flex; flex-direction: column; gap: 2rem; }

/* =================================================================
   Project / post rows
   ================================================================= */

.project, .post-row {
  position: relative;
  padding-left: 0;
  margin-left: 0;
}
.project::before, .post-row::before { content: none; }

.project-row-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.project-title {
  font-family: inherit;
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0;
  letter-spacing: -0.005em;
  flex: 1 1 auto;
  line-height: 1.3;
}
.project-title a { text-decoration: none; }
.project-title a:hover {
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  text-underline-offset: 4px;
}

.project-tags-right {
  font-family: inherit;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.project-tags-right .tag { color: var(--text-muted); }

.project-desc {
  margin: 0 0 0.6rem;
  color: var(--text);
  max-width: var(--reading-width);
  font-size: 1rem;
  line-height: 1.6;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  align-items: center;
}
.project-date {
  font-family: inherit;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-faint);
}
.project-tags .tag {
  font-family: inherit;
  font-style: italic;
  font-size: 0.88rem;
  color: var(--text-muted);
}
.project-links a {
  color: var(--text-muted);
  font-style: italic;
  text-decoration: underline;
  text-decoration-color: var(--rule);
}
.project-links a:hover { color: var(--text); text-decoration-color: var(--text-muted); }
.project-links a + a { margin-left: 0.5rem; }
.project-links .read-more {
  font-family: inherit;
  font-style: italic;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  border: none;
  padding: 0;
}
.project-links .read-more:hover {
  text-decoration-color: var(--text);
}

.empty {
  color: var(--text-muted);
  font-style: italic;
  margin-top: 1rem;
}

/* =================================================================
   Project / post detail
   ================================================================= */

.project-nav {
  font-family: inherit;
  font-style: italic;
  font-size: 0.9rem;
  margin-bottom: 2rem;
}
.project-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 120ms ease;
}
.project-nav a:hover { color: var(--text); }

.project-page-header { margin-bottom: 2.5rem; }
.project-page-header::after { content: none; }
.project-page-header .page-title { margin-bottom: 0.5rem; }
.project-page-header .page-lede { margin-bottom: 1.25rem; }
.project-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1rem;
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-muted);
  align-items: center;
  margin-bottom: 1rem;
}
.project-page-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-family: inherit;
  font-style: italic;
  font-size: 0.95rem;
}
.project-page-links a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
  border: none;
}
.project-page-links a:hover { text-decoration-color: var(--text); }

.project-body { max-width: var(--reading-width); }

/* =================================================================
   Site footer + subscribe
   ================================================================= */

.site-footer {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

.subscribe {
  border-top: 1px solid var(--rule);
  padding-top: 2.5rem;
  margin-bottom: 2.5rem;
}
.subscribe-lede {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.98rem;
  max-width: var(--reading-width);
}
.subscribe-lede a {
  color: var(--text-muted);
  text-decoration-color: var(--rule);
  font-style: italic;
}
.subscribe-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 26rem;
}
.subscribe-form input[type="email"] {
  flex: 1 1 14rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.55rem 0.75rem;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 120ms ease;
}
.subscribe-form input[type="email"]:focus {
  outline: none;
  border-color: var(--text);
}
.subscribe-form button {
  background: var(--text);
  color: var(--bg);
  border: 1px solid var(--text);
  border-radius: 2px;
  padding: 0.55rem 1.1rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 120ms ease;
}
.subscribe-form button:hover { opacity: 0.85; }

.footer-meta {
  border-top: 1px solid var(--rule);
  padding-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.footer-links { margin: 0 0 0.5rem; font-style: italic; }
.footer-links a { color: var(--text-muted); text-decoration-color: var(--rule); }
.footer-links a:hover { color: var(--text); }
.footer-colophon {
  margin: 0;
  font-style: italic;
  font-size: 0.85rem;
  color: var(--text-faint);
}
.footer-colophon a { color: var(--text-faint); text-decoration-color: var(--rule); }

/* Hide any leftover decorative elements */
.deco-tetris, .deco-corner, .deco-corner-tr, .deco-ribbon, .deco-float-left { display: none; }

/* =================================================================
   Responsive
   ================================================================= */

@media (max-width: 720px) {
  body { font-size: 18px; }
  main { padding-top: 2rem; padding-bottom: 4rem; }
  .hero { margin: 1.5rem 0 3rem; }
  .hero-name { font-size: 1.9rem; }
  .page-title { font-size: 1.65rem; }
}
@media (max-width: 480px) {
  .site-header { padding-top: 1.5rem; gap: 0.5rem 1rem; }
  .hero-name { font-size: 1.7rem; }
  .hero-bio { font-size: 1.05rem; }
}
