/* ============================================================
   Calera Computing, Inc. — The Lattice Letters
   Dedicated Blog Stylesheet · Layered on top of styles.css
   ============================================================ */

/* --- Reading Progress Bar --- */
.blog-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: var(--blog-progress-color);
  z-index: 10000;
  transition: width var(--duration-fast) var(--ease-out);
}

/* --- Table of Contents (TOC) --- */
/* Desktop sticky/fixed sidebar */
.blog-toc {
  position: fixed;
  left: calc(50% - 500px - 240px - 48px);
  top: 120px;
  width: 240px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  padding-right: var(--space-3);
  scrollbar-width: thin;
  scrollbar-color: var(--stone-300) transparent;
  z-index: 90;
}

.blog-toc::-webkit-scrollbar {
  width: 4px;
}

.blog-toc::-webkit-scrollbar-thumb {
  background: var(--stone-300);
  border-radius: var(--radius-full);
}

.blog-toc__title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.blog-toc ul,
.blog-toc-mobile ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.blog-toc li,
.blog-toc-mobile li {
  margin-bottom: var(--space-2);
}

.blog-toc li.toc-h3,
.blog-toc-mobile li.toc-h3 {
  padding-left: var(--space-4);
}

.blog-toc a,
.blog-toc-mobile a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: var(--text-sm);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              padding var(--duration-fast) var(--ease-out);
  line-height: 1.4;
  display: block;
}

.blog-toc a:hover,
.blog-toc-mobile a:hover {
  color: var(--text-primary);
}

.blog-toc a.active,
.blog-toc-mobile a.active {
  color: var(--blog-toc-active);
  font-weight: 600;
  border-left: 2px solid var(--blog-toc-active);
  padding-left: var(--space-2);
  margin-left: calc(-1 * var(--space-2));
}

/* Mobile collapsible drawer */
.blog-toc-mobile {
  display: block;
  margin: var(--space-6) 0;
  padding: var(--space-4);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.blog-toc-mobile summary {
  cursor: pointer;
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  outline: none;
}

.blog-toc-mobile summary::-webkit-details-marker {
  display: none;
}

.blog-toc-mobile summary::after {
  content: "+";
  font-size: var(--text-lg);
  font-weight: 400;
  color: var(--text-secondary);
  transition: transform var(--duration-fast) var(--ease-out);
}

.blog-toc-mobile[open] summary::after {
  transform: rotate(45deg);
}

.blog-toc-mobile__content {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-color);
}

/* Toggle TOC visibility based on viewport */
@media (max-width: 1200px) {
  .blog-toc {
    display: none;
  }
}

@media (min-width: 1201px) {
  .blog-toc-mobile {
    display: none;
  }
}

/* --- Interactive Demo Containers --- */
.demo-container {
  margin: var(--space-8) 0;
  background: var(--blog-demo-bg);
  border: 1px solid var(--blog-demo-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  /* Phase 2: Elevated floating card treatment */
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.08),
              0 2px 8px -2px rgba(0, 0, 0, 0.04);
  transition: border-color var(--duration-normal) var(--ease-out),
              box-shadow var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
  /* Editorial breakout: wider than text column */
  margin-left: -24px;
  margin-right: -24px;
}

html[data-theme="dark"] .demo-container {
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.35),
              0 2px 8px -2px rgba(0, 0, 0, 0.2);
}

.demo-container:hover {
  border-color: var(--accent-500);
  transform: translateY(-3px);
  box-shadow: 0 20px 50px -8px rgba(59, 130, 246, 0.15),
              0 8px 24px -4px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .demo-container:hover {
  box-shadow: 0 20px 50px -8px rgba(59, 130, 246, 0.25),
              0 8px 24px -4px rgba(0, 0, 0, 0.3);
}

/* Phase 1: Demo scroll-reveal entrance — lift off the page */
.demo-reveal {
  opacity: 0;
  transform: translateY(40px) scale(0.97);
  transition: opacity 0.9s var(--ease-out),
              transform 0.9s var(--ease-out),
              box-shadow 0.9s var(--ease-out);
}

.demo-reveal--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* On mobile, collapse breakout margins */
@media (max-width: 768px) {
  .demo-container {
    margin-left: -8px;
    margin-right: -8px;
  }
}

.demo-container__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--blog-demo-border);
  background: rgba(0, 0, 0, 0.015);
}

