/* ==========================================================================
   Core Design System & Theme Styles
   Dark-first, minimal, modern, content-focused web platform.
   Vanilla CSS only - No frameworks, zero build steps.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Self-Hosted Font Declarations
   -------------------------------------------------------------------------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/inter-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/inter-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/inter-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-500.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Noto Sans Bengali';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/noto-sans-bengali-400.woff2') format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1, U+11DF0-11DF1;
}

@font-face {
  font-family: 'Noto Sans Bengali';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/noto-sans-bengali-600.woff2') format('woff2');
  unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1, U+11DF0-11DF1;
}

@font-face {
  font-family: 'Hind Siliguri';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/hind-siliguri-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Hind Siliguri';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/hind-siliguri-600.woff2') format('woff2');
}

/* --------------------------------------------------------------------------
   2. Design Tokens & CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Typography Stacks */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --font-bengali: 'Noto Sans Bengali', 'Hind Siliguri', var(--font-sans);

  /* Spacing Scale */
  --space-1: 0.25rem;   /* 4px */
  --space-2: 0.5rem;    /* 8px */
  --space-3: 0.75rem;   /* 12px */
  --space-4: 1rem;      /* 16px */
  --space-5: 1.25rem;   /* 20px */
  --space-6: 1.5rem;    /* 24px */
  --space-8: 2rem;      /* 32px */
  --space-10: 2.5rem;   /* 40px */
  --space-12: 3rem;     /* 48px */
  --space-16: 4rem;     /* 64px */
  --space-20: 5rem;     /* 80px */

  /* Layout Boundaries */
  --container-max: 1280px;
  --container-wide: 1280px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 220ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Elevation Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px 0 rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
}

/* Default Theme: Dark-First */
:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Surfaces & Backgrounds */
  --bg-body: #0a0c10;
  --bg-surface: #11141a;
  --bg-surface-elevated: #161b24;
  --bg-surface-hover: #1c222e;
  --bg-code: #0f131a;

  /* Borders */
  --border-subtle: #1e2430;
  --border-muted: #283142;
  --border-focus: #10b981;

  /* Typography Colors */
  --text-primary: #f1f5f9;
  --text-normal: #f1f5f9;
  --text-muted: #94a3b8;
  --text-subtle: #64748b;
  --text-inverse: #0a0c10;

  /* Single Vibrant Modern Accent: Emerald */
  --accent: #10b981;
  --color-accent: #10b981;
  --accent-hover: #059669;
  --accent-active: #047857;
  --accent-subtle: rgba(16, 185, 129, 0.12);
  --accent-glow: rgba(16, 185, 129, 0.25);
  --accent-contrast: #042f2e;

  /* Semantic feedback */
  --color-success: #10b981;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
}

/* Light Theme Override */
[data-theme="light"] {
  color-scheme: light;

  /* Surfaces & Backgrounds */
  --bg-body: #ffffff;
  --bg-surface: #f8fafc;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-code: #f6f8fa;

  /* Borders */
  --border-subtle: #e2e8f0;
  --border-muted: #cbd5e1;
  --border-focus: #059669;

  /* Typography Colors - High Contrast WCAG AAA */
  --text-primary: #0f172a;       /* Deep slate-900 (17:1 contrast on white) */
  --text-normal: #1e293b;        /* Deep slate-800 (14:1 contrast on white) */
  --text-muted: #334155;         /* Slate-700 (9:1 contrast on white) */
  --text-subtle: #475569;        /* Slate-600 (6:1 contrast on white) */
  --text-inverse: #ffffff;

  /* Single Accent in Light Mode - High Contrast Emerald */
  --accent: #059669;
  --color-accent: #059669;
  --accent-hover: #047857;
  --accent-active: #065f46;
  --accent-subtle: rgba(5, 150, 105, 0.08);
  --accent-glow: rgba(5, 150, 105, 0.18);
  --accent-contrast: #ffffff;

  /* Semantic feedback */
  --color-success: #059669;
  --color-error: #dc2626;
  --color-warning: #d97706;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.06);
}

/* --------------------------------------------------------------------------
   3. Base Element Resets & Normalization
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Universal Media Scaling & Boundary Containment */
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

iframe,
embed,
object {
  max-width: 100%;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  accent-color: var(--accent);
}

::selection {
  background-color: var(--accent);
  color: var(--accent-contrast);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Accessible Focus States */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* Skip link for keyboard navigation */
.skip-link {
  position: absolute;
  top: -999px;
  left: 1rem;
  z-index: 1000;
  background-color: var(--accent);
  color: var(--accent-contrast);
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.skip-link:focus {
  top: 1rem;
}

/* --------------------------------------------------------------------------
   4. Typography & Bangla Adjustments
   -------------------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-top: 1.8em;
  margin-bottom: 0.6em;
}

h1:first-child,
h2:first-child,
h3:first-child {
  margin-top: 0;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }

p {
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

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

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

/* Monospace used STRICTLY for labels, tags, metrics, and code */
code, kbd, samp, pre, .font-mono, .label-mono, .tag-mono, .badge-mono {
  font-family: var(--font-mono);
}

code {
  font-size: 0.875em;
  background-color: var(--bg-surface-elevated);
  color: var(--accent);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

pre {
  background-color: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  overflow-x: auto;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.9rem;
}

blockquote {
  border-left: 3px solid var(--accent);
  padding-left: var(--space-4);
  margin: var(--space-6) 0;
  color: var(--text-muted);
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: var(--space-8) 0;
}

sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: super;
  top: -0.25em;
}

sub {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: sub;
  bottom: -0.25em;
}

s, del, strike {
  text-decoration: line-through;
  opacity: 0.8;
}

mark {
  background-color: rgba(234, 179, 8, 0.25);
  color: inherit;
  padding: 1px 4px;
  border-radius: 3px;
}

/* Bangla Typography Enhancements (targeted to text copy without shifting root rem) */
html[lang="bn"] body,
body:lang(bn),
.bn-text {
  font-family: var(--font-bengali);
  letter-spacing: 0.005em;
}

html[lang="bn"] p,
html[lang="bn"] li,
html[lang="bn"] .rich-text,
body:lang(bn) p,
body:lang(bn) li,
.bn-text {
  font-size: 1.04rem;
  line-height: 1.76;
}

html[lang="bn"] h1, :lang(bn) h1 { font-size: 2.35rem; line-height: 1.35; }
html[lang="bn"] h2, :lang(bn) h2 { font-size: 1.75rem; line-height: 1.4; }
html[lang="bn"] h3, :lang(bn) h3 { font-size: 1.4rem; line-height: 1.45; }

/* --------------------------------------------------------------------------
   5. Layout & Grid System
   -------------------------------------------------------------------------- */
.container,
.container-wide {
  width: 100%;
  max-width: var(--container-max, 1280px);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(1rem, 3.5vw, 2.5rem);
  padding-right: clamp(1rem, 3.5vw, 2.5rem);
  box-sizing: border-box;
}

.site-main {
  flex: 1 0 auto;
  padding-top: var(--space-8);
  padding-bottom: var(--space-12);
  box-sizing: border-box;
}

.template-homepage .site-main,
.portfolio-home .site-main {
  padding-top: 0;
  padding-bottom: var(--space-12);
}

/* Ensure no trailing margin accumulates before the footer on any page */
.site-main > :last-child,
.site-main > .container > :last-child,
.site-main > .container-wide > :last-child,
.site-main > article > :last-child,
.site-main section:last-child {
  margin-bottom: 0 !important;
}

/* --------------------------------------------------------------------------
   6. Header & Navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  background-color: rgba(10, 12, 16, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
  box-sizing: border-box;
}

[data-theme="light"] .site-header {
  background-color: rgba(248, 250, 252, 0.88);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: var(--space-4);
  box-sizing: border-box;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
  line-height: 1;
}

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

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  display: inline-block;
}

.site-brand-logo {
  height: 28px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: inline-block;
  vertical-align: middle;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.user-nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.user-nav-links a,
.user-nav-links .nav-link {
  color: var(--text-muted);
  font-size: 0.925rem;
  font-weight: 500;
  text-decoration: none;
  padding: var(--space-1) 0;
  line-height: 1.2;
  transition: color var(--transition-fast);
}

.user-nav-links a:hover,
.user-nav-links .nav-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

/* ==============================================================================
   Global Navbar Search Field
   ============================================================================== */
.nav-search-form {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background-color: var(--bg-surface-elevated, #1e293b);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: var(--radius-full, 9999px);
  padding: 0 10px 0 32px;
  height: 36px;
  width: 210px;
  transition: width var(--transition-normal, 0.2s), border-color var(--transition-fast, 0.15s), box-shadow var(--transition-fast, 0.15s), background-color var(--transition-fast, 0.15s);
  box-sizing: border-box;
}

[data-theme="light"] .nav-search-wrapper {
  background-color: #f1f5f9;
  border-color: #e2e8f0;
}

.nav-search-wrapper:hover {
  border-color: var(--border-normal, #475569);
}

.nav-search-wrapper:focus-within {
  width: 270px;
  border-color: var(--accent, #38bdf8);
  box-shadow: 0 0 0 3px var(--accent-glow, rgba(56, 189, 248, 0.2));
  background-color: var(--bg-surface, #0f172a);
}

[data-theme="light"] .nav-search-wrapper:focus-within {
  background-color: #ffffff;
  border-color: var(--accent, #0284c7);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.18);
}

.nav-search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-subtle, #94a3b8);
  pointer-events: none;
  transition: color var(--transition-fast, 0.15s);
}

.nav-search-wrapper:focus-within .nav-search-icon {
  color: var(--accent, #38bdf8);
}

.nav-search-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary, #f8fafc);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0;
  box-sizing: border-box;
}

.nav-search-input::placeholder {
  color: var(--text-subtle, #94a3b8);
  opacity: 0.85;
}

.nav-search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.nav-search-kbd {
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-subtle, #94a3b8);
  background: var(--bg-surface, #0f172a);
  border: 1px solid var(--border-subtle, #334155);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.2;
  margin-left: 6px;
  pointer-events: none;
  user-select: none;
  transition: opacity var(--transition-fast, 0.15s);
}

[data-theme="light"] .nav-search-kbd {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #64748b;
}

.nav-search-wrapper:focus-within .nav-search-kbd {
  opacity: 0;
}

@media (max-width: 768px) {
  .nav-search-form {
    width: 100%;
    order: -1;
    margin-bottom: var(--space-2);
  }

  .nav-search-wrapper {
    width: 100% !important;
    height: 42px;
    padding-left: 36px;
  }

  .nav-search-icon {
    left: 12px;
  }

  .nav-search-input {
    font-size: 0.95rem;
  }
}

/* Navigation Menu List & Multi-Level Dropdowns */
.nav-menu-list {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  position: relative;
  list-style: none;
}

.nav-item .nav-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dropdown-chevron,
.sub-chevron {
  transition: transform var(--transition-fast);
  color: var(--text-subtle);
  margin-left: 2px;
}

/* Desktop Dropdown Behavior */
@media (min-width: 769px) {
  .nav-item-has-children:hover > .nav-dropdown-link .dropdown-chevron,
  .nav-item-has-children:focus-within > .nav-dropdown-link .dropdown-chevron,
  .nav-item-has-children.open-sub > .nav-dropdown-link .dropdown-chevron {
    transform: rotate(180deg);
    color: var(--accent);
  }

  .nav-sub-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-1);
    list-style: none;
    margin: 0;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
  }

  .nav-sub-item {
    position: relative;
    list-style: none;
  }

  .nav-sub-item > .nav-sub-menu {
    top: 0;
    left: calc(100% + 4px);
  }

  .nav-item-has-children:hover > .nav-sub-menu,
  .nav-item-has-children:focus-within > .nav-sub-menu,
  .nav-sub-item-has-children:hover > .nav-sub-menu,
  .nav-sub-item-has-children:focus-within > .nav-sub-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-sub-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
  }

  .nav-sub-link:hover,
  .nav-sub-link:focus,
  .nav-sub-link.active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
  }
}

/* Flat Menu Component */
.flat-menu-wrapper {
  margin: var(--space-4) 0;
}

.flat-menu-heading {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
  margin-bottom: var(--space-3);
}

.flat-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.flat-menu-link {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.flat-menu-link:hover,
.flat-menu-link.active {
  color: var(--text-primary);
  text-decoration: none;
}


/* Mobile Accordion Dropdowns */
@media (max-width: 768px) {
  .nav-menu-list {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: var(--space-3);
  }

  .nav-item {
    width: 100%;
  }

  .nav-dropdown-link {
    width: 100%;
    justify-content: space-between;
    padding: var(--space-2) 0;
  }

  .nav-item-has-children.open-sub > .nav-dropdown-link .dropdown-chevron {
    transform: rotate(180deg);
    color: var(--accent);
  }

  .nav-sub-menu {
    display: none;
    list-style: none;
    padding: var(--space-1) 0 var(--space-1) var(--space-3);
    margin: var(--space-1) 0 0 0;
    border-left: 2px solid var(--border-subtle);
    width: 100%;
  }

  .nav-item-has-children.open-sub > .nav-sub-menu,
  .nav-sub-item-has-children.open-sub > .nav-sub-menu {
    display: block;
  }


  .nav-sub-link {
    display: block;
    padding: var(--space-2) 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
  }
}

.mobile-nav-toggle {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: inline-flex !important;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: var(--space-4);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-4);
    box-shadow: var(--shadow-md);
    z-index: 99;
  }

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

  .user-nav-links {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: var(--space-3);
  }

  .header-actions {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.header-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  background-color: var(--accent);
  color: var(--accent-contrast, #000) !important;
  text-decoration: none !important;
  transition: all var(--transition-fast);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.header-cta-btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Control Buttons (Theme & Language) */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  padding: 0;
}

.icon-button:hover {
  color: var(--text-primary);
  border-color: var(--border-muted);
  background-color: var(--bg-surface-hover);
}

.icon-button svg {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2;
}

/* Language Switcher */
.lang-switcher {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  cursor: pointer;
  display: inline-block;
  line-height: 1.2;
}

.lang-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-hover);
  text-decoration: none;
}

.lang-btn.active {
  background-color: var(--accent);
  color: var(--accent-contrast) !important;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.user-nav-links .nav-link.active,
.user-nav-links .nav-link.ancestor {
  color: var(--accent);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   7. Footer (Styles maintained in Section: Hero & 4-Column Footer below)
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   8. Components: Badges, Tags, Buttons, Cards
   -------------------------------------------------------------------------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}

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

.tag-accent {
  background-color: var(--accent-subtle);
  border-color: rgba(16, 185, 129, 0.25);
  color: var(--accent);
}

.badge-theme {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  line-height: 1.2;
}

.badge-theme svg {
  flex-shrink: 0;
  color: currentColor;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-size: 0.925rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--accent-contrast);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: var(--accent-contrast);
  text-decoration: none;
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-muted);
  text-decoration: none;
}

.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease;
}

.card:hover {
  border-color: var(--border-muted);
}

/* Responsive Listing Card Grid & Modern Bento Grid */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: var(--space-6);
}

@media (max-width: 720px) {
  .card-grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
}

/* ==============================================================================
   Dynamic Masonry Grid Layout (Zero-Waste Responsive Packing)
   ============================================================================== */
.masonry-grid,
.projects-grid,
.posts-grid,
.tools-grid,
.shop-grid,
.products-grid {
  --masonry-gap: 24px;
  position: relative;
  width: 100%;
  margin-top: var(--space-4, 16px);
  margin-bottom: var(--space-10, 40px);
  /* Progressive fallback: clean CSS Grid before JS initializes */
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--masonry-gap);
  align-items: start;
  transition: height 0.28s ease;
}

