/**
 * HELP SITE (public/help.php) -- a single scrollable page: a persistent
 * left sidebar (scroll-spy nav, see help-scrollspy.js) and a center
 * content column, using the same .beacon-nav top bar as other marketing
 * pages. A dedicated stylesheet, same reasoning as beacon-admin.css.
 */

/* ---- 2-column layout ---- */
.beacon-help-layout {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
}

/* ---- Left sidebar ---- */
/* Sticky/scroll live on the outer <nav>, not the <details> inside it --
   position: sticky on <details> itself is silently ignored in Chrome. */
.beacon-help-sidebar {
  /* .beacon-nav is a fixed 64px tall -- clears it, not a made-up value. */
  position: sticky;
  top: calc(64px + 1.5rem);
  /* The full nav tree (with sub-headings) can be taller than the
     viewport, so it needs its own scroll, capped below the top bar. */
  max-height: calc(100vh - 64px - 3rem);
  overflow-y: auto;
}

/* Hides the <summary> toggle above the mobile breakpoint, keeping the
   sidebar permanently expanded on desktop. */
.beacon-help-sidebar-mobile-toggle > summary {
  display: none;
}

/* Forces the nav content to display on desktop even though the <details>
   has no [open] attribute -- one markup serves both mobile (closed by
   default) and desktop (open by default). */
.beacon-help-sidebar-mobile-toggle .beacon-help-sidebar-groups {
  display: block;
}

/* Newer Chrome renders a closed <details>' children inside an internal
   ::details-content pseudo-element with content-visibility: hidden --
   overriding display on our own light-DOM child alone doesn't reach it. */
.beacon-help-sidebar-mobile-toggle::details-content {
  content-visibility: visible;
}

.beacon-help-sidebar-group {
  margin-bottom: 1.5rem;
}

.beacon-help-sidebar-group:last-child {
  margin-bottom: 0;
}

.beacon-help-sidebar-group h2 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--beacon-slate-400);
  margin-bottom: 0.5rem;
}

.beacon-help-sidebar-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.beacon-help-sidebar-link {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: var(--beacon-radius-lg);
  font-size: 0.88rem;
  color: var(--beacon-text-secondary);
  text-decoration: none;
  line-height: 1.3;
}

.beacon-help-sidebar-link:hover {
  background: var(--beacon-slate-50);
  color: var(--beacon-fg);
}

/* Nested sub-heading links -- one <ul> per top-level section that has
   real <h3 id="..."> headings. Must come after .beacon-help-sidebar-link
   above so its smaller font-size/padding win on matching specificity. */
.beacon-help-sidebar-sublist {
  list-style: none;
  margin: 0.15rem 0 0.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.beacon-help-sidebar-sublink {
  padding: 0.3rem 0.6rem 0.3rem 1.35rem;
  font-size: 0.82rem;
}

/* .active is toggled by help-scrollspy.js, not a :target-based CSS trick --
   :target only reflects the URL's hash, never updating while just scrolling. */
.beacon-help-sidebar-link.active {
  background: var(--beacon-blue-50);
  color: var(--beacon-blue-600);
  font-weight: 600;
}

/* ---- Content column ---- */
.beacon-help-content {
  min-width: 0;
  max-width: 720px;
  /* help-scrollspy.js needs room to scroll the LAST heading up to its
     trigger line -- without this, the last heading could never be marked active. */
  padding-bottom: 70vh;
}

/* .beacon-help-content h1, not a bare tag selector -- matches the global
   .beacon-body h1/h2/h3/p reset's 0-1-1 specificity (see that gotcha, beacon.css). */
.beacon-help-content h1 {
  font-size: 2rem;
  line-height: 1.2;
  margin-bottom: 1rem;
}

/* Each h2 below is a whole real section (see public/help.php -- one
   per entry in getHelpSiteNavSections(), src/help-site.php), so this
   gets real vertical breathing room between one topic ending and the
   next beginning -- more than a plain sub-heading (h3 below) would. */
.beacon-help-content h2 {
  font-size: 1.5rem;
  line-height: 1.3;
  margin: 3rem 0 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--beacon-border);
}

.beacon-help-content section:first-of-type h2 {
  margin-top: 2rem;
  padding-top: 0;
  border-top: none;
}

/* Every sidebar link points at the <section> itself, not the <h2> --
   without this, clicking one lands the section hidden behind the sticky
   nav. Same 5.5rem clearance as the h3 rule below, matching
   help-scrollspy.js's own rootMargin. */
.beacon-help-content section {
  scroll-margin-top: 5.5rem;
}

.beacon-help-content h3 {
  font-size: 1.1rem;
  line-height: 1.3;
  margin: 1.75rem 0 0.75rem;
  scroll-margin-top: 5.5rem;
}

.beacon-help-content p {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--beacon-text-secondary);
  margin-bottom: 1.1rem;
}

.beacon-help-content ul,
.beacon-help-content ol {
  font-size: 0.98rem;
  line-height: 1.7;
  color: var(--beacon-text-secondary);
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
}

