/* =============================================
   Toc — Indice H2/H3 con titolo + excerpt
   Desktop sticky, taglio bottom come card panna
   ============================================= */
.rewell-toc {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.rewell-toc__placeholder {
  padding: 1.5rem;
  border: 1px dashed #999999;
  color: #999999;
  text-align: center;
  background: #fff;
}

.rewell-toc__card {
  background: #fff;
  background: #ffffff;
  border: 1px solid rgba(32, 34, 36, 0.12);
  padding: 1.5rem 1.25rem 2rem;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 28px), 50% 100%, 0 calc(100% - 28px));
  /* taglio a V in basso */
  padding-bottom: 2.5rem;
}

.rewell-toc__title {
  font-size: 1.05rem;
  font-weight: 600;
  font-style: italic;
  line-height: 1.3;
  color: #202224;
  margin: 0;
}

.rewell-toc__line {
  border: 0;
  border-top: 1px solid #202224;
  margin: 1rem 0;
  opacity: 1;
}

.rewell-toc__excerpt {
  font-size: 0.875rem;
  line-height: 1.6;
  color: #202224;
}

.rewell-toc__excerpt p {
  margin: 0 0 0.5rem;
}

.rewell-toc__excerpt p:last-child {
  margin: 0;
}

.rewell-toc__list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}

.rewell-toc__list > li {
  margin: 0;
  padding: 0;
}

.rewell-toc__list a {
  display: block;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  color: #202224;
  line-height: 1.4;
  padding: 0.2rem 0;
}

.rewell-toc__list a:hover {
  color: #000;
}

.rewell-toc__item--h2 a {
  font-size: 0.9375rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 0.75rem;
}

.rewell-toc__item--h2:first-child a {
  margin-top: 0;
}

.rewell-toc__item--h3 {
  margin-left: 1.75rem !important;
  list-style: none;
}

.rewell-toc__item--h3::before {
  content: "•";
  display: inline-block;
  margin-right: 0.35rem;
  color: #202224;
  font-weight: 700;
  vertical-align: middle;
}

.rewell-toc__item--h3 a {
  display: inline !important;
  font-size: 0.875rem;
  font-weight: 600;
  font-style: italic;
  text-transform: none;
  padding-left: 0.15rem;
}

.rewell-toc__item--h3-deep {
  margin-left: 3rem !important;
  list-style: disc;
  list-style-position: inside;
}

.rewell-toc__item--h3-deep a {
  display: inline;
  font-size: 0.8125rem;
  font-weight: 400;
}

.rewell-toc__empty {
  font-size: 0.8125rem;
  color: #999999;
  font-style: italic;
}

.rewell-toc__list a.is-active {
  font-weight: 700;
  background: rgba(201, 210, 160, 0.25);
  padding-left: 0.25rem;
}

/* Desktop — come archivio: colonna sticky, Toc statico */
@media (min-width: 1024px) {
  .rewell-toc {
    position: static;
    width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
  }

  .wp-block-columns:has(.rewell-toc) {
    align-items: flex-start !important;
  }

  .wp-block-column.rewell-archive-filters-col:has(.rewell-toc) {
    position: sticky !important;
    top: calc(88px + var(--wp-admin--admin-bar--height, 0px) + 16px) !important;
    align-self: flex-start !important;
    z-index: 2;
  }

  /* Sblocca overflow/contain di tutti gli antenati */
  .is-layout-flex:has(.rewell-toc),
  .is-layout-constrained:has(.rewell-toc),
  main:has(.rewell-toc),
  .wp-site-blocks:has(.rewell-toc) {
    overflow: visible !important;
    contain: none !important;
  }

  /* Fallback per browser senza :has() — classe aggiunta via JS */
  .rewell-toc--sticky-parent {
    overflow: visible !important;
    contain: none !important;
  }
  .wp-block-columns.rewell-toc--sticky-parent {
    align-items: flex-start !important;
  }
  .wp-block-column.rewell-toc--sticky-parent.rewell-archive-filters-col {
    position: sticky !important;
    top: calc(88px + var(--wp-admin--admin-bar--height, 0px) + 16px) !important;
    align-self: flex-start !important;
  }
}

/* Editor confinement */
.editor-styles-wrapper .rewell-toc,
.block-editor-block-list__block .rewell-toc {
  max-width: 100% !important;
}
