/* ==========================================================================
   blog.css — The Grimoire (blog index) + long-form post typography
   Depends on theme.css custom properties.
   ========================================================================== */

/* ==========================================================================
   Blog index — /blog
   ========================================================================== */

.blog-hero {
  padding-top: var(--hero-pad-top);
  min-height: 60vh;
}

.blog-head { max-width: 760px; }

.blog-title {
  font-size: clamp(2.4rem, 5.6vw, 4rem);
  margin-top: 1rem;
}

.blog-intro {
  margin-top: 1.2rem;
  color: var(--star-3);
  font-size: 1.12rem;
  max-width: 58ch;
}

/* -- Tag filter notice -- */
.tag-filter-note {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 2.2rem;
  padding: 0.85rem 1.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: rgba(242, 193, 78, 0.05);
  color: var(--star-3);
  font-size: 0.95rem;
}
.tag-filter-name {
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 0.88em;
  letter-spacing: 0.04em;
}
.tag-filter-clear {
  margin-left: auto;
  color: var(--star-2);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line-bright);
  padding-bottom: 1px;
}
.tag-filter-clear:hover { color: var(--gold-hot); }

/* -- Post list rows -- */
.post-list {
  list-style: none;
  display: grid;
  border-top: 1px solid var(--line);
}

.post-row {
  position: relative;
  display: grid;
  grid-template-columns: 200px 1fr 44px;
  gap: 1.5rem 2.2rem;
  align-items: start;
  padding: 2.2rem 0.5rem 2.4rem;
  border-bottom: 1px solid var(--line);
  transition: background 0.35s, border-color 0.35s;
}

/* -- Cover thumbnail: etched gold hairline frame, 3:2 -- */
.post-row-cover {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--radius-s);
  border: 1px solid rgba(242, 193, 78, 0.32);
  background: var(--void-2);
  box-shadow: 0 14px 34px -18px rgba(0, 0, 0, 0.7);
}
.post-row-cover::after {
  /* etched inner hairline */
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px solid rgba(242, 193, 78, 0.16);
  border-radius: calc(var(--radius-s) - 3px);
  pointer-events: none;
  z-index: 1;
}
.post-row-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform 0.9s var(--ease-spring);
}
.post-row:hover .post-row-cover img { transform: scale(1.055); }
.post-row:hover .post-row-cover { border-color: rgba(242, 193, 78, 0.55); }

.post-row::before {
  content: '';
  position: absolute;
  left: -1.2rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent, var(--gold), transparent);
  opacity: 0;
  transform: scaleY(0.4);
  transition: opacity 0.4s, transform 0.4s var(--ease-spring);
}

.post-row:hover { background: rgba(255, 255, 255, 0.018); }
.post-row:hover::before { opacity: 1; transform: scaleY(1); }

.post-row-date {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--star-3);
  margin-bottom: 0.7rem;
  white-space: nowrap;
  transition: color 0.35s;
}
.post-row:hover .post-row-date { color: var(--gold); }

.post-row-title {
  font-size: clamp(1.35rem, 2.6vw, 1.75rem);
  line-height: 1.2;
}
.post-row-title a {
  color: var(--star-1);
  transition: color 0.3s;
}
/* Stretched link: whole row is clickable, tag chips stay above it */
.post-row-title a::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}
.post-row:hover .post-row-title a { color: var(--gold-hot); }
.post-row-title a:focus-visible {
  outline: 1px solid var(--line-bright);
  outline-offset: 4px;
}
.post-row:has(.post-row-title a:focus-visible) {
  background: rgba(255, 255, 255, 0.03);
  outline: 1px solid var(--line-bright);
  outline-offset: 2px;
  border-radius: var(--radius-s);
}

.post-row-excerpt {
  margin-top: 0.7rem;
  color: var(--star-3);
  font-size: 1rem;
  max-width: 62ch;
}

.post-row-arrow {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  align-self: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--star-4);
  opacity: 0.6;
  transform: translateX(-6px);
  transition: opacity 0.35s, transform 0.35s var(--ease-spring), border-color 0.35s, color 0.35s, box-shadow 0.35s;
}
.post-row-arrow svg { width: 18px; height: 18px; }
.post-row:hover .post-row-arrow {
  opacity: 1;
  transform: translateX(0);
  border-color: var(--line-bright);
  color: var(--gold-hot);
  box-shadow: var(--glow-gold);
}

