/* ============================================
   The Quiet Essay — Editorial blog theme
   ============================================ */

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

:root {
  --bg: #f6f5f0;
  --bg-subtle: #edece6;
  --text: #2c2c2c;
  --text-secondary: #555;
  --text-muted: #888;
  --border: #d4d0c8;
  --link: #2c2c2c;
  --link-underline: #b8b4a8;
  --link-hover: #000;
  --link-hover-underline: #2c2c2c;
  --code-bg: #edecea;
  --blockquote-border: #c8c4b8;
  --blockquote-text: #555;
  --tag-bg: #e4e2da;
  --tag-text: #666;
  --draft-bg: #d4a574;
  --draft-text: #fff;
}

html {
  font-family: 'Newsreader', Georgia, 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.68;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-weight: 400;
}

::selection {
  background: #d4cfc4;
  color: #1a1a1a;
}

/* === Links === */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s ease;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: var(--link-hover-underline);
}

/* === Nav === */
.nav {
  max-width: 800px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 0;
  display: flex;
  justify-content: flex-start;
  align-items: baseline;
  gap: 1.5rem;
}

.nav-links {
  display: flex;
  gap: 1.25rem;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.2s ease;
}

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

/* === Layout === */
.home, .blog-listing {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.post-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

/* === About === */
.about {
  margin-bottom: 0;
}

.about h2 {
  font-size: 1.8rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.about p {
  margin-bottom: 0.65rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
}

.about a {
  color: var(--text-secondary);
}

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

/* === Post Previews === */
.post-preview {
  margin-bottom: 2.25rem;
}

.post-preview-title {
  font-size: 1.15rem;
  font-weight: 400;
  color: var(--text);
  text-decoration: none;
  line-height: 1.35;
  display: inline-block;
}

.post-preview-title:hover {
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.post-preview-lede {
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.2rem;
  font-size: 0.9rem;
  line-height: 1.55;
}

.post-preview-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
}

.tag {
  display: inline-block;
  background: var(--tag-bg);
  color: var(--tag-text);
  border-radius: 3px;
  padding: 0.1rem 0.4rem;
  font-size: 0.7rem;
  font-weight: 500;
  margin-left: 0.3rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  vertical-align: middle;
}

.tag-draft {
  background: var(--draft-bg);
  color: var(--draft-text);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.06em;
}

/* === Blog Post === */
.post-title {
  font-size: 2.2rem;
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.post-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0.01em;
}

/* === Post Body Typography === */
.post-body p {
  margin-bottom: 1.15rem;
}

.post-body h1 {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  margin-top: 3rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.post-body h2 {
  font-size: 1.55rem;
  font-weight: 400;
  letter-spacing: -0.015em;
  margin-top: 2.75rem;
  margin-bottom: 0.85rem;
  line-height: 1.25;
}

.post-body h3 {
  font-size: 1.25rem;
  font-weight: 400;
  margin-top: 2.25rem;
  margin-bottom: 0.65rem;
  line-height: 1.3;
}

.post-body h4 {
  font-size: 1.05rem;
  font-weight: 500;
  margin-top: 1.75rem;
  margin-bottom: 0.5rem;
}

.post-body h5 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.post-body h6 {
  font-size: 0.85rem;
  font-weight: 500;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.post-body ul, .post-body ol {
  margin: 0.75rem 0 1.15rem;
  padding-left: 1.5rem;
}

.post-body ul { list-style-type: disc; }
.post-body ol { list-style-type: decimal; }

.post-body li {
  margin-bottom: 0.35rem;
  line-height: 1.6;
}

.post-body li > p {
  margin: 0;
}

.post-body li > ul,
.post-body li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.post-body blockquote {
  border-left: 3px solid var(--blockquote-border);
  padding-left: 1.25rem;
  margin: 1.75rem 0;
  font-style: italic;
  color: var(--blockquote-text);
}

.post-body blockquote p {
  margin-bottom: 0.65rem;
}

.post-body blockquote p:last-child {
  margin-bottom: 0;
}

.post-body code {
  font-family: ui-monospace, 'SF Mono', 'Menlo', 'Cascadia Code', monospace;
  font-size: 0.78em;
  background: none;
  padding: 0;
  border-radius: 0;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.post-body pre {
  background: var(--code-bg);
  padding: 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 0.82rem;
  line-height: 1.55;
}

.post-body pre code {
  background: none;
  padding: 0;
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 3px;
  margin: 1.75rem 0;
  cursor: zoom-in;
}

.post-body figure {
  margin: 1.75rem 0;
}

.post-body figure img {
  margin: 0;
}

.post-body figcaption {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 0.6rem;
  line-height: 1.5;
}

.post-body a {
  color: var(--link);
}

.post-body a:hover {
  color: var(--link-hover);
}

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

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

.post-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem auto;
  max-width: 80px;
}

/* === Back Link === */
.back-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-decoration: none;
  margin-bottom: 1.25rem;
  letter-spacing: 0.02em;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: color 0.2s ease;
}

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

/* === Lightbox === */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(42, 40, 36, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
  padding: 3rem;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-overlay img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06);
  transform: scale(0.94);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-overlay.active img {
  transform: scale(1);
}

.lightbox-caption {
  color: rgba(246, 245, 240, 0.55);
  font-size: 0.82rem;
  margin-top: 1rem;
  max-width: 600px;
  text-align: center;
  font-family: 'Newsreader', Georgia, serif;
  font-style: italic;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease 0.08s, transform 0.3s ease 0.08s;
}

.lightbox-overlay.active .lightbox-caption {
  opacity: 1;
  transform: translateY(0);
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(246, 245, 240, 0.06);
  border: 1px solid rgba(246, 245, 240, 0.1);
  border-radius: 50%;
  color: rgba(246, 245, 240, 0.45);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(246, 245, 240, 0.12);
  border-color: rgba(246, 245, 240, 0.18);
  color: rgba(246, 245, 240, 0.8);
}

/* === Footnotes === */
.footnote-ref a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
  padding: 0 1px;
  transition: color 0.2s ease;
}

.footnote-ref a:hover {
  color: var(--text);
}

.footnotes-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3rem auto 1.5rem;
  max-width: 80px;
}

.footnotes {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.footnotes-list {
  padding-left: 1.25rem;
  margin: 0;
}

.footnotes-list li {
  margin-bottom: 0.5rem;
}

.footnotes-list p {
  margin: 0;
  display: inline;
}

.footnote-backref {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85em;
  margin-left: 0.25rem;
}

.footnote-backref:hover {
  color: var(--text);
}

/* Footnote popover tooltip */
.fn-popover {
  position: absolute;
  z-index: 100;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.85rem 1rem;
  max-width: 360px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--text-secondary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.fn-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

/* === Responsive === */
@media (max-width: 640px) {
  html {
    font-size: 17px;
  }

  .nav {
    padding: 1.75rem 1.25rem 0;
  }

  .home, .blog-listing {
    padding: 2rem 1.25rem 4rem;
  }

  .post-page {
    padding: 2rem 1.25rem 4rem;
  }

  .post-title {
    font-size: 1.7rem;
  }

  .about h2 {
    font-size: 1.5rem;
  }
}
