/* Post layout: heading block, left TOC, cover, tables, cards. */

#main.post {
  margin: 0 auto;
  max-width: 950px;
  width: 100%;
  padding: 1rem 1.3rem;
  position: relative;
  --post-caption-font-size: 13px;
  --media-breakout: 220px;
  --toc-width: 210px;
  --toc-gap: 34px;
}

@media (min-width: 1200px) { #main.post { max-width: 970px; } }
@media (min-width: 1400px) { #main.post { max-width: 990px; } }
@media (min-width: 1600px) { #main.post { max-width: 1010px; } }

/* Heading block ----------------------------------------------------------- */

#main.post .post-heading { text-align: center; }

#main.post .post-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.18;
  color: var(--fg);
  max-width: 820px;
  margin: 1.5rem auto 0;
}

#main.post .publish-metadata {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.15;
  color: var(--fg3);
  margin-top: 1rem;
}

#main.post .publish-metadata .author {
  color: var(--fg1);
  line-height: 1.5;
  max-width: 760px;
}

#main.post .publish-metadata .affiliations,
#main.post .publish-metadata .author-notes,
#main.post .publish-metadata .meta-sub {
  color: var(--fg3);
  font-size: 13px;
  line-height: 1.45;
  max-width: 760px;
}

#main.post .publish-metadata .author-notes { color: var(--fg4); }

#main.post .publish-metadata .meta-sub {
  font-size: 13.5px;
  margin-top: 0.35rem;
}

#main.post .publish-metadata .author sup,
#main.post .authors-list sup,
#main.post .authors-affiliations sup,
#main.post .authors-notes sup {
  color: var(--fg4);
  font-family: var(--font-serif);
  font-size: 0.72em;
  font-weight: 600;
  line-height: 0;
  margin-left: 0.04em;
}

#main.post .authors-list {
  margin: 0.25rem 0 0.45rem;
  color: var(--fg1);
}

#main.post .authors-affiliations,
#main.post .authors-notes {
  margin: 0.25rem 0;
  color: var(--fg3);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
}

/* Buttons ----------------------------------------------------------------- */

#main.post .post-links {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

#main.post .post-links a.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 5px 13px 5px 11px;
  border: 1px solid color-mix(in srgb, var(--fg4) 35%, var(--bg) 65%);
  border-radius: 999px;
  background: var(--bg);
  color: var(--fg2);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

#main.post .post-links a.btn:hover {
  color: var(--fg);
  border-color: color-mix(in srgb, var(--fg4) 70%, var(--bg) 30%);
  background: color-mix(in srgb, var(--fg4) 6%, var(--bg) 94%);
}

#main.post .post-links a.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Cover ------------------------------------------------------------------- */

#main.post .post-cover {
  text-align: center;
  margin: 2rem auto;
  max-width: min(100%, 820px);
}

#main.post .post-cover img.nora-cover {
  display: block;
  width: min(100%, 980px);
  height: auto;
  margin: 0.5rem auto;
  border: 1px solid color-mix(in srgb, var(--fg4) 16%, var(--bg) 84%);
  border-radius: 5px;
}

#main.post .post-cover .post-cover-caption {
  font-family: var(--font-sans);
  font-size: var(--post-caption-font-size);
  line-height: 1.45;
  text-align: center;
  color: var(--fg3);
  margin: 0.5rem auto 0;
  max-width: 760px;
}

/* Shell + left TOC -------------------------------------------------------- */

#main.post .post-content-shell {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 660px) minmax(0, 1fr);
}

#main.post .post-content-shell > article.content {
  grid-column: 2;
  width: 100%;
}

#main.post .left-toc {
  --toc-chevron-gutter: 1.3rem;
  box-sizing: border-box;
  grid-column: 1;
  justify-self: end;
  position: sticky;
  top: calc(var(--site-header-height) + 2rem);
  width: calc(var(--toc-width) + var(--toc-chevron-gutter));
  max-height: calc(100vh - var(--site-header-height) - 3rem);
  margin: 0 var(--toc-gap) 0 0;
  overflow-y: auto;
  padding-left: var(--toc-chevron-gutter);
  transform: translateY(10px);
  font-family: var(--font-sans);
  font-size: var(--post-caption-font-size);
  line-height: 1.4;
  color: var(--fg2);
  scrollbar-width: none;
  z-index: 1;
}

#main.post .left-toc::-webkit-scrollbar { display: none; }

#main.post .left-toc ul { list-style: none; padding-left: 0; margin: 0; }
#main.post .left-toc li { margin: 0 0 0.7rem 0; position: relative; }

#main.post .left-toc a {
  color: var(--fg4);
  text-decoration: none;
  transition: color 0.2s ease-in-out;
}

