/* ===== GeneratePress TOC ===== */
.gp-toc {
  border: 1px solid color-mix(in srgb, var(--contrast) 10%, transparent);
  border-radius: 16px;
  padding: 16px 18px;
  margin: 24px 0 28px;
  background: color-mix(in srgb, var(--base-3) 98%, transparent);
}

.gp-toc__title {
  font-weight: 700;
  margin-bottom: 10px;
  font-size: 15px;
}

.gp-toc__list,
.gp-toc__sublist {
  list-style: none;
  padding-left: 0;
  margin: 0;  	
}



.gp-toc__item {
  margin: 3px 0;
}

.gp-toc__sublist {
  margin-top: 6px;
  padding-left: 14px;
  border-left: 2px solid color-mix(in srgb, var(--contrast) 10%, transparent);
}

.gp-toc__link {
  text-decoration: none;
  color: var(--contrast);
  display: inline-block;
  padding: 2px 0;
  opacity: 0.9;
  line-height: 1.2;	
}

.gp-toc__link:hover {
  color: var(--accent);
  opacity: 1;
}

.gp-toc__link.is-active {
  color: var(--accent);
  font-weight: 700;
  opacity: 1;
}

/* Базова ієрархія (опційно підкрутити) */
.gp-toc__item.level-3 > .gp-toc__link { font-size: 0.98em; }
.gp-toc__item.level-4 > .gp-toc__link { font-size: 0.95em; opacity: 0.85; }

/* Sticky на desktop */
@media (min-width: 992px) {
  .gp-toc.is-sticky {
    position: sticky;
    top: var(--toc-sticky-top, 90px);
    z-index: 2;
  }
}




/* Якщо користувач просить менше анімацій */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
}




/* ===== Right rail container for TOC ===== */


/* ===== Desktop right rail ===== */
#toc-rail {
  /*position: fixed;
  top: 140px;*/
  /*bottom: 45%;*/	
  right: 24px;
  width: min(320px, 22vw);
  z-index: 20;
  max-height: calc(100vh - 280px);
  margin-top:24px;	
  display: flex;
}

/* TOC module layout (title fixed, list scrollable) */
#toc-rail .gp-toc {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 100%;
  margin: 0;
}

#toc-rail .gp-toc__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 0 0 auto;
  margin-bottom: 8px;
}

#toc-rail .gp-toc__list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  scroll-behavior: smooth;
}

/* Desktop collapsed mode */
.gp-toc.is-collapsed .gp-toc__list {
  display: none;
}

/* Collapse button (inside title) */
.gp-toc__btn {
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--contrast) 12%, transparent);
  background: color-mix(in srgb, var(--base-3) 92%, transparent);
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
  line-height: 1;
}

.gp-toc__btn:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}

/* ===== Mobile toggle button ===== */
#toc-toggle.toc-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;

  border: 1px solid color-mix(in srgb, var(--contrast) 12%, transparent);
  background: color-mix(in srgb, var(--base-3) 96%, transparent);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(0,0,0,.12);
	
  color: var(--contrast);	
}

/* Mobile overlay panel */
#toc-mobile {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: none;
}

#toc-mobile.is-open {
  display: block;
}

#toc-mobile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.45);
}

#toc-mobile .toc-mobile__panel {
  position: absolute;
  right: 12px;
  left: 12px;
  bottom: 72px; /* над кнопкою */
  max-height: calc(100vh - 120px);
  overflow: hidden;

  border: 1px solid color-mix(in srgb, var(--contrast) 12%, transparent);
  background: color-mix(in srgb, var(--base-3) 98%, transparent);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,.18);
}

/* У мобільній панелі список також має скрол */
#toc-mobile .gp-toc {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  margin: 0;
}

#toc-mobile .gp-toc__list {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
}

/* ===== Responsive visibility rules ===== */
@media (min-width: 992px) {
  #toc-toggle { display: none; }
  #toc-mobile { display: none !important; }
}

@media (max-width: 991px) {
  #toc-rail { display: none; }
	
  .gp-toc__btn { display:none;}		
	
}

.gp-toc__btn, .gp-toc__btn:hover {
	/*color: var(--accent); /* #f0f0f0 !important;*/
}

.gp-toc__btn {
	color: var(--contrast-2); /* #f0f0f0 !important;*/
	background: var(--base-2);
}