/* -- Tag chips (shared: index rows + post header) -- */
.tag-chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
  position: relative;
  z-index: 2; /* above the stretched row link */
}
.tag-chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--star-3);
  padding: 0.28rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  transition: color 0.3s, border-color 0.3s, background 0.3s, transform 0.3s var(--ease-spring);
}
.tag-chip:hover,
.tag-chip:focus-visible {
  color: var(--gold-hot);
  border-color: var(--line-bright);
  background: var(--gold-dim);
  transform: translateY(-1px);
}

/* -- Empty state -- */
.blog-empty {
  display: grid;
  justify-items: center;
  gap: 1.4rem;
  padding: clamp(3rem, 8vw, 6rem) 1.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-m);
  text-align: center;
}
.blog-empty svg {
  width: 56px;
  height: 56px;
  color: var(--gold);
  opacity: 0.75;
}
.blog-empty p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.25rem;
  color: var(--star-2);
}

/* ==========================================================================
   Post page — /blog/{slug}
   ========================================================================== */

.post-article { padding-top: var(--hero-pad-top); }

/* ==========================================================================
   Aurora reading thread — 2px progress bar fixed above the nav border.
   Progress is information, not decoration: it stays under reduced motion.
   Driven natively by a scroll-driven animation where supported; post.js
   provides an rAF fallback (.post-progress--js) elsewhere.
   ========================================================================== */
.post-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 101; /* nav is 100 — the thread sits on its top edge */
  background: var(--aurora);
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}
.post-progress[hidden] { display: none; }

/* Smoothing between discrete scroll jumps (JS fallback only; the class is
   withheld under reduced motion — see post.js live MediaQueryList). */
.post-progress--smooth { transition: transform 0.12s linear; }

@keyframes post-progress-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@supports (animation-timeline: view()) and (timeline-scope: --post-read) {
  html { timeline-scope: --post-read; }
  .post-body { view-timeline: --post-read block; }
  /* contain 0% → article top meets viewport top; contain 100% → article
     bottom enters at the viewport bottom, i.e. the footer comes into view. */
  .post-progress {
    animation: post-progress-grow 1s linear both;
    animation-timeline: --post-read;
    animation-range: contain 0% contain 100%;
  }
}

/* -- Full-bleed cover hero: 46vh banner under the fixed nav -- */
.post-hero {
  position: relative;
  height: 46vh;
  min-height: 300px;
  overflow: hidden;
  background: var(--void-1);
}
.post-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 50% 38%;
  animation: post-kenburns 20s ease-in-out infinite alternate;
  will-change: transform;
}
@keyframes post-kenburns {
  from { transform: scale(1); }
  to   { transform: scale(1.07); }
}
/* Bottom scrim dissolves the art into the void; light top scrim keeps nav legible */
.post-hero-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(6, 4, 15, 0.6) 0%,
    rgba(6, 4, 15, 0.12) 24%,
    rgba(6, 4, 15, 0) 44%,
    rgba(6, 4, 15, 0.58) 74%,
    var(--void-0) 100%
  );
}

.post-article--hero { padding-top: 0; }
.post-article--hero .post-measure { position: relative; z-index: 2; }
/* Title block overlaps the scrim so the Fraunces h1 sits half-on the art */
.post-article--hero .post-header { margin-top: clamp(-9rem, -15vh, -4.5rem); }
.post-article--hero .post-title { text-shadow: 0 2px 30px rgba(6, 4, 15, 0.85); }
.post-article--hero .post-meta { text-shadow: 0 1px 14px rgba(6, 4, 15, 0.9); }

.post-measure {
  max-width: 720px;
  margin: 0 auto;
}

/* -- Header -- */
.post-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold);
}
.post-meta-rune { color: var(--star-4); letter-spacing: 0; }

.post-title {
  margin-top: 1.1rem;
  font-size: clamp(2.1rem, 5vw, 3.3rem);
}

.post-header-tags { margin-top: 1.4rem; }

/* ==========================================================================
   Long-form body typography
   ========================================================================== */
.post-body {
  margin-top: 2.8rem;
  font-size: 1.09rem;
  line-height: 1.78;
  color: var(--star-2);
}

.post-body > * + * { margin-top: 1.35em; }

