/* ============================================================
   Blog styles. Loaded after style.css and reuses its tokens.
   ============================================================ */

/* reading progress rail, sits under the sticky header */
.read-bar {
  position: fixed;
  top: 68px;
  left: 0;
  z-index: 899;
  width: 100%;
  height: 4px;
  background: rgba(17, 13, 10, 0.6);
}

.read-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #c95724, #d98938, #ffd18e);
}

/* ---------- shared page furniture ---------- */
.page-head {
  padding: clamp(52px, 8vw, 92px) 0 clamp(28px, 4vw, 44px);
}

.back-link {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.back-link:hover {
  color: var(--accent);
}

/* ---------- blog index ---------- */
.post-list {
  display: grid;
  gap: 18px;
  padding-bottom: clamp(36px, 5vw, 56px);
}

/* Home page section inherits .section padding; keep the list tight. */
#blog .post-list {
  padding-bottom: 0;
  margin-top: 22px;
  max-width: 820px;
}

.post-card {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(48, 33, 22, 0.96), rgba(34, 24, 17, 0.98));
  border: 1px solid rgba(217, 137, 56, 0.26);
  border-left: 4px solid var(--accent);
  box-shadow: 6px 6px 0 var(--shadow);
}

.post-card:hover {
  color: inherit;
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 var(--shadow);
}

.post-card h3 {
  margin: 8px 0 10px;
  font-size: clamp(11px, 1.4vw, 13px);
  line-height: 1.55;
}

.post-card:hover h3 {
  color: var(--accent);
}

.post-card p {
  margin: 0;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.55;
}

.post-card .card-cta {
  margin-top: 12px;
  color: #ffd18e;
  font-weight: 700;
  font-size: 13.5px;
}

.post-card-body {
  min-width: 0;
}

.card-thumb {
  margin: 0;
  border: 1px solid rgba(217, 137, 56, 0.3);
  /* Matches the figures' own background so letterboxing is invisible. */
  background: #f7f2ea;
  overflow: hidden;
  align-self: stretch;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  min-height: 120px;
  max-height: 150px;
  object-fit: cover;
  object-position: 50% 45%;
}

/* Blog index page can stretch a bit wider; still compact. */
.page-head + .post-list {
  max-width: 820px;
  padding-bottom: clamp(64px, 9vw, 104px);
}

@media (max-width: 640px) {
  .post-card {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .card-thumb img {
    min-height: 0;
    max-height: 140px;
    aspect-ratio: 16 / 7;
  }
}

/* meta rows: date / read time / tags */
.post-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.post-meta li {
  display: flex;
  align-items: center;
  gap: 14px;
}

.post-meta li + li::before {
  content: '';
  width: 4px;
  height: 4px;
  background: var(--faint);
}

.post-meta .tag {
  padding: 3px 9px;
  color: #ffd18e;
  background: rgba(217, 137, 56, 0.12);
  border: 1px solid rgba(217, 137, 56, 0.34);
  font-size: 12px;
}

/* ---------- post page ---------- */
.post-head {
  padding: clamp(46px, 7vw, 80px) 0 clamp(26px, 4vw, 40px);
  border-bottom: 1px solid rgba(217, 137, 56, 0.2);
}

.post-title {
  margin: 0 0 22px;
  max-width: 24ch;
  font-size: clamp(21px, 3.4vw, 36px);
  line-height: 1.42;
  color: #ffe6bd;
  text-shadow: 4px 4px 0 rgba(87, 48, 23, 0.85);
}

.standfirst {
  max-width: 68ch;
  margin: 0 0 26px;
  color: var(--text);
  font-size: clamp(17px, 2vw, 20px);
}

/* The TOC comes first in the markup so it is reachable early, but sits in the
   right-hand column on wide screens. */
.post-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
  padding: clamp(34px, 5vw, 56px) 0 clamp(64px, 9vw, 104px);
}

.post-layout > .post-body {
  grid-area: 1 / 1;
}

.post-layout > .post-toc {
  grid-area: 1 / 2;
}

/* ---------- table of contents ---------- */
.post-toc {
  position: sticky;
  top: 100px;
  padding: 20px;
  background: rgba(38, 27, 19, 0.72);
  border: 1px solid rgba(217, 137, 56, 0.22);
  font-size: 13.5px;
}

.post-toc p {
  margin: 0 0 14px;
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.post-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: toc;
}

.post-toc li {
  counter-increment: toc;
  margin-bottom: 9px;
  line-height: 1.45;
}

.post-toc a {
  display: flex;
  gap: 9px;
  color: var(--muted);
}

.post-toc a::before {
  content: counter(toc, decimal-leading-zero);
  color: var(--faint);
}

.post-toc a:hover,
.post-toc a.active {
  color: #ffd18e;
}

.post-toc a.active::before {
  color: var(--accent);
}

/* ---------- article body ---------- */
.post-body {
  max-width: 74ch;
  font-size: clamp(16.5px, 1.9vw, 18px);
}

.post-body > h2 {
  margin: clamp(48px, 6vw, 64px) 0 20px;
  padding-top: 4px;
  font-size: clamp(15px, 2.1vw, 19px);
  line-height: 1.5;
  scroll-margin-top: 96px;
}

.post-body > h2:first-child {
  margin-top: 0;
}

