/* ============================================================
   ty-blog-toc — values from the TrustYou Design System
   Desktop (>= 960px): sticky side column.
   Mobile/tablet (< 960px): collapsible box above the featured image.
   ============================================================ */
.ty-toc {
  --ty-toc-text:    #616161;
  --ty-toc-line:    #E0E0E0;
  --ty-toc-accent:  #6847F5;
  --ty-toc-hover:   #4E2BD9;
  --ty-toc-ink:     #080032;
  --ty-toc-surface: #F5F5F5;

  display: none;   /* shown only with JS, see below */
  font-family: Roboto, Helvetica, Arial, sans-serif;
  min-width: 0;
}
/* Without :has() the template cannot build the grid, so the TOC stays out entirely. */
@supports selector(:has(*)) {
  .ty-js .ty-toc--eligible { display: block; }
}

.ty-toc__label {
  margin: 0 0 16px;
  font-size: 12px; font-weight: 500; line-height: 1.4;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--ty-toc-text);
}

.ty-toc__list,
.ty-toc__list ol { list-style: none; margin: 0; padding: 0; }
.ty-toc__list { border-left: 2px solid var(--ty-toc-line); }
.ty-toc__list li { margin: 0; }

.ty-toc__link {
  position: relative;
  display: block;
  padding: 8px 0 8px 16px;
  font-size: 14px; line-height: 1.45; font-weight: 400;
  color: var(--ty-toc-text);
  text-decoration: none;
  transition: color .15s ease;
}
/* H3 entries (H2 + H3 mode) stay on the same rail, indented one step */
.ty-toc__list ol .ty-toc__link,
.ty-toc__item--h3 > .ty-toc__link { padding-left: 32px; }

.ty-toc__link[aria-current="location"] {
  color: var(--ty-toc-accent);
  font-weight: 500;
}
/* 4px bar centred over the 2px grey rail */
.ty-toc__link[aria-current="location"]::before {
  content: "";
  position: absolute; top: 0; bottom: 0; left: -3px;
  width: 4px; border-radius: 2px;
  background: var(--ty-toc-accent);
}
.ty-toc__link:hover { color: var(--ty-toc-hover); }

.ty-toc__top {
  display: inline-block;
  margin-top: 24px;
  font-size: 14px; font-weight: 500; line-height: 1.45;
  color: var(--ty-toc-accent);
  text-decoration: none;
  transition: color .15s ease;
}
.ty-toc__top:hover { color: var(--ty-toc-hover); }

.ty-toc a:focus-visible,
.ty-toc__toggle:focus-visible {
  outline: 2px solid var(--ty-toc-accent);
  outline-offset: -2px;
  border-radius: 4px;
}

/* Headings the TOC points at land below the fixed site header.
   --ty-toc-top = measured header height + 24px, set by module.js. */
[data-ty-toc-target] { scroll-margin-top: var(--ty-toc-top, 88px); }
[data-ty-toc-target][tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

/* ---------- Desktop ---------- */
@media (min-width: 960px) {
  .ty-toc {
    position: sticky;
    top: var(--ty-toc-top, 88px);
    max-height: calc(100vh - var(--ty-toc-top, 88px) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 2px 4px 2px 3px;   /* room for the active bar and focus ring inside the scroll box */
  }
  .ty-toc__toggle { display: none; }
}

/* ---------- Mobile / tablet ---------- */
@media (max-width: 959.98px) {
  .ty-toc {
    margin: 0 0 24px;
    background: var(--ty-toc-surface);
    border-radius: 8px;
  }
  .ty-toc__toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    width: 100%; min-height: 52px; padding: 0 16px;
    margin: 0; border: 0; border-radius: 8px;
    background: none; cursor: pointer; text-align: left;
    font: inherit; color: inherit;
    -webkit-tap-highlight-color: transparent;
  }
  .ty-toc__toggle-label {
    font-size: 15px; font-weight: 700; line-height: 1.3;
    color: var(--ty-toc-ink);
  }
  .ty-toc__toggle-meta {
    display: inline-flex; align-items: center; gap: 6px; flex: none;
    font-size: 13px; font-weight: 500; white-space: nowrap;
    color: var(--ty-toc-accent);
  }
  .ty-toc__chev { transition: transform .2s ease; }
  .ty-toc.is-open .ty-toc__chev { transform: rotate(180deg); }

  .ty-toc__panel { display: none; padding: 0 16px 4px; }
  .ty-toc.is-open .ty-toc__panel { display: block; }

  .ty-toc__label,
  .ty-toc__top { display: none; }

  .ty-toc__list { border-left: 0; }
  .ty-toc__link {
    display: flex; align-items: center;
    min-height: 44px;
    padding: 12px 0;
    border-top: 1px solid var(--ty-toc-line);
    color: var(--ty-toc-accent);
  }
  .ty-toc__list ol .ty-toc__link,
  .ty-toc__item--h3 > .ty-toc__link { padding-left: 16px; }
  .ty-toc__link[aria-current="location"]::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ty-toc__link, .ty-toc__top, .ty-toc__chev { transition: none; }
}
