/*
 * A4 (2026-11-17): compact, collapsed-by-default table of contents.
 * Overrides the Easy Table of Contents markup (#ez-toc-container) from the theme so the
 * look does not depend on plugin settings. Collapsing itself is a plugin option
 * (ez-toc-settings: visibility_hide_by_default=1); the sticky "Contents" tab on articles is
 * the plugin's sticky-toggle (see DESIGN-PLAN.md, A4). Selectors use the container id for
 * specificity, so load order against the plugin CSS does not matter.
 */

/* Card: published 8px radius and shadow, no border */
#ez-toc-container {
  box-sizing: border-box;
  width: 100%;
  margin: 10px 0 !important;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, .1);
  overflow: hidden;
}

/* Header row: title left, toggle icon right, whole row is the tap target (>= 56 px) */
#ez-toc-container .ez-toc-title-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 16px;
  text-align: center;
}
#ez-toc-container .ez-toc-title-container p {
  margin: 0;
  padding: 0;
}
#ez-toc-container p.ez-toc-title {
  flex: 1 1 auto;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .06em;
  line-height: 1.2;
  text-align: left;
  text-transform: uppercase;
}
#ez-toc-container .ez-toc-title-toggle {
  display: block;
}
#ez-toc-container a.ez-toc-toggle {
  float: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}
/* stretch the toggle link over the whole header row (the plugin handles the click on the link) */
#ez-toc-container a.ez-toc-toggle::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}
#ez-toc-container a.ez-toc-toggle:focus-visible {
  outline: 2px solid #000;
  outline-offset: -4px;
  border-radius: 20px;
}

/* List: no side padding on items (was 25 px), tight rhythm */
#ez-toc-container nav {
  padding: 0 16px 12px;
}
#ez-toc-container .ez-toc-list,
#ez-toc-container .ez-toc-list ul {
  margin: 0;
  padding: 0;
}
#ez-toc-container .ez-toc-list li {
  margin: 0;
  padding: 0;
}
#ez-toc-container .ez-toc-list ul {
  padding-left: 16px;
}
#ez-toc-container .ez-toc-list a {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 2px 0;
  font-size: 15px;
  line-height: 1.35;
  text-decoration: none;
}
#ez-toc-container .ez-toc-list a:hover {
  text-decoration: underline;
}
#ez-toc-container .ez-toc-list a:focus-visible {
  outline: 2px solid #000;
  outline-offset: 2px;
}

/* Desktop: two columns when expanded */
@media (min-width: 1025px) {
  #ez-toc-container .ez-toc-list-level-1 {
    column-count: 2;
    column-gap: 40px;
  }
  #ez-toc-container .ez-toc-list-level-1 > li {
    break-inside: avoid;
  }
}

/* Touch / small screens: 44 px targets, expanded list scrolls inside the card */
@media (pointer: coarse), (max-width: 1024px) {
  #ez-toc-container .ez-toc-list a {
    min-height: 44px;
    padding: 6px 0;
  }
  #ez-toc-container nav {
    max-height: 65vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}

/*
 * Sticky "Contents" opener (plugin sticky-toggle, articles only).
 * Desktop keeps the plugin's slim vertical tab at the right edge. On touch / small screens that
 * tab covers ~38 px of the text column, so it becomes a pill at the bottom-left (the "to top"
 * button lives at the bottom-right). Keep `bottom` in sync with the cookie banner when A3 lands.
 */
@media (pointer: coarse), (max-width: 1024px) {
  body a.ez-toc-open-icon {
    top: auto;
    right: auto;
    left: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px 0 14px;
    border-radius: 999px;
    background: #ffe500;
    color: #111;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .28);
    line-height: 1;
  }
  body a.ez-toc-open-icon::before {
    content: "";
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z' fill='%23111'/%3E%3C/svg%3E") center / contain no-repeat;
  }
  body a.ez-toc-open-icon span.text {
    writing-mode: horizontal-tb;
    transform: none;
    font-size: 14px;
    font-weight: 600;
  }
  body a.ez-toc-open-icon span.arrow {
    display: none;
  }
}

/* Preserve the published mobile link spacing and hide legacy list markers. */
@media (max-width: 600px) {
  #ez-toc-container a {
    margin-top: 12px !important;
  }
}
li.ez-toc-page-1::before,
li.ez-toc-heading-level-3::before,
li.ez-toc-heading-level-4::before {
  content: '' !important;
}
