/* =========================================
   Font Stacks
   — Serif  : all editorial content
              (headings, body, excerpts, hero copy, blockquotes)
   — Sans   : all UI chrome
              (nav, dates, badges, buttons, captions, labels,
               TOC, filters, footer)
   ========================================= */

:root {
  --font-serif: Palatino, "Palatino Linotype", "Book Antiqua", serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}


/* =========================================
   Color Tokens
   ========================================= */

:root {
  --color-bg:        #fff;
  --color-text:      #222;
  --color-muted:     #444;
  --color-subtle:    #6b6b6b;  /* 4.8:1 on white — WCAG AA ✓ */
  --color-border:    #e0e0e0;
  --color-header-bg: #fff;
  --color-nav-link:  #444;
}

:root[data-dark] {
  --color-bg:        #1a1a1a;
  --color-text:      #e8e8e8;
  --color-muted:     #aaa;
  --color-subtle:    #999;     /* 5.7:1 on #1a1a1a — WCAG AA ✓ */
  --color-border:    #333;
  --color-header-bg: #141414;
  --color-nav-link:  #bbb;
}


/* =========================================
   Reset & Base
   ========================================= */

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

/* Base uses serif — the default for all editorial text */
body {
  font-family: var(--font-serif);
  font-size: clamp(15px, 1.2vw + 11px, 18px);
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
}

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

a:hover {
  text-decoration: underline;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}


/* =========================================
   Accessibility Utility
   ========================================= */

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


/* =========================================
   Sticky Header
   ========================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* UI chrome — sans */
.site-title {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.site-title:hover {
  text-decoration: none;
  opacity: 0.75;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}


/* =========================================
   Navigation — sans
   ========================================= */

.nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.nav a {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--color-nav-link);
  letter-spacing: 0.02em;
}

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

.nav a[aria-current="page"] {
  color: var(--color-text);
  font-weight: 600;
}


/* =========================================
   Hamburger
   ========================================= */

.nav-toggle-input {
  display: none;
}

.nav-toggle-label {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2rem;
  height: 2rem;
  cursor: pointer;
}

.hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform-origin: center;
}

#nav-toggle:checked ~ .nav-toggle-label .hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
#nav-toggle:checked ~ .nav-toggle-label .hamburger-bar:nth-child(2) {
  opacity: 0;
}
#nav-toggle:checked ~ .nav-toggle-label .hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}


/* =========================================
   Dark Mode Toggle — sans (UI chrome)
   ========================================= */

.dark-mode-input {
  display: none;
}

.dark-mode-label {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
}

.dark-mode-label:hover {
  background: var(--color-border);
}

/* Icon is a symbol, not text — no font-family needed */
.dark-mode-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--color-text);
}

:root[data-dark] .dark-mode-icon {
  font-size: 0.9rem;
}


/* =========================================
   Content Wrapper
   ========================================= */

.content-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}


/* =========================================
   Featured Post
   ========================================= */

.featured-post {
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--color-border);
}

.featured-image-wrap {
  margin-bottom: 1.25rem;
}

.featured-image {
  width: 100%;
  aspect-ratio: 900 / 400;
  object-fit: cover;
  border-radius: 2px;
}

.featured-post .post-meta {
  margin-bottom: 0.4rem;
}

/* Editorial — serif */
.featured-post .post-title {
  font-family: var(--font-serif);
  font-size: clamp(1.6rem, 3.5vw + 0.5rem, 2rem);
  line-height: 1.25;
  margin-bottom: 0.75rem;
}

.featured-post .post-title a:hover {
  text-decoration: underline;
}

/* Editorial — serif */
.featured-post .post-excerpt {
  font-family: var(--font-serif);
  color: var(--color-muted);
  margin-bottom: 1rem;
  max-width: 70ch;
}


/* =========================================
   Post List
   ========================================= */