#main.post .left-toc a:hover {
  color: var(--fg1);
  text-decoration: underline;
  text-underline-offset: 2px;
}

#main.post .left-toc a.is-active,
#main.post .left-toc a[aria-current="location"],
#main.post .left-toc .toc-item.is-marker-target > a { color: var(--fg); }

#main.post .left-toc .toc-active-marker {
  --toc-active-marker-size: 4px;
  background: var(--fg);
  border-radius: 50%;
  height: var(--toc-active-marker-size);
  width: var(--toc-active-marker-size);
  left: calc((var(--toc-chevron-gutter) - var(--toc-active-marker-size)) / 2 - 0.05rem);
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translate3d(0, calc(var(--toc-active-marker-y, 0px) - 50%), 0);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.16s ease-in-out;
  will-change: transform, opacity;
}

#main.post .left-toc.has-active-marker .toc-active-marker { opacity: 1; }

@media (min-width: 1120px) {
  #main.post .left-toc { margin-right: calc(var(--toc-gap) + 72px); }
}

@media (max-width: 1000px) {
  #main.post .left-toc { display: none; }
  #main.post .post-content-shell { display: block; }
  #main.post article.content { margin: 0 auto; max-width: min(100%, 660px); }
}

/* Lists ------------------------------------------------------------------- */

#main.post article.content .tldr-list,
#main.post article.content .lesson-list {
  margin: 1rem 0 1.6rem;
  padding-left: 1.3rem;
}

#main.post article.content .tldr-list li,
#main.post article.content .lesson-list li { margin: 0.55rem 0; }

#main.post article.content p.lead {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--fg1);
}

/* Cards ------------------------------------------------------------------- */

#main.post .metric-grid,
#main.post .protocol-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border: 1px solid color-mix(in srgb, var(--fg4) 18%, var(--bg) 82%);
  border-radius: 4px;
  margin: 1.4rem 0 2rem;
  overflow: hidden;
}

#main.post .protocol-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

#main.post .metric-grid .card,
#main.post .protocol-grid .card {
  padding: 1rem 1.1rem;
  border-right: 1px solid color-mix(in srgb, var(--fg4) 14%, var(--bg) 86%);
  border-bottom: 1px solid color-mix(in srgb, var(--fg4) 14%, var(--bg) 86%);
  background: var(--bg);
}

#main.post .metric-grid .card:nth-child(3n),
#main.post .protocol-grid .card:nth-child(2n) { border-right: 0; }

#main.post .metric-grid .card:nth-last-child(-n+3),
#main.post .protocol-grid .card:nth-last-child(-n+2) { border-bottom: 0; }

#main.post .card-num {
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg4);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

#main.post .card-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

#main.post .card-text {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--fg3);
  margin: 0;
}

/* Formula ----------------------------------------------------------------- */

#main.post .formula {
  border-left: 3px solid color-mix(in srgb, var(--fg) 45%, var(--bg) 55%);
  padding: 0.8rem 1rem;
  margin: 1rem 0 1.4rem;
  background: color-mix(in srgb, var(--fg_code) 7%, var(--bg) 93%);
  font-family: var(--font-sans);
  color: var(--fg2);
}

#main.post .formula .formula-display {
  display: block;
  margin: 0.55rem 0 0.45rem;
  overflow-x: auto;
  font-family: 'Source Serif 4', 'Iowan Old Style BT', 'Times New Roman', serif;
  font-size: 16px;
  font-style: italic;
  font-variant-numeric: lining-nums;
  line-height: 1.65;
  color: var(--fg);
  white-space: nowrap;
}

#main.post .formula .formula-display sub,
#main.post .formula .formula-display sup { font-style: normal; line-height: 0; }

#main.post .formula .formula-note {
  display: block;
  color: var(--fg3);
  font-size: 13.5px;
  line-height: 1.5;
}

/* Wide benchmark tables --------------------------------------------------- */

#main.post .benchmark-table-wrap {
  width: min(1040px, calc(100vw - 48px));
  margin: 1.4rem 0 1.6rem 50%;
  overflow-x: auto;
  transform: translateX(-50%);
  border: 1px solid color-mix(in srgb, var(--fg4) 18%, var(--bg) 82%);
  border-radius: 4px;
  background: var(--bg);
}

#main.post table.benchmark-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 13.5px;
}

#main.post table.benchmark-table caption {
  caption-side: bottom;
  padding: 0.8rem 1rem 0.95rem;
  color: var(--fg3);
  font-size: 13px;
  line-height: 1.45;
  text-align: left;
}

#main.post table.benchmark-table thead th {
  text-align: left;
  font-weight: 600;
  color: var(--fg);
  padding: 0.6rem 0.55rem;
  border-bottom: 1.5px solid var(--fg);
  font-size: 12.5px;
  white-space: nowrap;
}

