/* =============================================================================
   GJESSING.IO - Editorial Theme v4
   Mobile-first, dark/light mode, refined
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CSS Custom Properties
   ----------------------------------------------------------------------------- */
:root {
  /* Typography */
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Font sizes */
  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.8rem);
  --text-sm: clamp(0.85rem, 0.8rem + 0.25vw, 0.9rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.05rem);
  --text-lg: clamp(1.1rem, 1rem + 0.5vw, 1.2rem);
  --text-xl: clamp(1.2rem, 1.1rem + 0.5vw, 1.4rem);
  --text-2xl: clamp(1.5rem, 1.25rem + 1vw, 1.85rem);
  --text-3xl: clamp(1.85rem, 1.5rem + 1.5vw, 2.5rem);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Layout */
  --content-width: 800px;
  --nav-height: 60px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* Light theme */
:root {
  --color-bg: #ffffff;
  --color-bg-secondary: #f8f9fa;
  --color-bg-tertiary: #f1f3f4;
  --color-surface: #ffffff;
  --color-surface-hover: #f8f9fa;
  --color-border: #e5e7eb;
  --color-border-subtle: #f1f3f4;

  --color-text: #1a1a1a;
  --color-text-secondary: #4b5563;
  --color-text-tertiary: #6b7280;
  --color-text-muted: #9ca3af;

  --color-accent: #c45221;
  --color-accent-hover: #a3421a;
  --color-accent-subtle: rgba(196, 82, 33, 0.1);

  --color-link: #c45221;
  --color-link-hover: #a3421a;

  --color-code-bg: #f6f8fa;
  
  --color-mark-bg: #fff59d;
  --color-mark-text: #1a1a1a;
}

/* Dark theme */
[data-theme="dark"] {
  --color-bg: #0d0d0d;
  --color-bg-secondary: #161616;
  --color-bg-tertiary: #1f1f1f;
  --color-surface: #1a1a1a;
  --color-surface-hover: #242424;
  --color-border: #2d2d2d;
  --color-border-subtle: #242424;

  --color-text: #f0f0f0;
  --color-text-secondary: #b3b3b3;
  --color-text-tertiary: #8a8a8a;
  --color-text-muted: #666666;

  --color-accent: #e07040;
  --color-accent-hover: #f08050;
  --color-accent-subtle: rgba(224, 112, 64, 0.15);

  --color-link: #e07040;
  --color-link-hover: #f08050;

  --color-code-bg: #1f1f1f;
  
  /* High contrast highlight for dark mode */
  --color-mark-bg: #ffd54f;
  --color-mark-text: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg: #0d0d0d;
    --color-bg-secondary: #161616;
    --color-bg-tertiary: #1f1f1f;
    --color-surface: #1a1a1a;
    --color-surface-hover: #242424;
    --color-border: #2d2d2d;
    --color-border-subtle: #242424;
    --color-text: #f0f0f0;
    --color-text-secondary: #b3b3b3;
    --color-text-tertiary: #8a8a8a;
    --color-text-muted: #666666;
    --color-accent: #e07040;
    --color-accent-hover: #f08050;
    --color-accent-subtle: rgba(224, 112, 64, 0.15);
    --color-link: #e07040;
    --color-link-hover: #f08050;
    --color-code-bg: #1f1f1f;
    --color-mark-bg: #ffd54f;
    --color-mark-text: #1a1a1a;
  }
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-base), color var(--transition-base);
}

/* -----------------------------------------------------------------------------
   Typography
   ----------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

h1 { font-size: var(--text-3xl); font-weight: 700; margin-bottom: var(--space-lg); }
h2 { font-size: var(--text-2xl); margin-top: var(--space-2xl); margin-bottom: var(--space-md); }
h3 { font-size: var(--text-xl); margin-top: var(--space-xl); margin-bottom: var(--space-sm); }
h4 { font-size: var(--text-lg); margin-top: var(--space-lg); margin-bottom: var(--space-sm); }

p { margin-bottom: var(--space-md); }

a {
  color: var(--color-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

strong { font-weight: 600; }
small { font-size: var(--text-sm); }

/* Highlight - high contrast in both themes */
mark {
  background: var(--color-mark-bg);
  color: var(--color-mark-text);
  padding: 1px 4px;
  border-radius: 2px;
}

