.home-scroll-cue {
    --project-chevron-size: 12px;
    position: absolute;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    z-index: 5;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    color: #fff;
    text-decoration: none;
    transform: translateX(-50%);
    touch-action: manipulation;
}

.home-scroll-cue .project-chevron {
    transform: rotate(135deg);
}

.home-scroll-cue:focus-visible {
    outline: 1px solid #fff;
    outline-offset: 2px;
}

.fp-enabled #sectionone:not(.active) .home-scroll-cue {
    visibility: hidden;
}

:is(#sectionthree, #sectionfour) {
    --project-nav-inset: clamp(4px, 1.5vw, 22px);
    --project-nav-button-padding: 4px;
    --project-nav-button-gap: 9px;
    --project-chevron-size: 8.5px;
    --project-bar-height: calc(56px + env(safe-area-inset-bottom, 0px));
    --project-panel-padding: 1.5rem;
    --project-panel-padding-block: var(--project-panel-padding);
    --project-panel-vertical-extension: 0px;
    --project-panel-text-inset: calc(
        var(--project-nav-inset) + var(--project-nav-button-padding) +
        var(--project-chevron-size) + var(--project-nav-button-gap)
    );
    --project-panel-inset: calc(var(--project-panel-text-inset) - var(--project-panel-padding));
    --project-title-delay: 0.3s;
}

:is(#sectionthree, #sectionfour) .fp-controlArrow {
    display: none;
}

.project-browser {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 5;
    box-sizing: border-box;
    padding: 0 var(--project-nav-inset) env(safe-area-inset-bottom, 0px);
    background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.3) 28px);
}

:is(#sectionthree, #sectionfour):not(.active) .project-browser {
    visibility: hidden;
}

.project-browser-controls {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    height: 56px;
}

.project-browser button {
    display: flex;
    align-items: center;
    gap: var(--project-nav-button-gap);
    min-height: 48px;
    padding: 0 var(--project-nav-button-padding);
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: clamp(12px, 3.5vw, 16px);
    white-space: nowrap;
    cursor: pointer;
    touch-action: manipulation;
}

.project-browser button:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.project-browser button:focus-visible,
.project-description-toggle:focus-visible,
.project-description:focus-visible {
    outline: 1px solid #fff;
    outline-offset: -1px;
}

.project-next {
    grid-column: 3;
    justify-content: flex-end;
}

.project-chevron {
    box-sizing: border-box;
    width: var(--project-chevron-size);
    height: var(--project-chevron-size);
    border-top: 1.5px solid currentColor;
    border-right: 1.5px solid currentColor;
    transform: rotate(45deg);
}

.project-previous .project-chevron {
    transform: rotate(-135deg);
}

.project-counter {
    color: #ddd;
    font-size: clamp(11px, 2.2vw, 13px);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

:is(#sectionthree, #sectionfour) .slide .intro {
    --project-description-progress: 0;
    position: absolute;
    bottom: calc(var(--project-bar-height) - var(--project-panel-vertical-extension) * var(--project-description-progress));
    left: var(--project-panel-inset);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: fit-content;
    max-width: min(calc(42rem + 2 * var(--project-panel-extra-padding, 0px)),
                   calc(100% - 2 * var(--project-panel-inset)));
    max-height: calc(min(var(--project-panel-height-limit, 57%),
                         100% - var(--project-bar-height) - 88px) + 2 * var(--project-panel-vertical-extension));
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 160ms ease-in, transform 160ms ease-in, visibility 0s 160ms;
}

:is(#sectionthree, #sectionfour) .slide .intro.is-description-open {
    --project-description-progress: 1;
    width: 100%;
    /* Reveal the full width before the close icon fades in. */
    clip-path: inset(0 max(0px, (100% - var(--project-description-collapsed-width, 100%)) *
                           max(0, 1 - 2 * var(--project-description-progress))) 0 0);
}

:is(#sectionthree, #sectionfour) .slide .intro::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(0, 0, 0, 0.5);
    opacity: var(--project-description-progress);
    pointer-events: none;
}

:is(#sectionthree, #sectionfour) .is-current-slide .intro {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    transition: opacity 250ms ease-out,
                transform 250ms ease-out,
                visibility 0s;
    transition-delay: var(--project-title-delay);
}

.project-title {
    flex: 0 0 auto;
    margin: 0;
    font-size: clamp(16px, 2vw, 22px);
    line-height: 1.2;
}

.project-description-toggle {
    position: relative;
    display: flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    min-height: 44px;
    padding-inline: var(--project-panel-padding);
    padding-block: calc(6px + (var(--project-panel-padding-block) - 6px) * var(--project-description-progress))
                   calc(6px + 2px * var(--project-description-progress));
    border: 0;
    background: rgba(0, 0, 0, calc(0.55 * (1 - var(--project-description-progress))));
    color: inherit;
    font: inherit;
    text-align: left;
    overflow-wrap: anywhere;
    cursor: pointer;
    touch-action: manipulation;
}

.is-description-open .project-description-toggle {
    box-sizing: border-box;
    width: 100%;
}

.is-description-open .project-description-toggle > :first-child {
    max-width: calc(100% - 28px);
}

.project-description-icon {
    position: absolute;
    inset-inline-end: var(--project-panel-padding);
    width: 1em;
    font-size: 18px;
    font-weight: normal;
    line-height: 1;
    text-align: center;
    opacity: max(0, 2 * var(--project-description-progress) - 1);
    pointer-events: none;
}

.project-description-icon::before {
    content: '×';
}

.shows-reopen-icon .project-description-icon {
    position: static;
    flex: 0 0 1em;
    margin-inline-start: 10px;
    opacity: 1;
}

.shows-reopen-icon .project-description-icon::before {
    content: '+';
}

.project-description {
    min-height: 0;
    padding: 0 var(--project-panel-padding) var(--project-panel-padding-block);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #a0a0a0 transparent;
}

.project-description::-webkit-scrollbar {
    display: block;
    width: 5px;
}

.project-description::-webkit-scrollbar-thumb {
    border-radius: 5px;
    background: #a0a0a0;
}

.project-description h3 {
    margin: 0 0 8px;
    font-size: 0.875rem;
    line-height: 1.4;
}

.project-description p:last-child {
    margin-bottom: 0;
}

@media (max-width: 767px) {
    :is(#sectionthree, #sectionfour) {
        --project-nav-inset: clamp(8px, 3vw, 44px);
        --project-panel-padding: calc(clamp(1.6rem, calc(var(--project-panel-text-inset) - 2px), 2.35rem) * 2 / 3);
        --project-panel-extra-padding: calc(var(--project-panel-padding) - 0.8rem);
        --project-panel-padding-block: 1.175rem;
        /* Move the bottom edge with the padding so the text stays put. */
        --project-panel-vertical-extension: calc(var(--project-panel-padding-block) - 1.6rem);
        --project-panel-height-limit: calc(57% + 1.6rem);
    }

    .project-title {
        font-size: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    :is(#sectionthree, #sectionfour) .slide .intro {
        transition: none;
    }

    :is(#sectionthree, #sectionfour) .is-current-slide .intro {
        transition: visibility 0s var(--project-title-delay);
    }
}
