/* Guide (app/pages/guide.php): a reading layout. The banner, .wg-layout, .wg-article, widgets, cards and
   the FAQ come from wisdigix.css; this file holds the guide head, the reading measure, both tables of
   contents (the sticky one keeps the max-height and overflow js/pages/guide.js measures for .is-tall),
   the data tables and the sources. Prefix guide-. */

.page-guide .wg-article {
    --guide-inset: 0px;   /* read by .guide-table; the text and the tables now share the column's edge */
    position: relative;   /* the skip link to the contents appears over the article it belongs to */
}
.guide-body { --table-ground: var(--ground); }
.guide-body.wg-section--stone { --table-ground: var(--ground-alt); }

/* Long guide titles: a calmer size than the 68px page h1, still the page's largest type */
.page-guide .wg-banner h1 {
    max-width: 18em;
    font-size: clamp(2rem, 1.45rem + 2.3vw, 3.5rem);
    line-height: 1.06;
}

/* Reading time and date: one ruled line over the photo */
.page-guide .wg-guide__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .25rem 1.5rem;
    margin: 0 0 var(--s-5);
    padding-bottom: var(--s-4);
    border-bottom: 1px solid var(--rule);
}
.page-guide .wg-guide__head p { margin: 0; }
.page-guide .wg-guide__head .wg-guide__tag { color: var(--fg-strong); }

/* The reading measure: about 68 characters of body text */
.guide-section > p,
.guide-section > .wg-checklist { max-width: 42rem; }
.guide-section > p { line-height: 1.7; }
.guide-section > .wg-checklist { margin: 0 0 1.25em; }
.guide-section > .wg-checklist:last-child { margin-bottom: 0; }
.guide-section > .wg-checklist li { padding-block: .375rem; }
.guide-section > .wg-checklist li::before { top: calc(.375rem + .8em - 8px); }
.guide-section > .wg-checklist li::after { top: calc(.375rem + .8em - 6px); }

/* Inline table of contents: a quiet disclosure at the top of the column below 992px */
.guide-toc--inline {
    margin-bottom: var(--s-6);
    padding: 0 var(--s-5);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--surface-1);
}
.guide-toc--inline > details { border-bottom: 0; }
.guide-toc--inline summary { padding-block: var(--s-4); font-size: 1rem; }
.guide-toc--inline .wg-faq__answer { padding: 0 0 var(--s-3); }
.guide-toc--inline .wg-widget__list a::before { display: none; }

/* Sidebar: side by side on tablets (shared rule), the table of contents across both columns */
@media (min-width: 768px) and (max-width: 991px) {
    .guide-side__toc { grid-column: 1 / -1; }
}
@media (max-width: 767px) {
    .guide-side__toc + .wg-widget { margin-top: var(--s-5); }
}

/* The sticky table of contents: entries hang off one rail; hover marks the entry with a dot on it */
.guide-toc .wg-widget__list {
    margin-left: .25rem;
    border-left: 1px solid var(--rule);
}
.guide-toc .wg-widget__list > li { border-top: 0; }
/* Twelve question-length entries still fit a 900px screen, so the list stays in view on most laptops */
.guide-toc .wg-widget__list a {
    min-height: 0;
    padding: .375rem 0 .375rem 1rem;
    font-size: var(--fs-small);
    line-height: 1.38;
}
.guide-toc .wg-widget__list a::before {
    top: calc(.375rem + .69em);
    left: -3.5px;
}
.guide-toc .wg-widget__list a:focus-visible::before { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) {
    .guide-toc .wg-widget__list a:hover::before { opacity: 1; transform: none; }
}