/* -----------------------------------------------------------------------------
   Header & Navigation
   ----------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

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

.nav-brand {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.03em;
  flex-shrink: 0;
}

.nav-brand:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-sm);
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--color-text);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

.nav-menu {
  display: none;
  position: absolute;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md);
  flex-direction: column;
}

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

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
}

.nav-links a {
  display: block;
  padding: var(--space-sm) 0;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-links a:hover { color: var(--color-accent); text-decoration: none; }
.nav-links a[aria-current="page"] { color: var(--color-accent); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-left: auto;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-toggle:hover { background: var(--color-bg-tertiary); color: var(--color-text); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .nav-menu {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    background: none;
    border: none;
    padding: 0;
    gap: var(--space-lg);
  }
  .nav-links { flex-direction: row; gap: var(--space-lg); }
  .nav-links a { padding: var(--space-xs) 0; }
}

/* -----------------------------------------------------------------------------
   Pagefind Search - Fixed mobile positioning
   ----------------------------------------------------------------------------- */
.nav-search { position: relative; }

.nav-search .pagefind-ui {
  --pagefind-ui-scale: 0.9;
  --pagefind-ui-primary: var(--color-accent);
  --pagefind-ui-text: var(--color-text);
  --pagefind-ui-background: var(--color-bg);
  --pagefind-ui-border: var(--color-border);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: var(--radius-md);
  --pagefind-ui-font: var(--font-body);
}

.nav-search .pagefind-ui__search-input {
  width: 140px;
  height: 38px;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: border-color var(--transition-fast), width var(--transition-base);
}

.nav-search .pagefind-ui__search-input:focus {
  outline: none;
  border-color: var(--color-accent);
  width: 200px;
}

.nav-search .pagefind-ui__search-input::placeholder { color: var(--color-text-muted); }
.nav-search .pagefind-ui__search-clear,
.nav-search .pagefind-ui__form::before { display: none; }

/* Results - fixed positioning for mobile */
.nav-search .pagefind-ui__drawer {
  position: fixed;
  top: calc(var(--nav-height) + var(--space-sm));
  left: var(--space-md);
  right: var(--space-md);
  width: auto;
  max-width: 400px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  padding: var(--space-md);
}

@media (min-width: 768px) {
  .nav-search .pagefind-ui__drawer {
    position: absolute;
    top: calc(100% + var(--space-sm));
    left: auto;
    right: 0;
    width: 380px;
    max-width: none;
  }
}

.nav-search .pagefind-ui__results-area { margin-top: 0; }

.nav-search .pagefind-ui__result {
  padding: var(--space-md);
  margin: 0 0 var(--space-sm);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-sm);
  border: none;
}

.nav-search .pagefind-ui__result:hover { background: var(--color-bg-tertiary); }
.nav-search .pagefind-ui__result-link { font-weight: 600; font-size: var(--text-sm); color: var(--color-text); text-decoration: none; }
.nav-search .pagefind-ui__result-link:hover { color: var(--color-accent); }

.nav-search .pagefind-ui__result-excerpt {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: var(--space-xs);
  line-height: 1.5;
}

.nav-search .pagefind-ui__result-excerpt mark {
  background: var(--color-accent-subtle);
  color: var(--color-accent);
}

.nav-search .pagefind-ui__message { font-size: var(--text-sm); color: var(--color-text-muted); padding: var(--space-md); }
.nav-search .pagefind-ui__result-nested { display: none; }

/* -----------------------------------------------------------------------------
   Main Content
   ----------------------------------------------------------------------------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md) var(--space-3xl);
}

/* -----------------------------------------------------------------------------
   Article Styles
   ----------------------------------------------------------------------------- */
article header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--color-border-subtle);
}

article header h1 { margin-bottom: var(--space-sm); }

.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.post-meta time { display: flex; align-items: center; gap: var(--space-xs); }
.post-meta svg { flex-shrink: 0; }

