/* V36 — restore consistent in-page navigation and tighten interior-page rhythm. */

/* Auto-generated in-page rail for content pages that did not retain the historical .toc. */
.auto-toc{
  position:fixed;
  top:108px;
  left:max(48px, calc((100vw - 1240px)/2 + 48px));
  z-index:24;
  width:218px;
  max-height:calc(100vh - 142px);
  overflow:auto;
  padding:4px 18px 18px 0;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transform:translateY(8px);
  transition:opacity .22s ease,transform .22s ease,visibility .22s;
  scrollbar-width:thin;
  background:linear-gradient(90deg,var(--bg) 78%,rgba(247,244,236,0));
}
.auto-toc.is-visible{opacity:1;visibility:visible;pointer-events:auto;transform:none}
.auto-toc .toc-title{
  margin:0 0 12px;
  font-family:var(--mono);
  font-size:10px;
  line-height:1.4;
  letter-spacing:.16em;
  text-transform:uppercase;
  color:var(--ink);
  font-weight:600;
}
.auto-toc a{
  display:block;
  padding:7px 0 7px 14px;
  border-inline-start:1px solid var(--line);
  color:var(--muted);
  font-size:12.5px;
  line-height:1.35;
  transition:color .18s ease,border-color .18s ease,padding .18s ease;
}
.auto-toc a:hover,.auto-toc a.on{color:var(--ink);border-color:var(--gold);padding-inline-start:18px}

/* Reserve the historical left-hand column only where the page actually has the rail. */
@media(min-width:1101px){
  body.has-auto-toc .with-auto-toc-content > .wrap{
    padding-inline-start:330px;
  }
  body.rtl.has-auto-toc .with-auto-toc-content > .wrap{
    padding-inline-start:48px;
    padding-inline-end:330px;
  }
  body.rtl .auto-toc{
    left:auto;
    right:max(48px, calc((100vw - 1240px)/2 + 48px));
    padding:4px 0 18px 18px;
    background:linear-gradient(270deg,var(--bg) 78%,rgba(247,244,236,0));
  }
}

/* On tablet/mobile the same navigation becomes a compact block at the start of the page. */
@media(max-width:1100px){
  .auto-toc{
    position:relative;
    inset:auto;
    width:auto;
    max-width:calc(100% - 48px);
    max-height:none;
    margin:26px auto 0;
    padding:18px 20px;
    border:1px solid var(--line);
    background:var(--bg-2);
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:none;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:0 18px;
  }
  .auto-toc .toc-title{grid-column:1/-1;margin-bottom:8px}
  .auto-toc a{font-size:12px;padding:7px 0 7px 11px}
}
@media(max-width:620px){
  .auto-toc{max-width:calc(100% - 32px);margin-top:18px;padding:16px;grid-template-columns:1fr}
}

/* The pages that lost the left rail were also using oversized section padding.
   Tighten only those substantive sections; homepage and existing editorial pages remain untouched. */
body.has-auto-toc .with-auto-toc-content{
  padding-top:68px;
  padding-bottom:68px;
}
body.has-auto-toc .with-auto-toc-content + .with-auto-toc-content{
  padding-top:48px;
}
body.has-auto-toc .with-auto-toc-content .sechead{
  margin-bottom:34px;
}
body.has-auto-toc .with-auto-toc-content .sechead h2{
  margin-top:16px;
}
@media(max-width:1100px){
  body.has-auto-toc .with-auto-toc-content{padding-top:58px;padding-bottom:58px}
  body.has-auto-toc .with-auto-toc-content + .with-auto-toc-content{padding-top:38px}
}
@media(max-width:760px){
  body.has-auto-toc .with-auto-toc-content{padding-top:44px;padding-bottom:44px}
  body.has-auto-toc .with-auto-toc-content + .with-auto-toc-content{padding-top:30px}
  body.has-auto-toc .with-auto-toc-content .sechead{margin-bottom:26px}
}

/* Anchor jumps must clear the persistent header. */
body.has-auto-toc h2[id]{scroll-margin-top:112px}

/* Heading-only template sections should read as introductions, not empty panels. */
body.has-auto-toc .with-auto-toc-content.toc-heading-only{
  padding-top:42px;
  padding-bottom:8px;
}
body.has-auto-toc .with-auto-toc-content.toc-heading-only + .with-auto-toc-content{
  padding-top:28px;
}
body.has-auto-toc .toc-heading-only .sechead{margin-bottom:0}
@media(max-width:760px){
  body.has-auto-toc .with-auto-toc-content.toc-heading-only{padding-top:30px;padding-bottom:4px}
  body.has-auto-toc .with-auto-toc-content.toc-heading-only + .with-auto-toc-content{padding-top:20px}
}

/* RTL desktop mega menus must open inward rather than increasing document width. */
@media(min-width:1181px){
  body.rtl .mega-item .mega-dd,
  html[dir="rtl"] .mega-item .mega-dd{
    left:auto!important;
    right:50%!important;
    transform:translateX(36%)!important;
    max-width:min(900px,calc(100vw - 32px))!important;
  }
}
@media(min-width:1101px){
  html[dir="rtl"] body.has-auto-toc .with-auto-toc-content > .wrap{
    padding-inline-start:48px;
    padding-inline-end:330px;
  }
  html[dir="rtl"] .auto-toc{
    left:auto;
    right:max(48px, calc((100vw - 1240px)/2 + 48px));
    padding:4px 0 18px 18px;
    background:linear-gradient(270deg,var(--bg) 78%,rgba(247,244,236,0));
  }
}

/* Restore the shared three-column evidence/card grid lost from the global stylesheet. */
.cards3{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:0;
  border-top:1px solid var(--line);
}
.cards3 > .rcard{min-width:0}
.cards3 > .rcard:nth-child(3n){border-inline-end:0}
@media(max-width:1000px){
  .cards3{grid-template-columns:repeat(2,minmax(0,1fr))}
  .cards3 > .rcard:nth-child(3n){border-inline-end:1px solid var(--line)}
  .cards3 > .rcard:nth-child(2n){border-inline-end:0}
}
@media(max-width:620px){
  .cards3{grid-template-columns:1fr}
  .cards3 > .rcard{border-inline-end:0!important}
}
