/* Shared table-of-contents styles for blog posts and service pages. */
@media only screen and (min-width: 0rem) {
  .blog-with-toc {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .toc-sidebar,
  #service-sidebar {
    display: none;
  }

  .toc-mobile {
    display: flex;
    position: sticky;
    top: 60px;
    z-index: 100;
    background: #fff;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    white-space: nowrap;
    gap: 0.5rem;
    border-bottom: 1px solid #ebebeb;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    transition: padding-top 0.18s ease;
  }

  .toc-mobile.is-stuck {
    padding-top: 1.25rem;
  }

  .toc-mobile::-webkit-scrollbar {
    display: none;
  }

  .toc-mobile:empty {
    display: none;
  }

  .toc-chip {
    display: inline-block;
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    background: #f3f4f6;
    color: var(--bodyTextColor, #737373);
    text-decoration: none;
    font-size: 0.8125rem;
    border-radius: 20px;
    transition: background 0.2s ease, color 0.2s ease;
  }

  .toc-chip:hover,
  .toc-chip.active {
    background: var(--primary, #006940);
    color: var(--bodyTextColorWhite, #fff);
  }

  .toc-sidebar .cs-featured-group,
  #service-sidebar .cs-featured-group {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    border: 1px solid #ebebeb;
    background: #fff;
    padding: 1.75rem 1.5rem;
    border-radius: 0.5rem;
  }

  .toc-sidebar .cs-sidebar-header,
  #service-sidebar .cs-sidebar-header {
    display: block;
    color: var(--headerColor, #1a1a1a);
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 1rem;
    position: relative;
    text-align: center;
  }

  .toc-sidebar .cs-sidebar-header:after,
  #service-sidebar .cs-sidebar-header:after {
    content: "";
    display: block;
    width: 3rem;
    height: 3px;
    margin: 0.875rem auto 0;
    background: var(--headerColor, #1a1a1a);
  }

  .toc-sidebar .toc,
  #service-sidebar .toc {
    width: 100%;
  }

  .toc-sidebar .toc ol,
  #service-sidebar .toc ol {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.875rem;
  }

  .toc-sidebar .toc li,
  #service-sidebar .toc li {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .toc-sidebar .toc li > ol,
  #service-sidebar .toc li > ol {
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding-left: 1rem;
  }

  .toc-sidebar .toc a,
  #service-sidebar .toc a {
    display: inline-block;
    width: 100%;
    border-left: 2px solid transparent;
    color: var(--bodyTextColor, #737373);
    line-height: 1.45em;
    text-decoration: none;
    transition: color 0.2s ease-in-out, border-color 0.2s ease-in-out, padding 0.2s ease-in-out;
  }

  .toc-sidebar .toc a:hover,
  .toc-sidebar .toc a:focus-visible,
  #service-sidebar .toc a:hover,
  #service-sidebar .toc a:focus-visible {
    color: var(--primary, #006940);
  }

  .toc-sidebar .toc a.cs-toc-current,
  .toc-sidebar .toc a.active,
  #service-sidebar .toc a.cs-toc-current,
  #service-sidebar .toc a.active {
    border-left-color: var(--primary, #006940);
    color: var(--primary, #006940);
    font-weight: 700;
    padding-left: 0.5rem;
  }
}

@media only screen and (min-width: 48rem) {
  .toc-mobile {
    top: 70px;
  }
}