html[data-theme="dark"] .demo-container__header {
  background: rgba(255, 255, 255, 0.015);
}

.demo-container__label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.demo-container__label-icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--accent-500);
  stroke-width: 2;
}

.demo-container__controls {
  display: flex;
  align-items: center;
  gap: var(--space-3) var(--space-4); /* row-gap column-gap */
  flex-wrap: wrap;
}

.demo-container__body {
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 250px;
}

.demo-container__canvas {
  max-width: 100%;
  height: auto;
  display: block;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.demo-container__caption {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  border-top: 1px solid var(--blog-demo-border);
  background: rgba(0, 0, 0, 0.01);
  text-align: center;
}

/* --- Power Algebra Machine --- */
.reduction-step {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin: var(--space-1) 0;
}
.step-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--text-muted);
  width: 60px;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.math-container {
  min-width: 140px;
  text-align: left;
}
.vector-val-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  gap: var(--space-1);
  color: var(--text-primary);
  margin-top: var(--space-2);
  margin-bottom: var(--space-6);
}
.vector-coeff-bracket {
  color: var(--accent-500);
  font-size: var(--text-3xl);
  font-weight: 300;
}
.vector-coeff-val {
  position: relative;
  padding: 0 var(--space-2);
  min-width: 32px;
  text-align: center;
}
.vector-coeff-val::after {
  content: attr(data-label);
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 500;
}
.vector-coeff-comma {
  color: var(--text-muted);
}
.vector-algebraic-caption {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* --- Demo Controls --- */
.demo-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 160px;
  height: 6px;
  padding: 8px 0;
  background: var(--border-color);
  background-clip: content-box;
  outline: none;
  transition: background var(--duration-fast);
  cursor: pointer;
}

.demo-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent-500);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-spring),
              background var(--duration-fast);
}

.demo-slider::-webkit-slider-thumb:hover {
  background: var(--accent-600);
  transform: scale(1.15);
}

.demo-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--accent-500);
  cursor: pointer;
  border: 2px solid var(--bg-primary);
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-spring),
              background var(--duration-fast);
}

.demo-slider::-moz-range-thumb:hover {
  background: var(--accent-600);
  transform: scale(1.15);
}

.demo-btn {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--text-xs);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-out);
}

.demo-btn:hover {
  border-color: var(--accent-500);
  background: var(--bg-card-hover);
  color: var(--accent-600);
}

.demo-btn--active {
  background: var(--accent-500);
  border-color: var(--accent-500);
  color: white;
}

.demo-btn--active:hover {
  background: var(--accent-600);
  border-color: var(--accent-600);
  color: white;
}

.demo-readout {
  font-family: 'Space Mono', 'Courier New', Courier, monospace;
  font-size: var(--text-xs);
  color: var(--text-primary);
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-variant-numeric: tabular-nums;
}

/* --- Theorem & Proof Blocks --- */
/* Phase 8: Elevated "page fold" with corner label */
.blog-theorem {
  margin: var(--space-6) 0;
  padding: var(--space-5) var(--space-6);
  padding-top: var(--space-6);
  background: var(--blog-theorem-bg);
  border-left: 4px solid var(--blog-theorem-border);
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  position: relative;
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.08);
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.blog-theorem:hover {
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.12);
}

html[data-theme="dark"] .blog-theorem {
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.3);
}

html[data-theme="dark"] .blog-theorem:hover {
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
}

.blog-theorem::before {
  content: "Theorem";
  position: absolute;
  top: var(--space-3);
  right: var(--space-4);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blog-theorem-border);
  opacity: 0.45;
}

.blog-theorem p:last-child {
  margin-bottom: 0;
}