/* -- Drop cap on the opening paragraph -- */
.post-body > p:first-of-type::first-letter {
  float: left;
  font-family: var(--font-display);
  font-weight: 560;
  font-size: 3.9em;
  line-height: 0.78;
  padding: 0.1em 0.14em 0 0;
  color: var(--gold);
}
@supports (-webkit-background-clip: text) or (background-clip: text) {
  .post-body > p:first-of-type::first-letter {
    background: linear-gradient(150deg, var(--gold-hot) 10%, var(--gold) 45%, var(--rose) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--gold); /* fallback if clip silently fails */
  }
}

/* -- Headings -- */
.post-body h2,
.post-body h3,
.post-body h4 {
  font-family: var(--font-display);
  color: var(--star-1);
  line-height: 1.2;
  text-wrap: balance;
}
.post-body h2 {
  font-size: 1.75rem;
  margin-top: 2.4em;
}
.post-body h2::before {
  content: '';
  display: block;
  width: 44px;
  height: 2px;
  margin-bottom: 1rem;
  background: linear-gradient(90deg, var(--gold), transparent);
  border-radius: 2px;
}
.post-body h3 {
  font-size: 1.32rem;
  margin-top: 2em;
  color: var(--gold-hot);
}
.post-body h4 {
  font-size: 1.1rem;
  margin-top: 1.8em;
}

/* -- Heading anchors (injected by post.js) --
   Absolutely positioned at the heading's static text end, so revealing
   them never shifts layout. Deep-links clear the fixed nav. */
.post-body h2,
.post-body h3 { position: relative; }
.post-body h2[id],
.post-body h3[id] { scroll-margin-top: calc(var(--nav-h) + 1.5rem); }

.post-body .heading-anchor {
  position: absolute; /* static position: right after the last word */
  margin-left: 0.35em;
  padding: 0 0.25em; /* hit target lives in the heading's padding box */
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 0.72em;
  line-height: inherit;
  color: var(--gold);
  text-decoration: none;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.25s, transform 0.25s var(--ease-spring), color 0.25s;
}
.post-body h2:hover .heading-anchor,
.post-body h3:hover .heading-anchor,
.post-body .heading-anchor:focus-visible {
  opacity: 1;
  transform: translateX(0);
}
.post-body .heading-anchor:hover { color: var(--gold-hot); }
.post-body .heading-anchor:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
  border-radius: 4px;
}
@media (hover: none) {
  .post-body .heading-anchor { opacity: 0.55; transform: none; }
}

/* -- Links -- */
.post-body a {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: rgba(242, 193, 78, 0.45);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color 0.25s, text-decoration-color 0.25s;
}
.post-body a:hover {
  color: var(--gold-hot);
  text-decoration-color: var(--gold-hot);
}

/* -- Emphasis -- */
.post-body strong { color: var(--star-1); font-weight: 600; }

/* -- Blockquotes: gold rune border, italic Fraunces -- */
.post-body blockquote {
  margin: 2.2em 0;
  padding: 0.4em 0 0.4em 1.6em;
  border-left: 2px solid var(--gold);
  position: relative;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.18em;
  line-height: 1.55;
  color: var(--star-1);
}
.post-body blockquote::before {
  content: '';
  position: absolute;
  left: -5px;
  top: 50%;
  width: 8px;
  height: 8px;
  transform: translateY(-50%) rotate(45deg);
  background: var(--void-0);
  border: 1px solid var(--gold);
}
.post-body blockquote p + p { margin-top: 0.8em; }
.post-body blockquote cite {
  display: block;
  margin-top: 0.7em;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.68em;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--star-3);
}

/* -- Lists -- */
.post-body ul,
.post-body ol {
  padding-left: 1.4em;
  display: grid;
  gap: 0.55em;
}
.post-body li::marker { color: var(--gold); }

