/*
 * MAPEL opening screen, design-and-build-state section 4.5.
 * A dark band with the kicker and the title across the full width of the window. Below it the
 * body is prose on the page background, and the consent sentence and the start button sit
 * together in a start box of their own. From 1024px the box stands beside the body, and below
 * 1024px above it. The box never leaves the window. Once its top reaches 24px from the top of the
 * window on a wide screen, or 16px on a narrow one, scripts/mapel-opening.js holds it there with
 * fixed positioning and keeps its place in the page with a placeholder of the same size, so the
 * pinning does not depend on the browser's sticky positioning. On a narrow screen the pinned box
 * keeps 16px of the page background around it, so the text never runs up against it. On a window
 * under 500px tall nothing is pinned. In light mode the start button carries a color of its own,
 * the plum the principal investigator chose, so it stands apart from every other button in the
 * survey. In dark mode it takes the primary color, as the principal investigator decided. The
 * mode button sits at the top right of the band, where the header carries it on every other
 * screen, drawn for the dark band. The header and the progress bar are not drawn on this
 * screen, and the screen takes the 880px cap of a question screen. Values section 4.5 does not
 * state, which are the band colors, the band spacing, the box spacing and the lead size of the
 * first paragraph, are judgements set for the principal investigator's review.
 */
:root {
    --mapel-start: #821551;
    --mapel-start-strong: #6A1142;
    --mapel-on-start: #FFFFFF;
    --mapel-open-band: #12384E;
    --mapel-open-band-title: #FFFFFF;
    --mapel-open-band-kicker: rgba(255, 255, 255, 0.78);
}

:root[data-mapel-mode="dark"] {
    --mapel-start: var(--mapel-primary);
    --mapel-start-strong: var(--mapel-primary-strong);
    --mapel-on-start: var(--mapel-on-primary);
    --mapel-open-band: #1B262E;
    --mapel-open-band-title: #DADDDF;
    --mapel-open-band-kicker: #86AEC2;
}

/* Vanilla's script container above the page is 1px tall, which would show as a line above the band */
body.mapel:has(#mapel-page[data-content="firstpage"]) #beginScripts {
    height: 0;
    overflow: hidden;
}

body.mapel .mapel-welcome {
    margin: 0;
    padding: 0;
    text-align: left;
}

/* The band runs edge to edge while its text stays on the container edge. The shadow carries
   the fill out to the window edges and the clip keeps it from adding to the page height. */
body.mapel .mapel-open-band {
    position: relative;
    margin: 0 0 40px;
    padding: 56px 0 52px;
    background-color: var(--mapel-open-band);
    box-shadow: 0 0 0 100vmax var(--mapel-open-band);
    clip-path: inset(0 -100vmax);
}

body.mapel .mapel-open-kicker {
    margin: 0 0 12px;
    color: var(--mapel-open-band-kicker);
    font-family: var(--mapel-font);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body.mapel .mapel-open-title {
    margin: 0;
    color: var(--mapel-open-band-title);
    font-family: var(--mapel-font);
    font-size: 44px;
    font-weight: 600;
    line-height: 1.18;
    letter-spacing: -0.015em;
}

/* The body and the start box. The body comes first in the page, so it is read first. */
body.mapel .mapel-open-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 288px;
    column-gap: 32px;
    align-items: start;
}

body.mapel .mapel-open-body {
    grid-column: 1;
    grid-row: 1;
}

body.mapel .mapel-open-body p {
    margin: 0 0 16px;
    color: var(--mapel-text);
    font-family: var(--mapel-font);
    font-size: 15px;
    font-weight: 400;
    line-height: 1.6;
}

body.mapel .mapel-open-body p:first-child {
    font-size: 17px;
}

/* The passage the item bank marks in bold */
body.mapel .mapel-open-body strong {
    font-weight: 600;
}

body.mapel .mapel-open-start,
body.mapel .mapel-open-start-place {
    grid-column: 2;
    grid-row: 1;
}

