/* --- Base --------------------------------------------------------------- */

:root {
  --bg: #0f0e11;
  --bg-alt: #1a181d;

  --text: #f7eedb;
  --text-muted: #c6bda8;

  --accent: #d9a850;
  --accent-soft: #b88c45;

  --border: rgba(255, 255, 255, 0.06);

  --shadow: rgba(0, 0, 0, 0.55);
  --shadow-soft: rgba(0, 0, 0, 0.35);

  --transition: 180ms ease;
  --radius: 6px;
}

[data-theme="light"] {
  --bg: #faf9f7;
  --bg-alt: #f0eeeb;

  --text: #1a1a1a;
  --text-muted: #555555;

  --accent: #8b6914;
  --accent-soft: #a67c00;

  --border: rgba(0, 0, 0, 0.08);

  --shadow: rgba(0, 0, 0, 0.12);
  --shadow-soft: rgba(0, 0, 0, 0.08);
}

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

body {
  margin: 0;
  padding: 0;
  font-family: "Merriweather", "Georgia", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout -------------------------------------------------------------- */

body {
  max-width: 860px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

/* --- Headings ------------------------------------------------------------ */

h1, h2, h3, h4, h5, h6 {
  font-family: "Merriweather", serif;
  font-weight: 700;
  color: var(--accent);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

h1 {
  font-size: 2.25rem;
  letter-spacing: -0.02em;
  margin-top: 0;
}
h2 {
  font-size: 1.7rem;
  letter-spacing: -0.01em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
h3 {
  font-size: 1.35rem;
  color: var(--accent-soft);
}

/* --- Text Elements ------------------------------------------------------- */

p {
  margin: 0 0 1.25rem;
  color: var(--text);
  font-size: 1rem;
}

strong { font-weight: 600; }

em { font-style: italic; }

/* --- Links --------------------------------------------------------------- */

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

a:hover { border-bottom-color: var(--accent); }

/* --- Images -------------------------------------------------------------- */

img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1rem 0;
}

img[align="left"] { margin-right: 1.5rem; }
img[align="right"] { margin-left: 1.5rem; }

figure { margin: 1.5rem 0; }
figcaption {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 0.5rem;
  font-style: italic;
}

/* --- Code Blocks --------------------------------------------------------- */

pre, code {
  font-family: "Fira Code", "SF Mono", Monaco, monospace;
  font-size: 0.9em;
}

pre {
  background: var(--bg-alt);
  padding: 1rem 1.25rem;
  border-radius: 8px;
  box-shadow: 0 4px 20px var(--shadow-soft);
  overflow-x: auto;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

pre code {
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
}

code {
  background: var(--bg-alt);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--border);
}

/* --- Blockquotes --------------------------------------------------------- */

blockquote {
  margin: 1.5rem 0;
  padding: 1rem 1.4rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent-soft);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-style: italic;
}

/* --- Lists --------------------------------------------------------------- */

ul, ol {
  margin: 0 0 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.4rem;
  padding-left: 0.25rem;
  line-height: 1.6;
}

ul li { list-style-type: disc; }
ol li { list-style-type: decimal; }

ul ul, ol ol, ul ol, ol ul {
  margin-top: 0.4rem;
  margin-bottom: 0;
}

li::marker {
  color: var(--accent-soft);
}

/* --- Tables -------------------------------------------------------------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

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

th {
  color: var(--accent-soft);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Buttons / Generic CTA ---------------------------------------------- */

.button, button, input[type="submit"] {
  appearance: none;
  background: var(--accent-soft);
  color: #1a140b;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  box-shadow: 0 0 12px var(--shadow);
}

.button:hover, button:hover, input[type="submit"]:hover {
  background: var(--accent);
  box-shadow: 0 0 16px var(--shadow-soft);
}

/* --- Footer -------------------------------------------------------------- */

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

/* --- Site Header & Navigation ------------------------------------------- */

.site-header, header {
  margin-bottom: 3rem;
  text-align: center;
}

.site-title, .site-title a {
  color: var(--accent);
  text-decoration: none;
  margin-bottom: 0.5rem;
}

.site-subtitle { color: var(--text-muted); font-style: italic; margin-bottom: 1.5rem; }

.site-nav ul, nav ul {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.site-nav ul li, nav ul li {
  list-style: none;
  padding: 0;
  margin: 0;
}

.site-nav a, nav a { color: var(--text-muted); font-weight: 500; }
.site-nav a:hover, nav a:hover { color: var(--accent); }

.social-links { display: flex; gap: 1rem; justify-content: center; }
.social-link { color: var(--text-muted); font-size: 0.9rem; }

.social-link:hover { color: var(--accent); }

.theme-toggle {
  background: none; border: none; cursor: pointer; font-size: 1.25rem; color: var(--text-muted);
  padding: 0 0.5rem; transition: var(--transition);
}

.theme-toggle:hover { color: var(--accent); }
/* --- Post Styling ------------------------------------------------------- */

.post-header { margin-bottom: 2rem; }
.post-title { color: var(--accent); margin-bottom: 0.5rem; }
.post-date, .post-description { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.post-content { margin-bottom: 3rem; }

.posts-list article {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.posts-list article:last-child { border-bottom: none; }

/* --- Mermaid Diagram Styling ------------------------------------------- */

.mermaid {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin: 1.5rem 0;
  text-align: center;
  overflow-x: auto;
}

/* --- Scroll Progress -------------------------------------------------- */

.scroll-progress-container {
  position: fixed; top: 0; left: 0; width: 100%; height: 3px;
  z-index: 1001; background: var(--bg-alt);
}
.scroll-progress-bar {
  height: 100%; background: var(--accent); width: 0%;
  transition: width 50ms ease-out;
}

/* --- Reading Time -------------------------------------------------- */

.reading-time { font-size: 0.85em; color: var(--text-muted); margin-bottom: 1em; }

/* --- Post Navigation -------------------------------------------------- */

.post-navigation {
  display: flex; justify-content: space-between;
  margin-top: 2em; padding-top: 1em; border-top: 1px solid var(--border);
}
.post-navigation a { color: var(--accent); text-decoration: none; }
.post-navigation a:hover { text-decoration: underline; }

/* --- Wiki Layout ------------------------------------------------------- */

body.wiki-page {
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.wiki-header {
  max-width: 860px;
  margin: 0 auto 2rem;
  padding: 2rem 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.wiki-header h1 { margin-top: 0; margin-bottom: 0.5rem; }
.wiki-header .wiki-tags { margin-top: 0; font-size: 0.85rem; color: var(--text-muted); }

.wiki-container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1rem;
}

.wiki-sidebar {
  float: left;
  width: 160px;
  padding-right: 1rem;
  margin: 1rem;
  font-size: 0.85rem;
  overflow: visible;
  text-align: left;
}

.wiki-sidebar nav {
  margin-bottom: 1.5rem;
  text-align: left;
}
.wiki-sidebar h3 {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.wiki-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
}
.wiki-sidebar li {
  margin-bottom: 0.4rem;
  text-align: left;
}
.wiki-sidebar a {
  color: var(--text-muted);
  display: block;
  padding: 0.2rem 0;
  white-space: nowrap;
}
.wiki-sidebar a:hover {
  color: var(--accent);
}

.wiki-tree { margin-left: 0; }
.wiki-tree-children { margin-left: 0.75rem; padding-left: 0.75rem; border-left: 1px solid var(--border); }

.wiki-content {
  margin-left: 150px;
  max-width: 640px;
}

.wiki-content article { margin: 0; }

.wiki-tags { margin-top: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.wiki-tags a { color: var(--accent-soft); }

body.wiki-page .site-footer {
  max-width: 860px;
  margin: 3rem auto 0;
  padding: 2rem 1rem;
}

/* Wiki responsive */
@media (max-width: 700px) {
  .wiki-sidebar { float: none; width: 100%; padding-right: 0; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
  .wiki-content { margin-left: 0; max-width: 100%; }
}

/* --- Print Styles ------------------------------------------------------- */

@media print {
  :root {
    --bg: #ffffff;
    --bg-alt: #f5f5f5;
    --text: #1a1a1a;
    --text-muted: #4a4a4a;
    --accent: #1a1a1a;
    --accent-soft: #333333;
    --border: #e0e0e0;
  }

  html, body {
    background: white;
    color: black;
    font-size: 12pt;
    line-height: 1.5;
  }

  a { color: black; text-decoration: underline; }
  a[href]::after { content: " (" attr(href) ")"; font-size: 0.9em; color: #666; }

  /* Hide interactive elements */
  .site-nav, .site-header nav, footer, .scroll-progress-container,
  .wiki-sidebar, .post-navigation, .social-links { display: none !important; }

  /* Layout for print */
  body { max-width: 100%; padding: 0; margin: 0; }
  .main-content, .wiki-container, .post-content { margin: 0; padding: 0; max-width: 100%; }
  .wiki-header { border: none; margin-bottom: 1rem; padding: 0; }

  /* Code blocks */
  pre, code { background: #f5f5f5 !important; border: 1px solid #ddd; }

  /* Images */
  img { max-width: 100%; height: auto; }

  /* Headings */
  h1, h2, h3, h4, h5, h6 { color: black; page-break-after: avoid; }
  pre, blockquote { page-break-inside: avoid; }
}