/* Tags */
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.tag {
  display: inline-block;
  padding: 2px var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tag:hover { background: var(--color-accent); color: #fff; text-decoration: none; }

.tag-label {
  display: inline-block;
  padding: 2px var(--space-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--color-accent-subtle);
  color: var(--color-accent);
  border-radius: var(--radius-sm);
}

/* Article content */
.article-content { font-size: var(--text-base); }
.article-content > * + * { margin-top: var(--space-md); }
.article-content h2, .article-content h3, .article-content h4 { margin-top: var(--space-2xl); }

.article-content a {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--color-accent-subtle);
}
.article-content a:hover { text-decoration-color: var(--color-accent); }

/* Lists */
.article-content ul, .article-content ol { padding-left: var(--space-lg); margin: var(--space-md) 0; }
.article-content li { margin: var(--space-sm) 0; }
.article-content li::marker { color: var(--color-text-tertiary); }

/* Blockquotes */
.article-content blockquote {
  margin: var(--space-xl) 0;
  padding: var(--space-md) var(--space-lg);
  border-left: 3px solid var(--color-accent);
  background: var(--color-bg-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic;
  color: var(--color-text-secondary);
}
.article-content blockquote p:last-child { margin-bottom: 0; }

/* Code - with copy button */
.article-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--color-code-bg);
  border-radius: var(--radius-sm);
}

.article-content pre {
  position: relative;
  margin: var(--space-lg) 0;
  padding: var(--space-md);
  padding-top: var(--space-xl);
  background: var(--color-code-bg);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: var(--text-sm);
}

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

/* Copy button for code blocks - always visible */
.code-copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-xs);
  font-family: var(--font-body);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.code-copy-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.code-copy-btn.copied { background: var(--color-accent); color: #fff; border-color: var(--color-accent); }

/* Images */
.article-content img,
.article-content picture {
  display: block;
  max-width: 100%;
  height: auto;
  margin: var(--space-xl) auto;
  border-radius: var(--radius-md);
}

.article-content figure {
  margin: var(--space-xl) auto;
  text-align: center;
}

.article-content figure img,
.article-content figure picture {
  margin: 0 auto;
}

.article-content figcaption {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-top: var(--space-sm);
  font-style: italic;
}

/* Image size classes (from preprocess) */
.article-content figure.img-small { max-width: 300px; }
.article-content figure.img-medium { max-width: 500px; }
.article-content figure.img-large { max-width: 100%; }

/* Tables */
.article-content table {
  width: 100%;
  margin: var(--space-lg) 0;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.article-content th, .article-content td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

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

.article-content hr {
  margin: var(--space-2xl) 0;
  border: none;
  border-top: 1px solid var(--color-border);
}

/* -----------------------------------------------------------------------------
   Post Cards - Fully Clickable
   ----------------------------------------------------------------------------- */
.page-header { margin-bottom: var(--space-2xl); }
.page-header h1 { margin-bottom: var(--space-sm); }
.page-header .lead { font-size: var(--text-lg); color: var(--color-text-secondary); }


/* Featured post section */
.featured-post {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  border-bottom: 1px solid var(--color-border);
}

.featured-post .post-body h2 { font-size: var(--text-2xl); margin: 0 0 var(--space-sm); }
.featured-post .post-body h2 a { color: var(--color-text); text-decoration: none; }
.featured-post .post-body h2 a:hover { color: var(--color-accent); }
.featured-post .excerpt { font-size: var(--text-base); color: var(--color-text-secondary); margin-bottom: var(--space-md); }

/* Post grid */
.post-grid { display: grid; gap: var(--space-lg); }
@media (min-width: 500px) { .post-grid { grid-template-columns: repeat(2, 1fr); } }

/* Post card - entire card clickable */
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border-subtle);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  color: inherit;
}

a.post-card:hover { border-color: var(--color-border); box-shadow: var(--shadow-md); text-decoration: none; }

.post-card .thumb {
  width: 100%;
  height: 160px;
  object-fit: cover;
  background: var(--color-bg-tertiary);
}

.post-card .post-body {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  flex: 1;
}

.post-card .post-body h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0 0 var(--space-sm);
  line-height: 1.35;
  color: var(--color-text);
}

a.post-card:hover .post-body h3 { color: var(--color-accent); }