@media (min-width: 992px) {
    .guide-toc--inline { display: none; }

    /* The sticky list holds the column while the article runs, so its wrapper takes the free height.
       In one flow it would slide over the widgets below it. */
    .guide-side { display: flex; flex-direction: column; }
    .guide-side__toc { flex: 1 0 auto; }
    .guide-side__toc + .wg-widget { margin-top: var(--s-5); }

    /* A list longer than the screen scrolls inside the widget, clear of the stuck header and the
       back-to-top square, so the last entry can still be reached and focused. */
    .guide-toc {
        max-height: calc(100vh - 72px - var(--s-5) - 5.5rem);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--rule-strong) transparent;
    }
    /* Taller than that, it scrolls with the page, whole, instead of clipping its last entry inside its
       own scrollbar. js/pages/guide.js measures it; without JS it is static from the start. */
    .guide-toc.is-tall.wg-sticky { position: static; }
    .guide-toc.is-tall { max-height: none; overflow-y: visible; }
    .no-js .guide-toc.wg-sticky { position: static; }
    .no-js .guide-toc { max-height: none; overflow-y: visible; }
}
#guide-toc-title:focus { outline: none; }
/* The skip link's -100px is measured from the article, and the section's top padding is taller, so it
   would show; it moves off screen until it has focus */
.guide-toc-skip:not(:focus) { left: -9999px; }
@media (max-width: 991px) {
    .guide-toc-skip { display: none; }   /* below 992px the inline list already comes first */
}

/* Cards sit inside the article, so they keep their own text spacing */
.guide-cards .wg-card p { margin: 0; }
.guide-links .wg-rows { margin-top: var(--s-2); }

/* Comparison tables (data-schema.md `table`): a strong rule, a 620 head row, hairline rows, the row
   labels held in place while the other columns scroll. Positioned so the visually hidden caption is
   clipped here instead of widening the page. */
.guide-table {
    position: relative;
    margin-inline: calc(-1 * var(--guide-inset));
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-top: 1px solid var(--rule-strong);
    scrollbar-width: thin;
    scrollbar-color: var(--rule-strong) transparent;
}
.guide-table:focus-visible { outline-offset: 3px; }
.guide-table table {
    width: 100%;
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-small);
    line-height: 1.55;
}
.guide-table th,
.guide-table td {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--rule);
    font-weight: 400;
    text-align: left;
    vertical-align: top;
}
.guide-table :is(th, td):first-child { padding-left: 0; }
.guide-table thead th {
    border-bottom-color: var(--rule-strong);
    background: var(--table-ground);
    color: var(--fg-strong);
    font-size: var(--fs-label);
    font-weight: 650;
    letter-spacing: .02em;
    vertical-align: bottom;
}
.guide-table tbody th {
    position: sticky;
    left: 0;
    border-right: 1px solid var(--rule);
    background: var(--table-ground);
    color: var(--fg-strong);
    font-weight: 600;
}
.guide-table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}
/* A long row label must not fill the region once it is held in place: the other columns scroll out
   from under it, and without a limit the longest labels left 58px for them at 320px. */
@media (max-width: 639px) {
    .guide-table tbody th { width: 8rem; }
}
.wg-article .guide-table__hint { margin: 0 0 .625rem; }
.wg-article .wg-checklist + .guide-table__hint { margin-top: var(--s-5); }
@media (min-width: 640px) {
    .wg-article .guide-table__hint { display: none; }
    .wg-checklist ~ .guide-table,
    p ~ .guide-table { margin-top: var(--s-5); }
    .guide-table table { min-width: 0; }
}

/* Sources: links over hairlines */
.guide-sources {
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--rule-strong);
    font-size: var(--fs-small);
    line-height: 1.55;
    list-style: none;
}
.guide-sources li { padding: .75rem 0; border-bottom: 1px solid var(--rule); }
.guide-sources a {
    display: inline-block;
    min-height: 24px;
    color: var(--fg-strong);
    overflow-wrap: anywhere;
    text-decoration: underline;
    text-decoration-color: var(--rule-strong);
    text-decoration-thickness: 1px;
    text-underline-offset: .22em;
    transition: text-decoration-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.guide-sources a:hover,
.guide-sources a:focus-visible { color: var(--accent-fg); text-decoration-color: currentColor; }

@media print {
    /* The article, whole: the links around it take up pages of cards and sidebars on paper */
    .guide-side, .guide-toc--inline, .guide-links, .wg-article__photo, .guide-table__hint { display: none !important; }
    .wg-layout { display: block; }
    .guide-table { margin-inline: 0; overflow: visible; }
    .guide-table table { min-width: 0; }
    .guide-table thead th, .guide-table tbody th { position: static; }
}
