/*
 * Content pages: prose, tables, FAQ, callouts, cards, bands.
 *
 * Everything is scoped to .u-page__content--prose, a class page.php adds
 * only to ordinary content pages (see inc/pages.php). Checkout, account
 * and any page holding a store shortcode never get it, so nothing here
 * can restyle a purchase form.
 *
 * Written for HTML typed into a page's content (the content API, or the
 * editor): plain h2/h3/p/ul/table/details work with no classes, and the
 * u-pg-* classes below add the patterns plain HTML cannot express. The
 * HTML filter keeps all of these tags and classes; it drops scripts,
 * styles and iframes.
 *
 * Patterns (documented in content_ideas/PAGE-PATTERNS.md):
 *   .u-pg-lede      intro paragraph, larger
 *   .u-pg-callout   note box; add --warn for a caution
 *   .u-pg-table     wrapper that scrolls a wide table on phones
 *   .u-pg-spec      <dl> of label / value rows (requirements, facts)
 *   .u-pg-cards     grid of .u-pg-card (2-3 columns, stacks on mobile)
 *   .u-pg-band      full-width band; --soft or --dark; inner .u-pg-band__inner
 *   .u-pg-cta       call-to-action block (heading, text, .u-btn links)
 *   <details>       accordion, no JavaScript
 */

.u-page__content--prose {
    --pg-measure: 760px;
    font-size: 17px;
    line-height: 1.7;
    color: var(--u-text);
}

/* Reading width for text; wide things (tables, cards, bands) use the
   full container. :where() keeps specificity at one class so a pattern
   below can override it. */
.u-page__content--prose > :where(p, ul, ol, dl, h2, h3, h4, h5, h6, blockquote, details, hr, pre, .u-pg-callout) {
    max-width: var(--pg-measure);
}

.u-page__content--prose p {
    margin: 0 0 1.1em;
}

.u-page__content--prose > p:first-child {
    margin-top: 0;
}

.u-page__content--prose h2,
.u-page__content--prose h3,
.u-page__content--prose h4,
.u-page__content--prose h5,
.u-page__content--prose h6 {
    color: var(--u-ink);
    font-weight: 900;
    letter-spacing: -0.03em;
    line-height: 1.15;
    scroll-margin-top: calc(var(--u-header-h) + 16px);
}

.u-page__content--prose h2 {
    margin: 2.2em 0 .55em;
    font-size: clamp(24px, 2.6vw, 34px);
}

.u-page__content--prose h3 {
    margin: 1.9em 0 .5em;
    font-size: clamp(20px, 2vw, 25px);
}

.u-page__content--prose h4 {
    margin: 1.7em 0 .45em;
    font-size: 19px;
}

/* Older pages use h5/h6 as small headings. */
.u-page__content--prose h5,
.u-page__content--prose h6 {
    margin: 1.5em 0 .4em;
    font-size: 16px;
    letter-spacing: -0.01em;
}

.u-page__content--prose > :first-child {
    margin-top: 0;
}

