/* lw-legal-doc -- shared legal-document reading surface: the white document card
   with the sticky "Contents / n of N read" TOC rail + numbered article body
   (recitals/notice band, article heads, clauses, plain-English gloss,
   "Important" callout). Promoted verbatim 2026-08-23 from
   Components/Shared/Form5119/Form5119Document.razor.css (itself lifted from
   the client AccountAgreement page, measured against ledgerwise-ui
   form-5119-document.tsx) when LienWaiverDocument became the second consumer
   -- the lien waiver signing step now reads exactly like the account
   agreement step. Class names keep the historical aa-* prefix. Consumers:
   Form5119Document (account agreement), LienWaiverDocument (lien waiver).
   Colors reference --lw-* tokens. */

/* -- Document shell: TOC sidebar + body --
   overflow:clip (NOT hidden) so the sticky TOC pins against the page
   scroller instead of being confined to the card. */
.aa-doc {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    background: var(--lw-white);
    border: 1px solid var(--lw-border);
    border-radius: var(--lw-radius-card);
    box-shadow: var(--lw-shadow-card);
    overflow: clip;
}

/* -- TOC sidebar --
   The aside spans the card's full height (tinted band + divider, per the
   reference); only the inner wrapper is sticky. */
.aa-toc {
    border-right: 1px solid var(--lw-border);
    background: var(--lw-form-surface);
}

.aa-toc__inner {
    position: sticky;
    top: 8px;
    padding: 20px 12px;
}

.aa-toc__progress {
    padding: 0 12px 12px;
}

.aa-toc__progress-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.aa-toc__progress-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    color: var(--lw-gray-space);
}

.aa-toc__progress-count {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--lw-gray-graphite);
}

.aa-toc__progress-track {
    margin-top: 8px;
    height: 4px;
    border-radius: 9999px;
    background: var(--lw-border);
    overflow: hidden;
}

.aa-toc__progress-fill {
    height: 100%;
    border-radius: 9999px;
    background: var(--lw-primary-blue);
    transition: width 0.3s ease;
}

.aa-toc__nav {
    position: relative;
    display: flex;
    flex-direction: column;
}

.aa-toc__rail {
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 16px;
    width: 1px;
    background: var(--lw-border);
}

.aa-toc__item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start !important;
    gap: 10px;
    padding: 8px 8px 8px 6px;
    border: 0;
    background: transparent;
    border-radius: var(--lw-radius-control);
    text-align: left;
    font-size: 13px;
    color: var(--lw-gray-graphite);
    cursor: pointer;
    transition: color 0.15s ease;
    font-family: inherit;
}

.aa-toc__item:hover {
    color: var(--lw-text-primary);
}

.aa-toc__item.is-active {
    font-weight: 600;
    color: var(--lw-text-primary);
}

.aa-toc__node {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    border: 2px solid var(--lw-border);
    background: var(--lw-white);
    font-size: 9px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--lw-gray-space);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

/* Row hover firms the ring (reference group-hover:border-grey-steel). */
.aa-toc__item:hover .aa-toc__node:not(.is-active):not(.is-read) {
    border-color: var(--lw-gray-steel);
}

.aa-toc__node.is-active {
    border-color: var(--lw-primary-blue);
    color: var(--lw-primary-blue);
}

.aa-toc__node.is-read {
    border-color: var(--lw-success-dark);
    background: var(--lw-success-dark);
    color: var(--lw-white);
}

.aa-toc__node.is-read .mud-icon-root {
    color: var(--lw-white) !important;
    width: 12px;
    height: 12px;
    font-size: 12px;
}

.aa-toc__dot {
    width: 6px;
    height: 6px;
    border-radius: 9999px;
    background: var(--lw-primary-blue);
}

.aa-toc__item-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* -- Document body -- */
.aa-body {
    min-width: 0;
}

/* -- Recitals --
   (The former aa-preamble masthead -- eyebrow + 24px title + gold rule +
   underlined party fields -- was removed 2026-07-19: the reference document
   body opens directly with this band.) */
.aa-recitals {
    border-bottom: 1px solid var(--lw-border);
    background: var(--lw-form-surface);
    padding: 20px 32px;
}

.aa-recitals__label {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--lw-gray-space);
}

.aa-recitals__list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.aa-recital {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.625;
    color: var(--lw-text-primary);
}

.aa-recital strong {
    font-weight: 600;
    color: var(--lw-text-primary);
}

/* -- Articles -- */
.aa-article {
    padding: 24px 32px;
    scroll-margin-top: 16px;
    border-top: 1px solid var(--lw-border);
}

.aa-article:first-child {
    border-top: 0;
}

.aa-article__head {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.aa-article__num {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--lw-primary-blue);
}

.aa-article__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--lw-text-primary);
    margin: 0;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .aa-article__title { font-size: 16px; }
}

.aa-article__clauses {
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.aa-clause__heading {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--lw-text-primary);
}

.aa-clause__text {
    margin: 2px 0 0;
    font-size: 0.875rem;
    line-height: 1.625;
    color: var(--lw-text-primary);
}

/* Plain-English gloss */
.aa-gloss {
    margin-top: 12px;
    border-radius: var(--lw-radius-control);
    background: var(--lw-bg-muted);
    padding: 12px 16px;
}

.aa-gloss__label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--lw-primary-blue);
    margin: 0;
}

.aa-gloss__text {
    margin: 6px 0 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.625;
    color: var(--lw-text-primary);
}

/* "Important" callout (articles 05 / 06 / 08) */
.aa-callout {
    margin-top: 16px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    border-radius: var(--lw-radius-control);
    /* Reference border is warning-badge-text/30. */
    border: 1px solid color-mix(in srgb, var(--lw-status-warning-fg) 30%, transparent);
    background: var(--lw-status-warning-bg);
    padding: 16px 20px;
}

.aa-callout__icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    background: var(--lw-status-warning-fg);
    margin-top: 2px;
}

.aa-callout__icon .mud-icon-root {
    color: var(--lw-white) !important;
    width: 14px;
    height: 14px;
    font-size: 16px;
}

.aa-callout__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--lw-status-warning-fg);
    margin: 0;
}

.aa-callout__text {
    margin: 4px 0 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.625;
    color: var(--lw-text-primary);
}

/* -- Responsive -- */
@media (max-width: 1024px) {
    .aa-doc {
        grid-template-columns: 1fr;
    }

    .aa-toc {
        display: none;
    }

    .aa-recitals,
    .aa-article {
        padding-left: 20px;
        padding-right: 20px;
    }
}
