/* ==========================================================================
   Minimalist & Timeless Design System
   ========================================================================== */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  /* Light Theme */
  --bg-page: #ffffff;
  --bg-subtle: #f9fafb;
  --border-subtle: #e5e7eb;
  --border-strong: #d1d5db;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #6b7280;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-subtle: #eff6ff;

  /* GitHub-style alerts (Light) */
  --callout-note-bg: #f8fafc;
  --callout-note-border: #0284c7;
  --callout-note-text: #0369a1;

  --callout-tip-bg: #f8fafc;
  --callout-tip-border: #16a34a;
  --callout-tip-text: #15803d;

  --callout-warning-bg: #fefce8;
  --callout-warning-border: #ca8a04;
  --callout-warning-text: #a16207;

  --callout-important-bg: #faf5ff;
  --callout-important-border: #9333ea;
  --callout-important-text: #7e22ce;

  --callout-caution-bg: #fef2f2;
  --callout-caution-border: #dc2626;
  --callout-caution-text: #b91c1c;
}

[data-theme="dark"] {
  /* Dark Theme */
  --bg-page: #121316;
  --bg-subtle: #181a1f;
  --border-subtle: #272a30;
  --border-strong: #383c45;
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-subtle: rgba(96, 165, 250, 0.1);

  /* GitHub-style alerts (Dark) */
  --callout-note-bg: #161a23;
  --callout-note-border: #38bdf8;
  --callout-note-text: #7dd3fc;

  --callout-tip-bg: #141c17;
  --callout-tip-border: #4ade80;
  --callout-tip-text: #86efac;

  --callout-warning-bg: #1c1a14;
  --callout-warning-border: #facc15;
  --callout-warning-text: #fde047;

  --callout-important-bg: #1a1622;
  --callout-important-border: #c084fc;
  --callout-important-text: #d8b4fe;

  --callout-caution-bg: #1f1416;
  --callout-caution-border: #f87171;
  --callout-caution-text: #fca5a5;
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text-primary);
  background-color: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.15s ease, color 0.15s ease;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

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

/* ==========================================================================
   Site Header
   ========================================================================== */
.site-header {
  border-bottom: 1px solid var(--border-subtle);
  background-color: var(--bg-page);
}

.header-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-brand {
  text-decoration: none;
}

.site-brand:hover {
  text-decoration: none;
}

.brand-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

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

.nav-list {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.nav-link {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.nav-link.active {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Theme Toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}

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

.theme-toggle .sun-icon {
  display: none;
}

.theme-toggle .moon-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon {
  display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
  display: none;
}

/* Mobile Toggle */
.mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  cursor: pointer;
  color: var(--text-secondary);
  align-items: center;
  justify-content: center;
}

.mobile-toggle .icon-close {
  display: none;
}

.mobile-toggle.is-active .icon-menu {
  display: none;
}

.mobile-toggle.is-active .icon-close {
  display: block;
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */
.site-main {
  flex: 1;
  padding: 2.5rem 1.5rem 4.5rem;
}

.content-wrapper {
  max-width: 820px;
  margin: 0 auto;
}

/* ==========================================================================
   Prose & Markdown Typography
   ========================================================================== */
.prose-content > * + * {
  margin-top: 1.25rem;
}

.prose-content h1 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.3;
  margin-top: 0.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.prose-content h2 {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.35;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.prose-content h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.prose-content p {
  color: var(--text-secondary);
  font-size: 1.02rem;
  line-height: 1.75;
}

.prose-content em {
  font-style: italic;
  color: var(--text-muted);
}

.prose-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

.prose-content ul,
.prose-content ol {
  padding-left: 1.4rem;
  color: var(--text-secondary);
}

.prose-content li {
  margin-top: 0.35rem;
  font-size: 1rem;
  line-height: 1.65;
}

.prose-content li > ul,
.prose-content li > ol {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
  padding-left: 1.2rem;
}

.prose-content hr {
  border: none;
  height: 1px;
  background-color: var(--border-subtle);
  margin: 2rem 0;
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.15em 0.35em;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
}

pre {
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* Images & Figures */
.prose-content img {
  display: block;
  margin: 1.5rem auto;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-subtle);
}

/* ==========================================================================
   Understated Callouts / Alerts (GitHub Markdown Style)
   ========================================================================== */
.callout {
  border-left: 3.5px solid;
  padding: 0.85rem 1.15rem;
  margin: 1.25rem 0;
  background-color: var(--bg-subtle);
  border-radius: 0 6px 6px 0;
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.35rem;
}

.callout-icon {
  flex-shrink: 0;
}

.callout-content p {
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
}

/* Callout Variants */
.callout-note {
  background-color: var(--callout-note-bg);
  border-color: var(--callout-note-border);
}
.callout-note .callout-header,
.callout-note .callout-icon {
  color: var(--callout-note-text);
}

.callout-tip {
  background-color: var(--callout-tip-bg);
  border-color: var(--callout-tip-border);
}
.callout-tip .callout-header,
.callout-tip .callout-icon {
  color: var(--callout-tip-text);
}

.callout-warning {
  background-color: var(--callout-warning-bg);
  border-color: var(--callout-warning-border);
}
.callout-warning .callout-header,
.callout-warning .callout-icon {
  color: var(--callout-warning-text);
}

.callout-important {
  background-color: var(--callout-important-bg);
  border-color: var(--callout-important-border);
}
.callout-important .callout-header,
.callout-important .callout-icon {
  color: var(--callout-important-text);
}

.callout-caution {
  background-color: var(--callout-caution-bg);
  border-color: var(--callout-caution-border);
}
.callout-caution .callout-header,
.callout-caution .callout-icon {
  color: var(--callout-caution-text);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-page);
}

.footer-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

@media (min-width: 640px) {
  .footer-container {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.footer-link {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

/* ==========================================================================
   Mobile Navigation
   ========================================================================== */
@media (max-width: 768px) {
  .mobile-toggle {
    display: flex;
  }

  .site-nav {
    position: fixed;
    top: 57px;
    left: 0;
    right: 0;
    background-color: var(--bg-page);
    border-bottom: 1px solid var(--border-subtle);
    padding: 1.25rem 1.5rem;
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    display: none;
  }

  .site-nav.is-open {
    display: flex;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .nav-link {
    font-size: 1rem;
    padding: 0.25rem 0;
  }

  .theme-toggle {
    align-self: flex-start;
    padding: 0.5rem 0.75rem;
    width: 100%;
    justify-content: center;
  }

  .site-main {
    padding: 1.75rem 1.25rem 3rem;
  }

  .prose-content h1 {
    font-size: 1.6rem;
  }
}
