.svg-icons {
  display: none;
}

/* ==========================================================================
   Variables
   ========================================================================== */
:root {
  /* Colors - Light (Sepia) Theme */
  --color-bg: #f4f1ea;
  --color-bg-alt: #ebe6dc;
  --color-text: #433422;
  --color-text-muted: #6b5d4d;
  --color-accent: #8b4513;
  --color-border: #d4c8b8;
  --color-highlight: #fff3cd;
  --color-code-bg: #282c34;
  --color-code-text: #abb2bf;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --font-mono: 'SF Mono', Menlo, Monaco, 'Courier New', monospace;

  /* Layout */
  --max-width: min(70%, 900px);
  --spacing: 1.5rem;
}

/* Dark Theme */
[data-theme="dark"] {
  --color-bg: #1a1a1a;
  --color-bg-alt: #252525;
  --color-text: #e0e0e0;
  --color-text-muted: #a0a0a0;
  --color-accent: #d4a574;
  --color-border: #3a3a3a;
  --color-highlight: #4a4020;
  --color-code-bg: #0d0d0d;
  --color-code-text: #abb2bf;
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  font-size: 18px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Layout - Header, Footer, Content
   ========================================================================== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  padding: var(--spacing);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-text);
}

.nav-links {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--color-text-muted);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--color-text);
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  color: var(--color-text);
}

.theme-toggle svg {
  width: 1.25rem;
  height: 1.25rem;
}

.content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: calc(var(--spacing) * 2) var(--spacing);
  flex: 1;
  width: 100%;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--spacing);
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   Home Page
   ========================================================================== */
.hero {
  text-align: center;
  margin-bottom: calc(var(--spacing) * 3);
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.tagline {
  font-size: 1.25rem;
  color: var(--color-text-muted);
}

.blog-sections,
.recent-posts {
  margin-bottom: calc(var(--spacing) * 2);
}

.blog-sections h2,
.recent-posts h2 {
  font-size: 1.25rem;
  margin-bottom: var(--spacing);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.sections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--spacing);
}

.section-card {
  padding: var(--spacing);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.section-card h3 {
  margin-bottom: 0.5rem;
}

.section-card p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ==========================================================================
   Post List
   ========================================================================== */
.post-list {
  list-style: none;
}

.post-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem;
}

