/* =========================================================================
   ep-toc — liukuva sisällysluettelo pitkille sivuille
   Palvelusivut ovat 17 000–33 000 px pitkiä, joten lukijalle tarvitaan tapa
   hypätä suoraan haluamaansa aiheeseen. Rakennetaan runtimessa (ep-toc.js)
   sivun sectioneiden pääotsikoista; ei näy editorissa eikä tulosteessa.
   ========================================================================= */

.ep-toc {
  position: fixed;
  top: 50%;
  right: 0;
  /* Piilossa kunnes ep-toc.js lisää .is-revealed (vierityksen jälkeen). */
  transform: translateY(-50%) translateX(14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease, transform .28s ease;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
  max-height: 78vh;
  font-family: var(--text-font, 'Poppins', sans-serif);
}

.ep-toc.is-revealed {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}

.ep-toc__panel {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(16, 81, 136, 0.14);
  border-right: 0;
  border-radius: 10px 0 0 10px;
  box-shadow: 0 10px 40px rgba(15, 44, 73, 0.14);
  padding: 18px 14px 18px 18px;
  overflow-y: auto;
  max-height: 78vh;
  width: 268px;
  transition: width .22s ease, padding .22s ease, opacity .22s ease;
}

.ep-toc__title {
  display: block;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--theme-color1, #105188);
  margin-bottom: 12px;
  white-space: nowrap;
}

.ep-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ep-toc__list li { margin: 0; }

.ep-toc__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  color: #0f2c49;
  font-size: 13.5px;
  line-height: 1.35;
  text-decoration: none;
  transition: color .18s ease;
}

.ep-toc__link::before {
  content: "";
  flex: 0 0 auto;
  width: 18px;
  height: 2px;
  background: rgba(15, 44, 73, 0.28);
  transition: width .18s ease, background-color .18s ease;
}

.ep-toc__link:hover,
.ep-toc__link:focus-visible {
  color: var(--theme-color1, #105188);
}

.ep-toc__link:hover::before,
.ep-toc__link:focus-visible::before {
  background: var(--theme-color1, #105188);
}

.ep-toc__link.is-active {
  color: var(--theme-color1, #105188);
  font-weight: 600;
}

.ep-toc__link.is-active::before {
  width: 26px;
  background: var(--theme-color2, #59e000);
}

.ep-toc__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Keskikokoiset näytöt: kutistettu tila, joka avautuu hoverilla ja fokuksella,
   jottei paneeli peitä sisältöä. */
@media (min-width: 1200px) and (max-width: 1799.98px) {
  .ep-toc__panel {
    width: 58px;
    padding: 16px 10px;
  }

  .ep-toc__title,
  .ep-toc__text {
    opacity: 0;
    transition: opacity .18s ease;
  }

  .ep-toc:hover .ep-toc__panel,
  .ep-toc:focus-within .ep-toc__panel {
    width: 268px;
    padding: 18px 14px 18px 18px;
  }

  .ep-toc:hover .ep-toc__title,
  .ep-toc:focus-within .ep-toc__title,
  .ep-toc:hover .ep-toc__text,
  .ep-toc:focus-within .ep-toc__text {
    opacity: 1;
  }
}

/* Mobiili ja tabletti: kelluva painike avaa listan. */
.ep-toc__toggle {
  display: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .28s ease, transform .28s ease;
  position: fixed;
  left: 20px;
  bottom: 22px;
  z-index: 91;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 30px;
  padding: 12px 20px;
  background: var(--theme-color1, #105188);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(15, 44, 73, 0.3);
  cursor: pointer;
}

.ep-toc__toggle.is-revealed {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.ep-toc__toggle svg { flex: 0 0 auto; }

@media (max-width: 1199.98px) {
  .ep-toc__toggle { display: inline-flex; }

  .ep-toc {
    top: auto;
    bottom: 80px;
    left: 16px;
    right: 16px;
    transform: translateY(8px);
    justify-content: flex-start;
    max-height: 60vh;
  }

  .ep-toc__panel {
    width: 100%;
    max-width: 420px;
    max-height: 60vh;
    border: 1px solid rgba(16, 81, 136, 0.14);
    border-radius: 12px;
  }

  .ep-toc.is-revealed { transform: translateY(0); }
  .ep-toc[hidden] { display: none; }

  .ep-toc__link { padding: 10px 0; font-size: 15px; }
  .ep-toc__text { white-space: normal; }
}

@media (min-width: 1200px) {
  .ep-toc[hidden] { display: flex; }
}

@media print {
  .ep-toc,
  .ep-toc__toggle { display: none !important; }
}

/* Editorissa sisällysluettelo ei saa peittää sectioneita eikä sen työkaluja. */
.scomediting .ep-toc,
.scomediting .ep-toc__toggle { display: none !important; }

/* Jos JS ei syystä tai toisesta aja, mitään ei jää roikkumaan näkymättömänä:
   elementit luodaan vasta ep-toc.js:ssä, joten tämä koskee vain tilannetta
   jossa skripti on luonut ne mutta reveal-logiikka ei ole ehtinyt ajaa. */
@media (prefers-reduced-motion: reduce) {
  .ep-toc,
  .ep-toc__toggle { transition: none; }
}