body.mapel .mapel-open-start {
    position: relative;
    z-index: 30;
    padding: 32px 28px;
    border: 1px solid var(--mapel-border);
    border-radius: 12px;
    background-color: var(--mapel-card);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.10);
}

/* Pinned by the script. The placeholder holds the box's place while it is pinned. */
body.mapel .mapel-open-start.mapel-pinned {
    position: fixed;
    margin: 0;
}

body.mapel .mapel-open-start-place {
    display: none;
}

body.mapel .mapel-open-start-place.mapel-holding {
    display: block;
}

body.mapel .mapel-open-consent {
    margin: 0 0 24px;
    padding: 0;
    border: 0;
    color: var(--mapel-heading);
    font-family: var(--mapel-font);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.6;
}

/* The start button, moved into the box by the script, fills the box width */
body.mapel .mapel-open-start .mapel-nav {
    margin: 0 !important;
    padding: 0 !important;
}

body.mapel .mapel-open-start .mapel-next {
    width: 100%;
    height: 64px;
    margin: 0;
    justify-content: center;
    background-color: var(--mapel-start);
    border-color: var(--mapel-start);
    color: var(--mapel-on-start);
    font-size: 17px;
    white-space: nowrap;
}

body.mapel .mapel-open-start .mapel-next:hover,
body.mapel .mapel-open-start .mapel-next:focus-visible {
    background-color: var(--mapel-start-strong);
    border-color: var(--mapel-start-strong);
    color: var(--mapel-on-start);
}

body.mapel .mapel-open-start .mapel-next:focus-visible {
    outline: 2px solid var(--mapel-start);
    outline-offset: 3px;
}

/* Without the script the button stays under the body on the left */
body.mapel #mapel-page[data-content="firstpage"] ~ #outerframeContainer .mapel-next {
    margin-left: 0;
}

@media only screen and (max-width: 1023px) {
    body.mapel .mapel-open-band {
        margin-bottom: 0;
        padding: 36px 0 34px;
    }

    body.mapel .mapel-open-title {
        font-size: 30px;
    }

    body.mapel .mapel-open-main {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    /* The box carries a 16px margin of the page background around it, so space is kept above
       and below it while it is pinned and the text never runs up against it */
    body.mapel .mapel-open-start,
    body.mapel .mapel-open-start-place {
        order: -1;
        margin: 0 0 8px;
    }

    body.mapel .mapel-open-start {
        padding: 24px 20px;
        box-shadow: 0 0 0 16px var(--mapel-page);
    }

    body.mapel .mapel-open-main::before {
        content: "";
        order: -2;
        display: block;
        height: 24px;
    }

    body.mapel .mapel-open-consent {
        margin-bottom: 20px;
        font-size: 14px;
    }

    body.mapel .mapel-open-start .mapel-next {
        height: 60px;
    }

    body.mapel .mapel-open-body {
        padding-top: 20px;
    }

    body.mapel .mapel-open-body p {
        font-size: 14px;
    }

    body.mapel .mapel-open-body p:first-child {
        font-size: 16px;
    }
}

/* The mode button on the band, at the place the header gives it on every other screen, 15px from
   the top and on the right edge of the header's 1240px cap with its 24px gutter */
body.mapel .mapel-open-mode {
    position: absolute;
    top: 15px;
    right: max(24px, calc((100vw - 1240px) / 2));
    z-index: 40;
}

body.mapel .mapel-open-mode .mapel-mode-btn {
    margin: 0;
    border-color: rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.85);
}

body.mapel .mapel-open-mode .mapel-mode-btn:hover {
    border-color: #FFFFFF;
    color: #FFFFFF;
}

body.mapel .mapel-open-mode .mapel-mode-btn:focus-visible {
    outline-color: #FFFFFF;
}

body.mapel .mapel-open-mode .mapel-mode-btn::after {
    background: #FFFFFF;
    color: var(--mapel-open-band);
}
