/* Index is wider than the ordinary board; all overrides stay on this page. */
body.index-page {
    --pico-color: #26352c;
    --pico-muted-color: #49564c;
    --pico-primary: #205737;
    --pico-primary-hover: #173f29;
    --pico-primary-underline: #205737;
    --pico-code-color: #26352c;
    --pico-code-background-color: #eeeFE7;
    width: min(calc(100% - 2rem), 76rem);
    container-type: inline-size;
    line-height: 1.75;
    text-align: start;
    overflow-wrap: anywhere;
}

.index-page h1 {
    max-width: 100%;
    margin-bottom: 2rem;
    font-size: clamp(1.6rem, 4vw, 2.5rem);
}

.index-layout {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    column-gap: clamp(2rem, 5vw, 5rem);
    align-items: start;
}

/* A visible skip link avoids dependence on hover or a hidden control. */
.index-skip {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    margin-bottom: 1.5rem;
    padding-inline: 0.5rem;
}

.index-contents {
    display: block;
    min-width: 0;
    padding: 1rem;
    border: 1px solid #a7b4a6;
    border-radius: var(--pico-border-radius);
    background: #f0f3eb;
}

.index-contents h2 {
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
    line-height: 1.5;
}

.index-contents ul {
    display: block;
    margin: 0;
    padding: 0;
}

.index-contents li {
    display: block;
    margin: 0;
    padding: 0;
    list-style: none;
}

.index-contents a {
    display: flex;
    align-items: center;
    min-height: 2.75rem;
    margin: 0;
    padding: 0.5rem;
    border-radius: 0.2rem;
    line-height: 1.5;
}

.index-article {
    width: 100%;
    min-width: 0;
    max-width: 68ch;
    margin: 0;
    padding: 0;
}

.index-page p {
    margin-bottom: 1.5em;
}

.index-article p,
.index-article ul,
.index-article ol {
    max-width: 68ch;
}

.index-intro {
    font-size: 1.125rem;
    font-weight: 500;
}

.index-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--site-divider-color);
}

.index-section:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.index-section h2 {
    margin-bottom: 1.25rem;
    font-size: 1.5rem;
    line-height: 1.4;
}

.index-section h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    font-size: 1.125rem;
    line-height: 1.5;
}

.index-section li {
    margin-bottom: 0.75rem;
}

.index-page :is(h2, h3, section, main, [id]) {
    scroll-margin-block: 1.5rem;
}

.index-page a,
.index-page a:visited {
    color: var(--pico-primary);
    text-decoration: underline;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

.index-page a:hover {
    color: var(--pico-primary-hover);
    text-decoration-thickness: 0.15em;
}

.index-page :focus {
    outline: 3px solid #205737;
    outline-offset: 4px;
}

.index-article:focus {
    outline-offset: 0.5rem;
}

.index-callout {
    padding: 1rem 1.25rem;
    border-inline-start: 0.25rem solid var(--pico-primary);
    border-radius: 0 var(--pico-border-radius) var(--pico-border-radius) 0;
    background: #f0f3eb;
}

.index-page code {
    white-space: normal;
    overflow-wrap: anywhere;
}

.index-updated {
    color: var(--pico-muted-color);
}

.index-next {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
}

.index-next a,
.index-page footer a {
    display: inline-flex;
    align-items: center;
    min-width: 2.75rem;
    min-height: 2.75rem;
    padding-block: 0.25rem;
}

/* Keep all contents links in normal flow on narrow or short viewports. */
@media (min-width: 64rem) and (min-height: 48rem) {
    .index-contents {
        position: sticky;
        top: 1.5rem;
    }
}

@media (max-width: 63.999rem) {
    .index-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 2.5rem;
    }

    .index-contents,
    .index-article {
        width: 100%;
        max-width: 68ch;
        margin-inline: auto;
    }

    .index-contents ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.25rem 0.75rem;
    }
}

@media (max-width: 35rem) {
    .index-contents ul {
        grid-template-columns: minmax(0, 1fr);
    }

    .index-page h1 {
        gap: 0.5rem;
    }

    .index-callout {
        padding: 0.75rem;
    }
}

/* Container rem units also respond to enlarged text, unlike viewport queries
   whose rem thresholds use the browser's initial font size. */
@container (max-width: 60rem) {
    .index-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 2.5rem;
    }

    .index-contents,
    .index-article {
        width: 100%;
        max-width: 68ch;
        margin-inline: auto;
    }

    .index-contents {
        position: static;
    }
}

@media (prefers-reduced-motion: reduce) {
    .index-page {
        scroll-behavior: auto;
    }

    .index-page * {
        animation: none;
        transition: none;
    }
}

@media (forced-colors: active) {
    .index-page :focus {
        outline-color: Highlight;
    }
}

@media print {
    body.index-page {
        width: 100%;
        color: #000;
        background: #fff;
    }

    .index-layout {
        display: block;
    }

    .index-contents,
    .index-skip,
    .index-next,
    .index-page footer {
        display: none;
    }

    .index-article {
        max-width: none;
    }

    .index-section :is(h2, h3) {
        break-after: avoid;
    }
}