.post-card .excerpt {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-md);
  flex: 1;

  display: -webkit-box;        /* for WebKit browsers */
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;       /* WebKit-specific */

  display: box;                /* fallback for older spec */
  line-clamp: 3;               /* standard property (not widely supported yet) */

  overflow: hidden;
}


.post-card .card-meta { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: auto; }

/* Section headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-text);
}

.section-header h2 {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.section-header .view-all { font-size: var(--text-sm); font-weight: 500; }

/* -----------------------------------------------------------------------------
   Tag Filters & Pages
   ----------------------------------------------------------------------------- */
.tag-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border-subtle);
}

.tag-filter {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--text-sm);
  font-weight: 500;
  background: var(--color-bg-secondary);
  color: var(--color-text-secondary);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.tag-filter:hover { background: var(--color-bg-tertiary); color: var(--color-text); text-decoration: none; }
.tag-filter.active { background: var(--color-accent); color: #fff; }

.tag-page-header { margin-bottom: var(--space-xl); }
.tag-page-header h1 { display: flex; align-items: center; gap: var(--space-sm); }
.tag-page-header h1 span { font-size: var(--text-xl); font-weight: 400; color: var(--color-text-tertiary); }

.all-tags {
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.all-tags h2 { font-size: var(--text-lg); margin-bottom: var(--space-md); }

.tag-cloud { display: flex; flex-wrap: wrap; gap: var(--space-sm); }

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

.footer-inner {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-xl) var(--space-md);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

.footer-nav h4, .footer-connect h4 {
  font-size: var(--text-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-md);
}

.footer-nav ul, .footer-connect ul { list-style: none; }
.footer-nav li, .footer-connect li { margin: var(--space-sm) 0; }
.footer-nav a { font-size: var(--text-sm); color: var(--color-text-secondary); }
.footer-nav a:hover { color: var(--color-accent); }

.footer-connect ul { display: flex; gap: var(--space-md); }

.footer-connect a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}

.footer-connect a:hover { background: var(--color-accent); color: #fff; text-decoration: none; }
.footer-connect svg { width: 20px; height: 20px; }

.footer-bottom {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-md);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  text-align: center;
}

/* -----------------------------------------------------------------------------
   Comments (Giscus dark mode)
   ----------------------------------------------------------------------------- */
.giscus-frame { color-scheme: light dark; }

.comments-section {
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.comments-section h2 { font-size: var(--text-lg); margin-bottom: var(--space-lg); }

/* -----------------------------------------------------------------------------
   Related Posts - excluded from Pagefind
   ----------------------------------------------------------------------------- */
.related-posts { margin-top: var(--space-3xl); }

/* -----------------------------------------------------------------------------
   Utilities
   ----------------------------------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.4s ease forwards; }

.stagger-children > * { opacity: 0; animation: fadeIn 0.4s ease forwards; }
.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }

.post-footer {
  margin-top: var(--space-2xl);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.post-footer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.post-footer-tags span { font-size: var(--text-sm); color: var(--color-text-tertiary); }

/* -----------------------------------------------------------------------------
   Print Styles
   ----------------------------------------------------------------------------- */
@media print {
  /* Reset colors for print */
  :root,
  [data-theme="dark"] {
    --color-bg: #ffffff;
    --color-text: #000000;
    --color-text-secondary: #333333;
    --color-text-tertiary: #555555;
    --color-border: #cccccc;
    --color-link: #000000;
    --color-code-bg: #f5f5f5;
  }
  
  /* Hide non-content elements */
  .site-header,
  .nav,
  .nav-search,
  .theme-toggle,
  .nav-toggle,
  .nav-menu,
  .site-footer,
  .footer-inner,
  .footer-bottom,
  .tag-filters,
  .related-posts,
  .comments-section,
  .code-copy-btn,
  .post-tags,
  .post-footer-tags {
    display: none !important;
  }
  
  /* Full width content */
  body {
    background: white;
    color: black;
    font-size: 12pt;
    line-height: 1.5;
  }
  
  main {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }
  
  article {
    max-width: 100%;
  }
  
  /* Typography adjustments */
  h1 { font-size: 24pt; }
  h2 { font-size: 18pt; }
  h3 { font-size: 14pt; }
  
  /* Links - show URL in print */
  .article-content a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555;
  }
  
  /* Don't break inside these elements */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    break-after: avoid;
  }
  
  p, blockquote, ul, ol, figure {
    page-break-inside: avoid;
    break-inside: avoid;
  }
  
  /* Images */
  img, figure {
    max-width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }
  
  figure {
    margin: 1em 0;
  }
  
  figcaption {
    font-size: 10pt;
  }
  
  /* Code blocks */
  pre, code {
    background: #f5f5f5 !important;
    border: 1px solid #ddd;
    font-size: 9pt;
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  
  pre {
    padding: 1em;
    page-break-inside: avoid;
  }
  
  /* Blockquotes */
  blockquote {
    border-left: 3px solid #333;
    padding-left: 1em;
    margin-left: 0;
    font-style: italic;
  }
  
  /* Tables */
  table {
    border-collapse: collapse;
    width: 100%;
  }
  
  th, td {
    border: 1px solid #ddd;
    padding: 0.5em;
  }
  
  /* Page margins */
  @page {
    margin: 2cm;
  }
}

/* -----------------------------------------------------------------------------
   Post List (used in tags/list.html)
   ----------------------------------------------------------------------------- */
.post-list {
  list-style: none;
}

.post-list-item {
  border-bottom: 1px solid var(--color-border-subtle);
}

.post-list-item:last-child {
  border-bottom: none;
}

.post-list-item a {
  display: block;
  padding: var(--space-md) 0;
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast);
}

