/*
  Magnetic Enterprises blog styles.
  Loaded after styles.css on blog pages.

  Table of contents:
    1. Blog index & cards
    2. Article layout
    3. Article body
    4. Figures & tables
    5. Metric grid
    6. Screen-reader utilities
    7. Canvas story motion
    8. Responsive
    9. Reduced motion
*/

/* 1. Blog index & cards ---------------------------------------------------- */

.page-header {
  position: relative;
}
.blog-index,
.article {
  width: min(72rem, calc(100% - 2.5rem));
  margin: 0 auto;
}
.blog-index {
  min-height: calc(100svh - 5.5rem);
  padding: clamp(5rem, 10vw, 9rem) 0;
}
.blog-intro {
  max-width: 48rem;
  margin-bottom: clamp(4rem, 8vw, 7rem);
}
.blog-intro h1,
.article-header h1 {
  line-height: 1.02;
}
.blog-intro > p:last-child,
.article-deck {
  max-width: 42rem;
  color: var(--muted);
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  line-height: 1.55;
}
.post-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2rem;
  align-items: start;
  padding: clamp(1.5rem, 4vw, 3rem);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background-color 180ms ease;
}
.post-card:hover,
.post-card:focus-visible {
  background: var(--post-hover);
}
.post-card h2 {
  max-width: 48rem;
  margin-bottom: 1rem;
  font-size: clamp(1.75rem, 4vw, 3rem);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.04em;
}
.post-card p:last-child {
  max-width: 42rem;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}
.post-card > span {
  color: var(--blue);
  font-size: 2rem;
}
.post-meta {
  margin-bottom: 1rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
/* 2. Article layout ---------------------------------------------------------- */

.article {
  padding: clamp(4rem, 8vw, 7rem) 0 clamp(6rem, 12vw, 10rem);
}
.article-header {
  max-width: 61rem;
  margin-bottom: clamp(4rem, 8vw, 7rem);
}
.article-hero {
  margin: 0 0 clamp(4rem, 8vw, 7rem);
}
.article-hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 1.5rem;
}
.article-header h1 {
  margin-bottom: 2rem;
}
.back-link {
  display: inline-block;
  margin-bottom: 3rem;
  color: var(--muted);
  font-weight: 600;
}
/* 3. Article body --------------------------------------------------------------- */

.article-body {
  width: min(43rem, 100%);
  margin: 0 auto;
  font-size: 1.1rem;
  line-height: 1.75;
}
.article-body .lede {
  margin-bottom: 3.5rem;
  color: var(--muted);
  font-size: 1.35rem;
  line-height: 1.55;
}
.article-body h2 {
  margin: 3.5rem 0 1rem;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.04em;
}
.article-body p {
  margin-bottom: 1.5rem;
}
.article-body ul,
.article-body ol {
  margin: 0 0 2rem;
  padding-left: 1.25rem;
}
.article-body li {
  margin-bottom: 0.75rem;
}
.article-body h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.25rem;
}
.article-body pre {
  max-width: 100%;
  margin: 0 0 2rem;
  padding: 1.25rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--post-hover);
  font-size: 0.85rem;
  line-height: 1.6;
}
.article-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.plain-summary,
.evidence-details {
  margin: 2rem 0;
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--post-hover);
}
.plain-summary h2 {
  margin-top: 0;
}
.plain-summary ul,
.evidence-details > :last-child {
  margin-bottom: 0;
}
.evidence-details summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 700;
}
.evidence-details[open] summary {
  margin-bottom: 1.25rem;
}
.evidence-details pre,
.evidence-details .table-wrap {
  margin-bottom: 0.75rem;
  background: var(--paper);
}
/* 4. Figures & tables ------------------------------------------------------------- */

.article-figure {
  max-width: 100%;
  margin: 3rem 0;
}
.article-figure:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.article-figure svg {
  display: block;
  width: 100%;
  height: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--paper);
}
.article-figure figcaption,
.figure-note {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}
.table-wrap {
  max-width: 100%;
  margin: 0 0 0.75rem;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}
.table-wrap:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}
.article-body table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  font-size: 0.85rem;
  line-height: 1.45;
}
.article-body th,
.article-body td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.article-body th {
  background: var(--post-hover);
  font-weight: 700;
}
.article-body tbody tr:last-child td {
  border-bottom: 0;
}
/* 5. Metric grid ------------------------------------------------------------------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 2.5rem 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--line);
}
.metric-grid > div {
  display: flex;
  min-height: 8rem;
  flex-direction: column;
  justify-content: center;
  padding: 1.25rem;
  background: var(--paper);
}
.metric-grid strong {
  color: var(--blue);
  font-size: 2rem;
  line-height: 1;
}
.metric-grid span {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}
/* 6. Screen-reader utilities ---------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
/* 7. Canvas story motion --------------------------------------------------------------- */

.canvas-story-hero {
  width: min(61rem, 100%);
  margin: calc(clamp(4rem, 8vw, 7rem) * -0.5) 0 clamp(4rem, 8vw, 7rem);
}
.canvas-story-hero svg {
  background:
    radial-gradient(
      circle at 50% 50%,
      color-mix(in srgb, var(--blue) 9%, transparent),
      transparent 52%
    ),
    var(--paper);
}
.canvas-story .story-node {
  transform-box: fill-box;
  transform-origin: center;
  animation: canvas-story-node-in 650ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.canvas-story .story-node text {
  stroke: none;
}
.canvas-story .story-node-two {
  animation-delay: 180ms;
}
.canvas-story .story-node-three {
  animation-delay: 360ms;
}
.canvas-story .story-node-four {
  animation-delay: 540ms;
}
.canvas-story .story-edge {
  stroke-dasharray: 520;
  stroke-dashoffset: 520;
  animation: canvas-story-edge-draw 900ms ease forwards;
}
.canvas-story .story-edge-one {
  animation-delay: 240ms;
}
.canvas-story .story-edge-two {
  animation-delay: 480ms;
}
.canvas-story .story-edge-three {
  animation-delay: 720ms;
}
.canvas-story .story-node-pulse {
  animation:
    canvas-story-node-in 650ms 360ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
    canvas-story-node-pulse 2.8s 1.2s ease-in-out infinite;
}
.canvas-story .canvas-runtime-flow {
  stroke-dasharray: 9 11;
  animation: canvas-story-flow 1.1s linear infinite;
}
.canvas-story .canvas-runtime-feedback {
  animation-duration: 1.8s;
}

@keyframes canvas-story-node-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes canvas-story-node-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    filter: drop-shadow(
      0 0 10px color-mix(in srgb, var(--blue) 42%, transparent)
    );
  }
}

@keyframes canvas-story-edge-draw {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes canvas-story-flow {
  to {
    stroke-dashoffset: -20;
  }
}

/* 8. Responsive ------------------------------------------------------------------------ */

@media (max-width: 700px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
  .article-figure {
    overflow-x: auto;
  }
  .article-figure svg {
    width: 42rem;
    max-width: none;
  }
  .article-figure figcaption {
    position: sticky;
    left: 0;
    width: calc(100vw - 2.5rem);
  }
}
/* 9. Reduced motion ---------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .post-card {
    transition: none;
  }
  .canvas-story .story-node,
  .canvas-story .story-node-pulse,
  .canvas-story .story-edge,
  .canvas-story .canvas-runtime-flow {
    animation: none;
    filter: none;
    opacity: 1;
    stroke-dashoffset: 0;
    transform: none;
  }
}