.blog-proof {
  margin: var(--space-6) 0;
  padding: var(--space-5) var(--space-6);
  padding-top: var(--space-6);
  background: var(--blog-proof-bg);
  border-left: 4px solid var(--border-color);
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  position: relative;
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.06);
  transition: box-shadow var(--duration-normal) var(--ease-out);
}

.blog-proof:hover {
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.1);
}

html[data-theme="dark"] .blog-proof {
  box-shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.25);
}

.blog-proof::before {
  content: "Proof";
  position: absolute;
  top: var(--space-3);
  right: var(--space-4);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  opacity: 0.45;
}

.blog-proof p:last-child {
  margin-bottom: 0;
  padding-right: var(--space-5);
}

.blog-proof::after {
  content: "■";
  position: absolute;
  bottom: var(--space-5);
  right: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1;
}

/* --- Pull Quotes --- */
/* Phase 4: Pull quote "pop" with gradient glow */
.blog-pullquote {
  margin: var(--space-10) 0;
  padding: var(--space-6) 0;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
  background: rgba(255, 255, 255, 0.005);
  position: relative;
}

/* Radial glow backdrop */
.blog-pullquote::before {
  content: "";
  position: absolute;
  inset: -20px -40px;
  background: radial-gradient(ellipse at center,
    rgba(59, 130, 246, 0.05) 0%,
    transparent 70%);
  pointer-events: none;
  z-index: 0;
}

html[data-theme="dark"] .blog-pullquote::before {
  background: radial-gradient(ellipse at center,
    rgba(59, 130, 246, 0.08) 0%,
    transparent 70%);
}

@media (min-width: 769px) {
  .blog-pullquote {
    margin-left: calc(50% - 44vw);
    margin-right: calc(50% - 44vw);
    width: 88vw;
    padding: var(--space-8) var(--space-12);
    border-top: 2px solid var(--border-subtle);
    border-bottom: 2px solid var(--border-subtle);
  }
}

.blog-pullquote__text,
.vln-doc .blog-pullquote__text {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  line-height: 1.4;
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  /* Gradient text: primary → accent */
  background: linear-gradient(135deg, var(--text-primary) 30%, var(--accent-500) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Key Insight Callouts --- */
.blog-callout {
  margin: var(--space-6) 0;
  padding: var(--space-4) var(--space-5);
  background: var(--blog-callout-bg);
  border-left: 3px solid var(--blog-callout-border);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

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

/* --- Historical Callout Boxes --- */
/* Phase 7: Museum placard card with elevation + tilt hover */
.blog-historical {
  margin: var(--space-8) 0;
  padding: var(--space-6);
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-500);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.1);
  transition: transform 0.4s var(--ease-out),
              box-shadow 0.4s var(--ease-out);
}

.blog-historical:hover {
  transform: translateY(-4px) rotate(-0.3deg);
  box-shadow: 0 16px 48px -8px rgba(0, 0, 0, 0.15);
}

html[data-theme="dark"] .blog-historical {
  box-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .blog-historical:hover {
  box-shadow: 0 16px 48px -8px rgba(0, 0, 0, 0.45);
}

.blog-historical__label {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.blog-historical__quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: var(--space-3);
}

.blog-historical__attribution {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 500;
  text-align: right;
}

/* --- Series Navigation --- */
.blog-series-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: var(--space-4);
  margin: var(--space-12) 0;
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-color);
}

.blog-series-nav__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-4) var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all var(--duration-fast) var(--ease-out);
}

.blog-series-nav__link:hover {
  border-color: var(--accent-500);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.blog-series-nav__link--prev {
  align-items: flex-start;
  text-align: left;
}

.blog-series-nav__link--next {
  align-items: flex-end;
  text-align: right;
}

.blog-series-nav__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.blog-series-nav__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.3;
}

/* --- Series Timeline --- */
.blog-series-timeline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin: var(--space-10) auto var(--space-16);
  max-width: 900px;
  position: relative;
  padding: 0 var(--space-4);
}

.blog-series-timeline::before {
  content: "";
  position: absolute;
  top: 24px;
  left: var(--space-8);
  right: var(--space-8);
  height: 2px;
  background: var(--blog-series-line);
  z-index: 1;
}