.post-list-item a:hover {
  text-decoration: none;
}

.post-list-item a:hover h3 {
  color: var(--color-accent);
}

.post-list-item h3 {
  font-size: var(--text-base);
  font-family: var(--font-body);
  font-weight: 600;
  margin: 0 0 var(--space-xs);
  color: var(--color-text);
  transition: color var(--transition-fast);
}

.post-list-item .excerpt {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-xs);
}

.post-list-item time {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}
/* =============================================================================
   FEATURED POST REFINEMENTS (v2)
   Add to end of main.css - replaces previous featured-refinements CSS
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Featured Post Image - Match Normal Card Size
   ----------------------------------------------------------------------------- */

.featured-post .featured-card {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--color-border-subtle);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.featured-post .featured-card:hover {
  border-color: var(--color-border);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}

/* Image wrapper for badge positioning - needs visible overflow for floating badge */
.featured-post .thumb-wrapper {
  position: relative;
  overflow: visible; /* Allow badge to float outside */
}

.featured-post .featured-card .thumb {
  width: 100%;
  height: 180px;
  object-fit: cover;
  background: var(--color-bg-tertiary);
  transition: transform var(--transition-base);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.featured-post .featured-card:hover .thumb {
  transform: scale(1.02);
}

/* Desktop layout */
@media (min-width: 600px) {
  .featured-post .featured-card {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    align-items: stretch;
  }
  
  .featured-post .thumb-wrapper {
    height: 100%;
  }
  
  .featured-post .featured-card .thumb {
    height: 100%;
    min-height: 220px;
    max-height: 280px;
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  }
  
  .featured-post .featured-card .post-body {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
}

/* -----------------------------------------------------------------------------
   Featured Badge - Floating Outside Container
   Enable or disable with display: none !important; on .featured-badge
   ----------------------------------------------------------------------------- */

.featured-badge {
  position: absolute;
  top: 12px;
  left: -8px; /* Float outside the container */
  z-index: 10;
  
  /* Pill shape with angled edge */
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px 7px 10px;
  
  /* Ribbon-like shape */
  border-radius: 3px 20px 20px 3px;
  
  /* Colors - bright green */
  background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
  color: #052e16;
  
  /* Typography */
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  
  /* Shadow for floating effect */
  box-shadow: 
    0 4px 12px rgba(22, 163, 74, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.1),
    -2px 2px 4px rgba(0, 0, 0, 0.08);
  
  /* Subtle border for definition */
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Ribbon tail effect - small triangle on left */
.featured-badge::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 8px 0 0;
  border-color: #15803d transparent transparent transparent;
}

/* Star icon */
.featured-badge svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  fill: currentColor;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
}

/* ==========================================================================
   FEATURED BADGE VISIBILITY OPTIONS
   Toggle between these two options by commenting/uncommenting
   ========================================================================== */

/* OPTION A: Show badge on ALL screen sizes (currently active) */
/* No hiding rule needed - badge shows everywhere by default */

/* OPTION B: Show badge on MOBILE ONLY (uncomment to activate)
@media (min-width: 600px) {
  .featured-badge {
    display: none !important;
  }
}
*/

/* Mobile adjustments */
@media (max-width: 599px) {
  .featured-badge {
    top: 10px;
    left: -6px;
    padding: 6px 12px 6px 8px;
    font-size: 9px;
    gap: 4px;
  }
  
  .featured-badge svg {
    width: 10px;
    height: 10px;
  }
  
  .featured-badge::before {
    bottom: -3px;
    border-width: 3px 6px 0 0;
  }
}

/* Dark mode adjustments */
[data-theme="dark"] .featured-badge {
  background: linear-gradient(135deg, #4ade80 0%, #22c55e 100%);
  color: #052e16;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 
    0 4px 12px rgba(74, 222, 128, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.2),
    -2px 2px 4px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .featured-badge::before {
  border-color: #16a34a transparent transparent transparent;
}

/* Print: hide badge */
@media print {
  .featured-badge {
    display: none;
  }
}

/* -----------------------------------------------------------------------------
   404 Page Styles
   ----------------------------------------------------------------------------- */

.page-404 {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-404 main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-page {
  text-align: center;
  padding: var(--space-2xl);
}

.error-content h1 {
  font-size: clamp(6rem, 20vw, 12rem);
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-muted);
  line-height: 1;
  margin: 0;
}

.error-message {
  font-size: var(--text-2xl);
  font-weight: 600;
  color: var(--color-text);
  margin: var(--space-md) 0;
}

.error-description {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xl);
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.error-link {
  display: inline-block;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-accent);
  color: #fff;
  text-decoration: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background var(--transition-fast);
}

.error-link:hover {
  background: var(--color-accent-hover);
  text-decoration: none;
}

/* =============================================================================
   EXTERNAL LINK STYLING & TABLE OF CONTENTS
   Add these styles to the end of assets/css/main.css
   ============================================================================= */

/* -----------------------------------------------------------------------------
   External Link Indicator (render-link.html hook)
   ----------------------------------------------------------------------------- */
.external-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  white-space: nowrap;
}

.external-icon {
  width: 0.9em;
  height: 0.9em;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  margin-left: 2px;
  stroke: currentColor;
}

.external-link:hover .external-icon {
  opacity: 1;
}

/* Prevent icon from breaking to next line in article content */
.article-content .external-link {
  display: inline-flex;
}

/* Dark mode - ensure icon is visible */
[data-theme="dark"] .external-icon {
  color: var(--color-link);
}

/* Print: hide external icons */
@media print {
  .external-icon {
    display: none;
  }
}

/* -----------------------------------------------------------------------------
   Table of Contents (TOC) - Collapsible
   Controlled by frontmatter: toc: true
   ----------------------------------------------------------------------------- */
.article-toc {
  margin-bottom: var(--space-lg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}

.toc-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  user-select: none;
  list-style: none; /* Remove default marker */
}

.toc-toggle::-webkit-details-marker {
  display: none; /* Remove default marker in Safari */
}

.toc-toggle:hover {
  background: var(--color-bg-secondary);
}

.toc-title {
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-tertiary);
  margin: 0;
}

