/* Blog — listing index + single post on the public navy theme.
   Pairs with public_base.html (loads after base.css). */

/* Offset anchor scrolling so the sticky/fixed nav doesn't cover the target. */
html { scroll-padding-top: 117px; }
@media (max-width: 720px) {
  /* Mobile uses the section-nav pill (~44px tall at top:10px) instead. */
  html { scroll-padding-top: 91px; }
}

.blog-page,
.post-page { display: block; }

/* ───────── Preview banner (draft mode) ───────── */
.preview-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.08));
  border-bottom: 1px solid rgba(245, 158, 11, 0.45);
  color: #fbbf24;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 10px 0;
  text-align: center;
}

/* ───────── Hero (shared by index + post) ───────── */
.blog-hero,
.post-hero {
  background: transparent;
  padding: clamp(48px, 8vw, 96px) 0 clamp(24px, 4vw, 40px);
}

.blog-head,
.post-head {
  max-width: 820px;
  display: flex; flex-direction: column; gap: 14px;
}
.blog-head .eyebrow,
.post-head .eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px; border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #9DB8FF;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 12px);
  align-self: flex-start;
}
.blog-head .eyebrow-dot,
.post-head .eyebrow-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tg-blue-light);
  box-shadow: 0 0 10px var(--tg-blue-light);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.4); opacity: .55; } }

.blog-head h1,
.post-head h1 {
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #fff;
  text-wrap: balance;
}
.blog-head h1 .grad,
.post-head h1 .grad {
  background: linear-gradient(135deg, #5BB6FF, #9DB8FF);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.blog-sub,
.post-sub {
  font-size: clamp(15px, 1.3vw, 17px);
  color: rgba(255,255,255,.62);
  line-height: 1.55;
  max-width: 640px;
  text-wrap: pretty;
}

/* ───────── Post meta strip ───────── */
.post-meta {
  display: flex; flex-wrap: wrap;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(11px, 1.1vw, 12px);
  color: rgba(255,255,255,.5);
  letter-spacing: .02em;
  margin-top: 6px;
}
.post-meta-item { display: inline-flex; align-items: center; }
.post-meta-item + .post-meta-item::before {
  content: "·";
  margin: 0 12px;
  color: rgba(255,255,255,.3);
}

/* ───────── Cover image ───────── */
.post-cover-wrap {
  margin: 0 auto clamp(20px, 3vw, 32px);
}
.post-cover {
  display: block;
  width: 100%; max-width: 1120px;
  margin: 0 auto;
  aspect-ratio: 16/8;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid var(--navy-line);
  box-shadow: 0 24px 60px rgba(8, 14, 36, .35);
}

/* ───────── Body section ───────── */
.blog-body,
.post-body {
  background: transparent;
  padding: clamp(8px, 2vw, 24px) 0 clamp(72px, 10vw, 128px);
}

.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: clamp(24px, 3vw, 40px);
  align-items: flex-start;
}
@media (max-width: 1000px) {
  .post-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .post-layout .paper { margin: 0 12px; }
}

/* ───────── Paper card ───────── */
.paper {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: clamp(28px, 5vw, 56px) clamp(22px, 5vw, 64px);
  box-shadow: 0 24px 60px rgba(8, 14, 36, .35);
  max-width: 820px;
  margin: 0 auto;
}
.post-layout .paper { max-width: none; }

/* On mobile the global .section-nav pill mirrors the post H2 anchors, so the
   in-flow .post-toc card is redundant. */
@media (max-width: 1000px) {
  .blog-head .eyebrow,
  .post-head .eyebrow { display: none; }
}
@media (max-width: 720px) {
  .post-toc { display: none; }
  .blog-page .blog-hero,
  .post-page .post-hero { padding-top: 80px; }
}

/* ───────── Sidebar TOC ───────── */
.post-toc {
  position: sticky;
  top: 116px;
  align-self: start;
  min-width: 0;
  order: 2;
}
@media (max-width: 1000px) {
  .post-toc {
    order: 0;
    position: sticky;
    top: 10px;
    z-index: 10;
    background: rgba(15, 27, 61, .92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--navy-line);
    border-radius: 14px;
    padding: 6px 10px;
    margin: 0 12px;
    box-shadow: 0 8px 24px rgba(8, 14, 36, .35);
  }
  .post-toc-summary .post-toc-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .post-toc-back { width: 28px; height: 28px; margin-right: 8px; }
  .post-toc-tags { display: none; }
}
.post-toc:empty { display: none; }
.post-toc[hidden] { display: none; }

/* Back-to-blog arrow (lives inside summary, on same row as the title) */
.post-toc-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  flex-shrink: 0;
  border-radius: 8px;
  color: rgba(255,255,255,.55);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--navy-line);
  margin-right: 12px;
  pointer-events: auto;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}
