/* ========================================
   Font Color Configuration
   ========================================
   Customize all font colors below for light and dark themes.
   Each variable controls specific text elements throughout the site.
*/

:root {
  /* Background & Borders */
  --bg: #ffffff;
  --border: #e6e6e6;
  --header-bg: transparent;
  --footer-bg: transparent;

  /* Primary Text Colors */
  --text-primary: #111111;        /* Main body text, headings, brand */
  --text-secondary: #555555;      /* Muted text: dates, post meta, footer links */

  /* Link Colors */
  --link-default: #0a73ff;        /* Standard links (nav, general links) */
  --link-article: #0b3d91;        /* Article/post content links */
  --link-hover: #111111;          /* Link hover state */

  /* Code Colors */
  --code-inline-bg: rgba(127,127,127,0.12);
  --code-inline-text: inherit;    /* Inherits from parent text color */
  --code-block-bg: #0b0b0b;
  --code-block-text: #f5f5f5;

  /* Legacy support (maps to new variables) */
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --link: var(--link-default);
}

[data-theme="dark"] {
  /* Background & Borders */
  --bg: #0e0f12;
  --border: #1e2026;
  --header-bg: transparent;
  --footer-bg: transparent;

  /* Primary Text Colors */
  --text-primary: #e7e9ee;        /* Main body text, headings, brand */
  --text-secondary: #a0a6b0;      /* Muted text: dates, post meta, footer links */

  /* Link Colors */
  --link-default: #6aa2ff;        /* Standard links (nav, general links) */
  --link-article: #5b8bd8;        /* Article/post content links */
  --link-hover: #e7e9ee;          /* Link hover state */

  /* Code Colors */
  --code-inline-bg: rgba(255,255,255,0.08);
  --code-inline-text: inherit;
  --code-block-bg: #151821;
  --code-block-text: #e7e9ee;

  /* Legacy support (maps to new variables) */
  --text: var(--text-primary);
  --muted: var(--text-secondary);
  --link: var(--link-default);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica", "Helvetica Neue", Arial, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Noto Sans", sans-serif;
  line-height: 1.6;
}

.container {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 16px;
}

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

/* Remove top black line: no top border or bar */
.site-header {
  background: var(--header-bg);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
}

.brand {
  font-weight: 700;
  font-size: 20px;
  color: var(--text);
}

.site-nav a {
  margin-right: 16px;
  color: var(--text);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 20px;
  padding: 4px 10px;
  cursor: pointer;
}

/* Sticky footer layout */
html { height: 100%; }
body {
  display: flex;
  min-height: 100vh; /* desktop */
  min-height: 100dvh; /* modern browsers dynamic viewport */
  min-height: 100svh; /* small viewport units */
  flex-direction: column;
}
.site-main { flex: 1 0 auto; padding: 8px 0 40px; }
.site-footer { margin-top: auto; }

/* Home */
.home .site-title { margin-top: 0; }
.posts-heading { margin-top: 32px; font-size: 18px; color: var(--muted); }
.post-list { list-style: none; padding: 0; margin: 12px 0 0; }
.post-list li { padding: 10px 0; border-bottom: 1px dashed var(--border); display: flex; justify-content: space-between; }
.post-date { color: var(--muted); font-size: 14px; }
/* Larger home post titles */
.home .post-list a { font-size: 20px; font-weight: 700; }

/* Page/Post */
.page h1, .post h1 { margin-top: 0; }
.post-header { margin-bottom: 16px; }
.post-meta { color: var(--muted); }
.post-content p { margin: 16px 0; }
.post-content pre, .page-content pre {
  background: var(--code-block-bg);
  color: var(--code-block-text);
  padding: 12px 16px;
  overflow: auto;
  border-radius: 6px;
}

/* Expand container for post pages with TOC */
.site-main:has(.post-container),
.container:has(.post-container) {
  max-width: none;
  padding: 0;
}

/* Post Container with TOC */
.post-container {
  position: relative;
  width: 100%;
}