@media only screen and (min-width: 64rem) {
  .toc-mobile {
    display: none;
  }

  .toc-sidebar,
  #service-sidebar {
    display: block;
    flex: none;
    align-self: flex-start;
    position: sticky;
    top: 6rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    margin: 0;
    width: 220px;
    max-width: none;
  }

  .toc-sidebar .cs-featured-group,
  #service-sidebar .cs-featured-group {
    padding: 1.5rem 1.25rem;
  }

  .toc-sidebar .cs-sidebar-header,
  #service-sidebar .cs-sidebar-header {
    font-size: 1rem;
    text-align: left;
  }

  .toc-sidebar .cs-sidebar-header:after,
  #service-sidebar .cs-sidebar-header:after {
    margin-left: 0;
    margin-right: auto;
  }

  /* `.blog-with-toc` is the outer container; the hero (breadcrumb + header
     + image) sits at full width, then `.blog-article-body` is the 3-column
     grid (rail | body | sidebar) that starts right below the image. */
  .blog-with-toc {
    display: block;
  }

  .blog-with-toc .blog-article {
    max-width: none;
  }

  .blog-article-body {
    display: grid;
    grid-template-columns: 3.25rem minmax(0, 1fr) 220px;
    grid-template-areas: "rail main sidebar";
    gap: 1.5rem;
    align-items: start;
    margin-top: 1.5rem;
  }

  .blog-article-body > .post-share-rail { grid-area: rail; }
  .blog-article-body > .main-content { grid-area: main; min-width: 0; }
  .blog-article-body > .toc-sidebar { grid-area: sidebar; }
}

@media only screen and (min-width: 81.25rem) {
  .toc-sidebar,
  #service-sidebar {
    width: 240px;
  }

  .blog-article-body {
    grid-template-columns: 3.25rem minmax(0, 1fr) 240px;
    gap: 2rem;
  }
}

@media only screen and (min-width: 100rem) {
  .toc-sidebar,
  #service-sidebar {
    width: 260px;
  }

  .blog-article-body {
    grid-template-columns: 3.5rem minmax(0, 1fr) 260px;
    gap: 2.5rem;
  }
}

@media only screen and (min-width: 130rem) {
  .toc-sidebar,
  #service-sidebar {
    width: 280px;
  }

  .blog-article-body {
    grid-template-columns: 3.5rem minmax(0, 1fr) 280px;
    gap: 3rem;
  }
}

@media only screen and (min-width: 160rem) {
  .toc-sidebar,
  #service-sidebar {
    width: 320px;
  }

  .blog-article-body {
    grid-template-columns: 4rem minmax(0, 1fr) 320px;
    gap: 3.5rem;
  }
}

@media only screen and (min-width: 0rem) {
  body.dark-mode .toc-sidebar .cs-featured-group,
  body.dark-mode #service-sidebar .cs-featured-group {
    border-color: rgba(255, 255, 255, 0.12);
    background: var(--medium, #1e293b);
  }

  body.dark-mode .toc-sidebar .cs-sidebar-header,
  body.dark-mode #service-sidebar .cs-sidebar-header {
    color: var(--bodyTextColorWhite, #fff);
  }

  body.dark-mode .toc-sidebar .cs-sidebar-header:after,
  body.dark-mode #service-sidebar .cs-sidebar-header:after {
    background-color: var(--bodyTextColorWhite, #fff);
  }

  body.dark-mode .toc-sidebar .toc a,
  body.dark-mode #service-sidebar .toc a {
    color: var(--bodyTextColorWhite, #fff);
    opacity: 0.75;
  }

  body.dark-mode .toc-sidebar .toc a:hover,
  body.dark-mode .toc-sidebar .toc a:focus-visible,
  body.dark-mode #service-sidebar .toc a:hover,
  body.dark-mode #service-sidebar .toc a:focus-visible {
    color: var(--primaryLight, #00bd74);
    opacity: 1;
  }

  body.dark-mode .toc-sidebar .toc a.cs-toc-current,
  body.dark-mode .toc-sidebar .toc a.active,
  body.dark-mode #service-sidebar .toc a.cs-toc-current,
  body.dark-mode #service-sidebar .toc a.active {
    border-left-color: var(--primaryLight, #00bd74);
    color: var(--primaryLight, #00bd74);
    opacity: 1;
  }

  body.dark-mode .toc-mobile {
    background: var(--dark, #0d1411);
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  body.dark-mode .toc-chip {
    background: var(--medium, #1a221d);
    color: rgba(255, 255, 255, 0.78);
  }

  body.dark-mode .toc-chip:hover,
  body.dark-mode .toc-chip.active {
    background: var(--primaryLight, #00bd74);
    color: var(--dark, #0d1411);
  }
}