.post-body h3 {
  margin: 36px 0 12px;
  font-size: 13px;
  color: #ffd18e;
  scroll-margin-top: 96px;
}

.post-body p {
  margin: 0 0 20px;
}

.post-body ul,
.post-body ol {
  margin: 0 0 22px;
  padding-left: 24px;
}

.post-body li {
  margin-bottom: 10px;
}

.post-body strong {
  color: #ffe0af;
}

.post-body a:not(.btn) {
  color: #ffd18e;
  border-bottom: 1px solid rgba(217, 137, 56, 0.55);
  font-weight: 600;
}

.post-body a:not(.btn):hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.post-body hr {
  height: 0;
  margin: 44px 0;
  border: 0;
  border-top: 1px solid rgba(217, 137, 56, 0.2);
}

.lede {
  color: #ffe6bd;
  font-size: clamp(17.5px, 2.1vw, 20.5px);
}

/* ---------- figures ---------- */
.post-figure {
  margin: 34px 0;
}

.post-figure img {
  width: 100%;
  background: #f7f2ea;
  border: 2px solid var(--line);
  box-shadow: 6px 6px 0 var(--shadow);
}

.post-figure.dark img {
  background: #120e0a;
}

/* Small native renders (the 96x96 planner gif) upscale cleanly only when blocky. */
.post-figure.pixel img {
  width: min(360px, 100%);
  margin-inline: auto;
  image-rendering: pixelated;
}

.post-figure figcaption {
  margin-top: 14px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.post-figure figcaption b {
  color: #ffd18e;
}

/* ---------- stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
  margin: 30px 0;
}

.stat {
  padding: 16px 18px;
  background: rgba(38, 27, 19, 0.8);
  border: 1px solid rgba(217, 137, 56, 0.24);
  border-top: 3px solid var(--accent);
}

.stat b {
  display: block;
  color: #ffe6bd;
  font-family: var(--font-pixel);
  font-size: 15px;
  line-height: 1.3;
}

.stat span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

/* ---------- callout ---------- */
.callout {
  margin: 30px 0;
  padding: 20px 22px;
  background: rgba(201, 87, 36, 0.09);
  border: 1px solid rgba(217, 137, 56, 0.3);
  border-left: 4px solid var(--accent-2);
  font-size: 16px;
}

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

.callout .callout-label {
  display: block;
  margin-bottom: 10px;
  color: var(--accent);
  font-family: var(--font-pixel);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------- tables ---------- */
.table-wrap {
  margin: 28px 0;
  overflow-x: auto;
  border: 1px solid rgba(217, 137, 56, 0.24);
}

.post-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

.post-body th,
.post-body td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(217, 137, 56, 0.16);
  white-space: nowrap;
}

.post-body th {
  color: #ffd18e;
  background: rgba(48, 33, 22, 0.95);
  font-weight: 700;
}

.post-body tbody tr:nth-child(even) {
  background: rgba(38, 27, 19, 0.5);
}

.post-body tbody tr:last-child td {
  border-bottom: 0;
}

.post-body td.win {
  color: #ffe0af;
  font-weight: 700;
}

/* ---------- code ---------- */
.post-body code {
  padding: 2px 6px;
  color: #ffd18e;
  background: rgba(17, 13, 10, 0.8);
  border: 1px solid rgba(217, 137, 56, 0.2);
  font-size: 0.9em;
  white-space: nowrap;
}

.post-body pre {
  margin: 26px 0;
  padding: 18px;
  overflow-x: auto;
  background: #100c09;
  border: 1px solid rgba(217, 137, 56, 0.24);
  box-shadow: 5px 5px 0 var(--shadow);
  font-size: 13.5px;
  line-height: 1.65;
}

.post-body pre code {
  padding: 0;
  color: var(--text);
  background: none;
  border: 0;
  white-space: pre;
}

.post-body pre .c {
  color: var(--faint);
}

/* the two-term loss, rendered without a math library */
.equation {
  margin: 30px 0;
  padding: 22px 18px;
  text-align: center;
  background: rgba(17, 13, 10, 0.7);
  border: 1px solid rgba(217, 137, 56, 0.24);
  color: #ffe6bd;
  font-size: clamp(15px, 2vw, 18px);
  line-height: 2;
}

.equation .term {
  color: var(--accent);
}

.equation small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- references ---------- */
.ref-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 15px;
}

.ref-list li {
  padding-left: 26px;
  margin-bottom: 12px;
  text-indent: -26px;
  color: var(--muted);
  line-height: 1.6;
}

/* ---------- post footer ---------- */
.post-end {
  margin-top: clamp(44px, 6vw, 64px);
  padding-top: 28px;
  border-top: 1px solid rgba(217, 137, 56, 0.22);
}

.post-end h2 {
  margin-bottom: 14px;
  font-size: 13px;
}

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  .post-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .post-layout > .post-toc {
    grid-area: 1 / 1;
    position: static;
    max-width: 74ch;
  }

  .post-layout > .post-body {
    grid-area: 2 / 1;
  }
}

@media (max-width: 520px) {
  .read-bar {
    top: 60px;
  }

  .post-toc {
    top: 84px;
  }

  .post-body,
  .callout {
    font-size: 15.5px;
  }

  .post-figure img {
    box-shadow: 4px 4px 0 var(--shadow);
  }
}