.blog-series-timeline__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  position: relative;
  z-index: 2;
  text-align: center;
}

.blog-series-timeline__dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--bg-primary);
  border: 3px solid var(--blog-series-line);
  margin-bottom: var(--space-3);
  transition: all var(--duration-fast) var(--ease-out);
  box-shadow: 0 0 0 4px var(--bg-primary);
}

.blog-series-timeline__item:hover .blog-series-timeline__dot {
  border-color: var(--accent-500);
  background: var(--accent-500);
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4), 0 0 0 4px var(--bg-primary);
}

.blog-series-timeline__item.active .blog-series-timeline__dot {
  border-color: var(--accent-500);
  background: var(--bg-primary);
  box-shadow: 0 0 0 4px var(--bg-primary);
}

.blog-series-timeline__edition {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
  transition: color var(--duration-fast);
}

.blog-series-timeline__item:hover .blog-series-timeline__edition {
  color: var(--accent-500);
}

.blog-series-timeline__title {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  max-width: 140px;
  line-height: 1.4;
  transition: color var(--duration-fast);
}

.blog-series-timeline__item:hover .blog-series-timeline__title {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .blog-series-timeline {
    flex-direction: column;
    gap: var(--space-6);
    padding-left: var(--space-6);
    margin-bottom: var(--space-10);
  }
  .blog-series-timeline::before {
    top: var(--space-2);
    bottom: var(--space-10);
    left: 21px;
    width: 2px;
    height: auto;
  }
  .blog-series-timeline__item {
    flex-direction: row;
    align-items: center;
    text-align: left;
    gap: var(--space-4);
    width: 100%;
  }
  .blog-series-timeline__dot {
    margin-bottom: 0;
    box-shadow: 0 0 0 6px var(--bg-primary);
  }
  .blog-series-timeline__title {
    font-size: 11px;
    max-width: none;
  }
  .demo-container__header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }
  .demo-container__controls {
    width: 100%;
    justify-content: flex-start;
  }
}

/* --- Enhanced Table Hover --- */
.vln-doc table tr {
  transition: background-color var(--duration-fast) var(--ease-out);
}

.vln-doc table tr:hover,
.vln-doc table tr.table-row--highlighted {
  background-color: var(--table-row-hover);
}

/* --- Author Card --- */
.blog-author-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin: var(--space-8) 0;
}

.blog-author-card__avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--accent-500);
}

.blog-author-card__info {
  display: flex;
  flex-direction: column;
}

.blog-author-card__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-primary);
}