@media (min-width: 1024px) {
  .masonry-grid,
  .projects-grid,
  .posts-grid,
  .tools-grid,
  .shop-grid,
  .products-grid {
    --masonry-gap: 28px;
  }
}

/* Single item or only-child: exclude tools, search, projects, shop, and posts from stretching full-width */
.tools-grid > .card:only-child,
.tools-grid > article:only-child,
.tools-grid > .tool-card,
.tools-grid > .resource-card,
.tool-card:only-child,
.resource-card:only-child,
.search-results-grid > .card,
.search-results-grid > article,
.projects-grid > .card:only-child,
.projects-grid > article:only-child,
.shop-grid > .card:only-child,
.shop-grid > article:only-child,
.posts-grid > .card:only-child,
.posts-grid > article:only-child {
  grid-column: auto !important;
  max-width: 520px !important;
}

.projects-grid:not(.masonry-active) > .card:only-child,
.projects-grid:not(.masonry-active) > article:only-child,
.shop-grid:not(.masonry-active) > .card:only-child,
.shop-grid:not(.masonry-active) > article:only-child,
.posts-grid:not(.masonry-active) > .card:only-child,
.posts-grid:not(.masonry-active) > article:only-child {
  max-width: 520px !important;
  grid-column: 1 !important;
}

/* ==============================================================================
   Search Results Grid (Clean Standard Responsive Cards - Never Bento / Never Stretched)
   ============================================================================== */
.search-results-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
  gap: var(--space-6) !important;
  align-items: stretch !important;
  width: 100% !important;
  margin-top: var(--space-6) !important;
  margin-bottom: var(--space-10) !important;
  position: static !important;
  height: auto !important;
}

@media (max-width: 640px) {
  .search-results-grid {
    grid-template-columns: 1fr !important;
    gap: var(--space-4) !important;
  }
}

.search-results-grid > .card,
.search-results-grid > article,
.search-results-grid .search-result-card {
  grid-column: auto !important;
  width: 100% !important;
  max-width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  position: static !important;
  transform: none !important;
  box-sizing: border-box !important;
  margin: 0 !important;
}

/* Single search result stays at clean column width instead of stretching across the screen */
.search-results-grid > .card:only-child,
.search-results-grid > article:only-child,
.search-results-grid > .search-result-card:only-child {
  max-width: 520px !important;
  grid-column: 1 !important;
}

.search-results-grid .bento-card-wide,
.search-results-grid .project-result-card,
.search-results-grid .tool-result-card,
.search-results-grid .blog-result-card,
.search-results-grid .product-result-card,
.search-results-grid .search-result-card {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  grid-column: auto !important;
}


/* When JavaScript initializes and takes over absolute positioning */
.masonry-grid.masonry-active,
.projects-grid.masonry-active,
.posts-grid.masonry-active,
.tools-grid.masonry-active,
.shop-grid.masonry-active,
.products-grid.masonry-active {
  display: block !important;
}

.masonry-active > .card,
.masonry-active > article {
  position: absolute;
  top: 0;
  left: 0;
  margin: 0 !important;
  box-sizing: border-box;
  transition: transform 0.28s cubic-bezier(0.2, 0, 0.2, 1), opacity 0.2s ease, box-shadow var(--transition-fast), border-color var(--transition-fast);
  will-change: transform;
}

/* Ensure images inside masonry cards do not overflow before loading */
.masonry-grid .card-thumb-link img,
.projects-grid .card-thumb-link img,
.posts-grid .card-thumb-link img,
.shop-grid .card-thumb-link img,
.products-grid .card-thumb-link img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

/* FAQ Answer Paragraph Bottom Margin (Reduced to 0.25rem per specs) */
.faq-answer p,
.faq-answer-inner p,
.faq-answer-content p,
details .faq-answer p,
details .faq-answer-content p,
details div.rich-text p {
  margin-bottom: 0.25rem !important;
}
.faq-answer p:last-child,
.faq-answer-inner p:last-child,
.faq-answer-content p:last-child,
details .faq-answer p:last-child,
details .faq-answer-content p:last-child,
details div.rich-text p:last-child {
  margin-bottom: 0 !important;
}

/* Category Filter Pill Overrides - Never Underline on Hover/Focus */
.cat-pill,
.cat-pill:hover,
.cat-pill:focus,
.cat-pill:active,
.cat-pill.active {
  text-decoration: none !important;
}


