/* =============================================================
   Article TOC & Social Share  -  v2.0
   Desktop (>=1200px): TOC in the LEFT gutter, share icons in the
   RIGHT gutter of the article text column, both sticky.
   Below 1200px: TOC = collapsible bar (fixes to the top while
   scrolling down, replacing the header), share icons = bottom pill.
   ============================================================= */
:root{--ats-cw:720px;}

/* ---------------- Table of contents ---------------- */
.ats-toc-wrap{display:block;position:relative;margin:0 0 24px;box-sizing:border-box;}
.ats-toc{
  position:relative;box-sizing:border-box;width:100%;
  background:#f1f1f1 !important;border-radius:4px !important;
  font-family:inherit !important;color:#111;
}
.ats-toc-head{
  display:none;width:100%;min-height:44px;margin:0;padding:12px 16px;
  align-items:center;justify-content:space-between;gap:10px;
  background:transparent;border:0;border-radius:inherit;cursor:pointer;text-align:left;
  font-family:inherit;font-weight:700;font-size:15px;line-height:1.3;color:#111;
  -webkit-tap-highlight-color:transparent;
}
.ats-toc-arrow{flex:none;font-size:13px;transition:transform .2s ease;}
.ats-toc.ats-open .ats-toc-arrow{transform:rotate(180deg);}