.post-container .post {
  max-width: 840px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Page layout (without TOC) */
.page {
  max-width: 840px;
}

/* Table of Contents */
.toc-wrapper {
  position: fixed;
  top: 80px;
  left: calc(50% + 840px / 2 + 40px);
  width: 280px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.toc-wrapper.visible {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.toc-wrapper .toc,
.toc {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.toc-title {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.toc-list li {
  margin: 0;
  padding: 0;
}

.toc-list a {
  display: block;
  padding: 6px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  line-height: 1.4;
  transition: color 0.2s ease;
}

.toc-list a:hover {
  color: var(--link-hover);
}

.toc-list a.active {
  color: var(--link-default);
  font-weight: 600;
  border-left: 2px solid var(--link-default);
  padding-left: 8px;
  margin-left: -8px;
}

.toc-h2 {
  font-weight: 600;
}

.toc-h3 {
  padding-left: 16px;
  font-weight: 400;
  font-size: 13px;
}

.toc-h3 a {
  font-size: 13px;
}

/* Links: home post titles and post content */
.home .post-list a, .post-content a { color: var(--link-article); text-decoration: none; }
.home .post-list a:hover, .post-content a:hover { color: var(--link-hover); text-decoration: underline; }

/* Footer: single line, left Github handle, right arbitrary icons/links */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--footer-bg);
}
.footer-inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 16px 0;
}
.site-footer, .site-footer * { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Noto Sans", sans-serif; }
.social-link { margin-right: 16px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.social-link:hover { color: var(--link-hover); }
.social-icon { font-weight: 700; display: inline-flex; }
.social-name { font-weight: 600; }

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

/* Make post content images clickable */
.post-content img {
  cursor: pointer;
  transition: opacity 0.3s ease;
}

.post-content img:hover {
  opacity: 0.85;
}

/* Image Lightbox Modal */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  cursor: zoom-out;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.lightbox-image {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  animation: lightbox-zoom-in 0.3s ease;
}

@keyframes lightbox-zoom-in {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 40px;
  color: #ffffff;
  font-weight: bold;
  cursor: pointer;
  z-index: 10000;
  user-select: none;
  transition: color 0.3s ease;
}

.lightbox-close:hover {
  color: #cccccc;
}

/* Prevent body scroll when lightbox is open */
body.lightbox-open {
  overflow: hidden;
}

/* Code inline */
code {
  background: var(--code-inline-bg);
  color: var(--code-inline-text);
  padding: 2px 4px;
  border-radius: 4px;
}

/* Responsive Design */
/* Mobile-first approach - styles above are base (mobile) */

/* Hide TOC when screen is too narrow */
@media (max-width: 1200px) {
  .toc-wrapper {
    display: none;
  }
}

/* Tablet breakpoint (768px and below) */
@media (max-width: 768px) {
  .container {
    padding: 0 20px;
  }

  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding: 16px 0;
  }

  .site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: 100%;
  }

  .site-nav a {
    margin-right: 0;
  }

  .brand {
    font-size: 18px;
  }

  .home .post-list a {
    font-size: 18px;
  }

  .post-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .post-date {
    font-size: 13px;
  }

  /* Post page responsive */
  .site-main:has(.post-container),
  .container:has(.post-container) {
    max-width: 840px;
    padding: 0;
  }

  .post-container .post {
    max-width: 100%;
    padding: 0 20px;
  }
}

/* Mobile breakpoint (480px and down) */
@media (max-width: 480px) {
  .container {
    padding: 0 16px;
  }

  .header-inner {
    padding: 12px 0;
  }

  .brand {
    font-size: 16px;
  }

  .site-nav {
    font-size: 14px;
  }

  .theme-toggle {
    padding: 3px 8px;
    font-size: 14px;
  }

  .home .post-list a {
    font-size: 16px;
  }

  .posts-heading {
    font-size: 16px;
    margin-top: 24px;
  }

  .post-list li {
    padding: 8px 0;
  }

  .post-date {
    font-size: 12px;
  }

  .site-main {
    padding: 4px 0 32px;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 0;
  }

  .social-link {
    margin-right: 12px;
  }

  /* Post page mobile optimizations */
  .site-main:has(.post-container),
  .container:has(.post-container) {
    max-width: 840px;
    padding: 0;
  }

  .post-container .post {
    padding: 0 16px;
  }

  .post h1 {
    font-size: 24px;
    line-height: 1.3;
  }

  .post-meta {
    font-size: 13px;
  }

  .post-content {
    font-size: 15px;
  }

  .post-content h2 {
    font-size: 20px;
    margin-top: 24px;
  }

  .post-content h3 {
    font-size: 18px;
    margin-top: 20px;
  }

  .post-content pre {
    font-size: 13px;
    padding: 10px 12px;
  }
}

/* Large screens (1200px and up) - optional enhancements */
@media (min-width: 1200px) {
  .container {
    max-width: 960px;
  }
}

/* Smooth scrolling for TOC navigation */
html {
  scroll-behavior: smooth;
}