.toc-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}

.article-toc[open] .toc-icon {
  transform: rotate(180deg);
}

.toc-nav {
  padding: 0 var(--space-md) var(--space-sm);
  font-size: var(--text-xs);
}

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

/* Nested lists - subtle indent */
.toc-nav ul ul {
  padding-left: var(--space-md);
  margin-top: 2px;
}

.toc-nav li {
  margin: 2px 0;
  line-height: 1.4;
}

.toc-nav a {
  color: var(--color-text-tertiary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.toc-nav a:hover {
  color: var(--color-text);
}

/* Print: hide TOC */
@media print {
  .article-toc {
    display: none;
  }
}/* =============================================================================
   CSS ADDITIONS - Add these to the end of main.css
   ============================================================================= */

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

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  cursor: zoom-out;
}

.lightbox-caption {
  margin-top: var(--space-md);
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--text-sm);
  text-align: center;
  max-width: 600px;
}

.lightbox-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 10;
}

.lightbox-close:hover,
.lightbox-close:focus {
  background: rgba(255, 255, 255, 0.2);
  outline: none;
}

/* Mobile lightbox adjustments */
@media (max-width: 600px) {
  .lightbox {
    padding: var(--space-sm);
  }
  
  .lightbox-content {
    max-width: 100%;
    max-height: 100%;
  }
  
  .lightbox-img {
    max-height: 80vh;
  }
  
  .lightbox-close {
    top: var(--space-sm);
    right: var(--space-sm);
  }
}