.post-toc-back:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
  border-color: rgba(91,182,255,.4);
}

/* Collapse — title always shows; chevron and click toggle only on mobile */
.post-toc-collapse > summary {
  display: flex;
  align-items: center;
  list-style: none;
  cursor: default;
  pointer-events: none;
  user-select: none;
  min-height: 32px;
  margin-bottom: 12px;
}
.post-toc-collapse > summary::-webkit-details-marker { display: none; }
.post-toc-collapse > summary::marker { content: ''; }
.post-toc-summary .post-toc-title { margin: 0; }
.post-toc-chevron {
  display: none;
  margin-left: auto;
  color: rgba(255,255,255,.5);
  transition: transform .2s ease;
}
.post-toc-collapse[open] .post-toc-chevron { transform: rotate(180deg); }
@media (max-width: 1000px) {
  .post-toc-collapse > summary {
    cursor: pointer;
    pointer-events: auto;
    margin-bottom: 0;
    min-height: 28px;
  }
  .post-toc-collapse[open] > summary { margin-bottom: 6px; }
  .post-toc-chevron { display: block; }
}

/* Home link inside expanded panel — tablet/mobile only, shown once the page nav scrolls off */
.post-toc-home {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--navy-line);
  width: 100%;
  color: rgba(255,255,255,.55);
  font-size: 12.5px;
  text-decoration: none;
  transition: color .15s ease;
}
.post-toc-home:hover { color: #fff; }
@media (max-width: 1000px) {
  .post-toc-home { display: inline-flex; padding: 8px 10px; margin-bottom: 4px; font-size: 12px; }
  .post-toc-home[hidden] { display: none; }
}
.post-toc-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(255,255,255,.45);
  margin: 0 0 12px 14px;
}
@media (max-width: 1000px) {
  .post-toc-title { margin-left: 0; }
}
.post-toc-nav { display: flex; flex-direction: column; gap: 2px; }
.post-toc-nav:empty { display: none; }
.post-toc-nav:empty + * { display: none; }

.post-toc-nav a {
  display: block;
  padding: 7px 14px;
  border-left: 2px solid transparent;
  font-size: 13.5px;
  line-height: 1.4;
  color: rgba(255,255,255,.6);
  border-radius: 0 8px 8px 0;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
  text-wrap: pretty;
}
.post-toc-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.04);
}
.post-toc-nav a.is-active {
  color: var(--tg-blue-light);
  border-left-color: var(--tg-blue-light);
  background: rgba(91,182,255,.08);
}
@media (max-width: 1000px) {
  .post-toc-nav a { padding: 5px 10px; font-size: 12.5px; }
}

/* ───────── Prose typography ───────── */
.post-prose { font-size: clamp(16px, 1.2vw, 18px); line-height: 1.7; }
.post-prose > * + * { margin-top: 1em; }

.post-prose h2 {
  font-size: clamp(22px, 2.2vw, 28px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
  margin-top: 2em;
  color: var(--ink);
}
.post-prose h2:first-child { margin-top: 0; }

.post-prose h3 {
  font-size: clamp(17px, 1.4vw, 19px);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 1.6em;
  color: var(--ink);
}

.post-prose h4 {
  font-size: clamp(15px, 1.15vw, 16px);
  font-weight: 700;
  margin-top: 1.4em;
  color: var(--ink);
}

.post-prose p { color: var(--ink-soft); }
.post-prose strong { color: var(--ink); font-weight: 600; }

.post-prose a {
  color: var(--tg-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.post-prose a:hover { text-decoration-thickness: 2px; }

.post-prose ul, .post-prose ol {
  padding-left: 1.4em;
  color: var(--ink-soft);
}
.post-prose ul { list-style: disc; }
.post-prose ol { list-style: decimal; }
.post-prose li + li { margin-top: .35em; }
.post-prose li::marker { color: var(--ink-mute); }

.post-prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

.post-prose blockquote {
  margin: 1.4em 0;
  padding: .6em 1.1em;
  border-left: 3px solid var(--tg-blue);
  background: var(--bg);
  border-radius: 0 10px 10px 0;
  color: var(--ink-soft);
}

.post-prose code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .92em;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  padding: .1em .4em;
}
.post-prose pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: .9em;
  line-height: 1.55;
}
.post-prose pre code {
  background: transparent; border: 0; padding: 0;
}

.post-prose img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.6em auto;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.post-prose figure { margin: 1.6em 0; }
.post-prose figcaption {
  margin-top: .6em;
  font-size: .9em;
  color: var(--ink-mute);
  text-align: center;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.post-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95em;
}
.post-prose th, .post-prose td {
  text-align: left;
  padding: .6em .8em;
  border-bottom: 1px solid var(--line);
}
.post-prose th { color: var(--ink); font-weight: 600; }
.post-prose td { color: var(--ink-soft); }

/* ───────── Tags (inside sidebar TOC) ───────── */
.post-toc-tags {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--navy-line);
}
.post-toc-tags .post-toc-title { margin-bottom: 10px; }
@media (max-width: 1000px) {
  .post-toc-tags { margin-top: 18px; padding-top: 14px; }
}
.post-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 14px;
}
@media (max-width: 1000px) {
  .post-tags { padding: 0; }
}
.post-tag {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--navy-line);
  color: rgba(255,255,255,.6);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: .02em;
}