.ats-toc .ats-toc-list{list-style:none !important;margin:0 !important;padding:16px 18px !important;}
.ats-toc .ats-item{
  list-style:none !important;margin:0 !important;padding:6px 0 !important;
  font-size:14px !important;line-height:1.4 !important;font-weight:400 !important;color:#333 !important;
}
.ats-toc .ats-item.ats-l3{padding-left:16px !important;font-size:13px !important;}
.ats-toc .ats-item a{color:#333 !important;text-decoration:none !important;position:relative;}
.ats-toc .ats-item a:hover{text-decoration:underline !important;}
.ats-toc .ats-item.ats-active{font-weight:700 !important;}
.ats-toc .ats-item.ats-active a{color:#000 !important;}
.ats-toc .ats-item.ats-active::before{
  content:"\25B8";color:#d0021b;margin-right:6px;margin-left:-14px;display:inline-block;
}

/* ---------------- Share icons (shared look) ---------------- */
.ats-share{display:flex;flex-direction:column;gap:12px;box-sizing:border-box;}
.ats-btn{
  position:relative;width:42px;height:42px;margin:0;padding:0;border:0;border-radius:50%;
  display:flex;align-items:center;justify-content:center;flex:none;
  text-decoration:none !important;cursor:pointer;line-height:1;
  box-shadow:0 2px 6px rgba(0,0,0,.15);
  transition:transform .15s ease,box-shadow .15s ease;
  -webkit-tap-highlight-color:transparent;
}
.ats-btn:hover{transform:scale(1.08);box-shadow:0 4px 10px rgba(0,0,0,.22);}
.ats-btn svg{display:block;}
.ats-pinterest{background:#E60023;}
.ats-facebook{background:#1877F2;}
.ats-twitter{background:#000;}
.ats-copylink{background:#F0653F;}
.ats-email{background:#C6549E;}
.ats-tip{
  position:absolute;top:50%;right:calc(100% + 8px);transform:translateY(-50%);
  background:#222;color:#fff;font-size:12px;line-height:1.2;font-weight:500;
  padding:5px 9px;border-radius:4px;white-space:nowrap;
  opacity:0;pointer-events:none;transition:opacity .2s ease;
}
.ats-tip.ats-show{opacity:1;}

/* headings land below the sticky header when reached through a link */
body.single-post h2[id],body.single-post h3[id]{scroll-margin-top:100px;}

/* =============================================================
   DESKTOP  >= 1200px  -  side rails
   ============================================================= */
@media (min-width:1200px){
  .ats-toc-wrap{
    --ats-w:clamp(170px, calc((100vw - var(--ats-cw)) / 2 - 76px), 240px);
    --ats-gap:28px;
    float:left;width:var(--ats-w);
    margin:4px var(--ats-gap) 20px calc(-1 * (var(--ats-w) + var(--ats-gap)));
    position:-webkit-sticky;position:sticky;top:100px;z-index:2;
  }
  body.admin-bar .ats-toc-wrap,body.admin-bar .ats-share{top:132px;}
  .ats-toc{max-height:calc(100vh - 130px);overflow-y:auto;overscroll-behavior:contain;scrollbar-width:thin;}
  .ats-toc-head{display:none !important;}

  .ats-share{
    float:right;width:42px;
    /* pushed further right so the icons line up under the header menu icon */
    margin:4px calc(-50vw + 484px) 20px 28px;
    /* vertically centred in the viewport (5 icons + gaps = 258px) */
    position:-webkit-sticky;position:sticky;top:calc(50vh - 129px);z-index:2;
  }
  body.admin-bar .ats-share{top:calc(50vh - 97px);}
}

/* =============================================================
   MOBILE / TABLET  < 1200px
   ============================================================= */
@media (max-width:1199px){
  .ats-toc-wrap{clear:both;float:none;width:auto;}
  .ats-toc-head{display:flex;}
  .ats-toc .ats-toc-list{display:none !important;}
  .ats-toc.ats-open .ats-toc-list{
    display:block !important;position:absolute !important;left:0;right:0;top:100%;width:100%;
    max-height:65vh;max-height:65dvh;overflow-y:auto;overscroll-behavior:contain;
    background:#f1f1f1;box-shadow:0 6px 12px rgba(0,0,0,.18);box-sizing:border-box;
    border-radius:0 0 4px 4px;
  }

  /* bar fixed to the top (JS adds .ats-fixed after the user scrolled past it) */
  .ats-toc.ats-fixed{
    position:fixed !important;top:var(--ats-top,0px);left:0;right:0;width:100%;z-index:140;
    border-radius:0 !important;box-shadow:0 2px 6px rgba(0,0,0,.12);
    transition:transform .22s ease,visibility 0s;
  }
  .ats-toc.ats-fixed.ats-open .ats-toc-list{border-radius:0;}
  .ats-toc.ats-fixed.ats-away{
    transform:translate3d(0,-110%,0);visibility:hidden;pointer-events:none;
    transition:transform .22s ease,visibility 0s linear .22s;
  }

  /* the theme header slides away while the TOC bar is shown */
  .ats-hdr-ready{transition:transform .22s ease;}
  .ats-hdr-away{
    transform:translate3d(0,-100%,0) !important;box-shadow:none !important;
    visibility:hidden;pointer-events:none;
    transition:transform .22s ease,visibility 0s linear .22s;
  }

  /* share icons: bottom pill */
  .ats-share{
    position:fixed;left:50%;right:auto;bottom:calc(15px + env(safe-area-inset-bottom,0px));
    transform:translateX(-50%);z-index:130;
    flex-direction:row;gap:12px;padding:8px 10px;
    background:rgba(255,255,255,.95);border-radius:30px;box-shadow:0 2px 10px rgba(0,0,0,.15);
    max-width:calc(100vw - 24px);
    transition:opacity .2s ease,visibility 0s;
  }
  .ats-share.ats-off{opacity:0;visibility:hidden;pointer-events:none;transition:opacity .2s ease,visibility 0s linear .2s;}
  .ats-btn{width:36px;height:36px;}
  .ats-tip{top:auto;right:auto;bottom:calc(100% + 12px);left:50%;transform:translateX(-50%);}
}

@media (prefers-reduced-motion:reduce){
  .ats-toc.ats-fixed,.ats-hdr-ready,.ats-hdr-away,.ats-share,.ats-btn,.ats-toc-arrow{transition:none !important;}
}
@media print{.ats-toc-wrap,.ats-share{display:none !important;}}
