/* Legal (hub and documents, app/pages/legal.php). Banner, section heads, the meta line, widgets and
   .wg-prose come from wisdigix.css; this file holds the document's reading layout (the "On this page"
   nav held in the left columns, the text at a reading measure on the right), its tables, the other
   documents, and the hub's two groups. Prefix legal-. */

.legal-doc { --table-ground: var(--ground); }
.legal-doc.wg-section--stone { --table-ground: var(--ground-alt); }

/* 1. Document: head, then the nav beside the text, then the other documents
   ----------------------------------------------------------------------- */
/* minmax(0, 1fr) and min-width: 0, so a wide table scrolls inside its region instead of widening the page */
.legal-doc__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-6) var(--gap); }
.legal-doc__grid > * { min-width: 0; }
.legal-doc__head .wg-section-head { max-width: 46rem; margin-bottom: 0; }
.legal-doc__head .wg-section-head .wg-meta { margin: var(--s-3) 0 var(--s-4); }
/* The summary describes the document; the document's own lead paragraph follows, so it stays the quieter one */
.legal-doc__head .wg-section-head > p:not(.wg-meta) { color: var(--fg-muted); font-size: var(--fs-body); line-height: 1.6; }
@media (min-width: 992px) {
    .legal-doc__grid {
        grid-template-columns: repeat(12, minmax(0, 1fr));
        column-gap: var(--gap);
        row-gap: 0;
    }
    .legal-doc__head { grid-column: 5 / -1; grid-row: 1; padding-bottom: var(--s-7); }
    .legal-doc__side { grid-column: 1 / span 3; grid-row: 1 / span 3; }
    .legal-doc__grid > .legal-body { grid-column: 5 / -1; grid-row: 2; }
    .legal-doc__grid > .legal-related { grid-column: 5 / -1; grid-row: 3; }
    /* A document with no sections reads in one centred column */
    .legal-doc__grid.legal-doc__grid--single > * { grid-column: 3 / span 8; }
}

/* "On this page": the entries hang off one rail, the same as a guide's contents */
.legal-toc .wg-widget__list {
    margin-left: .25rem;
    border-left: 1px solid var(--rule);
}
.legal-toc .wg-widget__list > li { border-top: 0; }
.legal-toc .wg-widget__list a {
    min-height: 0;
    padding: .5rem 0 .5rem 1rem;
    font-size: var(--fs-small);
    line-height: 1.4;
}
.legal-toc .wg-widget__list a::before {
    top: calc(.5rem + .7em);
    left: -3.5px;
}
.legal-toc .wg-widget__list a:focus-visible::before { opacity: 1; transform: none; }
@media (hover: hover) and (pointer: fine) {
    .legal-toc .wg-widget__list a:hover::before { opacity: 1; transform: none; }
}
@media (min-width: 992px) {
    /* Clear of the stuck header and the back-to-top square; a long list scrolls inside itself */
    .legal-toc {
        max-height: calc(100vh - 72px - var(--s-5) - 5.5rem);
        overflow-y: auto;
        scrollbar-width: thin;
        scrollbar-color: var(--rule-strong) transparent;
    }
}
@media (max-width: 991px) {
    .legal-toc .wg-widget__list { columns: 2 14rem; column-gap: var(--gap); }
    .legal-toc .wg-widget__list > li { break-inside: avoid; }
}

/* The text */
.legal-body { max-width: 42rem; }
.legal-body > .wg-lead { color: var(--fg-strong); }
.legal-body > p,
.legal-body li { line-height: 1.7; }
.legal-body h2 {
    margin: 2.5em 0 .75em;
    padding-top: var(--s-5);
    border-top: 1px solid var(--rule);
    font-size: clamp(1.5rem, 1.3rem + .8vw, 2rem);
    scroll-margin-top: calc(72px + var(--s-5));
}
.legal-body > h2:first-child,
.legal-body > .wg-lead + h2 { margin-top: 1.75em; }
.legal-body h3 { margin: 1.75em 0 .5em; font-size: var(--fs-h4); font-weight: 620; }
.legal-body ol { padding-left: 1.4em; }
.legal-body ol li { margin-bottom: .4em; }
.legal-body code {
    padding: .05em .35em;
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    color: var(--fg-strong);
    font-family: var(--font-mono);
    font-size: .875em;
    overflow-wrap: anywhere;
}