/* -- Code -- */
.post-body pre {
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  margin: 2em 0;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--star-2);
}
.post-body pre code {
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.post-body :not(pre) > code {
  font-size: 0.86em;
  background: var(--void-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.12em 0.42em;
  color: var(--aqua);
  white-space: nowrap;
}

/* -- Code-shell wrapper + copy chip (injected by post.js) --
   The wrapper carries the pre's rhythm and anchors the chip so it stays
   put while the code scrolls horizontally underneath. */
.post-body .code-shell { position: relative; margin: 2em 0; }
.post-body .code-shell > pre { margin: 0; }

.code-copy {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--star-3);
  padding: 0.34rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 11, 36, 0.78); /* glass ghost over the code */
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.25s, transform 0.25s var(--ease-spring), color 0.25s, border-color 0.25s, background 0.25s;
}
.code-shell:hover .code-copy,
.code-shell:focus-within .code-copy {
  opacity: 1;
  transform: translateY(0);
}
.code-copy:hover,
.code-copy:focus-visible {
  color: var(--gold-hot);
  border-color: var(--line-bright);
  background: rgba(23, 16, 51, 0.92);
}
.code-copy:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}
.code-copy[data-copied] {
  color: var(--jade);
  border-color: rgba(74, 222, 128, 0.4);
}
@media (hover: none) {
  .code-copy { opacity: 1; transform: none; }
}

/* -- Horizontal rule as a centred rune -- */
.post-body hr {
  border: 0;
  margin: 3.2em 0;
  text-align: center;
  height: auto;
}
.post-body hr::before {
  content: '\25C7 \00A0 \25C6 \00A0 \25C7';
  font-size: 0.7rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  opacity: 0.75;
}

/* -- Images -- */
.post-body img {
  border-radius: var(--radius-m);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-deep), var(--glow-gold);
  margin: 2.2em auto;
}
.post-body figure { margin: 2.2em 0; }
.post-body figure img { margin: 0; }
.post-body figcaption {
  margin-top: 0.8em;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--star-4);
}

/* -- Tables (Markdig pipe tables) -- */
.post-body table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 0.95rem;
}
.post-body th,
.post-body td {
  border: 1px solid var(--line);
  padding: 0.6em 1em;
  text-align: left;
}
.post-body th {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(242, 193, 78, 0.05);
}

/* ==========================================================================
   Post footer
   ========================================================================== */
.post-footer { margin-top: 4rem; }

.post-footer .rune-divider {
  color: var(--gold);
  padding: 0;
}
.post-footer .rune-divider::before,
.post-footer .rune-divider::after { flex-basis: 160px; }

.post-colophon {
  margin-top: 1.6rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--star-3);
}

.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin-top: 2.8rem;
}
.post-nav-card {
  display: grid;
  gap: 0.45rem;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  background: var(--glass-2);
  transition: border-color 0.35s, transform 0.35s var(--ease-spring), box-shadow 0.35s;
}
.post-nav-card--older { text-align: right; }
.post-nav-card:hover,
.post-nav-card:focus-visible {
  border-color: var(--line-bright);
  transform: translateY(-3px);
  box-shadow: var(--glow-gold);
}
.post-nav-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--star-3);
}
.post-nav-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  line-height: 1.3;
  color: var(--star-1);
}
.post-nav-card:hover .post-nav-title,
.post-nav-card:focus-visible .post-nav-title { color: var(--gold-hot); }
.post-nav-spacer { min-height: 1px; }

.post-back-wrap {
  margin-top: 2.8rem;
  text-align: center;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 960px) {
  .post-row { grid-template-columns: 168px 1fr 44px; }
}

@media (max-width: 720px) {
  .post-row {
    grid-template-columns: 1fr;
    gap: 1.1rem;
    padding: 1.8rem 0.25rem 2rem;
  }
  .post-row-cover { max-width: 420px; }
  .post-row-date { margin-bottom: 0.5rem; }
  .post-row-arrow { display: none; }
  .post-row::before { left: -0.75rem; }

  .post-hero { min-height: 260px; }
  .post-article--hero .post-header { margin-top: clamp(-6rem, -11vh, -3.2rem); }

  .post-nav { grid-template-columns: 1fr; }
  .post-nav-card--older { text-align: left; }
  .post-nav-spacer { display: none; }

  .post-body { font-size: 1.03rem; }
}

@media (max-width: 420px) {
  .tag-filter-clear { margin-left: 0; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .post-hero-img { animation: none; transform: none; will-change: auto; }
  .post-row-cover img { transition: none; }
  .post-row:hover .post-row-cover img { transform: none; }

  /* The reading thread is information, not decoration: it keeps tracking
     scroll (the scroll-driven animation maps position, not time), but all
     transition smoothing goes. */
  .post-progress,
  .post-progress--smooth { transition: none; }

  /* Anchors and copy chips fade without sliding. */
  .post-body .heading-anchor,
  .code-copy { transition: none; transform: none; }
}
