/* ==========================================================================
   Document pages — policies, FAQ, information.

   Long-form reading, so the priorities are different from the marketing
   sections: a measured column, a clear heading rhythm, and a contents list
   that stays put while you scroll. Loaded only on pages (inc/assets.php).
   ========================================================================== */

.doc {
  padding: 46px 0 var(--section-pad);
}

/*
 * Named areas rather than source order: the contents rail sits beside the
 * title on desktop, but has to drop below it on mobile so the h1 is the first
 * thing on screen.
 */
.doc__grid {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "aside head"
    "aside body";
  gap: 0 64px;
  align-items: start;
}

.doc__head  { grid-area: head; }
.doc__aside { grid-area: aside; }
.doc__body  { grid-area: body; }

/* Nothing to navigate — centre the column instead of leaving a gap. */
.doc--solo .doc__grid {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "head" "body";
  max-width: 820px;
}

/* --- Contents ------------------------------------------------------------ */
.doc__aside {
  position: sticky;
  top: 104px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.doc__toc > summary {
  list-style: none;
  cursor: default;
}

.doc__toc > summary::-webkit-details-marker { display: none; }
.doc__toc > summary::marker { content: ""; }

.doc__toc-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--c-muted);
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}

.doc__toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: toc;
}

.doc__toc-list li {
  margin: 0 0 3px;
}

.doc__toc-list a {
  display: block;
  padding: 6px 0 6px 13px;
  border-left: 2px solid transparent;
  font-size: var(--fs-sm);
  line-height: 1.45;
  color: var(--c-body);
  text-decoration: none;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.doc__toc-list a:hover,
.doc__toc-list a:focus-visible {
  color: var(--c-primary-text);
  border-left-color: var(--c-border);
}

.doc__toc-list a.is-current {
  color: var(--c-primary-text);
  font-weight: var(--fw-medium);
  border-left-color: var(--c-ink);
}

/* --- Page head ----------------------------------------------------------- */
.doc__head {
  margin-bottom: 34px;
  padding-bottom: 26px;
  border-bottom: 1px solid var(--c-border);
}

.doc__title {
  font-size: var(--fs-3xl);
  line-height: var(--lh-tight);
  margin: 0 0 14px;
}

.doc__lead {
  max-width: 68ch;
  font-size: var(--fs-md);
  line-height: 1.6;
  color: var(--c-body);
  margin: 0 0 14px;
}

.doc__meta {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--c-muted);
  margin: 0;
}

/* --- Body copy ----------------------------------------------------------- */
.entry-content {
  max-width: 70ch;
  font-size: var(--fs-md);
  line-height: 1.75;
  color: var(--c-body);
}

.entry-content > *:first-child {
  margin-top: 0;
}

.entry-content p {
  margin: 0 0 1.15em;
}

/*
 * Sections need to be findable when skimming, so each h2 gets a rule above it.
 * scroll-margin clears the sticky header when a contents link jumps here.
 */
.entry-content h2 {
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--c-black);
  margin: 2em 0 .65em;
  padding-top: 1.2em;
  border-top: 1px solid var(--c-border-soft);
  scroll-margin-top: 104px;
}

.entry-content h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.entry-content h3 {
  font-size: var(--fs-md);
  font-weight: var(--fw-bold);
  color: var(--c-black);
  margin: 1.9em 0 .5em;
  scroll-margin-top: 104px;
}

.entry-content ul,
.entry-content ol {
  margin: 0 0 1.15em;
  padding-left: 1.25em;
}

.entry-content li {
  margin-bottom: .5em;
  padding-left: .2em;
}

.entry-content li::marker {
  color: var(--c-ink);
}

.entry-content a {
  color: var(--c-primary-text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.entry-content a:hover {
  text-decoration-thickness: 2px;
}

.entry-content strong {
  color: var(--c-black);
  font-weight: var(--fw-bold);
}

.entry-content hr {
  height: 1px;
  border: 0;
  background: var(--c-border);
  margin: 2.4em 0;
}

.entry-content blockquote {
  margin: 1.6em 0;
  padding: 4px 0 4px 20px;
  border-left: 3px solid var(--c-ink);
  color: var(--c-black);
}

.entry-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.4em;
  font-size: var(--fs-sm);
}

.entry-content th,
.entry-content td {
  padding: 10px 12px;
  border: 1px solid var(--c-border);
  text-align: left;
}

.entry-content th {
  background: var(--c-bg-specs);
  color: var(--c-black);
}

/* Wide tables scroll rather than pushing the page sideways. */
.entry-content .table-scroll {
  overflow-x: auto;
}

/* --- Editorial note ------------------------------------------------------ */
/*
 * A quiet aside, not a warning panel. It is a note to the site owner about
 * unfinished copy, so it should sit below the content rather than compete
 * with it.
 */
.doc__note {
  max-width: 70ch;
  margin: 40px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--c-border-soft);
  font-size: var(--fs-sm);
  line-height: 1.7;
  color: var(--c-muted);
}

/* Gaps still to be filled in, marked without shouting. */
.doc-todo,
.entry-content .doc-todo {
  color: var(--c-muted);
  font-style: italic;
}

.entry-content p.doc-todo {
  font-size: var(--fs-sm);
  padding-left: 14px;
  border-left: 2px solid var(--c-border);
}

/* --- Related / help ------------------------------------------------------ */
.doc__help {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  margin-top: 52px;
  padding-top: 32px;
  border-top: 1px solid var(--c-border);
}

.doc__help-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--c-muted);
  margin: 0 0 14px;
}

.doc__help-list {
  list-style: none;
  margin: 0;
  padding: 0;
  columns: 2;
  column-gap: 26px;
}

.doc__help-list li {
  margin-bottom: 8px;
  break-inside: avoid;
}

.doc__help-list a {
  font-size: var(--fs-sm);
  color: var(--c-body);
  text-decoration: none;
}

.doc__help-list a:hover {
  color: var(--c-primary-text);
  text-decoration: underline;
}

.doc__help-col--cta p {
  font-size: var(--fs-sm);
  line-height: 1.6;
  margin: 0 0 16px;
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 1023px) {
  .doc__grid,
  .doc--solo .doc__grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "head" "aside" "body";
    gap: 0;
  }

  /* Collapsible here, so make the summary look and behave like a control. */
  .doc__toc > summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .doc__toc > summary::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform var(--dur) var(--ease);
  }

  .doc__toc[open] > summary::after {
    transform: rotate(-135deg);
  }

  .doc__toc[open] > summary {
    margin-bottom: 12px;
  }

  /*
   * The sidebar becomes a collapsed summary above the content — a sticky rail
   * would eat most of a phone screen.
   */
  .doc__aside {
    position: static;
    max-height: none;
    overflow: visible;
    margin: 0 0 30px;
    padding: 16px 18px;
    background: var(--c-bg-specs);
    border-radius: var(--radius);
  }

  .doc__toc-title {
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 0;
  }

  .doc__toc-list {
    columns: 2;
    column-gap: 22px;
  }

  .doc__toc-list li {
    break-inside: avoid;
  }

  .doc__toc-list a {
    padding-left: 0;
    border-left: 0;
  }

  .doc__toc-list a.is-current {
    border-left: 0;
  }
}

@media (max-width: 767px) {
  .doc {
    padding-top: 30px;
  }

  .entry-content,
  .doc__lead,
  .doc__note {
    max-width: none;
  }

  .entry-content {
    font-size: var(--fs-base);
  }

  .doc__toc-list,
  .doc__help-list {
    columns: 1;
  }

  .doc__help {
    grid-template-columns: minmax(0, 1fr);
    gap: 26px;
  }
}