/* ───────── Index grid ───────── */
.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: clamp(20px, 3vw, 28px);
  max-width: 1120px;
  margin: 0 auto;
}

.post-card {
  display: flex; flex-direction: column;
  background: rgba(255,255,255,.03);
  border: 1px solid var(--navy-line);
  border-radius: 18px;
  overflow: hidden;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
.post-card:hover {
  transform: translateY(-2px);
  border-color: rgba(91,182,255,.3);
  background: rgba(255,255,255,.05);
}
.post-card-cover {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--navy-2);
}
.post-card-cover img {
  width: 100%; height: 100%;
  display: block;
  object-fit: cover;
}
.post-card-body {
  display: flex; flex-direction: column; gap: 10px;
  padding: clamp(18px, 2.4vw, 24px);
  flex: 1;
}
.post-card-cat {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(10px, 1vw, 11px);
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--tg-blue-light);
  align-self: flex-start;
}
.post-card-title {
  color: #fff;
  font-size: clamp(18px, 1.7vw, 21px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.01em;
  text-wrap: balance;
}
.post-card-excerpt {
  color: rgba(255,255,255,.6);
  font-size: clamp(13px, 1.2vw, 14px);
  line-height: 1.5;
  flex: 1;
}
.post-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(10px, 1vw, 11px);
  color: rgba(255,255,255,.42);
  margin-top: 4px;
}
.post-card-meta-dot {
  width: 3px; height: 3px; border-radius: 50%;
  background: rgba(255,255,255,.3);
}

/* ───────── Related reads (post page) ───────── */
.post-related {
  background: transparent;
  padding: clamp(16px, 3vw, 32px) 0 clamp(72px, 10vw, 128px);
}
.post-related-head {
  max-width: 1120px;
  margin: 0 auto clamp(20px, 3vw, 28px);
  display: flex; flex-direction: column; gap: 8px;
}
.post-related-title {
  font-size: clamp(22px, 2.4vw, 32px);
  color: #fff;
  font-weight: 700;
  letter-spacing: -.01em;
  text-wrap: balance;
}

/* ───────── Blog post: switch to mobile nav at the TOC breakpoint ───────── */
/* At ≤1000px the sidebar TOC collapses, so replace the desktop nav with the
   mobile section-nav pill on post pages. Only targets post pages via :has(). */
@media (max-width: 1000px) {
  body:has(.post-page) .nav { display: none; }
  body:has(.post-page) .section-nav {
    display: block;
    left: 12px;
    right: 12px;
    opacity: 0.8;
  }
  body:has(.post-page) .section-nav.is-prominent { opacity: 1; }
  body:has(.post-page) .section-nav:has([open]) { opacity: 1; }
}
/* At tablet the section-nav handles both site + article nav, so the sticky TOC bar is redundant */
@media (min-width: 721px) and (max-width: 1000px) {
  .post-toc { display: none; }
  body:has(.post-page) .section-nav {
    max-width: 480px;
    left: 0;
    right: 0;
    margin-inline: auto;
  }
}

/* ───────── Empty state ───────── */
.blog-empty {
  text-align: center;
  padding: clamp(40px, 6vw, 80px) 20px;
  color: rgba(255,255,255,.55);
  font-size: clamp(14px, 1.3vw, 16px);
  border: 1px dashed var(--navy-line);
  border-radius: 18px;
  max-width: 640px;
  margin: 0 auto;
}
