/* ============================================================
   MEA Reviews — Sticky TOC (оглавление, right rail · desktop)
   "On this page" table of contents for a single review. On
   desktop it sticks in the right column with a scroll-spy active
   state and a thin reading-progress line; on mobile it folds into
   a tap-to-open <details> panel. Light "tech / computer" theme
   matching hero-intro / rating-criteria / faq / footer. Tokens
   are scoped to .mea-toc so they never clash with page :root vars.
   Self-contained — no external CSS; the inline scroll-spy JS is
   optional progressive enhancement.
   ============================================================ */

.mea-toc {
  /* ---- Design tokens (mirror of rating-criteria / faq) ---- */
  --toc-surface: #ffffff;
  --toc-surface-2: #f4f4f4;
  --toc-border: #e0e0e0;
  --toc-text: #1f2733;
  --toc-muted: #5b6676;
  --toc-faint: #8a94a6;
  --toc-accent: #0f62fe;      /* electric blue */
  --toc-accent-2: #06b6d4;    /* cyan */

  --toc-radius: 0;
  --toc-radius-sm: 0;
  --toc-top: 96px;            /* sticky offset — clear the site header */

  --toc-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --toc-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --toc-duration: 200ms;
  --toc-ease: cubic-bezier(0.16, 1, 0.3, 1);

  display: block;
  font-family: var(--toc-sans);
  color: var(--toc-text);
  background: var(--toc-surface);
  border: 1px solid var(--toc-border);
  border-radius: var(--toc-radius);
  box-shadow: none;
  overflow: hidden;
}

/* ---- Header / mobile toggle -------------------------------- */
.mea-toc__summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.95rem 1.05rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  border-bottom: 1px solid var(--toc-border);
  background:
    linear-gradient(180deg, var(--toc-surface) 0%, var(--toc-surface-2) 100%);
}
.mea-toc__summary::-webkit-details-marker { display: none; }

.mea-toc__kicker {
  font: 700 0.66rem/1 var(--toc-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--toc-accent);
  order: 1;
  flex: 0 0 auto;
}
.mea-toc__title {
  font: 800 0.98rem/1.1 var(--toc-sans);
  letter-spacing: -0.01em;
  color: var(--toc-text);
  order: 2;
  margin-left: 0.15rem;
}
.mea-toc__chevron {
  width: 18px;
  height: 18px;
  color: var(--toc-faint);
  order: 3;
  margin-left: auto;
  transition: transform var(--toc-duration) var(--toc-ease);
}
.mea-toc[open] .mea-toc__chevron { transform: rotate(180deg); }

/* ---- Reading-progress line --------------------------------- */
.mea-toc__progress {
  height: 3px;
  background: var(--toc-surface-2);
  overflow: hidden;
}
.mea-toc__bar {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--toc-accent), var(--toc-accent-2));
  transition: transform 120ms linear;
}

/* ---- List -------------------------------------------------- */
.mea-toc__nav { padding: 0.5rem 0.55rem 0.7rem; }
.mea-toc__list {
  counter-reset: mea-toc;
  list-style: none;
  margin: 0;
  padding: 0;
}
.mea-toc__item { margin: 0; }

.mea-toc__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.6rem 0.55rem 0.7rem;
  border-radius: var(--toc-radius-sm);
  text-decoration: none;
  color: var(--toc-muted);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  counter-increment: mea-toc;
  transition: color var(--toc-duration) var(--toc-ease),
              background-color var(--toc-duration) var(--toc-ease);
}
/* Numbered prefix */
.mea-toc__link::before {
  content: counter(mea-toc, decimal-leading-zero);
  flex: 0 0 auto;
  font: 700 0.7rem/1 var(--toc-mono);
  color: var(--toc-faint);
  transition: color var(--toc-duration) var(--toc-ease);
}
/* Active marker dot (hidden until active) */
.mea-toc__dot {
  position: absolute;
  left: -0.05rem;
  top: 50%;
  width: 3px;
  height: 0;
  border-radius: 0;
  background: linear-gradient(180deg, var(--toc-accent), var(--toc-accent-2));
  transform: translateY(-50%);
  transition: height var(--toc-duration) var(--toc-ease);
}
.mea-toc__label { flex: 1 1 auto; }

.mea-toc__link:hover {
  color: var(--toc-text);
  background: var(--toc-surface-2);
}
.mea-toc__link:hover::before { color: var(--toc-accent); }

.mea-toc__link:focus-visible {
  outline: 2px solid var(--toc-accent);
  outline-offset: 2px;
}

/* Scroll-spy active state */
.mea-toc__link.is-active {
  color: var(--toc-text);
  background: var(--toc-surface-2);
}
.mea-toc__link.is-active::before { color: var(--toc-accent); }
.mea-toc__link.is-active .mea-toc__dot { height: 60%; }

/* ---- Desktop: sticky right rail ---------------------------- */
@media (min-width: 1024px) {
  .mea-toc {
    position: sticky;
    top: var(--toc-top);
    align-self: start;      /* don't stretch to grid row height */
    max-height: calc(100vh - var(--toc-top) - 1.5rem);
    overflow: auto;
  }
  /* On desktop the panel is always expanded; the caret only
     matters as a mobile affordance. */
  .mea-toc__chevron { display: none; }
  .mea-toc__summary { cursor: default; }
}

/* ---- Reduced motion --------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .mea-toc__chevron,
  .mea-toc__bar,
  .mea-toc__dot,
  .mea-toc__link { transition: none; }
  .mea-toc { scroll-behavior: auto; }
}