/* блокування прокрутки сторінки коли відкрито мобільну панель */
/*body.toc-lock {
  overflow: hidden;
  touch-action: none;
}
*/
/* щоб панель точно скролилась на iOS */
/*#toc-mobile .toc-mobile__panel {
  -webkit-overflow-scrolling: touch;
}*/



body.toc-lock {
  overflow: hidden; /* блокуємо сторінку */
}

/* Панель має скролитись */
#toc-mobile .toc-mobile__panel {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 120px);
  -webkit-overflow-scrolling: touch; /* iOS momentum scroll */
}

/* (не обов'язково) overlay може забороняти жести */
#toc-mobile {
  touch-action: none; /* забороняємо жести на затемненні */
}
#toc-mobile .toc-mobile__panel {
  touch-action: pan-y; /* але дозволяємо вертикальний скрол у панелі */
}




:root {
  --toc-rail-width: min(320px, 22vw);
  --toc-rail-collapsed-width: 245px; /* ширина кнопки */
}

/*#toc-rail {
  position: fixed;
  top: 140px;
  right: 12px;

  width: var(--toc-rail-width);
  max-height: calc(100vh - 140px);

  display: flex;
  align-items: stretch;

  transition: width .25s ease, opacity .2s ease;
}
*/

#toc-rail.is-collapsed {
  width: var(--toc-rail-collapsed-width);	
}

/* сам TOC */
#toc-rail .gp-toc {
  width: 100%;
  transition: opacity .2s ease;
}

/* коли згорнуто — ховаємо список */
#toc-rail.is-collapsed .gp-toc__list {
  display: none;
}

/* заголовок центруємо */
#toc-rail.is-collapsed .gp-toc__title {
  justify-content: center;
}


.gp-toc__btn {
  white-space: nowrap;
}

#toc-rail .gp-toc__btn {
  padding: 8px 14px;
  font-weight: 600;
}

/* коли rail згорнутий — кнопка стає основним елементом */
#toc-rail.is-collapsed .gp-toc__btn {
  padding: 8px 14px;
  font-weight: 600;
}

/* Offset для переходу по якорях (TOC) */
.entry-content h2,
.entry-content h3,
.entry-content h4 {
  scroll-margin-top: 140px; /* <-- потрібний відступ */
}

@media (max-width: 991px) {
  .entry-content h2,
  .entry-content h3,
  .entry-content h4 {
    scroll-margin-top: 96px;
  }
}


/* Кнопка "вгору" біля заголовка TOC */
.gp-toc__toplink {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 36px;
  height: 36px;

  border: 1px solid color-mix(in srgb, var(--contrast) 12%, transparent);
  border-radius: 999px;

  background: transparent;
  color: var(--contrast);

  font-size: 20px;
  line-height: 1;
  text-decoration: none;

  cursor: pointer;  
}

@media (max-width: 991px) { 
	.gp-toc__toplink {
		margin-left:15px;	
	}
}

.gp-toc__toplink:hover {
  color: var(--base-3) !important;
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  background: var(--accent);	
}


.gp-toc__toplink 
{
    font-size: 20px;
    border-radius: 3px;
    position: fixed;
    bottom: 30px;
    right: 30px;
    line-height: 36px;
    width: 36px;
    text-align: center;
    z-index: 10;
    transition: opacity 300ms ease-in-out;	
}

.gp-toc__toplink svg {
  height: 1em;
  width: 1em;
  top: 0;
  position: relative;
  fill: currentColor;
}


.toc-mobile__panel .gp-toc__toplink {
	  position: sticky;
	   gap: 18px;
}


/* трохи простору між "Зміст" і стрілкою */
.gp-toc__title {
  gap: 8px;
}


/* Offset при переході до H1 (кнопка "вгору") */
#h1-single-title {
  scroll-margin-top: 100px;
}

@media (max-width: 991px) {
  #h1-single-title {
    scroll-margin-top: 60px;
  }
}

/*сховати*/
body.toc-at-top .gp-toc__toplink {
  opacity: 0.1;
  pointer-events: none;
}


/*фокус заголовок*/
/* щоб можна було ставити фокус на контейнер заголовка */
.gp-toc__title {
  outline: none;
}
.gp-toc__title:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
  border-radius: 10px;
}


