/* ===============================================================
   Bitcrack Cyber — Post page (v2)
   Hero gradient/grain, drop cap, read-time, code chrome, TOC,
   per-post layout vocabulary, syntax highlighting (Pygments).
   Theme-aware via the existing palette CSS vars from blog.css /
   light/blog.css.
   =============================================================== */

/* ---------------------------------------------------------------
   Hero — matches the blog index hero so the site feels consistent.
   ---------------------------------------------------------- */
.post-hero {
  position: relative;
  padding: 10rem 0 4.5rem;
  overflow: hidden;
}
[data-theme="light"] .post-hero {
  background: var(--bg-surface);
}
.post-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black, transparent);
}
[data-theme="light"] .post-hero::before {
  background-image: radial-gradient(rgba(0,0,0,0.06) 1px, transparent 1px);
}

.post-hero-content {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1.5rem;
  z-index: 1;
}
.post-hero-content h1 {
  margin: 0 0 1.25rem;
  font-size: clamp(2.1rem, 4.5vw, 3rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
  color: var(--text);
}
.post-hero-content .post-excerpt {
  font-size: 1.15rem;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 640px;
  margin: 0 0 1.5rem;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.post-meta .blog-category,
.post-meta .blog-date { font-size: 0.78rem; }
.post-meta__sep {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
}
.post-meta__author {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.post-meta__author i { color: var(--accent); }
.post-meta__readtime {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.post-meta__readtime i { font-size: 0.72rem; opacity: 0.7; }

.post-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  text-decoration: none;
  margin: 0 0 3rem;
  transition: color 0.2s ease, gap 0.2s ease;
}
.post-back:hover { color: var(--accent); gap: 0.5rem; }
.post-back i { font-size: 0.7rem; color: var(--accent); }

/* ---------------------------------------------------------------
   Body layout — body + optional sticky right TOC sidebar.
   --------------------------------------------------------------- */
.post-body { padding: 3.5rem 0 6rem; }
.post-body__inner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.post-body__inner.has-toc {
  grid-template-columns: minmax(0, 1fr) 220px;
  column-gap: 3rem;
}

.post-content {
  min-width: 0;
  max-width: 720px;
  margin: 0 auto;
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text-secondary);
}
.post-body__inner.has-toc .post-content { margin: 0; }

.post-content h2,
.post-content h3,
.post-content h4 {
  color: var(--text);
  scroll-margin-top: 6rem;
  clear: both;
}
.post-content h2 { margin: 2.75rem 0 1rem; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.01em; }
.post-content h3 { margin: 2.25rem 0 0.75rem; font-size: 1.2rem; font-weight: 600; }
.post-content h4 { margin: 1.75rem 0 0.6rem; font-size: 1.05rem; font-weight: 600; }
.post-content p { margin: 0 0 1.25rem; }
.post-content ul, .post-content ol { margin: 0 0 1.25rem; padding-left: 1.5rem; }
.post-content li { margin-bottom: 0.5rem; }
.post-content strong { color: var(--text); font-weight: 700; }
.post-content blockquote { margin: 1.5rem 0; padding: 1rem 1.5rem; border-left: 3px solid var(--accent); background: var(--bg-card); border-radius: 0 8px 8px 0; font-style: italic; }
.post-content a { color: var(--accent); text-decoration: none; }
.post-content a:hover { text-decoration: underline; }
.post-content img { max-width: 100%; border-radius: 8px; margin: 1.5rem 0; display: block; }
.post-content hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* Drop cap on the first paragraph of the post — only when it's actually
   the first child (i.e. the post starts with body copy, not a heading). */
.post-content > p:first-child::first-letter {
  float: left;
  font-size: 3.6rem;
  line-height: 0.9;
  font-weight: 800;
  color: var(--accent);
  padding: 0.3rem 0.75rem 0 0;
  margin-top: 0.3rem;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
}

/* ---------------------------------------------------------------
   Code blocks (server-side highlighted via Pygments)
   --------------------------------------------------------------- */
.post-content pre.code-block {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0;
  overflow: hidden;
  margin: 1.75rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.6;
}
.post-content pre.code-block > code {
  display: block;
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  background: none;
  border: none;
  color: var(--text);
  font-size: inherit;
}
.post-content .code-block__head {
  /* Decorated client-side by blog.js when filename or copy button needed.
     Sits above <code>; the JS sets `data-decorated` so this rule applies. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem 0.55rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--text-muted);
}
.post-content .code-block__filename {
  color: var(--text);
  font-weight: 600;
}
.post-content .code-block__lang {
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.7rem;
}
.post-content .code-block__copy {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.post-content .code-block__copy:hover {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--accent);
}
.post-content .code-block__copy.is-copied {
  color: #10b981;
  border-color: rgba(16,185,129,0.4);
}

/* Inline code (non-block) */
.post-content code:not(.code-block code):not([class*="language-"]) {
  background: var(--bg-card);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
}

/* ---------------------------------------------------------------
   Pygments token colours (dark theme — applies via .post-content
   default; .post-hero/--text vars tell us which is active).
   --------------------------------------------------------------- */
.post-content .code-block .k,
.post-content .code-block .kn,
.post-content .code-block .kd,
.post-content .code-block .kr,
.post-content .code-block .kc { color: #c678dd; }
.post-content .code-block .nf,
.post-content .code-block .nc,
.post-content .code-block .nd,
.post-content .code-block .ne { color: #61afef; }
.post-content .code-block .nb,
.post-content .code-block .bp { color: #56b6c2; }
.post-content .code-block .nv,
.post-content .code-block .vi,
.post-content .code-block .vm { color: #e06c75; }
.post-content .code-block .s,
.post-content .code-block .s1,
.post-content .code-block .s2,
.post-content .code-block .sa,
.post-content .code-block .sb,
.post-content .code-block .sc,
.post-content .code-block .sh,
.post-content .code-block .sr,
.post-content .code-block .ss,
.post-content .code-block .se,
.post-content .code-block .si,
.post-content .code-block .sx { color: #98c379; }
.post-content .code-block .c,
.post-content .code-block .c1,
.post-content .code-block .cm,
.post-content .code-block .cp,
.post-content .code-block .ch,
.post-content .code-block .cs { color: #5c6370; font-style: italic; }
.post-content .code-block .mi,
.post-content .code-block .mf,
.post-content .code-block .mh,
.post-content .code-block .mo,
.post-content .code-block .mb,
.post-content .code-block .il { color: #d19a66; }
.post-content .code-block .o,
.post-content .code-block .ow { color: #abb2bf; }
.post-content .code-block .p { color: #abb2bf; }
.post-content .code-block .err { color: #e06c75; background: rgba(224,108,117,0.08); }
.post-content .code-block .gh,
.post-content .code-block .gu { color: #61afef; font-weight: bold; }
.post-content .code-block .gi { color: #98c379; }
.post-content .code-block .gd { color: #e06c75; }

/* Light-theme overrides for Pygments tokens (One Light palette). */
[data-theme="light"] .post-content .code-block .k,
[data-theme="light"] .post-content .code-block .kn,
[data-theme="light"] .post-content .code-block .kd,
[data-theme="light"] .post-content .code-block .kr,
[data-theme="light"] .post-content .code-block .kc { color: #a626a4; }
[data-theme="light"] .post-content .code-block .nf,
[data-theme="light"] .post-content .code-block .nc,
[data-theme="light"] .post-content .code-block .nd,
[data-theme="light"] .post-content .code-block .ne { color: #4078f2; }
[data-theme="light"] .post-content .code-block .nb,
[data-theme="light"] .post-content .code-block .bp { color: #0184bc; }
[data-theme="light"] .post-content .code-block .nv,
[data-theme="light"] .post-content .code-block .vi,
[data-theme="light"] .post-content .code-block .vm { color: #e45649; }
[data-theme="light"] .post-content .code-block .s,
[data-theme="light"] .post-content .code-block .s1,
[data-theme="light"] .post-content .code-block .s2,
[data-theme="light"] .post-content .code-block .sa,
[data-theme="light"] .post-content .code-block .sb,
[data-theme="light"] .post-content .code-block .sc,
[data-theme="light"] .post-content .code-block .sh,
[data-theme="light"] .post-content .code-block .sr,
[data-theme="light"] .post-content .code-block .ss,
[data-theme="light"] .post-content .code-block .se,
[data-theme="light"] .post-content .code-block .si,
[data-theme="light"] .post-content .code-block .sx { color: #50a14f; }
[data-theme="light"] .post-content .code-block .c,
[data-theme="light"] .post-content .code-block .c1,
[data-theme="light"] .post-content .code-block .cm,
[data-theme="light"] .post-content .code-block .cp,
[data-theme="light"] .post-content .code-block .ch,
[data-theme="light"] .post-content .code-block .cs { color: #a0a1a7; font-style: italic; }
[data-theme="light"] .post-content .code-block .mi,
[data-theme="light"] .post-content .code-block .mf,
[data-theme="light"] .post-content .code-block .mh,
[data-theme="light"] .post-content .code-block .mo,
[data-theme="light"] .post-content .code-block .mb,
[data-theme="light"] .post-content .code-block .il { color: #986801; }
[data-theme="light"] .post-content .code-block .o,
[data-theme="light"] .post-content .code-block .ow,
[data-theme="light"] .post-content .code-block .p { color: #383a42; }
[data-theme="light"] .post-content .code-block .err { color: #e45649; background: rgba(228,86,73,0.08); }

/* ---------------------------------------------------------------
   TOC sidebar (sticky, right-rail)
   --------------------------------------------------------------- */
.post-toc {
  align-self: start;
  position: sticky;
  top: 6rem;
  font-size: 0.82rem;
  line-height: 1.45;
  border-left: 1px solid var(--border);
  padding-left: 1.25rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
}
.post-toc__heading {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}
.post-toc__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.post-toc__item a {
  display: block;
  padding: 0.2rem 0;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 0.65rem;
  margin-left: -0.65rem;
  transition: color 0.15s, border-color 0.15s;
}
.post-toc__item a:hover { color: var(--text-secondary); }
.post-toc__item--h3 a { padding-left: 1.5rem; font-size: 0.78rem; }
.post-toc__item.is-active a {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Mobile: collapse TOC into a top "Contents" disclosure. */
.post-toc__mobile {
  display: none;
  margin: 0 auto 1.5rem;
  max-width: 720px;
  padding: 0 1.5rem;
}
.post-toc__mobile-trigger {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.7rem 1rem;
  cursor: pointer;
}
.post-toc__mobile-trigger i { color: var(--accent); }

/* ---------------------------------------------------------------
   Per-post layout vocabulary (callouts, columns, image floats…)
   --------------------------------------------------------------- */
.post-content img.w-25,    .post-content figure.w-25    { width: 25%;  max-width: 25%; }
.post-content img.w-50,    .post-content figure.w-50    { width: 50%;  max-width: 50%; }
.post-content img.w-75,    .post-content figure.w-75    { width: 75%;  max-width: 75%; }
.post-content img.w-100,   .post-content figure.w-100   { width: 100%; max-width: 100%; }
.post-content figure.w-25 img,
.post-content figure.w-50 img,
.post-content figure.w-75 img,
.post-content figure.w-100 img { width: 100%; max-width: 100%; }

.post-content img.align-left,  .post-content figure.align-left  { float: left;  margin: 0.4rem 1.5rem 0.75rem 0; clear: left; }
.post-content img.align-right, .post-content figure.align-right { float: right; margin: 0.4rem 0 0.75rem 1.5rem; clear: right; }
.post-content img.align-center,.post-content figure.align-center{ display: block; margin: 1.5rem auto; float: none; }

.post-content figure.full-bleed {
  width: 100vw;
  max-width: 100vw;
  margin-left: 50%;
  transform: translateX(-50%);
  border-radius: 0;
}
.post-content figure.full-bleed img { width: 100%; max-width: 100%; border-radius: 0; }

.post-content figure { margin: 1.5rem 0; }
.post-content figure img { margin: 0; }
.post-content figcaption,
.post-content figcaption.caption {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.5rem;
}

.post-content aside.callout {
  margin: 1.75rem 0;
  padding: 1rem 1.25rem 1rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--bg-card);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text);
}
.post-content aside.callout > :first-child { margin-top: 0; }
.post-content aside.callout > :last-child  { margin-bottom: 0; }
.post-content aside.callout--info   { border-left-color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.post-content aside.callout--tip    { border-left-color: #10b981; background: rgba(16, 185, 129, 0.08); }
.post-content aside.callout--warn   { border-left-color: #f59e0b; background: rgba(245, 158, 11, 0.10); }
.post-content aside.callout--danger { border-left-color: #ef4444; background: rgba(239, 68, 68, 0.10); }

.post-content blockquote.pullquote {
  margin: 2rem auto;
  max-width: 600px;
  padding: 1.25rem 1.5rem;
  border-left: none;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  background: transparent;
  border-radius: 0;
  text-align: center;
  font-size: 1.2rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.6;
  color: var(--text);
}
.post-content blockquote.pullquote > :first-child { margin-top: 0; }
.post-content blockquote.pullquote > :last-child  { margin-bottom: 0; }

.post-content .columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 1.75rem 0;
}
.post-content .columns .column > :first-child { margin-top: 0; }
.post-content .columns .column > :last-child  { margin-bottom: 0; }

.post-content mark.highlight {
  background: rgba(245, 158, 11, 0.30);
  color: inherit;
  padding: 0 0.2em;
  border-radius: 3px;
}

.post-content .clearfix { clear: both; }

/* ---------------------------------------------------------------
   Responsive
   --------------------------------------------------------------- */
@media (max-width: 1100px) {
  .post-body__inner.has-toc {
    grid-template-columns: minmax(0, 1fr);
    column-gap: 0;
  }
  .post-toc { display: none; }
  .post-toc__mobile.is-needed { display: block; }
}

@media (max-width: 1024px) {
  .post-hero { padding: 8rem 0 2.5rem; }
  .post-body { padding: 2.5rem 0 5rem; }
}

@media (max-width: 768px) {
  .post-hero { padding: 7rem 0 2rem; }
  .post-body { padding: 2rem 0 4rem; }
  .post-content { font-size: 0.95rem; line-height: 1.75; }
  .post-content h2 { margin: 2rem 0 0.85rem; font-size: 1.35rem; }
  .post-content h3 { margin: 1.5rem 0 0.6rem; font-size: 1.1rem; }
  .post-content > p:first-child::first-letter { font-size: 3rem; padding-right: 0.5rem; }
  .post-content .columns { grid-template-columns: 1fr; gap: 1.25rem; }
}

@media (max-width: 480px) {
  .post-hero { padding: 6rem 0 1.5rem; }
  .post-body { padding: 1.5rem 0 3rem; }
  .post-meta { gap: 0.5rem; }
  .post-content { font-size: 0.92rem; }
  .post-content blockquote { padding: 0.85rem 1rem; }
  .post-content pre.code-block { margin-left: -0.5rem; margin-right: -0.5rem; border-radius: 0; border-left: none; border-right: none; }
}