.post-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-item {
  padding: 2.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.post-item:first-child {
  padding-top: 2.5rem;
}

/* Optional image on a post-item (e.g. first post in a feed) */
.post-item--with-image .post-item-image {
  width: 100%;
  aspect-ratio: 900 / 400;
  object-fit: cover;
  border-radius: 2px;
  margin-bottom: 1.1rem;
}

/* Editorial — serif */
.post-item .post-title {
  font-family: var(--font-serif);
  font-size: clamp(1.15rem, 2vw + 0.5rem, 1.35rem);
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.post-item .post-title a:hover {
  text-decoration: underline;
}

/* Editorial — serif */
.post-item .post-excerpt {
  font-family: var(--font-serif);
  color: var(--color-muted);
  margin-bottom: 0.75rem;
  max-width: 70ch;
}


/* =========================================
   Shared Post Elements
   ========================================= */

/* UI chrome — sans */
.post-meta time {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--color-subtle);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* UI chrome — sans */
.read-more {
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: 0.02em;
}

.read-more:hover {
  text-decoration: underline;
}


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

@media screen and (max-width: 640px) {
  .header-inner {
    padding: 0 1rem;
  }

  .nav-toggle-label {
    display: flex;
  }

  .nav {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    background: var(--color-header-bg);
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0;
  }

  .nav a {
    width: 100%;
    padding: 0.65rem 20% 0.65rem 2rem;
    text-align: right;
    font-size: 0.95rem;
  }

  .nav a:hover {
    background: var(--color-border);
  }

  #nav-toggle:checked ~ .nav {
    display: flex;
  }

  .content-wrap {
    padding: 2rem 1rem 4rem;
  }
}


/* =========================================
   Single Post — Header
   ========================================= */

.post-full-header {
  margin-bottom: 1.5rem;
}

/* Editorial — serif */
.post-full-title {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw + 0.5rem, 2.4rem);
  line-height: 1.2;
  margin-top: 0.4rem;
}


/* =========================================
   Single Post — Layout grid
   ========================================= */

.post-layout {
  display: grid;
  grid-template-columns: 1fr 13rem;
  grid-template-areas:
    "image image"
    "body  toc";
  column-gap: 3rem;
}

.post-layout .featured-image-wrap {
  grid-area: image;
  margin-bottom: 2rem;
}

/* UI chrome — sans */
.post-layout .featured-image-wrap figcaption {
  font-family: var(--font-sans);
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-subtle);
  text-align: center;
}

.post-body {
  grid-area: body;
}


/* =========================================
   Table of Contents — sans (UI chrome)
   ========================================= */

.toc {
  grid-area: toc;
  align-self: start;
  position: sticky;
  top: 72px;
}

.toc-heading {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-subtle);
  margin-bottom: 0.6rem;
}

.toc-heading--files {
  margin-top: 1.5rem;
}

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

.toc-files li {
  padding: 0.2rem 0;
}

.toc-files a {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--color-muted);
  display: block;
}

.toc-files a::before {
  content: '↓ ';
  font-size: 0.75rem;
}

.toc-files a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.toc nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--color-border);
}

.toc nav li {
  padding: 0.2rem 0 0.2rem 0.85rem;
}

.toc nav li.toc-sub {
  padding-left: 1.5rem;
}

.toc nav a {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  color: var(--color-muted);
  line-height: 1.4;
  display: block;
}

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

.toc nav a.toc-active {
  color: var(--color-text);
  font-weight: 600;
}


/* =========================================
   Single Post — Body (editorial — serif)
   ========================================= */

.post-body {
  font-family: var(--font-serif);
  margin-bottom: 3rem;
}

.post-body > * + * {
  margin-top: 1.25em;
}

/* Editorial headings — serif */
.post-body h2 {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2.5vw + 0.4rem, 1.5rem);
  line-height: 1.3;
  margin-top: 2.25em;
}

.post-body h3 {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 1.5vw + 0.4rem, 1.2rem);
  line-height: 1.3;
  margin-top: 1.75em;
}

/* Editorial — serif */
.post-body blockquote {
  font-family: var(--font-serif);
  border-left: 3px solid var(--color-border);
  padding-left: 1.25rem;
  color: var(--color-muted);
  font-style: italic;
}

.post-body blockquote > * + * {
  margin-top: 0.75em;
}

.post-body ul,
.post-body ol {
  padding-left: 1.5rem;
}

.post-body li + li {
  margin-top: 0.35em;
}

/* Code is technical/UI — sans */
.post-body code {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.875em;
  background: var(--color-border);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

.post-body pre {
  background: var(--color-border);
  padding: 1.1rem 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85em;
  line-height: 1.6;
}


/* =========================================
   Single Post — Footer
   ========================================= */

.post-full-footer {
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}


/* =========================================
   Responsive — collapse sidebar ≤ 768px
   ========================================= */

@media screen and (max-width: 768px) {
  .post-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "image"
      "toc"
      "body";
  }

  .toc {
    position: static;
    margin-bottom: 2rem;
    padding: 1rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
  }
}


/* =========================================
   Archive — Layout
   ========================================= */

/* Editorial — serif */
.archive-title {
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 4vw + 0.5rem, 2.4rem);
  line-height: 1.2;
  text-align: center;
  margin-bottom: 2.5rem;
  grid-column: 2;
}

.archive-layout {
  display: grid;
  grid-template-columns: 1fr 2fr;
  column-gap: 3.5rem;
  align-items: start;
}

.archive-sidebar {
  position: sticky;
  top: 72px;
  padding-top: 2.5rem;
}

