/* Docs Guide template
   ---------------------------------------------
   Desktop (>= 960px, matches this theme's own .site-header breakpoint):
     30% sticky vertical tab nav + 70% content panel, full-width.
   Mobile (< 960px):
     A select-style trigger sticky at the top of the viewport, which opens
     a bottom-sheet dialog listing every section; the active panel stacks
     full-width beneath the trigger.

   All .docs-panel sections render in the DOM regardless of JS so the full
   article stays crawlable and readable with JS disabled; only .js-docs-ready
   (added by docs.js once it's initialised) turns on the hide-inactive-panel
   behaviour. The mobile trigger/dialog are pure JS enhancements on top of
   that, same as the desktop tab nav - without JS neither renders anything
   clickable, but the full article is still there to scroll and read.
   --------------------------------------------- */

.docs-template .content {
  max-width: none;
  width: 100%;
  float: none;
}

.docs-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.docs-layout mark {
  background: var(--eew-surface) !important;
}

.docs-nav {
  display: none;
}

/* Mobile: a select-styled trigger, sticky to the top of the viewport, that
   opens a bottom-sheet dialog listing every section. */
.docs-nav__mobile-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 10;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--eew-accent, #fff);
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.docs-nav__mobile-trigger::after {
  content: "";
  flex-shrink: 0;
  width: 0.5em;
  height: 0.5em;
  margin-top: -0.3em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.6;
  transform: rotate(45deg);
}

.docs-mobile-dialog {
  position: fixed;
  inset: auto 0 0 0;
  width: 100%;
  max-width: 100%;
  max-height: 70vh;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 16px 16px 0 0;
  background: var(--eew-surface);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.2);
}

.docs-mobile-dialog::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 4px;
  margin: 0.6rem auto 0.25rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.2);
}

.docs-mobile-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.docs-mobile-dialog[open] {
  animation: eew-docs-sheet-in 0.2s ease-out;
}

.docs-mobile-dialog[open]::backdrop {
  animation: eew-docs-backdrop-in 0.2s ease-out;
}

@keyframes eew-docs-sheet-in {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}

@keyframes eew-docs-backdrop-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.docs-mobile-dialog__list {
  margin: 0;
  padding: 0.5rem 2em max(0.5rem, env(safe-area-inset-bottom));
  list-style: none;
  max-height: 70vh;
  overflow-y: auto;
}

.docs-mobile-dialog__item {
  display: block;
  width: 100%;
  padding: 0.9rem 1.25rem;
  background: var(--eew-primary);
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  font: inherit;
  font-size: 1rem;
  text-align: left;
  cursor: pointer;
}

.docs-mobile-dialog__list li {
  list-style-type: none !important;
}

.docs-mobile-dialog__list li:last-child .docs-mobile-dialog__item {
  border-bottom: none;
}

.docs-mobile-dialog__item.is-active {
  font-weight: 700;
  color: var(--wp--preset--color--primary, #2563eb);
}

.docs-panels {
  min-width: 0;
}

.docs-panel {
  max-width: 70ch;
}

.docs-panel:focus {
  outline: var(--eew-background);
}

.docs-pagination {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--eew-surface);
}

.docs-pagination__link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-width: 45%;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--eew-surface);
  color: var(--eew-text-muted);
  border-radius: 12px;
  text-decoration: none;
}

.docs-pagination__link--next {
  margin-left: auto;
  text-align: right;
}

.docs-pagination__direction {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.65;
}

.docs-pagination__title {
  font-weight: 600;
}

.docs-pagination__spacer {
  flex: 1;
}

/* Before JS runs (or if it's disabled), every panel is visible and the
   article reads as one continuous, fully-crawlable page. */
.docs-panel + .docs-panel {
  margin-top: 3rem;
  padding-top: 3rem;
  border-top: 1px solid var(--eew-surface);
}

.js-docs-ready .docs-panel {
  display: none;
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.js-docs-ready .docs-panel.is-active {
  display: block;
}

@media only screen and (min-width: 960px) {
  .docs-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 3rem;
  }

  .docs-nav {
    display: flex;
    flex: 0 0 30%;
    flex-direction: column;
    gap: 0.5rem;
    border-right: 1px solid var(--eew-surface);
    /* Set at runtime by docs.js to sit just below the theme's own sticky
		   .site-header, whose height varies with the logo/menu content. */
    position: sticky;
    top: var(--eew-docs-sticky-offset, 0px);
    align-self: flex-start;
    max-height: calc(100vh - var(--eew-docs-sticky-offset, 0px));
    overflow-y: auto;
    padding: 0.75rem 1.5rem 0.75rem 0;
    background: transparent;
  }

  .docs-nav__item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    line-height: 1.2;
    cursor: pointer;
  }

  .docs-nav__item.is-active {
    background: var(--eew-text-muted);
    color: #fff;
  }

  .docs-nav__item.is-active:focus,
  .docs-nav__item.is-active:hover {
    box-shadow: 2px 2px 0px 0px var(--eew-accent);
    outline: none;
  }

  .docs-nav__mobile-trigger,
  .docs-mobile-dialog {
    display: none;
  }

  .docs-panels {
    flex: 0 0 70%;
  }

  /* Sub-nav (jump links generated from a section's own H3-H6 headings):
	   desktop only (hidden by default below), and only shown under whichever
	   tab is currently active, so the sidebar doesn't sprawl with every
	   section's subheadings at once. */
  .docs-nav__sub {
    margin: 0 !important;
    padding-left: 1.25rem;
    list-style: none;
  }

  .js-docs-ready .docs-nav__item.is-active + .docs-nav__sub {
    display: block;
  }

  .docs-nav__sub li {
    margin-bottom: 0px !important;
  }

  .docs-nav__sub-link {
    display: block;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    text-decoration: none;
    border-radius: 4px;
    opacity: 0.75;
  }

  .docs-nav__sub-link:hover,
  .docs-nav__sub-link:focus {
    background: rgba(0, 0, 0, 0.05);
    opacity: 1;
  }
}

.docs-nav__sub {
  display: none;
}