.u-site .u-page__content--prose a:not(.u-btn) {
    color: var(--u-brand);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.u-site .u-page__content--prose a:not(.u-btn):hover {
    color: var(--u-brand-hover);
}

.u-page__content--prose strong,
.u-page__content--prose b {
    color: var(--u-ink);
}

.u-page__content--prose ul,
.u-page__content--prose ol {
    margin: 0 0 1.2em;
    padding-left: 1.4em;
}

.u-page__content--prose li {
    margin-bottom: .4em;
}

.u-page__content--prose li > ul,
.u-page__content--prose li > ol {
    margin: .4em 0 0;
}

.u-page__content--prose hr {
    margin: 2.2em 0;
    border: 0;
    border-top: 1px solid var(--u-line);
}

.u-page__content--prose blockquote {
    margin: 1.6em 0;
    padding: .2em 0 .2em 1.2em;
    border-left: 3px solid var(--u-accent);
    color: var(--u-muted);
    font-size: 1.05em;
}

.u-page__content--prose code {
    padding: .1em .4em;
    background: var(--u-surface-soft);
    border-radius: 4px;
    font-size: .9em;
}

.u-page__content--prose img {
    display: block;
    margin: 1.6em 0;
    border-radius: var(--u-radius-lg);
}

.u-page__content--prose figure {
    margin: 1.6em 0;
}

.u-page__content--prose figcaption {
    margin-top: .5em;
    font-size: 14px;
    color: var(--u-muted);
}

/* Intro line -------------------------------------------------------- */

.u-page__lede {
    max-width: 760px;
    margin: -12px 0 28px;
    font-size: clamp(17px, 1.7vw, 20px);
    line-height: 1.55;
    color: var(--u-muted);
}

.u-page__content--prose .u-pg-lede {
    font-size: clamp(18px, 1.8vw, 21px);
    line-height: 1.55;
    color: var(--u-muted);
}

/* Tables ------------------------------------------------------------ */

/* A bare <table> still works: it scrolls sideways on its own. Wrapping
   it in .u-pg-table keeps it full width on desktop. */
.u-page__content--prose table {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 1.6em 0;
    overflow-x: auto;
    border-collapse: collapse;
    font-size: 15px;
    line-height: 1.5;
    -webkit-overflow-scrolling: touch;
}

.u-page__content--prose .u-pg-table {
    margin: 1.6em 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.u-page__content--prose .u-pg-table > table {
    display: table;
    margin: 0;
    overflow: visible;
}

.u-page__content--prose th,
.u-page__content--prose td {
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid var(--u-line);
    /* reset.css tints every cell (rgba(128,128,128,.07)); the row
       carries the zebra instead. */
    background: transparent;
    text-align: left;
    vertical-align: top;
}

.u-page__content--prose thead th {
    background: var(--u-surface-soft);
    border-bottom: 1px solid var(--u-line-strong);
    color: var(--u-ink);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* thead headings inside older pages are <h6>; keep them from adding
   their own margins in a cell. */
.u-page__content--prose th > h1,
.u-page__content--prose th > h2,
.u-page__content--prose th > h3,
.u-page__content--prose th > h4,
.u-page__content--prose th > h5,
.u-page__content--prose th > h6 {
    margin: 0;
    font-size: inherit;
    letter-spacing: inherit;
}

.u-page__content--prose tbody tr:nth-child(even) {
    background: #FAFBFC;
}

.u-page__content--prose td:first-child {
    font-weight: 600;
    color: var(--u-ink);
}

.u-page__content--prose td small {
    display: block;
    margin-top: 2px;
    color: var(--u-muted);
    font-weight: 400;
}

.u-page__content--prose .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Callouts ---------------------------------------------------------- */

.u-page__content--prose .u-pg-callout {
    margin: 1.6em 0;
    padding: 16px 20px;
    background: var(--u-surface-warm);
    border: 1px solid #EBDDAF;
    border-left: 4px solid var(--u-accent);
    border-radius: var(--u-radius);
    font-size: 16px;
    line-height: 1.6;
}

.u-page__content--prose .u-pg-callout > :last-child {
    margin-bottom: 0;
}

.u-page__content--prose .u-pg-callout--warn {
    background: #FDF1F0;
    border-color: #F0C9C6;
    border-left-color: var(--u-brand);
}

/* FAQ accordion ----------------------------------------------------- */

.u-page__content--prose details {
    margin: 0;
    border-bottom: 1px solid var(--u-line);
}

.u-page__content--prose details:first-of-type {
    border-top: 1px solid var(--u-line);
}

.u-page__content--prose summary {
    position: relative;
    padding: 18px 40px 18px 0;
    list-style: none;
    cursor: pointer;
    color: var(--u-ink);
    font-size: 17px;
    font-weight: 700;
    line-height: 1.4;
}

.u-page__content--prose summary::-webkit-details-marker {
    display: none;
}

.u-page__content--prose summary::after {
    content: "+";
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
    color: var(--u-muted);
}

.u-page__content--prose details[open] > summary::after {
    content: "\2212";
}

.u-page__content--prose summary:focus-visible {
    outline: 2px solid var(--u-brand);
    outline-offset: 2px;
}

.u-page__content--prose details > :not(summary) {
    margin-top: 0;
}

.u-page__content--prose details > :last-child {
    margin-bottom: 1.2em;
}

/* Spec list (requirements, facts) ------------------------------------ */

.u-page__content--prose .u-pg-spec {
    max-width: none;
    margin: 1.6em 0;
    padding: 0;
    border-top: 1px solid var(--u-line);
}

.u-page__content--prose .u-pg-spec > div {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr;
    gap: 6px 24px;
    padding: 14px 0;
    border-bottom: 1px solid var(--u-line);
}

.u-page__content--prose .u-pg-spec dt {
    margin: 0;
    font-weight: 700;
    color: var(--u-ink);
}

.u-page__content--prose .u-pg-spec dd {
    margin: 0;
}

.u-page__content--prose .u-pg-spec dd small {
    display: block;
    color: var(--u-muted);
}

@media (max-width: 640px) {
    .u-page__content--prose .u-pg-spec > div {
        grid-template-columns: 1fr;
    }
}

/* Cards ------------------------------------------------------------- */

.u-page__content--prose .u-pg-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    max-width: none;
    margin: 1.8em 0;
    padding: 0;
    list-style: none;
}

.u-page__content--prose .u-pg-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 24px;
    background: var(--u-surface);
    border: 1px solid var(--u-line);
    border-radius: var(--u-radius-lg);
}

.u-page__content--prose .u-pg-card > :where(h2, h3, h4) {
    margin: 0;
    font-size: 19px;
}

.u-page__content--prose .u-pg-card p {
    margin: 0;
    font-size: 15px;
    line-height: 1.55;
    color: var(--u-muted);
}

.u-page__content--prose .u-pg-card > :last-child:is(a) {
    margin-top: auto;
    padding-top: 8px;
    font-weight: 700;
}

/* Full-width bands -------------------------------------------------- */

.u-page__content--prose .u-pg-band {
    /* Break out of the container to the viewport edges. base.css clips
       horizontal overflow, so the extra scrollbar width cannot scroll. */
    margin: 3em calc(50% - 50vw);
    padding: clamp(40px, 6vw, 72px) 0;
    background: var(--u-surface-soft);
}

.u-page__content--prose .u-pg-band--dark {
    background: var(--u-dark);
    color: var(--u-dark-text);
}

.u-page__content--prose .u-pg-band--dark :where(h2, h3, h4, strong) {
    color: #fff;
}

.u-page__content--prose .u-pg-band__inner {
    max-width: calc(var(--u-container) + 2 * var(--u-gutter));
    margin-inline: auto;
    padding-inline: var(--u-gutter);
}

.u-page__content--prose .u-pg-band__inner > :first-child {
    margin-top: 0;
}

.u-page__content--prose .u-pg-band__inner > :last-child {
    margin-bottom: 0;
}

/* Call to action ---------------------------------------------------- */

.u-page__content--prose .u-pg-cta {
    max-width: none;
    margin: 2.6em 0 0;
    padding: clamp(28px, 4vw, 44px);
    background: var(--u-dark);
    border-radius: var(--u-radius-lg);
    color: var(--u-dark-text);
}

.u-page__content--prose .u-pg-cta > :where(h2, h3) {
    margin: 0 0 .4em;
    color: #fff;
}

.u-page__content--prose .u-pg-cta p {
    max-width: 56ch;
    margin: 0 0 1.2em;
}

.u-page__content--prose .u-pg-cta .u-btn {
    margin: 0 10px 10px 0;
}

@media (max-width: 767px) {
    .u-page__content--prose {
        font-size: 16px;
    }

    .u-page__content--prose th,
    .u-page__content--prose td {
        padding: 10px 12px;
    }

    /* A wide table scrolls sideways inside its wrapper, so give its
       columns a readable width instead of squeezing every column to a
       sliver (a licence table has sentences in its cells). Number
       columns keep their natural width. */
    .u-page__content--prose .u-pg-table th,
    .u-page__content--prose .u-pg-table td {
        min-width: 9rem;
    }

    .u-page__content--prose .u-pg-table th:first-child,
    .u-page__content--prose .u-pg-table td:first-child {
        min-width: 7rem;
    }

    .u-page__content--prose .u-pg-table th.num,
    .u-page__content--prose .u-pg-table td.num {
        min-width: 0;
    }
}