.beacon-help-content li {
  margin-bottom: 0.4rem;
}

.beacon-help-content a {
  color: var(--beacon-blue-600);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.beacon-help-content strong {
  color: var(--beacon-fg);
  font-weight: 600;
}

.beacon-help-content code {
  font-family: 'Geist Mono', monospace;
  font-size: 0.85em;
  background: var(--beacon-slate-100);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--beacon-slate-700);
}

.beacon-help-content .beacon-help-callout {
  background: var(--beacon-slate-50);
  border: 1px solid var(--beacon-border);
  border-radius: var(--beacon-radius-xl);
  padding: 1rem 1.25rem;
  margin: 0 0 1.5rem;
}

.beacon-help-content .beacon-help-callout p:last-child {
  margin-bottom: 0;
}

/* Copy-pasteable code/config examples -- same dark-block treatment as
   .beacon-copyable-script pre in beacon-admin.css, not reused directly
   since this public page doesn't load that admin-only stylesheet. */
.beacon-help-content pre {
  background: var(--beacon-slate-900);
  color: var(--beacon-slate-100);
  padding: 1rem 1.1rem;
  border-radius: var(--beacon-radius-lg);
  font-size: 0.82rem;
  line-height: 1.6;
  margin: 0;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.beacon-help-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Wraps one code example + its copy button -- relative positioning lets
   the button float in the block's top-right corner. */
.beacon-help-code-block {
  position: relative;
  margin: 0 0 1.25rem;
}

.beacon-help-copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--beacon-radius-lg);
  color: var(--beacon-slate-100);
  cursor: pointer;
  padding: 0;
}

.beacon-help-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.beacon-help-copy-btn:focus-visible {
  outline: 2px solid var(--beacon-blue-300);
  outline-offset: 2px;
}

/* The two icons are both always in the markup -- toggling which is
   visible via this single class, rather than swapping SVG content
   with JS, keeps the "Copied!" feedback itself pure CSS (only the
   class + the tooltip's aria-live text need JS at all). */
.beacon-help-copied-icon {
  display: none;
}

.beacon-help-copy-btn.is-copied .beacon-help-copy-icon {
  display: none;
}

.beacon-help-copy-btn.is-copied .beacon-help-copied-icon {
  display: block;
  color: var(--beacon-blue-300);
}

/* A floating tooltip shown after a copy -- opacity/transform transition
   so it animates in. A separate aria-live region announces it for screen readers. */
.beacon-help-copy-tooltip {
  position: absolute;
  bottom: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--beacon-fg);
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.3rem 0.65rem;
  border-radius: var(--beacon-radius-lg);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.beacon-help-copy-btn.is-copied .beacon-help-copy-tooltip {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* A small reference table -- used for the DNS record entry template
   under Custom domain. */
.beacon-help-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}

.beacon-help-content th,
.beacon-help-content td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--beacon-border);
}

.beacon-help-content th {
  background: var(--beacon-slate-50);
  font-weight: 600;
  color: var(--beacon-fg);
}

.beacon-help-content td code {
  white-space: nowrap;
}

/* ---- Responsive ----
   1000px matches renderBeaconMarketingNav()'s own breakpoint, so the top
   nav and this sidebar switch to mobile layouts at the same width. */
@media (max-width: 1000px) {
  .beacon-help-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }

  /* Undoes the desktop-only sticky/own-scroll rules -- on mobile this is
     a normal in-flow dropdown that should expand to its full height. */
  .beacon-help-sidebar {
    position: static;
    max-height: none;
    overflow-y: visible;
  }

  .beacon-help-sidebar-mobile-toggle {
    background: #ffffff;
    border: 1px solid var(--beacon-border);
    border-radius: var(--beacon-radius-xl);
    padding: 0;
  }

  /* The toggle is real again below this breakpoint -- a plain
     <details>/<summary>, no JS, matching .beacon-category-dropdown's
     own no-script-required pattern elsewhere in this app. */
  .beacon-help-sidebar-mobile-toggle > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
  }

  .beacon-help-sidebar-mobile-toggle > summary::-webkit-details-marker {
    display: none;
  }

  .beacon-help-sidebar-mobile-toggle > summary::after {
    content: '';
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid var(--beacon-slate-400);
    border-bottom: 2px solid var(--beacon-slate-400);
    transform: rotate(45deg);
  }

  .beacon-help-sidebar-mobile-toggle[open] > summary::after {
    transform: rotate(-135deg);
  }

  /* Restores the browser's own native <details> behavior below this
     breakpoint -- the unconditional "always visible" rule above this
     media query is desktop-only in intent; here, the content should
     genuinely only show once the visitor taps the summary open. */
  .beacon-help-sidebar-mobile-toggle:not([open]) .beacon-help-sidebar-groups {
    display: none;
  }

  .beacon-help-sidebar-groups {
    padding: 0 1.1rem 1.1rem;
  }
}