.post-item time {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

.post-section {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.summary {
  width: 100%;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-top: 0.5rem;
  margin-bottom: 0;
}

.summary p {
  display: inline;
  margin: 0;
}

.list-page h1 {
  margin-bottom: var(--spacing);
}

/* ==========================================================================
   Single Post
   ========================================================================== */
.post-header {
  margin-bottom: calc(var(--spacing) * 2);
}

.post-header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.post-meta {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.post-meta .author::before,
.post-meta .reading-time::before {
  content: "•";
  margin-right: 1rem;
}

/* Tags & Categories */
.tags,
.categories {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tags {
  margin-top: 0.75rem;
}

.categories {
  margin-bottom: 0.5rem;
}

.tag {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: var(--color-border);
  border-radius: 4px;
  color: var(--color-text-muted);
}

.category {
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  background: var(--color-accent);
  color: var(--color-bg);
  border-radius: 4px;
}

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

/* Post Navigation */
.post-footer {
  margin-top: calc(var(--spacing) * 2);
  padding-top: var(--spacing);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.prev-post,
.next-post {
  font-size: 0.9rem;
}

/* ==========================================================================
   Post Content
   ========================================================================== */

/* Headings */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.post-content h1 { font-size: 1.8rem; margin-top: 2.5rem; }
.post-content h2 { font-size: 1.5rem; }
.post-content h3 { font-size: 1.25rem; }
.post-content h4 { font-size: 1.1rem; }
.post-content h5 { font-size: 1rem; }
.post-content h6 { font-size: 0.9rem; color: var(--color-text-muted); }

/* Header Anchors */
.header-anchor {
  margin-left: 0.5rem;
  color: var(--color-text-muted);
  text-decoration: none;
  opacity: 0;
}

.header-anchor svg {
  width: 0.9em;
  height: 0.9em;
  vertical-align: middle;
}

.post-content :is(h1, h2, h3, h4, h5, h6):hover .header-anchor,
.header-anchor:focus {
  opacity: 1;
}

.header-anchor:hover {
  color: var(--color-accent);
}

/* Paragraphs & Lists */
.post-content p {
  margin-bottom: 1rem;
}

.post-content ul,
.post-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.post-content ul ul,
.post-content ol ol,
.post-content ul ol,
.post-content ol ul {
  margin-bottom: 0;
  margin-top: 0.25rem;
}

.post-content li {
  margin-bottom: 0.25rem;
}

/* Code */
.post-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-border);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.post-content pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: var(--spacing);
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 1rem;
}

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

.code-block {
  position: relative;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-btn svg {
  width: 1rem;
  height: 1rem;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background: var(--color-border);
}

/* Hugo Highlight */
.post-content .highlight {
  margin: 1rem 0;
  border-radius: 8px;
  overflow: hidden;
}

.post-content .highlight pre {
  margin: 0;
  border-radius: 0;
}

.post-content .highlight table {
  margin: 0;
  border: none;
}

.post-content .highlight td {
  padding: 0;
  border: none;
}

.post-content .highlight .lnt {
  color: var(--color-text-muted);
  padding-right: 1rem;
  user-select: none;
}

/* Blockquotes */
.post-content blockquote {
  border-left: 4px solid var(--color-accent);
  margin: 1.5rem 0;
  padding: 0.5rem 1rem;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  font-style: italic;
}

.post-content blockquote blockquote {
  margin: 0.5rem 0;
}

/* Tables */
.post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.post-content th,
.post-content td {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  text-align: left;
}

.post-content th {
  background: var(--color-bg-alt);
  font-weight: 600;
}

/* Images & Figures */
.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1rem 0;
}

.post-content figure {
  margin: 1.5rem 0;
}

.post-content figcaption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
}

/* Horizontal Rule */
.post-content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 2rem 0;
}

/* Footnotes */
.post-content .footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.85rem;
}

.post-content .footnotes hr {
  display: none;
}

.post-content .footnote-ref {
  font-size: 0.75em;
  vertical-align: super;
}

/* Task Lists */
.post-content ul.task-list {
  list-style: none;
  padding-left: 0;
}

.post-content .task-list-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.post-content input[type="checkbox"] {
  margin-top: 0.3rem;
}

/* Definition Lists */
.post-content dl {
  margin: 1rem 0;
}

.post-content dt {
  font-weight: 600;
  margin-top: 1rem;
}

.post-content dd {
  margin-left: 1.5rem;
  color: var(--color-text-muted);
}

/* Inline Elements */
.post-content mark {
  background: var(--color-highlight);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

.post-content kbd {
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.15em 0.4em;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.1);
}

.post-content abbr {
  text-decoration: underline dotted;
  cursor: help;
}

.post-content del {
  color: var(--color-text-muted);
}

/* Details/Summary */
.post-content details {
  margin: 1rem 0;
  padding: 1rem;
  background: var(--color-bg-alt);
  border-radius: 8px;
}

.post-content summary {
  cursor: pointer;
  font-weight: 600;
}

.post-content details[open] summary {
  margin-bottom: 0.75rem;
}

/* ==========================================================================
   Table of Contents
   ========================================================================== */
.table-of-contents {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--spacing);
  margin-bottom: calc(var(--spacing) * 2);
}

.table-of-contents h2 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-muted);
}

.table-of-contents nav,
.table-of-contents #TableOfContents {
  font-size: 0.9rem;
}

.table-of-contents ul {
  list-style: none;
  padding-left: 0;
}

.table-of-contents li {
  margin: 0.25rem 0;
}

.table-of-contents ul ul {
  padding-left: 1rem;
}

.table-of-contents a {
  color: var(--color-text);
}

.table-of-contents a:hover {
  color: var(--color-accent);
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
  :root {
    --max-width: 100%;
    --spacing: 1rem;
  }

  .hero h1 {
    font-size: 1.75rem;
  }

  .nav {
    flex-direction: column;
    gap: 1rem;
  }

  .post-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .header-anchor {
    opacity: 0.5;
  }
}