/* ==============================================================================
   Bento Grid Architecture (Modern Asymmetrical & Compact Layouts)
/* ==============================================================================
   Bento & Masonry Hybrid Grid System
   ============================================================================== */
.bento-grid,
.home-bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-5);
  width: 100%;
  align-items: stretch;
}

.bento-grid > .card,
.bento-grid > article,
.home-bento-grid > .card,
.home-bento-grid > article {
  grid-column: span 12;
  display: flex;
  flex-direction: column;
}

/* Card Body wrapper for robust vertical flex alignment */
.card-body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.card-body > .card-footer,
.card > .card-footer {
  margin-top: auto;
  padding-top: var(--space-3);
}

@media (min-width: 768px) {
  /* Standard 2-column bento cards (span 6 = 1 column in 2-column view) */
  .bento-grid > .card,
  .bento-grid > article,
  .home-bento-grid > .card,
  .home-bento-grid > article {
    grid-column: span 6;
  }

  /* When there is an odd trailing card (e.g. 3rd or 5th card), it takes TWO columns (span 12)
     to fill the remaining space cleanly and completely eliminate empty voids */
  .bento-grid > .card:last-child:nth-child(odd),
  .bento-grid > article:last-child:nth-child(odd),
  .home-bento-grid > .card:last-child:nth-child(odd),
  .home-bento-grid > article:last-child:nth-child(odd),
  .bento-grid > .bento-card-wide,
  .home-bento-grid > .bento-card-wide,
  .bento-card-wide {
    grid-column: span 12 !important;
  }
}

@media (min-width: 860px) {
  /* Expansive Horizontal Bento layout for curated wide lead cards only (never for products, posts, projects, or related grids) */
  .home-bento-grid > .bento-card-lead:not(.card-no-thumb):not(.product-card):not(.project-card):not(.post-card),
  .bento-card-wide:not(.card-no-thumb):not(.tool-card):not(.resource-card):not(.search-result-card):not(.project-result-card):not(.tool-result-card):not(.project-card):not(.product-card):not(.post-card):not(.blog-post-card) {
    display: grid !important;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr) !important;
    gap: var(--space-6) !important;
    align-items: stretch !important;
    overflow: hidden !important;
  }

  .home-bento-grid > .bento-card-lead:not(.card-no-thumb):not(.product-card):not(.project-card):not(.post-card) .card-thumb-link,
  .bento-card-wide:not(.card-no-thumb):not(.tool-card):not(.resource-card):not(.search-result-card):not(.project-result-card):not(.tool-result-card):not(.project-card):not(.product-card):not(.post-card):not(.blog-post-card) .card-thumb-link {
    margin-bottom: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    min-height: 200px;
    max-height: 340px;
    aspect-ratio: auto !important;
    overflow: hidden !important;
  }

  .home-bento-grid > .bento-card-lead:not(.card-no-thumb):not(.product-card):not(.project-card):not(.post-card) .card-thumb-link img,
  .bento-card-wide:not(.card-no-thumb):not(.tool-card):not(.resource-card):not(.search-result-card):not(.project-result-card):not(.tool-result-card):not(.project-card):not(.product-card):not(.post-card):not(.blog-post-card) .card-thumb-link img {
    height: 100% !important;
    width: 100% !important;
    max-width: 100% !important;
    object-fit: cover !important;
    border-radius: var(--radius-sm);
  }

  .home-bento-grid > .bento-card-lead:not(.card-no-thumb):not(.product-card):not(.project-card):not(.post-card) .card-body,
  .bento-card-wide:not(.card-no-thumb):not(.tool-card):not(.resource-card):not(.search-result-card):not(.project-result-card):not(.tool-result-card):not(.project-card):not(.product-card):not(.post-card):not(.blog-post-card) .card-body {
    min-width: 0 !important;
    max-width: 100% !important;
    overflow: hidden !important;
  }
}

/* Wide Featured / Lead Bento Tile (spans 12 columns horizontally on index pages) */
.bento-grid > .bento-card-lead {
  grid-column: span 12;
}

/* Horizontal Lead Bento Card (Featured top story on Archive pages) */
.bento-card-lead .bento-lead-inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  align-items: center;
}

@media (min-width: 900px) {
  .bento-card-lead:has(.card-thumb-link) .bento-lead-inner {
    grid-template-columns: 1.1fr 1fr;
  }
  .bento-card-lead.card-no-thumb .bento-lead-inner {
    grid-template-columns: 1fr !important;
  }
  .bento-card-lead .card-thumb-link {
    margin-bottom: 0;
    height: 100%;
    min-height: 200px;
    max-height: 260px;
  }
  .bento-card-lead .card-thumb-link img {
    height: 100%;
  }
}

/* Compact Bento Card (Tightly formatted, zero dead space) */
.bento-card-compact {
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.bento-card-compact .card-title {
  font-size: 1.12rem;
  line-height: 1.35;
  margin-bottom: var(--space-2);
}

.bento-card-compact .card-description {
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: var(--space-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 0;
}

.bento-card-compact .card-footer {
  margin-top: var(--space-2);
  padding-top: var(--space-2);
}

/* Card without image styling */
.card-no-thumb {
  border-top: 2px solid var(--accent);
}

/* Interactive Listing Cards (Projects & Blog Articles) */
.card-interactive {
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.25s ease,
              border-color 0.25s ease,
              background-color 0.25s ease;
  overflow: hidden;
}

.card-interactive:hover,
.project-card:hover,
.blog-post-card:hover,
.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 12px 24px -6px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(56, 189, 248, 0.2);
}

[data-theme="light"] .card-interactive:hover,
[data-theme="light"] .project-card:hover,
[data-theme="light"] .blog-post-card:hover,
[data-theme="light"] .post-card:hover {
  border-color: var(--accent);
  box-shadow: 0 12px 24px -6px rgba(15, 23, 42, 0.1), 0 0 0 1px rgba(2, 132, 199, 0.2);
}

/* ==============================================================================
   Resource & Tools Directory Components (Normal Proportional Cards, No Bento)
   ============================================================================== */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: var(--space-5, 20px);
  width: 100%;
  margin-top: var(--space-4, 16px);
  margin-bottom: var(--space-8, 32px);
  align-items: stretch;
}

@media (max-width: 640px) {
  .tools-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4, 16px);
  }
}

.tool-card,
.resource-card {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  position: relative;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-sizing: border-box;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.22s ease,
              box-shadow 0.22s ease;
  overflow: hidden;
  height: auto;
}

.tool-card:hover,
.resource-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 10px 22px -6px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(56, 189, 248, 0.2);
}

[data-theme="light"] .tool-card:hover,
[data-theme="light"] .resource-card:hover {
  box-shadow: 0 10px 22px -6px rgba(15, 23, 42, 0.1), 0 0 0 1px rgba(2, 132, 199, 0.2);
}

.resource-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.resource-card-title-group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
}

.resource-card-icon {
  font-size: 1.25rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-subtle);
}

.resource-card-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}

.resource-card-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.resource-card-title a:hover {
  color: var(--accent);
}

.resource-card-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.resource-card-description {
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0 0 var(--space-4) 0;
  flex: 1 1 auto;
  word-break: break-word;
}

.resource-card-footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.resource-visit-btn {
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--radius-md);
  text-decoration: none;
}

.resource-copy-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.03));
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.resource-copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.08);
}

@media (max-width: 640px) {
  .tool-category-section {
    margin: var(--space-6) 0 var(--space-8) !important;
  }
  .tool-card,
  .resource-card {
    padding: var(--space-4);
  }
  .resource-visit-btn {
    min-height: 40px;
    padding: 8px 16px;
  }
  .resource-copy-btn {
    min-width: 40px;
    min-height: 40px;
  }
  .external-resource-card {
    padding: var(--space-4) !important;
  }
  .external-resource-action {
    width: 100%;
  }
  .external-resource-action .btn {
    width: 100%;
    justify-content: center;
  }
}


/* Card Thumbnail preview & smooth zoom on card hover */
.card-thumb-link {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  aspect-ratio: 16 / 9;
  max-height: 160px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-3);
  text-decoration: none;
}

.card-thumb-link img {
  width: 100%;
  max-width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-interactive:hover .card-thumb-link img,
.project-card:hover .card-thumb-link img,
.blog-post-card:hover .card-thumb-link img,
.post-card:hover .card-thumb-link img {
  transform: scale(1.03);
}

/* Card Title with hover accent color */
.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 0;
  margin-bottom: var(--space-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-title a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Card Description */
.card-description {
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Footer */
.card-footer {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

/* --------------------------------------------------------------------------
   Portfolio Hero Section (Homepage Personal Showcase)
   -------------------------------------------------------------------------- */
.portfolio-hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-8);
  align-items: center;
  padding: var(--space-8) 0 var(--space-12);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-12);
}

@media (max-width: 820px) {
  .portfolio-hero {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  .portfolio-hero-avatar {
    order: -1;
  }
}

.portfolio-hero-content {
  display: flex;
  flex-direction: column;
}

.portfolio-status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 0.85rem;
  background-color: var(--accent-subtle);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: var(--space-4);
  width: fit-content;
}

.portfolio-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse-dot 2.5s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.portfolio-name {
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 0;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.portfolio-role {
  font-family: var(--font-mono);
  font-size: clamp(1rem, 2.5vw, 1.2rem);
  color: var(--accent);
  margin-bottom: var(--space-4);
  font-weight: 500;
}

.portfolio-bio {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 680px;
  margin-bottom: var(--space-6);
}

.portfolio-hero-avatar {
  display: flex;
  justify-content: center;
  align-items: center;
}

.portfolio-avatar-frame {
  width: 170px;
  height: 170px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid var(--border-muted);
  box-shadow: var(--shadow-md);
  background-color: var(--bg-surface-elevated);
  position: relative;
}

.portfolio-avatar-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.portfolio-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 700;
  color: var(--accent);
  background: linear-gradient(135deg, var(--bg-surface-elevated), var(--bg-surface-hover));
}

.portfolio-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.portfolio-socials {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
}

.portfolio-tags-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-wrap: wrap;
  margin-top: var(--space-2);
}