.blog-author-card__title {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.blog-author-card__links {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.blog-author-card__link {
  font-size: var(--text-xs);
  color: var(--accent-500);
  text-decoration: none;
  transition: color var(--duration-fast);
}

.blog-author-card__link:hover {
  color: var(--accent-600);
  text-decoration: underline;
}

/* --- SVG Diagram Containers --- */
.svg-diagram {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
  margin: var(--space-6) auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.svg-accent {
  stroke: var(--accent-500);
  fill: none;
}

.svg-muted {
  stroke: var(--text-muted);
  fill: none;
}

.svg-label {
  fill: var(--text-primary);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 500;
}

.svg-grid {
  stroke: var(--border-color);
  stroke-dasharray: 2 2;
}

/* --- Blog Card Enhancements ---
   (Note: Base card layout, opaque hover backgrounds, text transitions,
   tag badges, and gradient borders have been moved to styles.css to be shared
   with homepage featured writings) */

/* --- Print Styles --- */
@media print {
  nav,
  footer,
  .demo-container__header,
  .demo-container__controls,
  .blog-progress,
  .blog-toc,
  .blog-toc-mobile,
  .blog-series-nav,
  .blog-subscribe,
  .blog-card::before {
    display: none !important;
  }

  body {
    background: white !important;
    color: black !important;
  }

  .vln-doc {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  a[href^="http"]::after,
  a[href^="/"]::after {
    content: " (" attr(href) ")";
    font-size: 80%;
    color: var(--stone-500);
  }

  figure,
  img,
  canvas,
  .blog-theorem,
  .blog-proof,
  .demo-container {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* --- Blog Hero Section --- */
.blog-hero {
  position: relative;
  padding: var(--space-12) var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-8);
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.blog-hero__pattern {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  color: var(--text-primary);
  opacity: 0.06;
  pointer-events: none;
  z-index: 1;
}

html[data-theme="dark"] .blog-hero__pattern {
  opacity: 0.10;
}

.blog-hero__content {
  position: relative;
  z-index: 2;
  max-width: 680px;
  margin: 0 auto;
}

.blog-hero__content h1 {
  font-family: var(--font-display);
  font-size: var(--text-4xl);
  font-weight: 700;
  margin: var(--space-2) 0 var(--space-4) 0;
  line-height: 1.2;
  color: var(--text-primary);
}

.blog-hero__content p {
  color: var(--text-secondary);
  font-size: var(--text-lg);
  line-height: 1.6;
  margin: 0;
}

/* --- Blog Subscribe CTA --- */
.blog-subscribe {
  text-align: center;
  margin-top: var(--space-12);
  padding: var(--space-6);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.blog-subscribe p {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.blog-subscribe a {
  color: var(--accent-500);
  text-decoration: none;
  font-weight: 600;
  transition: color var(--duration-fast);
}

.blog-subscribe a:hover {
  color: var(--accent-600);
  text-decoration: underline;
}



/* --- Phase 6: Animated Heading Underline Accents --- */
.vln-doc h2 {
  position: relative;
  padding-bottom: var(--space-3);
}

.vln-doc h2::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-400, var(--accent-500)));
  border-radius: 2px;
  transition: width 0.8s var(--ease-out);
}

.vln-doc h2.heading--visible::after {
  width: 60px;
}

/* --- Phase 3: Staggered Section Entrance Animations --- */
.section-reveal > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}

.section-reveal--visible > * {
  opacity: 1;
  transform: translateY(0);
}

.section-reveal--visible > *:nth-child(1) { transition-delay: 0s; }
.section-reveal--visible > *:nth-child(2) { transition-delay: 0.07s; }
.section-reveal--visible > *:nth-child(3) { transition-delay: 0.14s; }
.section-reveal--visible > *:nth-child(4) { transition-delay: 0.21s; }
.section-reveal--visible > *:nth-child(5) { transition-delay: 0.28s; }
.section-reveal--visible > *:nth-child(6) { transition-delay: 0.35s; }
.section-reveal--visible > *:nth-child(7) { transition-delay: 0.42s; }
.section-reveal--visible > *:nth-child(8) { transition-delay: 0.49s; }
.section-reveal--visible > *:nth-child(n+9) { transition-delay: 0.55s; }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-delay: -1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    background-attachment: initial !important;
    scroll-behavior: auto !important;
    transition-duration: 0s !important;
    transition-delay: 0s !important;
  }

  .blog-series-nav__link:hover,
  .demo-container:hover,
  .blog-historical:hover {
    transform: none !important;
  }

  .demo-reveal,
  .section-reveal > * {
    opacity: 1 !important;
    transform: none !important;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Family Grid & Cards --- */
.family-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
  margin: var(--space-6) 0;
}

@media (min-width: 768px) {
  .family-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.family-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.family-card:hover {
  border-color: var(--accent-500);
  box-shadow: var(--shadow-md);
}

.family-card--full {
  grid-column: 1 / -1;
}

.family-card__header {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
}

/* --- Historical Timeline of Aperiodic Order & Quasicrystals --- */
.hist-timeline {
  position: relative;
  width: 100%;
  padding: var(--space-8) var(--space-4);
  box-sizing: border-box;
}

/* Timeline Axis Line */
.hist-timeline__line {
  position: absolute;
  background: var(--border-subtle);
  z-index: 1;
  transition: all var(--duration-normal, 0.3s) var(--ease-out, ease);
}

.hist-timeline__items {
  display: flex;
  position: relative;
  z-index: 2;
  width: 100%;
  box-sizing: border-box;
}

.hist-timeline__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  cursor: pointer;
  transition: transform var(--duration-fast, 0.15s) var(--ease-out, ease);
}

/* Timeline Dot */
.hist-timeline__dot {
  width: 14px;
  height: 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 3px solid var(--accent-500, #3b82f6);
  z-index: 3;
  transition: all var(--duration-normal, 0.3s) cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 0 4px var(--bg-card);
}

.hist-timeline__item--highlight .hist-timeline__dot {
  border-color: #f97316;
}

/* Hover effects */
.hist-timeline__item:hover .hist-timeline__dot {
  transform: scale(1.3);
  background: var(--accent-500, #3b82f6);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5), 0 0 0 4px var(--bg-card);
}

.hist-timeline__item--highlight:hover .hist-timeline__dot {
  background: #f97316;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.5), 0 0 0 4px var(--bg-card);
}

.hist-timeline__card {
  background: var(--bg-primary, #ffffff);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md, 8px);
  padding: var(--space-3) var(--space-2);
  width: 90%;
  max-width: 130px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-normal, 0.3s) var(--ease-out, ease);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hist-timeline__item:hover .hist-timeline__card {
  border-color: var(--accent-500, #3b82f6);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.hist-timeline__item--highlight:hover .hist-timeline__card {
  border-color: #f97316;
  box-shadow: 0 6px 16px rgba(249, 115, 22, 0.12);
}

.hist-timeline__icon {
  font-size: var(--text-lg, 18px);
  display: block;
  margin-bottom: var(--space-1);
}

.hist-timeline__card-text {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hist-timeline__year {
  font-family: var(--font-display), sans-serif;
  font-size: var(--text-sm, 14px);
  font-weight: 700;
  color: var(--text-primary);
  display: block;
  margin-bottom: 2px;
}

.hist-timeline__label {
  font-family: var(--font-body), sans-serif;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.hist-timeline__desc {
  font-family: var(--font-body), sans-serif;
  font-size: 10px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.2;
}

/* Horizontal positioning for desktop */
@media (min-width: 769px) {
  .hist-timeline {
    padding: var(--space-10) var(--space-2);
  }
  .hist-timeline__line {
    top: 50%;
    left: 60px;
    right: 60px;
    height: 3px;
    transform: translateY(-50%);
  }
  .hist-timeline__items {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  /* Alternate layouts to give breathing room */
  .hist-timeline__item:nth-child(odd) {
    flex-direction: column-reverse;
  }
  .hist-timeline__item:nth-child(even) {
    flex-direction: column;
  }
  
  .hist-timeline__item:nth-child(odd) .hist-timeline__card {
    margin-bottom: var(--space-4);
  }
  .hist-timeline__item:nth-child(even) .hist-timeline__card {
    margin-top: var(--space-4);
  }
}

/* Vertical positioning for mobile */
@media (max-width: 768px) {
  .hist-timeline {
    padding: var(--space-4) var(--space-3);
  }
  .hist-timeline__line {
    left: 28px;
    top: 20px;
    bottom: 20px;
    width: 3px;
  }
  .hist-timeline__items {
    flex-direction: column;
    gap: var(--space-4);
  }
  .hist-timeline__item {
    flex-direction: row;
    align-items: center;
    width: 100%;
    padding-left: 45px;
    box-sizing: border-box;
  }
  .hist-timeline__dot {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
  }
  .hist-timeline__item:hover .hist-timeline__dot {
    transform: translateY(-50%) scale(1.3);
  }
  .hist-timeline__card {
    max-width: none;
    width: 100%;
    text-align: left;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-4);
  }
  .hist-timeline__card-text {
    align-items: flex-start;
  }
  .hist-timeline__icon {
    margin-bottom: 0;
    font-size: 22px;
  }
  .hist-timeline__year {
    display: inline-block;
    margin-right: var(--space-2);
    margin-bottom: 0;
  }
  .hist-timeline__label {
    display: inline-block;
  }
  .hist-timeline__desc {
    margin-top: var(--space-1);
  }
}