/* Hide lightbox in print */
@media print {
  .lightbox {
    display: none !important;
  }
}

/* -----------------------------------------------------------------------------
   Code Block with Language Header (render-codeblock.html)
   ----------------------------------------------------------------------------- */
.code-block {
  position: relative;
  margin: var(--space-lg) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-code-bg);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-xs) var(--space-md);
  background: var(--color-bg-tertiary);
  border-bottom: 1px solid var(--color-border);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Adjust pre inside code-block */
.code-block pre {
  margin: 0;
  border-radius: 0;
  padding-top: var(--space-md);
}

/* Code block without header (no language specified) */
.code-block:not([data-lang]) pre {
  border-radius: var(--radius-md);
}

/* Position copy button for code-block - in header row */
.code-block .code-copy-btn {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-sm);
  /* Override the default pre-based positioning */
  padding: 2px var(--space-sm);
}

/* Code block without header - adjust copy button position */
.code-block:not([data-lang]) .code-copy-btn {
  top: var(--space-sm);
}

/* Make code-block the positioning context */
.code-block {
  position: relative;
}

/* Dark mode code header */
[data-theme="dark"] .code-header {
  background: var(--color-bg-secondary);
  border-bottom-color: var(--color-border);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .code-header {
    background: var(--color-bg-secondary);
    border-bottom-color: var(--color-border);
  }
}

/* -----------------------------------------------------------------------------
   Long Link Overflow Fix
   ----------------------------------------------------------------------------- */
.article-content {
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.article-content a {
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: break-word;
}

/* Ensure inline code in links also breaks properly */
.article-content a code {
  word-break: break-all;
}

/* Prevent any element from causing horizontal overflow */
.article-content * {
  max-width: 100%;
}

/* -----------------------------------------------------------------------------
   Series Navigation
   ----------------------------------------------------------------------------- */
.series-nav {
  margin: var(--space-xl) 0;
  padding: var(--space-md);
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
}

.series-header {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
}

.series-header svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

.series-header strong {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.series-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs) var(--space-md);
  font-size: var(--text-xs);
}

.series-list li {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--color-text-tertiary);
}

.series-list li::before {
  content: counter(series-counter);
  counter-increment: series-counter;
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-muted);
  min-width: 14px;
}

.series-list {
  counter-reset: series-counter;
}

.series-list li.current {
  color: var(--color-text);
  font-weight: 500;
}

.series-list li.current::before {
  color: var(--color-accent);
}

.series-list li a {
  color: var(--color-text-tertiary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.series-list li a:hover {
  color: var(--color-text);
}

.series-pagination {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs);
}

.series-prev,
.series-next {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--color-text-tertiary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.series-prev:hover,
.series-next:hover {
  color: var(--color-text);
  text-decoration: none;
}

.series-prev.disabled {
  visibility: hidden;
}

.series-pagination-label {
  color: var(--color-text-muted);
}

.series-pagination-title {
  display: none; /* Hide on small screens, show inline on larger */
}

@media (min-width: 500px) {
  .series-pagination-title {
    display: inline;
    color: var(--color-text-secondary);
  }
  
  .series-pagination-title::before {
    content: ": ";
  }
}

/* Print: simplify series nav */
@media print {
  .series-nav {
    background: none;
    border: 1px solid #ddd;
  }
  
  .series-pagination {
    display: none;
  }
}