#main.post table.benchmark-table tbody td {
  padding: 0.58rem 0.55rem;
  border-bottom: 1px solid color-mix(in srgb, var(--fg4) 14%, var(--bg) 86%);
  color: var(--fg2);
  vertical-align: top;
  white-space: nowrap;
}

#main.post table.benchmark-table tbody tr.row-highlight td {
  background: color-mix(in srgb, var(--fg_code) 8%, var(--bg) 92%);
  color: var(--fg);
}

#main.post table.benchmark-table tbody tr.group td {
  background: color-mix(in srgb, var(--fg4) 8%, var(--bg) 92%);
  color: var(--fg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#main.post table.benchmark-table .num { font-variant-numeric: tabular-nums; }

#main.post table.benchmark-table .delta {
  color: var(--fg4);
  font-size: 0.86em;
  margin-left: 0.15em;
}

#main.post table.benchmark-table .delta.up { color: #4b7f36; }
#main.post table.benchmark-table .delta.down { color: #a8412f; }

/* Column-width tables ----------------------------------------------------- */

#main.post .evidence-table-wrap {
  margin: 1.1rem 0 1.45rem;
  overflow-x: auto;
  border: 1px solid color-mix(in srgb, var(--fg4) 18%, var(--bg) 82%);
  border-radius: 4px;
  background: var(--bg);
}

#main.post table.evidence-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: 13px;
}

#main.post table.evidence-table caption {
  caption-side: bottom;
  padding: 0.65rem 0.8rem 0.8rem;
  color: var(--fg3);
  font-size: 12.5px;
  line-height: 1.45;
  text-align: left;
}

#main.post table.evidence-table th,
#main.post table.evidence-table td {
  padding: 0.48rem 0.62rem;
  border-bottom: 1px solid color-mix(in srgb, var(--fg4) 14%, var(--bg) 86%);
  text-align: left;
  vertical-align: top;
}

#main.post table.evidence-table th {
  color: var(--fg);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

#main.post table.evidence-table td { color: var(--fg2); }
#main.post table.evidence-table tr:last-child td { border-bottom: 0; }
#main.post table.evidence-table tbody tr.row-highlight td {
  background: color-mix(in srgb, var(--fg_code) 8%, var(--bg) 92%);
  color: var(--fg);
}
#main.post table.evidence-table tbody tr.group td {
  background: color-mix(in srgb, var(--fg4) 8%, var(--bg) 92%);
  color: var(--fg);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Resources --------------------------------------------------------------- */

#main.post .resource-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.75fr) minmax(0, 1.25fr);
  gap: 1.25rem;
  align-items: start;
  margin: 1.2rem 0 1.8rem;
}

#main.post .paper-preview {
  display: block;
  width: 100%;
  border: 1px solid color-mix(in srgb, var(--fg4) 18%, var(--bg) 82%);
  border-radius: 4px;
}

#main.post .resource-box {
  border: 1px solid color-mix(in srgb, var(--fg4) 18%, var(--bg) 82%);
  border-radius: 4px;
  padding: 1rem 1.1rem;
}

#main.post .resource-box p { margin-bottom: 0.5rem; font-size: 1rem; }
#main.post .resource-box ul { margin: 0.4rem 0 0.9rem; font-size: 0.95rem; }
#main.post .resource-box li { margin: 0.3rem 0; }
#main.post .resource-box pre { margin: 0; }

@media (max-width: 760px) {
  #main.post .metric-grid,
  #main.post .protocol-grid,
  #main.post .resource-row { grid-template-columns: 1fr; }
  #main.post .metric-grid .card,
  #main.post .protocol-grid .card {
    border-right: 0 !important;
    border-bottom: 1px solid color-mix(in srgb, var(--fg4) 14%, var(--bg) 86%) !important;
  }
  #main.post .metric-grid .card:last-child,
  #main.post .protocol-grid .card:last-child { border-bottom: 0 !important; }
  #main.post .post-title { font-size: 25px; }
  #main.post .benchmark-table-wrap { width: calc(100vw - 32px); }
}

/* Refinements ------------------------------------------------------------- */

#main.post .formula .formula-display sub,
#main.post .formula .formula-display sup,
#main.post .card-text sub,
#main.post .card-text sup,
#main.post table sub,
#main.post table sup {
  font-family: inherit;
  font-weight: 400;
}

#main.post table.evidence-table td[rowspan] {
  border-right: 1px solid color-mix(in srgb, var(--fg4) 14%, var(--bg) 86%);
  vertical-align: middle;
  color: var(--fg);
}

#main.post .resource-box pre { padding-right: 1rem; }
#main.post .resource-box pre code { font-size: 12px; }