/* UI chrome — sans */
.archive-sidebar-heading {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--color-subtle);
  margin-bottom: 1.25rem;
}

.archive-posts .post-item:first-child {
  border-top: 1px solid var(--color-border);
}


/* =========================================
   Archive — Filter Controls — sans (UI chrome)
   ========================================= */

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1.1rem;
}

.filter-label {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-subtle);
  letter-spacing: 0.03em;
}

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  padding: 0.4rem 2rem 0.4rem 0.65rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b6b6b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.filter-select:hover,
.filter-select:focus {
  border-color: var(--color-muted);
  outline: none;
}


/* =========================================
   Archive — Responsive (≤ 768px)
   ========================================= */

@media screen and (max-width: 768px) {
  .archive-layout {
    grid-template-columns: 1fr;
  }

  .archive-title {
    grid-column: 1;
  }

  .archive-sidebar {
    position: static;
    padding-top: 0;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    column-gap: 1rem;
    align-items: end;
  }

  .archive-sidebar-heading {
    display: none;
  }
}


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

.hero {
  border-bottom: 1px solid var(--color-border);
  padding: 4rem 1.5rem 3.5rem;
}

.hero-inner {
  max-width: 900px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 3rem;
  align-items: center;
}

/* Editorial — serif */
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3.5vw + 0.5rem, 2.5rem);
  line-height: 1.2;
  margin-bottom: 1rem;
}

/* Editorial — serif */
.hero-sub {
  font-family: var(--font-serif);
  color: var(--color-muted);
  max-width: 52ch;
  margin-bottom: 1.75rem;
}

.hero-ctas {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* UI chrome — sans */
.btn {
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.6rem 1.4rem;
  border-radius: 3px;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s, background 0.15s;
}

.btn--primary {
  background: var(--color-text);
  color: var(--color-bg);
}

.btn--primary:hover {
  opacity: 0.8;
  text-decoration: none;
}

.btn--ghost {
  border: 1px solid var(--color-border);
  color: var(--color-text);
}

.btn--ghost:hover {
  background: var(--color-border);
  text-decoration: none;
}

.hero-left {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.hero-photo {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 2px;
  filter: grayscale(15%);
}

.hero-eq-inner {
  text-align: center;
  padding: 2rem 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-bg);
}

/* UI chrome — sans */
.hero-eq-caption {
  font-family: var(--font-sans);
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--color-subtle);
  line-height: 1.5;
  max-width: 36ch;
  margin-left: auto;
  margin-right: auto;
}

@media screen and (max-width: 768px) {
  .hero-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-photo-wrap {
    position: static;
    max-width: 260px; /* portrait, not full-bleed, on mobile */
    margin: 0 auto;
  }
}


/* =========================================
   Authority Strip — sans (UI chrome)
   ========================================= */

.authority-strip {
  background: var(--color-border);
  padding: 1.5rem;
}

.authority-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem 2.5rem;
}

.authority-bio {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-muted);
  flex-shrink: 0;
  max-width: 42ch;
}

.badge-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  padding: 0.3rem 0.75rem;
  border-radius: 2px;
  white-space: nowrap;
}


/* =========================================
   Section Heading — serif (editorial)
   ========================================= */

.section-heading {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 2vw + 0.5rem, 1.5rem);
  line-height: 1.3;
  margin-bottom: 1.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}


/* =========================================
   Services
   ========================================= */

.services {
  margin-bottom: 3.5rem;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.service-card {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1.4rem 1.5rem;
}

/* Editorial — serif */
.service-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.3;
  margin-bottom: 0.6rem;
}

/* Editorial — serif */
.service-body {
  font-family: var(--font-serif);
  font-size: 0.9rem;
  color: var(--color-muted);
  line-height: 1.65;
}

@media screen and (max-width: 640px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
}


/* =========================================
   Recent Writing
   ========================================= */

.recent-writing {
  margin-bottom: 3.5rem;
}

.all-writing-link {
  margin-top: 1.5rem;
}


/* =========================================
   About
   ========================================= */

.about-section {
  margin-bottom: 3.5rem;
}

.about-section p + p {
  margin-top: 1em;
}

/* Editorial — serif */
.about-section p {
  font-family: var(--font-serif);
  color: var(--color-muted);
  max-width: 70ch;
}


/* =========================================
   Footer — sans (UI chrome)
   ========================================= */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 2.5rem 1.5rem;
}

.footer-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 2.5rem;
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-nav a,
.footer-social a {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--color-muted);
}

.footer-nav a:hover,
.footer-social a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.footer-social {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.footer-copy {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-subtle);
  margin-left: auto;
}

@media screen and (max-width: 640px) {
  .footer-copy {
    margin-left: 0;
  }
}