/* --------------------------------------------------------------------------
   9. Post Reading Utilities & Long Post ToC
   -------------------------------------------------------------------------- */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-bottom: var(--space-6);
}

.post-meta-separator {
  color: var(--border-muted);
}

.toc-container {
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin: var(--space-6) 0 var(--space-8);
  box-shadow: var(--shadow-sm);
  width: 100%;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Table of Contents (Clean, Normal & Collapsible)
   -------------------------------------------------------------------------- */
.toc-container {
  display: none; /* revealed by JS if >= 2 headings */
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  margin: var(--space-6) 0 var(--space-8) 0;
  box-sizing: border-box;
}

.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  user-select: none;
}

.toc-container.is-collapsed .toc-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.toc-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.toc-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.04));
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.toc-toggle-btn:hover {
  background: var(--bg-surface-hover, rgba(255, 255, 255, 0.08));
  color: var(--accent);
  border-color: var(--accent);
}

.toc-chevron {
  transition: transform 0.2s ease;
}

.toc-container.is-collapsed .toc-chevron {
  transform: rotate(-90deg);
}

.toc-container.is-collapsed .toc-list {
  display: none !important;
}

.toc-list {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Level 1: Main Topic (Clean, normal, no icons) */
.toc-item-main {
  list-style: none !important;
  padding-left: 0 !important;
  margin-top: 6px;
}

.toc-item-main:first-child {
  margin-top: 0;
}

.toc-item-main > .toc-link {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: inline-block;
  text-decoration: none;
  transition: color 0.15s ease, transform 0.15s ease;
}

.toc-item-main > .toc-link:hover {
  color: var(--accent);
  text-decoration: none;
  transform: translateX(3px);
}

/* Level 2: Subtopic (Normal clean indentation, no icons) */
.toc-item-subtopic {
  list-style: none !important;
  padding-left: 1.5rem !important;
  margin-top: 2px;
}

.toc-item-subtopic > .toc-link {
  font-weight: 400;
  font-size: 0.88rem;
  color: var(--text-muted);
  display: inline-block;
  text-decoration: none;
  transition: color 0.15s ease, transform 0.15s ease;
}

.toc-item-subtopic > .toc-link:hover {
  color: var(--accent);
  text-decoration: none;
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   10. Responsive Tweaks
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  h1 { font-size: 1.85rem; }
  h2 { font-size: 1.45rem; }
  h3 { font-size: 1.2rem; }

  .site-nav {
    gap: var(--space-3);
  }

  .nav-links {
    gap: var(--space-3);
  }

  .nav-link {
    font-size: 0.875rem;
  }
}

/* --------------------------------------------------------------------------
   11. Code Block & Prism Syntax Highlighting (Light Theme vs Deep Black Theme)
   -------------------------------------------------------------------------- */

.code-block-wrapper {
  margin: var(--space-6) 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.code-block-header {
  padding: var(--space-2) var(--space-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.code-copy-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.code-copy-btn.copied {
  color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.step-code-wrapper {
  position: relative;
  max-width: 100%;
  min-width: 0;
  margin: var(--space-3) 0;
}

.step-code-wrapper pre {
  margin: 0;
  font-size: 0.85rem;
  max-width: 100%;
  overflow-x: auto;
  box-sizing: border-box;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  padding-right: 70px;
}

.step-code-copy-btn {
  position: absolute;
  top: -13px;
  right: 2px;
  z-index: 5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
}

.code-block-wrapper pre {
  margin: 0;
  padding: var(--space-4);
  overflow-x: auto;
  border: none;
  border-radius: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  tab-size: 4;
}

.code-block-wrapper code {
  font-family: var(--font-mono);
  background: transparent !important;
  padding: 0 !important;
}

/* --- Dark Theme (Deep Black Background with Vibrant Highlighting) --- */
[data-theme="dark"] .code-block-wrapper,
:root:not([data-theme="light"]) .code-block-wrapper {
  background-color: #0d1117;
  border: 1px solid #30363d;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] .code-block-header,
:root:not([data-theme="light"]) .code-block-header {
  background-color: #161b22;
  border-bottom: 1px solid #30363d;
  color: #f0f6fc;
}

[data-theme="dark"] .code-filename,
:root:not([data-theme="light"]) .code-filename {
  color: #f0f6fc;
}

[data-theme="dark"] .code-block-header .tag-mono,
:root:not([data-theme="light"]) .code-block-header .tag-mono {
  color: #8b949e;
  background-color: #21262d;
  border: 1px solid #30363d;
}

[data-theme="dark"] .code-copy-btn,
:root:not([data-theme="light"]) .code-copy-btn {
  background-color: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
}

[data-theme="dark"] .code-copy-btn:hover,
:root:not([data-theme="light"]) .code-copy-btn:hover {
  background-color: #30363d;
  color: #ffffff;
}

[data-theme="dark"] .code-block-wrapper pre,
:root:not([data-theme="light"]) .code-block-wrapper pre {
  background-color: #0d1117;
  color: #e6edf3;
}

/* Dark Theme Syntax Highlighting Tokens */
[data-theme="dark"] .token.comment,
[data-theme="dark"] .token.prolog,
[data-theme="dark"] .token.doctype,
[data-theme="dark"] .token.cdata { color: #8b949e; font-style: italic; }
[data-theme="dark"] .token.punctuation { color: #c9d1d9; }
[data-theme="dark"] .token.keyword,
[data-theme="dark"] .token.tag { color: #ff7b72; font-weight: 600; }
[data-theme="dark"] .token.string,
[data-theme="dark"] .token.attr-value { color: #a5d6ff; }
[data-theme="dark"] .token.number,
[data-theme="dark"] .token.boolean,
[data-theme="dark"] .token.constant { color: #79c0ff; }
[data-theme="dark"] .token.function,
[data-theme="dark"] .token.class-name { color: #d2a8ff; font-weight: 500; }
[data-theme="dark"] .token.operator { color: #ff7b72; }
[data-theme="dark"] .token.property,
[data-theme="dark"] .token.variable { color: #ffa657; }
[data-theme="dark"] .token.attr-name { color: #7ee787; }
[data-theme="dark"] .token.selector { color: #7ee787; }
[data-theme="dark"] .token.inserted { color: #3fb950; background-color: rgba(46, 160, 67, 0.15); display: inline-block; width: 100%; }
[data-theme="dark"] .token.deleted { color: #f85149; background-color: rgba(248, 81, 73, 0.15); display: inline-block; width: 100%; }
[data-theme="dark"] .token.coord { color: #79c0ff; font-weight: 600; }

/* --- Light Theme (Clean Crisp Light Gray / White with High Contrast Highlighting) --- */
[data-theme="light"] .code-block-wrapper {
  background-color: #f6f8fa;
  border: 1px solid #d0d7de;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .code-block-header {
  background-color: #eaeef2;
  border-bottom: 1px solid #d0d7de;
  color: #1f2328;
}

[data-theme="light"] .code-filename {
  color: #1f2328;
}

[data-theme="light"] .code-block-header .tag-mono {
  color: #57606a;
  background-color: #ffffff;
  border: 1px solid #d0d7de;
}

[data-theme="light"] .code-copy-btn {
  background-color: #ffffff;
  border: 1px solid #d0d7de;
  color: #24292f;
}

[data-theme="light"] .code-copy-btn:hover {
  background-color: #f3f4f6;
  border-color: #afb8c1;
  color: #0969da;
}

[data-theme="light"] .code-block-wrapper pre {
  background-color: #f6f8fa;
  color: #1f2328;
}

/* Light Theme Syntax Highlighting Tokens */
[data-theme="light"] .token.comment,
[data-theme="light"] .token.prolog,
[data-theme="light"] .token.doctype,
[data-theme="light"] .token.cdata { color: #6e7781; font-style: italic; }
[data-theme="light"] .token.punctuation { color: #24292f; }
[data-theme="light"] .token.keyword,
[data-theme="light"] .token.tag { color: #cf222e; font-weight: 600; }
[data-theme="light"] .token.string,
[data-theme="light"] .token.attr-value { color: #0a3069; }
[data-theme="light"] .token.number,
[data-theme="light"] .token.boolean,
[data-theme="light"] .token.constant { color: #0550ae; }
[data-theme="light"] .token.function,
[data-theme="light"] .token.class-name { color: #8250df; font-weight: 500; }
[data-theme="light"] .token.operator { color: #cf222e; }
[data-theme="light"] .token.property,
[data-theme="light"] .token.variable { color: #953800; }
[data-theme="light"] .token.attr-name { color: #116329; }
[data-theme="light"] .token.selector { color: #116329; }
[data-theme="light"] .token.inserted { color: #1a7f37; background-color: rgba(46, 160, 67, 0.15); display: inline-block; width: 100%; }
[data-theme="light"] .token.deleted { color: #cf222e; background-color: rgba(207, 34, 46, 0.12); display: inline-block; width: 100%; }
[data-theme="light"] .token.coord { color: #0969da; font-weight: 600; }

/* --------------------------------------------------------------------------
   12. Component Visibility & High-Contrast Light Theme Overrides
   -------------------------------------------------------------------------- */
[data-theme="light"] body {
  background-color: #ffffff;
  color: #0f172a;
}

[data-theme="light"] .card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tag {
  background-color: #f1f5f9;
  border-color: #e2e8f0;
  color: #1e293b;
}

[data-theme="light"] .tag:hover {
  color: var(--accent);
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

[data-theme="light"] .tag-accent {
  background-color: var(--accent-subtle);
  border-color: var(--accent-glow);
  color: var(--accent);
  font-weight: 600;
}

[data-theme="light"] .btn-secondary {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] .btn-secondary:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

[data-theme="light"] .site-header {
  background-color: rgba(255, 255, 255, 0.94);
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .site-footer {
  background-color: #f8fafc;
  border-top-color: #e2e8f0;
  color: #475569;
}

[data-theme="light"] input,
[data-theme="light"] textarea,
[data-theme="light"] select {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="light"] input:focus,
[data-theme="light"] textarea:focus,
[data-theme="light"] select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

[data-theme="light"] .callout {
  background-color: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .callout-header {
  color: #0f172a;
}

[data-theme="light"] .callout-content {
  color: #1e293b;
}

[data-theme="light"] .post-meta {
  color: #475569;
}

[data-theme="light"] .post-meta-separator {
  color: #cbd5e1;
}

[data-theme="light"] .browser-frame-container {
  background-color: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .browser-frame-container > div:first-child {
  background-color: #f1f5f9;
  border-bottom-color: #e2e8f0;
}

[data-theme="light"] .browser-frame-container > div:first-child > div[style*="max-width: 480px"] {
  background-color: #ffffff !important;
  border-color: #cbd5e1 !important;
  color: #0f172a !important;
}

/* ==========================================================================
   Author Profile Card Component (Shown below Projects & Blog Posts)
   ========================================================================== */
.author-profile-card {
  position: relative;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-top: var(--space-10);
  margin-bottom: var(--space-8);
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.author-profile-card:hover {
  border-color: var(--border-muted);
  box-shadow: var(--shadow-md);
}

.author-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.author-avatar-img {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent);
  background-color: var(--bg-surface);
  display: block;
}

.author-avatar-placeholder {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(14, 165, 233, 0.2));
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 2rem;
  color: var(--accent);
}

.author-body {
  flex: 1;
  min-width: 0;
}

.author-header-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.author-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.author-role-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background-color: rgba(16, 185, 129, 0.12);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.25);
  display: inline-block;
}

.author-location {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.author-bio {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
}

.author-social-channels {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.author-social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.author-social-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  background-color: var(--bg-surface-elevated);
}

.author-social-link svg {
  width: 17px;
  height: 17px;
}

@media (max-width: 640px) {
  .author-profile-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-5);
  }
  .author-header-line {
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
  }
  .author-social-channels {
    justify-content: center;
  }
}

/* ==========================================================================
   Project Stack Tags Filter Bar & Clickable Tags
   ========================================================================== */
.tags-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) 0;
  margin-bottom: var(--space-8);
  border-bottom: 1px solid var(--border-subtle);
}

.tag-filter-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: var(--font-mono);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.tag-filter-link:hover {
  color: var(--text-primary);
  border-color: var(--accent);
  background-color: var(--bg-surface-elevated);
  text-decoration: none;
}

.tag-filter-link.active {
  background-color: var(--accent);
  color: #042013;
  border-color: var(--accent);
  font-weight: 600;
}

.tag-filter-clear {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: underline;
  margin-left: var(--space-2);
}

.tag-filter-clear:hover {
  color: var(--accent);
}

a.tag {
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

a.tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--bg-surface-elevated);
  transform: translateY(-1px);
}

/* ==========================================================================
   Related Content Section (Posts & Projects)
   ========================================================================== */
.related-content-section,
.related-projects-section {
  margin-top: var(--space-12);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-subtle);
  width: 100%;
}

.related-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.related-section-header-text {
  max-width: 680px;
}

.related-section-title {
  font-size: clamp(1.35rem, 3vw, 1.75rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  margin: 0 0 var(--space-1) 0;
}

.related-section-subtitle {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0;
}

.related-content-grid,
.related-projects-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-5);
  width: 100%;
}

.related-content-grid > .card,
.related-content-grid > article,
.related-projects-grid > .card,
.related-projects-grid > article {
  grid-column: span 12;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.related-content-grid > .card:hover,
.related-content-grid > article:hover,
.related-projects-grid > .card:hover,
.related-projects-grid > article:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}

[data-theme="light"] .related-content-grid > .card,
[data-theme="light"] .related-content-grid > article,
[data-theme="light"] .related-projects-grid > .card,
[data-theme="light"] .related-projects-grid > article {
  background-color: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .related-content-grid > .card:hover,
[data-theme="light"] .related-content-grid > article:hover,
[data-theme="light"] .related-projects-grid > .card:hover,
[data-theme="light"] .related-projects-grid > article:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

@media (min-width: 768px) {
  .related-content-grid > .card,
  .related-content-grid > article,
  .related-projects-grid > .card,
  .related-projects-grid > article {
    grid-column: span 6;
  }

  .related-content-grid > .card:last-child:nth-child(odd),
  .related-content-grid > article:last-child:nth-child(odd),
  .related-projects-grid > .card:last-child:nth-child(odd),
  .related-projects-grid > article:last-child:nth-child(odd) {
    grid-column: span 12 !important;
  }
}

/* Related grid layout wide odd trailing card inherits unified Bento horizontal rules above */

.related-project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  text-decoration: none;
}

.related-project-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.related-project-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-2) 0;
}

.related-project-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Light Mode Overrides for Author Card */
[data-theme="light"] .author-profile-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .author-profile-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .author-name {
  color: #0f172a;
}

[data-theme="light"] .author-bio {
  color: #334155;
}

[data-theme="light"] .author-social-link {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: #64748b;
}

[data-theme="light"] .author-social-link:hover {
  background-color: #ffffff;
  border-color: var(--accent);
  color: var(--accent);
}

[data-theme="light"] .related-project-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .related-project-title {
  color: #0f172a;
}

[data-theme="light"] .tag-filter-link {
  background-color: #ffffff;
  border-color: #cbd5e1;
  color: #475569;
}

/* ==========================================================================
   Hero & 4-Column Footer (Adopted from Personal Branding Design)
   ========================================================================== */

/* Hero Section */
.hero-section,
.portfolio-hero {
  width: 100%;
  padding: 5.5rem 0 4.5rem;
  border-bottom: 1px solid var(--border-subtle);
  background: radial-gradient(
    ellipse 85% 70% at 20% 0%,
    var(--accent-subtle) 0%,
    transparent 70%
  ), var(--bg-body);
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .hero-section,
[data-theme="light"] .portfolio-hero {
  background: radial-gradient(
    ellipse 85% 70% at 20% 0%,
    var(--accent-subtle) 0%,
    transparent 70%
  ), var(--bg-body);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(2rem, 4vw, 3.75rem);
  align-items: center;
}

/* Domain Pill */
.domain-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* Typography */
.hero-title {
  font-size: clamp(2.25rem, 4.5vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

.hero-subtitle {
  font-size: clamp(1.15rem, 2vw, 1.35rem);
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

.text-highlight {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.92em;
  background-color: var(--accent-subtle);
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
}

.hero-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-muted);
  max-width: 54ch;
  margin: 0 0 2rem 0;
}

/* Hero Buttons */
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.875rem;
}

/* Right Column: Focus Card */
.focus-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.focus-card:hover {
  border-color: var(--border-muted);
  box-shadow: var(--shadow-md);
}

.focus-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.15rem;
  background-color: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.window-dots {
  display: flex;
  gap: 6px;
}

.window-dots span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: var(--border-muted);
}

.window-dots span:first-child {
  background-color: var(--accent);
}

.focus-card-title {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.focus-card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.pillar-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.85rem;
  border-radius: 8px;
  background-color: var(--bg-body);
  border: 1px solid var(--border-subtle);
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease;
}

.pillar-item:hover {
  border-color: var(--border-muted);
  background-color: var(--bg-surface-elevated);
  transform: translateX(2px);
}

.pillar-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background-color: var(--accent-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  margin-top: 0.1rem;
}

.pillar-info h3,
.pillar-info .pillar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
}

.pillar-info p {
  font-size: 0.825rem;
  line-height: 1.5;
  color: var(--text-muted);
  margin: 0;
}

.focus-card-footer {
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background-color: var(--bg-surface-elevated);
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-subtle);
}

/* ================= 4-COLUMN FOOTER STYLES ================= */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 2.5rem 0 1.5rem;
  margin-top: 0;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.footer-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.8fr) repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(1.5rem, 2.5vw, 2.25rem);
  align-items: start;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.footer-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
}

.footer-logo {
  display: inline-block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.logo-accent {
  font-family: var(--font-mono);
  color: var(--accent);
  font-size: 0.95rem;
}

.footer-bio {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 36ch;
  margin: 0 0 0.85rem 0;
  text-align: left;
}

.footer-domain-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--accent);
  background-color: var(--accent-subtle);
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
}

.footer-nav-col {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  align-self: start;
}

.footer-heading {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  margin: 0 0 0.75rem 0;
  line-height: 1.2;
  text-align: left;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.35rem;
}

.footer-links li {
  margin: 0;
  padding: 0;
  text-align: left;
  list-style: none;
  line-height: 1.25;
}

.footer-links a {
  font-size: 0.875rem;
  line-height: 1.25;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0;
  text-align: left;
}

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

.footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.copyright {
  font-size: 0.82rem;
  color: var(--text-subtle);
  margin: 0;
  text-align: left;
}

.footer-bottom-right {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-left: auto;
}

.footer-meta {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
  margin: 0;
  text-align: right;
  white-space: nowrap;
}

/* Floating Back to Top Button (Icon only, zero layout space) */
.floating-back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background: var(--bg-surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.floating-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.floating-back-to-top:hover {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px var(--accent-glow);
}

.floating-back-to-top:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .floating-back-to-top {
    bottom: 18px;
    right: 18px;
    width: 38px;
    height: 38px;
  }
}

.footer-bottom-menu {
  display: inline-flex;
  align-items: center;
}

.footer-bottom-menu-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.footer-bottom-menu-link {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.footer-bottom-menu-link:hover,
.footer-bottom-menu-link.active {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 960px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 2.5rem;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }
}

@media (max-width: 640px) {
  .hero-section,
  .portfolio-hero {
    padding: 3.5rem 0 2.5rem;
  }

  .site-footer {
    padding: 2rem 0 1.5rem;
  }

  .footer-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 1.75rem 1.25rem !important;
  }

  .footer-brand {
    grid-column: 1 / -1 !important;
    max-width: 100%;
    padding-bottom: 0.25rem;
  }

  .footer-nav-col {
    min-width: 0;
  }

  .footer-bio {
    max-width: 100%;
    font-size: 0.88rem;
    line-height: 1.6;
  }

  .footer-links a {
    padding: 0.25rem 0;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding-top: 1.25rem;
  }

  .footer-bottom-right {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.75rem;
  }

  .footer-bottom-menu {
    width: 100%;
  }

  .footer-bottom-menu-list {
    justify-content: flex-start;
    gap: 0.6rem 1.25rem;
  }

  .footer-meta {
    text-align: left;
    white-space: normal;
    word-break: break-word;
    font-size: 0.72rem;
    line-height: 1.5;
  }

  .copyright {
    font-size: 0.82rem;
    line-height: 1.5;
  }
}

/* ==========================================================================
   Security Alert Component
   ========================================================================== */
.security-alert-box {
  position: relative;
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-md);
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}

.security-alert-box.security-alert-zeroday {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.08);
}

.security-alert-box.security-alert-hardening {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
}

.security-alert-box.security-alert-compliance {
  border-color: rgba(59, 130, 246, 0.45);
  background: rgba(59, 130, 246, 0.08);
}

.security-alert-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  padding-right: 145px;
}

.security-alert-icon {
  font-size: 1.15rem;
  line-height: 1.35;
  flex-shrink: 0;
}

.security-alert-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-normal);
  line-height: 1.35;
}

.security-alert-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  font-size: 0.7rem;
  font-family: var(--font-mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #f59e0b;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

@media (max-width: 640px) {
  .security-alert-box {
    padding-top: 2.4rem;
  }
  .security-alert-header {
    padding-right: 0;
  }
  .security-alert-badge {
    top: 8px;
    right: 10px;
  }
}

.security-alert-zeroday .security-alert-badge {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ef4444;
}

.security-alert-hardening .security-alert-badge {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(16, 185, 129, 0.35);
  color: #10b981;
}

.security-alert-compliance .security-alert-badge {
  background: rgba(59, 130, 246, 0.16);
  border-color: rgba(59, 130, 246, 0.35);
  color: #3b82f6;
}

.security-alert-message {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.security-alert-message p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Article References, Sources & Interactive Citation Badges
   ========================================================================== */
sup.ref-badge {
  font-size: 0.72rem;
  line-height: 0;
  vertical-align: super;
  position: relative;
  top: -0.35em;
  margin: 0 2px;
  display: inline-block;
}

.ref-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  color: var(--accent);
  background-color: var(--accent-subtle);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 1px 4px;
  border-radius: 4px;
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
  vertical-align: super;
  position: relative;
  top: -0.4em;
}

sup .ref-link,
sup.ref-badge .ref-link {
  vertical-align: baseline;
  top: 0;
}

.ref-link .ref-bracket {
  opacity: 0.45;
  font-weight: 400;
  font-size: 0.88em;
  margin: 0 0.5px;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}

.ref-link .ref-num {
  font-weight: 700;
}

.ref-link:hover {
  background-color: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
  transform: translateY(-1.5px);
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.35);
}

.ref-link:hover .ref-bracket {
  opacity: 0.85;
  color: var(--accent-contrast);
}

.article-references {
  margin-top: var(--space-10);
  margin-bottom: var(--space-8);
  padding: var(--space-6);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition-fast);
}

.references-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.references-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.references-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.references-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.reference-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background-color: var(--bg-surface);
  transition: all var(--transition-fast);
}

.reference-item:hover {
  border-color: var(--border-muted);
}

.ref-marker {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.ref-body {
  flex: 1;
  min-width: 0;
}

.ref-main-line {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-primary);
}

.ref-source-link {
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.ref-source-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.ref-source-title {
  font-weight: 600;
  color: var(--text-primary);
}

.ref-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-left: 6px;
}

.ref-note {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: var(--space-1) 0 0 0;
  line-height: 1.5;
}

.ref-backlink {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  margin-top: 4px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ref-backlink:hover {
  background-color: var(--accent);
  color: #042013;
  transform: translateY(-2px);
}

/* Pulsing highlight animation when jumping to reference or returning to text */
.ref-highlight-active {
  animation: refTargetPulse 2.2s ease-out forwards;
}

@keyframes refTargetPulse {
  0% {
    border-color: var(--accent);
    background-color: rgba(16, 185, 129, 0.25);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.35);
    transform: scale(1.015);
  }
  50% {
    border-color: var(--accent);
    background-color: rgba(16, 185, 129, 0.12);
  }
  100% {
    border-color: transparent;
    background-color: var(--bg-surface);
    box-shadow: none;
    transform: scale(1);
  }
}

/* Light Theme Overrides */
[data-theme="light"] .article-references {
  background-color: #ffffff;
  border-color: #e2e8f0;
}

[data-theme="light"] .reference-item {
  background-color: #f8fafc;
  border-color: #e2e8f0;
}

[data-theme="light"] .reference-item:hover {
  border-color: #cbd5e1;
}

[data-theme="light"] .ref-source-link {
  color: #0f172a;
}

[data-theme="light"] .ref-source-link:hover {
  color: var(--accent);
}

[data-theme="light"] .ref-link {
  border-color: var(--accent-subtle);
}

[data-theme="light"] .ref-link:hover {
  box-shadow: 0 3px 8px var(--accent-glow);
}

[data-theme="light"] .security-alert-box {
  background: rgba(245, 158, 11, 0.05);
}

[data-theme="light"] .security-alert-box.security-alert-zeroday {
  background: rgba(239, 68, 68, 0.05);
}

[data-theme="light"] .security-alert-box.security-alert-hardening {
  background: rgba(16, 185, 129, 0.05);
}

[data-theme="light"] .security-alert-box.security-alert-compliance {
  background: rgba(59, 130, 246, 0.05);
}

/* --------------------------------------------------------------------------
   19. Markdown & Universal Embeds Formatting
   -------------------------------------------------------------------------- */

/* Responsive Video & Embed Containers */
.responsive-video-wrapper,
.responsive-object-wrapper,
.video-embed-wrapper,
.responsive-embed,
.embed-responsive {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  overflow: hidden;
  margin: var(--space-6) 0;
  border-radius: var(--radius-lg, 12px);
  background: var(--bg-surface-elevated, #0f172a);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.responsive-video-wrapper iframe,
.responsive-object-wrapper iframe,
.video-embed-wrapper iframe,
.responsive-embed iframe,
.embed-responsive iframe,
.post-article-body iframe,
.rich-text iframe,
.markdown-rendered-block iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: inherit;
}

.native-video-wrapper,
.native-audio-wrapper {
  margin: var(--space-6) 0;
  width: 100%;
}

.native-video-wrapper video {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg, 12px);
  background: #000;
  display: block;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.native-audio-wrapper audio {
  width: 100%;
  border-radius: var(--radius-md, 8px);
}

/* GFM Task Lists / Todo Checkboxes */
.markdown-rendered-block ul.task-list {
  list-style: none !important;
  padding-left: 0.25rem !important;
  margin: var(--space-4) 0;
}

.markdown-rendered-block li.task-list-item {
  display: flex !important;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.markdown-rendered-block .task-list-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 1.15rem;
  height: 1.15rem;
  border: 1.5px solid var(--border-muted, #475569);
  border-radius: 4px;
  outline: none;
  cursor: default;
  margin-top: 0.2rem;
  flex-shrink: 0;
  background-color: var(--bg-surface, #1e293b);
  transition: border-color 0.2s, background-color 0.2s;
  vertical-align: middle;
  display: inline-block;
}

.markdown-rendered-block .task-list-checkbox:checked {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-size: 70% 70% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

/* Code Block Prism Token Overrides (Prevent HTML tags from inheriting UI badge styles) */
pre .token.tag,
code .token.tag {
  display: inline !important;
  align-items: initial !important;
  gap: 0 !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  background-color: transparent !important;
  font-size: inherit !important;
  letter-spacing: inherit !important;
  text-decoration: none !important;
  box-shadow: none !important;
}

/* Math & KaTeX Typography */
.math-display,
.katex-block {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-surface-elevated, rgba(15, 23, 42, 0.6));
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: var(--radius-lg, 12px);
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
  font-size: 1.15rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.math-inline,
.katex-inline {
  font-size: 1.05em;
  padding: 0 0.2em;
}

.katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-2) 0;
  margin: 0 !important;
}

/* Responsive Markdown Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: var(--space-6) 0;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
}

.table-responsive table,
.markdown-rendered-block table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.table-responsive th,
.markdown-rendered-block th {
  background: var(--bg-surface-elevated, rgba(15, 23, 42, 0.9));
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
}

.table-responsive td,
.markdown-rendered-block td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.06));
  color: var(--text-normal);
}

.table-responsive tr:hover td,
.markdown-rendered-block tr:hover td {
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.03));
}

/* Markdown Images */
.markdown-rendered-block img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg, 12px);
  margin: var(--space-6) auto;
  display: block;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* Markdown Strikethrough & Quotes */
.markdown-rendered-block del {
  color: var(--text-muted);
  text-decoration: line-through;
  opacity: 0.8;
}

.markdown-rendered-block blockquote {
  border-left: 3px solid var(--accent, #10b981);
  background: var(--bg-surface-elevated, rgba(15, 23, 42, 0.5));
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
  color: var(--text-normal);
}

/* Markdown Admonitions (!!! note, !!! warning) */
.markdown-rendered-block .admonition {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md, 8px);
  border-left: 4px solid var(--accent, #10b981);
  background: var(--bg-surface-elevated, rgba(15, 23, 42, 0.5));
}

.markdown-rendered-block .admonition-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.markdown-rendered-block .admonition.warning {
  border-left-color: #f59e0b;
}

.markdown-rendered-block .admonition.danger {
  border-left-color: #ef4444;
}

/* Light Theme Overrides for Markdown & Embeds */
[data-theme="light"] .responsive-video-wrapper,
[data-theme="light"] .responsive-object-wrapper,
[data-theme="light"] .video-embed-wrapper {
  background: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .math-display,
[data-theme="light"] .katex-block {
  background: #f8fafc;
  border-color: #e2e8f0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .table-responsive {
  border-color: #e2e8f0;
}

[data-theme="light"] .table-responsive th,
[data-theme="light"] .markdown-rendered-block th {
  background: #f1f5f9;
  border-bottom-color: #cbd5e1;
}

[data-theme="light"] .table-responsive td,
[data-theme="light"] .markdown-rendered-block td {
  border-bottom-color: #f1f5f9;
}

[data-theme="light"] .table-responsive tr:hover td,
[data-theme="light"] .markdown-rendered-block tr:hover td {
  background: #f8fafc;
}

[data-theme="light"] .markdown-rendered-block .task-list-checkbox:not(:checked) {
  background-color: #ffffff;
  border-color: #cbd5e1;
}

[data-theme="light"] .markdown-rendered-block .task-list-checkbox:checked {
  background-color: var(--accent) !important;
  border-color: var(--accent) !important;
}

.markdown-rendered-block mark {
  background: rgba(250, 204, 21, 0.25);
  color: inherit;
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

[data-theme="light"] .markdown-rendered-block mark {
  background: rgba(250, 204, 21, 0.45);
}

[data-theme="light"] .markdown-rendered-block blockquote {
  background: #f8fafc;
  border-left-color: var(--accent);
}

[data-theme="light"] .markdown-rendered-block .admonition {
  background: #f8fafc;
  border-left-color: var(--accent);
}

/* --------------------------------------------------
   20. Custom Form & Survey Builder System
   -------------------------------------------------- */

.form-builder-container {
  width: 100%;
  margin: 0 auto;
}

.form-layout-standard {
  max-width: 780px;
}

.form-layout-wide {
  max-width: 1040px;
}

.form-builder-header {
  margin-bottom: var(--space-8);
}

.form-builder-title {
  margin-top: var(--space-2);
  margin-bottom: var(--space-3);
  font-size: 2.2rem;
  letter-spacing: -0.02em;
}

.form-builder-intro {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.form-builder-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-10);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(12px);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-builder-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
}

.form-group-checkbox {
  gap: 0;
}

.form-fieldset {
  border: none;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.form-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.required-star {
  color: var(--accent, #10b981);
  font-weight: 700;
  margin-left: 2px;
}

.form-builder-form input[type="text"],
.form-builder-form input[type="email"],
.form-builder-form input[type="url"],
.form-builder-form input[type="number"],
.form-builder-form input[type="date"],
.form-builder-form input[type="datetime-local"],
.form-builder-form textarea,
.form-builder-form select {
  width: 100%;
  padding: 0.85rem 1.1rem;
  background-color: var(--bg-surface-elevated, #161e2e);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
  box-sizing: border-box;
}

.form-builder-form input:focus,
.form-builder-form textarea:focus,
.form-builder-form select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-subtle);
  background-color: var(--bg-surface);
}

.form-builder-form textarea {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.form-select-wrapper {
  position: relative;
  width: 100%;
}

.form-select-wrapper select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.75rem;
  cursor: pointer;
}

.form-select-wrapper::after {
  content: "";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.form-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: var(--space-3);
  width: 100%;
}

.form-option-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0.85rem 1rem;
  background-color: var(--bg-surface-elevated, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  font-size: 0.92rem;
  color: var(--text-primary);
}

.form-option-card:hover {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.form-option-card:has(input:checked) {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.form-option-card input[type="radio"],
.form-option-card input[type="checkbox"],
.form-single-checkbox-card input[type="checkbox"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.form-single-checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 0.85rem 1rem;
  background-color: var(--bg-surface-elevated, rgba(255, 255, 255, 0.02));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.form-single-checkbox-card:hover {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.form-single-checkbox-card:has(input:checked) {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.form-checkbox-text {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.4;
}

.form-help-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.form-error-text {
  font-size: 0.82rem;
  color: var(--color-error, #ef4444);
  font-weight: 500;
  margin-top: 2px;
}

.has-error input,
.has-error textarea,
.has-error select {
  border-color: var(--color-error, #ef4444) !important;
}

.form-alert {
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.form-alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-left: 4px solid #ef4444;
  color: var(--color-error, #ef4444);
}

.form-submit-row {
  display: flex;
  justify-content: flex-start;
  margin-top: var(--space-4);
}

.form-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.9rem 2.2rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.25);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.form-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.35);
}

.form-submit-btn:active {
  transform: translateY(0);
}

/* Landing / Submission Success View */
.form-landing-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-12) var(--space-10);
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.form-landing-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: 0 0 24px rgba(16, 185, 129, 0.2);
}

.form-builder-form input[type="date"]::-webkit-calendar-picker-indicator,
.form-builder-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(0.8) brightness(1.2);
  opacity: 0.85;
  transition: opacity var(--transition-fast), filter var(--transition-fast);
}

.form-builder-form input[type="date"]::-webkit-calendar-picker-indicator:hover,
.form-builder-form input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

[data-theme="light"] .form-builder-form input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="light"] .form-builder-form input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: none;
  opacity: 0.75;
}

.form-landing-card .tag {
  margin-bottom: var(--space-2);
}

.form-landing-title {
  font-size: 2.2rem;
  font-weight: 700;
  margin-top: 0;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

.form-landing-message {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.7;
  max-width: 580px;
  margin: 0 auto var(--space-8);
}

.form-landing-actions {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  flex-wrap: wrap;
}

/* Custom File & Document Upload Dropzone */
.form-file-dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  background-color: var(--bg-surface-elevated, #161e2e);
  border: 2px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), transform var(--transition-fast);
  overflow: hidden;
  user-select: none;
}

.form-file-dropzone:hover,
.form-file-dropzone.drag-active {
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.form-file-dropzone.has-file {
  border-style: solid;
  border-color: var(--accent);
  background-color: var(--accent-subtle);
}

.form-file-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 5;
}

.form-file-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform var(--transition-fast);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.form-file-dropzone:hover .form-file-icon {
  transform: translateY(-2px);
}

.form-file-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.form-file-prompt {
  font-size: 0.95rem;
  color: var(--text-primary);
}

.form-file-prompt strong {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.form-file-selected-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.form-file-selected-badge.has-file {
  color: var(--accent);
  background: rgba(16, 185, 129, 0.18);
  font-weight: 600;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

@media (max-width: 640px) {
  .form-builder-card {
    padding: var(--space-6) var(--space-4);
  }
  .form-landing-card {
    padding: var(--space-8) var(--space-4);
  }
  .form-options-grid {
    grid-template-columns: 1fr;
  }
  .form-submit-btn {
    width: 100%;
  }
  .form-landing-actions {
    flex-direction: column;
    width: 100%;
  }
  .form-landing-actions .btn {
    width: 100%;
  }
}

/* Light Theme Support */
[data-theme="light"] .form-builder-card,
[data-theme="light"] .form-landing-card {
  background-color: #ffffff;
  border-color: #e2e8f0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .form-builder-form input[type="text"],
[data-theme="light"] .form-builder-form input[type="email"],
[data-theme="light"] .form-builder-form input[type="url"],
[data-theme="light"] .form-builder-form input[type="number"],
[data-theme="light"] .form-builder-form input[type="date"],
[data-theme="light"] .form-builder-form input[type="datetime-local"],
[data-theme="light"] .form-builder-form textarea,
[data-theme="light"] .form-builder-form select {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

[data-theme="light"] .form-builder-form input:focus,
[data-theme="light"] .form-builder-form textarea:focus,
[data-theme="light"] .form-builder-form select:focus {
  background-color: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

[data-theme="light"] .form-option-card:hover,
[data-theme="light"] .form-single-checkbox-card:hover,
[data-theme="light"] .form-option-card:has(input:checked),
[data-theme="light"] .form-single-checkbox-card:has(input:checked) {
  background-color: var(--accent-subtle);
  border-color: var(--accent);
}

[data-theme="light"] .form-file-dropzone:hover,
[data-theme="light"] .form-file-dropzone.has-file {
  background-color: var(--accent-subtle);
  border-color: var(--accent);
}

[data-theme="light"] .form-file-selected-badge {
  background-color: #e2e8f0;
  color: #64748b;
}

[data-theme="light"] .form-file-selected-badge.has-file {
  background-color: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

/* ==============================================================================
   Universal Strict Media Containment & Zero-Overflow Engine
   Guarantees that any image, video, iframe, embed, or canvas never exceeds
   its parent boundary horizontally or vertically regardless of raw intrinsic size.
   ============================================================================== */
img,
picture,
video,
canvas,
svg {
  max-width: 100%;
  box-sizing: border-box;
}

/* Containers boundary enforcement */
.card,
.card-interactive,
.blog-post-card,
.project-card,
.product-card,
.article-image-figure,
.gallery-item,
.carousel-slide,
.carousel-figure,
.ba-container,
.ba-image-wrapper,
.card-body,
.related-content-section,
.related-content-grid {
  max-width: 100%;
  box-sizing: border-box;
}

/* RichText & Content Body Media Strict Constraints (Centered Display) */
.rich-text img,
.post-content img,
.case-study-body img,
.markdown-rendered-block img,
.prose img,
.article-body img,
.richtext-image,
.responsive-object img,
.stream-image-wrapper img,
.richtext-image-wrapper img {
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 100% !important;
  max-height: 480px !important;
  width: auto !important;
  height: auto !important;
  object-fit: cover !important;
  border-radius: var(--radius-md);
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .rich-text img,
  .post-content img,
  .case-study-body img,
  .markdown-rendered-block img,
  .prose img,
  .article-body img,
  .richtext-image,
  .responsive-object img,
  .stream-image-wrapper img,
  .richtext-image-wrapper img {
    max-height: 340px !important;
  }
}

.stream-image-wrapper,
.richtext-image-wrapper {
  position: relative;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  vertical-align: middle;
}

.rich-text figure,
.post-content figure,
.case-study-body figure,
.prose figure,
.article-body figure,
.stream-image-figure {
  display: block;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

.rich-text figure img,
.post-content figure img,
.case-study-body figure img,
.stream-image-figure img {
  display: block !important;
  margin: 0 auto !important;
}

.rich-text figcaption,
.post-content figcaption,
.case-study-body figcaption,
.stream-image-figure figcaption {
  text-align: center;
  margin-top: var(--space-2);
}

/* Focal Point Marker Visual Rectangle (Matches Wagtail Admin Selected Area) */
.focal-point-marker.focal-point-rect {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 4px;
  border: 2px dashed rgba(255, 255, 255, 0.95);
  background: rgba(56, 189, 248, 0.18);
  box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.7), inset 0 0 10px rgba(0, 0, 0, 0.3);
  z-index: 4;
  display: block;
  box-sizing: border-box;
  animation: focal-rect-pulse 2.4s ease-in-out infinite;
}

/* Corner Handles on the Rectangle */
.focal-rect-corner {
  position: absolute;
  width: 7px;
  height: 7px;
  border-color: #ffffff;
  border-style: solid;
  z-index: 2;
}

.focal-rect-corner.tl {
  top: -2px;
  left: -2px;
  border-width: 2px 0 0 2px;
}

.focal-rect-corner.tr {
  top: -2px;
  right: -2px;
  border-width: 2px 2px 0 0;
}

.focal-rect-corner.bl {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 2px 2px;
}

.focal-rect-corner.br {
  bottom: -2px;
  right: -2px;
  border-width: 0 2px 2px 0;
}

/* Center crosshair / target point */
.focal-rect-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 0 0 1.5px #0284c7, 0 0 6px rgba(56, 189, 248, 0.8);
  z-index: 3;
}

@keyframes focal-rect-pulse {
  0%, 100% {
    border-color: rgba(255, 255, 255, 0.95);
    background-color: rgba(56, 189, 248, 0.18);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.7), inset 0 0 10px rgba(0, 0, 0, 0.3);
  }
  50% {
    border-color: rgba(56, 189, 248, 1);
    background-color: rgba(56, 189, 248, 0.28);
    box-shadow: 0 0 0 1.5px rgba(0, 0, 0, 0.8), 0 0 12px rgba(56, 189, 248, 0.6), inset 0 0 12px rgba(56, 189, 248, 0.35);
  }
}

/* Full-Screen Trigger Button (Bottom-Right) */
.btn-image-fullscreen {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm, 6px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  transition: background 0.2s, transform 0.15s, border-color 0.2s, color 0.2s, opacity 0.2s;
  opacity: 0.88;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.btn-image-fullscreen:hover {
  background: rgba(15, 23, 42, 0.96);
  opacity: 1;
  transform: scale(1.08);
  border-color: var(--accent, #38bdf8);
  color: var(--accent, #38bdf8);
}

/* Global Fullscreen Lightbox Modal */
#global-image-lightbox-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(10, 15, 29, 0.96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-4);
  user-select: none;
  box-sizing: border-box;
}

#global-image-lightbox-modal.active {
  display: flex;
}

/* Ensure no wide table, preformatted code, or iframe blows out */
.rich-text table,
.post-content table,
.case-study-body table,
.rich-text pre,
.post-content pre {
  max-width: 100%;
  box-sizing: border-box;
}

/* ==============================================================================
   Product Catalog Card & Dynamic Bento Showcase Layout
   ============================================================================== */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-muted);
  box-shadow: var(--shadow-md);
}

.product-card-thumb {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-surface-elevated);
  overflow: hidden;
  border-bottom: 1px solid var(--border-subtle);
  width: 100%;
}

.product-card-thumb a {
  display: block;
  width: 100%;
  height: 100%;
}

.product-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-card-thumb img {
  transform: scale(1.03);
}

.product-card-body {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
}

.product-card-title {
  font-size: 1.22rem;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 0;
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}

.product-card-title a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.product-card-title a:hover {
  color: var(--accent);
}

.product-card-description {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-top: 0;
  margin-bottom: var(--space-4);
  flex: 1;
}

/* Strictly enforce single-line "View Details →" button on all screen sizes & multi-column grids */
.product-card .btn,
.product-card .btn-primary,
.product-card-btn {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 6px !important;
  text-decoration: none !important;
  letter-spacing: -0.01em;
}

/* Product Cards: Clean, Uniform Vertical Cards Across All Grids & Breakpoints */
.product-card,
.shop-grid .product-card,
.products-grid .product-card,
.home-products-grid .product-card {
  display: flex !important;
  flex-direction: column !important;
  grid-template-columns: none !important;
  overflow: hidden !important;
}

.product-card .product-card-thumb,
.product-card .card-thumb-wrapper {
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 16 / 9 !important;
  max-height: none !important;
  min-height: 0 !important;
  display: block !important;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
  border-right: none !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  position: relative !important;
  overflow: hidden !important;
}

.product-card .product-card-thumb a,
.product-card .product-card-thumb img,
.product-card .card-thumb-wrapper img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
}

.product-card .card-body,
.product-card .product-card-body {
  padding: var(--space-5) !important;
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}


/* ==============================================================================
   Universal Content & Media Centering System
   Strictly centers images, tables, video embeds, snippet blocks, and rich media
   across all screen widths and mobile devices.
   ============================================================================== */

/* 1. Article & Page Layout Centering */
.blog-post,
.project-detail,
.standard-page-content,
.folder-page-content {
  margin-left: auto !important;
  margin-right: auto !important;
}

.blog-post .post-header {
  text-align: center;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.blog-post .post-header .post-meta {
  justify-content: center;
}

.blog-post .post-header .tag-list,
.blog-post .post-header > div:last-child {
  justify-content: center;
}

.blog-post .post-cover,
.project-detail .project-cover {
  display: block;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center;
  max-width: 100%;
}

.blog-post .post-cover img,
.project-detail .project-cover img {
  display: block !important;
  width: 100% !important;
  height: auto;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Universal Full-Width Content Container across all pages:
   Blog, Project, Resources/Tools, Static, Folder, Shop, and Contact */
.post-content,
.blog-post .post-content,
.blog-post-content,
.blog-index-stream,
.project-index-stream,
.home-stream-content,
.project-case-study,
.project-case-study .post-content,
.project-case-study-content,
.project-detail .project-case-study .post-content,
.folder-stream-body,
.contact-stream,
.form-builder-stream,
.shop-index-stream,
#resources-container,
.resources-container {
  max-width: 100% !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  box-sizing: border-box;
}

/* ==============================================================================
   Universal Content List Normalization & Callout Styling
   Ensures consistent bullets, numbers, indentation, and left margins matching
   Key Takeaways and Pro Tips across all cards, snippets, and StreamField blocks.
   ============================================================================== */
.callout ul,
.callout-content ul,
.key-takeaways-card ul,
.pros-cons-card ul,
.post-content ul,
.rich-text ul,
.case-study-body ul,
.security-alert-message ul,
.security-advisory-card ul,
.store-notice-block ul,
.step-content-col ul,
.accordion-group ul,
.faq-answer-inner ul,
.myth-fact-block ul,
article ul:not([class]) {
  list-style-type: disc !important;
  margin: var(--space-2) 0 var(--space-3) 0 !important;
  padding-left: var(--space-4) !important;
}

.callout ol,
.callout-content ol,
.post-content ol,
.rich-text ol,
.case-study-body ol,
.security-alert-message ol,
.security-advisory-card ol,
.store-notice-block ol,
.step-content-col ol,
.accordion-group ol,
.faq-answer-inner ol,
.myth-fact-block ol,
article ol:not([class]) {
  list-style-type: decimal !important;
  margin: var(--space-2) 0 var(--space-3) 0 !important;
  padding-left: var(--space-4) !important;
}

.callout li,
.callout-content li,
.key-takeaways-card li,
.pros-cons-card li,
.post-content li,
.rich-text li,
.case-study-body li,
.security-alert-message li,
.security-advisory-card li,
.store-notice-block li,
.step-content-col li,
.accordion-group li,
.faq-answer-inner li,
.myth-fact-block li,
article li:not([class]) {
  margin-bottom: var(--space-2) !important;
  line-height: 1.65 !important;
}

.callout li:last-child,
.callout-content li:last-child,
.key-takeaways-card li:last-child,
.pros-cons-card li:last-child,
.post-content li:last-child,
.rich-text li:last-child,
.case-study-body li:last-child,
.security-alert-message li:last-child,
.security-advisory-card li:last-child,
.store-notice-block li:last-child,
.step-content-col li:last-child,
.accordion-group li:last-child,
.faq-answer-inner li:last-child,
.myth-fact-block li:last-child,
article li:not([class]):last-child {
  margin-bottom: 0 !important;
}

.callout p,
.callout-content p {
  margin-bottom: var(--space-2);
}

.callout p:last-child,
.callout-content p:last-child {
  margin-bottom: 0;
}

/* 2. Images, Figures & Captions Centering */
.post-content img,
.rich-text img,
.stream-image-figure,
.stream-image-wrapper,
.richtext-image,
.richtext-image-wrapper {
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center;
}

.post-content figure,
.rich-text figure,
.stream-image-figure {
  display: block !important;
  margin-left: auto !important;
  margin-right: auto !important;
  text-align: center;
}

.post-content figcaption,
.rich-text figcaption,
.stream-image-figure figcaption {
  text-align: center !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* 3. Tables Centering & Mobile Overflow Protection */
.data-table-wrapper,
.post-content table,
.rich-text table,
.comparison-table-block {
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 100%;
}

.data-table-wrapper {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table-wrapper table {
  margin-left: auto;
  margin-right: auto;
}

/* 4. Video & Rich Media Embeds Centering */
.video-embed-block,
.responsive-embed,
.video-viewport,
.post-content iframe,
.rich-text iframe,
.post-content video,
.rich-text video {
  margin-left: auto !important;
  margin-right: auto !important;
  display: block;
  max-width: 100%;
}

.video-embed-block .video-title,
.video-embed-block .video-caption {
  text-align: center;
}

/* 5. Snippet Blocks, Callouts & Interactive StreamField Components */
.reusable-content-block,
.cta-block,
.callout,
.callout-block,
.stat-callout-block,
.key-takeaways-card,
.security-advisory-card,
.store-notice-block,
.terminal-block,
.mermaid-block,
.timeline-block,
.faq-section-block,
.before-after-block,
.pros-cons-card,
.product-embed-card,
.download-card-block,
.step-by-step-container,
.author-embed-card,
.audio-player-block,
.tools-standalone-wrapper,
.api-endpoint-card,
.pull-quote-block,
.quote-block,
blockquote {
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 100%;
  box-sizing: border-box;
}