/* Data tables: a strong rule, a 620 head row, hairline rows. Below 640px a table scrolls in its own region. */
.legal-table {
    position: relative;
    margin: 0 0 var(--s-6);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-top: 1px solid var(--rule-strong);
    scrollbar-width: thin;
    scrollbar-color: var(--rule-strong) transparent;
}
.legal-table table {
    width: 100%;
    min-width: 560px;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--fs-small);
    line-height: 1.55;
}
.legal-table th,
.legal-table td {
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--rule);
    font-weight: 400;
    text-align: left;
    vertical-align: top;
}
.legal-table :is(th, td):first-child { padding-left: 0; }
.legal-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;
}
.legal-table tbody th { color: var(--fg-strong); font-weight: 600; }
.legal-table--narrow table { min-width: 0; }   /* two columns fit a phone: no sideways scroll */
.legal-table:focus-visible { outline-offset: 3px; }
.legal-body .legal-table__hint { margin: 0 0 .625rem; }
@media (min-width: 640px) {
    .legal-body .legal-table__hint { display: none; }
}

/* The other documents: two columns of rows under a strong rule */
.legal-related {
    margin-top: var(--s-8);
    padding-top: var(--s-5);
    border-top: 1px solid var(--rule-strong);
}
.legal-related__title {
    margin: 0 0 var(--s-3);
    font-size: var(--fs-h4);
    font-weight: 620;
    line-height: 1.3;
}
@media (min-width: 640px) {
    .legal-related .wg-widget__list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: var(--gap);
    }
}
.legal-related .wg-widget__list a::before { display: none; }

/* 2. Hub: two groups of documents, each a ruled list; the title link covers its entry
   ----------------------------------------------------------------------- */
.legal-hub { display: grid; gap: var(--s-7) var(--gap); }
@media (min-width: 992px) {
    .legal-hub {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: clamp(2rem, .5rem + 4vw, 5rem);
    }
}
.legal-group__title {
    margin: 0 0 var(--s-4);
    font-size: var(--fs-h3);
    font-weight: 620;
    line-height: 1.25;
    letter-spacing: -.014em;
}
.legal-hub__list {
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--rule-strong);
    list-style: none;
}
.legal-entry {
    position: relative;
    display: grid;
    gap: .375rem;
    padding: var(--s-5) 0;
    border-bottom: 1px solid var(--rule);
}
.legal-entry__name {
    justify-self: start;
    color: var(--fg-strong);
    font-size: var(--fs-h4);
    font-weight: 620;
    line-height: 1.3;
    letter-spacing: -.01em;
    text-decoration: underline;
    text-decoration-color: transparent;
    text-decoration-thickness: 1px;
    text-underline-offset: .2em;
    transition: text-decoration-color var(--dur-fast) var(--ease-out);
}
.legal-entry__name::after { content: ""; position: absolute; inset: 0; }
.legal-entry__name .wg-icon { color: var(--accent-fg); transition: transform var(--dur) var(--ease-out); }
.legal-entry__name:hover,
.legal-entry__name:focus-visible { color: var(--fg-strong); text-decoration-color: var(--accent-fg); }
.legal-entry__name:focus-visible { outline: none; }
.legal-entry:has(.legal-entry__name:focus-visible) { outline: 2px solid var(--focus); outline-offset: 4px; border-radius: var(--radius-sm); }
@media (hover: hover) and (pointer: fine) {
    .legal-entry:hover .legal-entry__name { text-decoration-color: var(--accent-fg); }
    .legal-entry:hover .legal-entry__name .wg-icon { transform: translateX(3px); }
}
.legal-entry__summary { max-width: 34rem; margin: 0; color: var(--fg); }
.legal-entry .wg-meta { margin: .25rem 0 0; }

.legal-hub__who {
    margin-top: var(--s-8);
    padding-top: var(--s-5);
    border-top: 1px solid var(--rule);
}
.legal-hub__who h2 {
    margin: 0 0 .5em;
    padding-top: 0;
    border-top: 0;
    font-size: var(--fs-h3);
}
.legal-hub__who p:last-child { margin-bottom: 0; }

@media print {
    .legal-doc__side, .legal-related { display: none !important; }
    .legal-doc__grid { display: block; }
    .legal-table { overflow: visible; }
    .legal-table table { min-width: 0; }
}
