* {
    box-sizing: border-box;
}

:root {
    --space: #050a35;
    --cream: #f8f3d9;
    --lavender: #aeb7ed;
    --dim: rgba(174, 183, 237, 0.38);
    --line: rgba(174, 183, 237, 0.25);
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
}

body {
    overflow: hidden;
    background: var(--space);
    color: var(--cream);
    font-family: "Silkscreen", monospace;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;

    background: radial-gradient(
        ellipse at center,
        transparent 42%,
        rgba(0, 0, 0, 0.38) 100%
    );
}

#starfield {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.explore-page {
    position: relative;
    z-index: 2;

    width: min(1400px, 92vw);
    height: 100%;
    margin: 0 auto;

    display: flex;
    flex-direction: column;

    padding: clamp(24px, 4vh, 48px) 0
             clamp(18px, 3vh, 32px);
}


/* =========================
   HEADER
   ========================= */

.page-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: start;
    gap: 24px;

    flex: 0 0 auto;
}

.page-header h1 {
    margin: 0;

    text-align: center;

    font-size: clamp(28px, 4vw, 48px);
    line-height: 1;
    letter-spacing: 0.04em;

    text-shadow:
        3px 3px 0 rgba(174, 183, 237, 0.2);
}

.page-header p {
    margin: 12px 0 0;

    color: var(--lavender);

    text-align: center;

    font-size: clamp(10px, 1.2vw, 14px);
    letter-spacing: 0.08em;
}

.back-link {
    justify-self: start;

    color: var(--lavender);
    text-decoration: none;

    font-size: clamp(10px, 1.1vw, 13px);

    padding-top: 5px;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--cream);
}

.header-spacer {
    display: block;
}


/* =========================
   MAIN EXPLORER
   ========================= */

.explorer {
    min-height: 0;

    flex: 1 1 auto;

    display: grid;

    /*
        The list gets the slightly bigger visual presence.
        We're here to show quantity, not pretend every project
        is the second coming of Minecraft.
    */
    grid-template-columns:
        minmax(360px, 1.05fr)
        minmax(360px, 0.95fr);

    align-items: center;

    gap: clamp(42px, 7vw, 110px);

    padding: clamp(24px, 4vh, 48px) 0;
}


/* =========================
   PROJECT LIST
   ========================= */

.project-list-wrap {
    position: relative;

    min-width: 0;

    height: min(68vh, 620px);

    overflow: hidden;
}

/*
    Fade the edges of the list into space.
    This makes the list look like it continues forever.
*/
.project-list-wrap::before,
.project-list-wrap::after {
    content: "";

    position: absolute;

    left: 0;
    right: 0;

    height: 25%;

    z-index: 3;

    pointer-events: none;
}

.project-list-wrap::before {
    top: 0;

    background: linear-gradient(
        to bottom,
        var(--space) 0%,
        transparent 100%
    );
}

.project-list-wrap::after {
    bottom: 0;

    background: linear-gradient(
        to top,
        var(--space) 0%,
        transparent 100%
    );
}

.project-list {
    position: absolute;
    inset: 0;

    display: flex;
    flex-direction: column;

    justify-content: center;

    gap: 3px;

    outline: none;
}

.project-item {
    position: relative;

    width: 100%;

    flex: 0 0 clamp(34px, 5vh, 50px);

    border: 0;

    background: transparent;

    color: var(--dim);

    font: inherit;
    font-size: clamp(11px, 1.25vw, 16px);

    text-align: left;

    padding: 0 28px;

    cursor: pointer;

    transition:
        color 120ms linear,
        opacity 120ms linear,
        transform 120ms ease;
}

.project-item::before {
    content: "";

    position: absolute;

    left: 0;
    top: 50%;

    width: 0;
    height: 2px;

    background: var(--cream);

    transform: translateY(-50%);

    transition: width 120ms ease;
}

.project-item.selected {
    color: var(--cream);

    font-weight: 700;

    transform: translateX(10px);
}

.project-item.selected::before {
    width: 16px;
}

.project-item:focus-visible {
    color: var(--cream);

    outline: 1px dashed var(--lavender);
    outline-offset: 4px;
}


/* =========================
   PROJECT PREVIEW
   ========================= */

.project-preview {
    min-width: 0;

    display: flex;
    flex-direction: column;

    justify-content: center;
}


/*
    THE THUMBNAIL IS NOW CLICKABLE.

    The image itself gets darker on hover,
    while the play icon stays bright.
*/
.preview-image-wrap {
    position: relative;

    display: block;

    width: min(100%, 560px);

    aspect-ratio: 16 / 10;

    border: 1px solid var(--line);

    background: rgba(5, 10, 53, 0.58);

    overflow: hidden;

    text-decoration: none;

    cursor: pointer;
}

.preview-image-wrap img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;

    image-rendering: pixelated;

    transition:
        filter 160ms ease,
        transform 160ms ease;
}


/*
    Tiny pixel-ish frame.
*/
.preview-image-wrap::after {
    content: "";

    position: absolute;

    inset: 0;

    pointer-events: none;

    border: 4px solid rgba(174, 183, 237, 0.035);
}


/*
    Play icon starts invisible.

    It's deliberately NOT a huge modern circular
    play button. We're making a weird little
    retro interface, not YouTube.
*/
.play-overlay {
    position: absolute;

    left: 50%;
    top: 50%;

    z-index: 2;

    color: var(--cream);

    font-size: clamp(28px, 4vw, 52px);

    opacity: 0;

    transform:
        translate(-50%, -50%)
        scale(0.82);

    text-shadow:
        3px 3px 0 rgba(5, 10, 53, 0.8);

    transition:
        opacity 140ms ease,
        transform 140ms ease;
}


/*
    Hovering the thumbnail:
    darken the picture + reveal the little bastard.
*/
.preview-image-wrap:hover img,
.preview-image-wrap:focus-visible img {
    filter: brightness(0.62);
}

.preview-image-wrap:hover .play-overlay,
.preview-image-wrap:focus-visible .play-overlay {
    opacity: 1;

    transform:
        translate(-50%, -50%)
        scale(1);
}

.preview-image-wrap:focus-visible {
    outline: 1px dashed var(--cream);
    outline-offset: 5px;
}


/* =========================
   IMAGE FALLBACK
   ========================= */

.image-fallback {
    position: absolute;
    inset: 0;

    display: grid;
    place-items: center;

    text-align: center;

    color: var(--dim);

    font-size: clamp(11px, 1.2vw, 15px);

    line-height: 1.8;
}


/* =========================
   PROJECT INFO
   ========================= */

.preview-copy {
    width: min(100%, 560px);
}

.project-title-row {
    display: flex;

    align-items: baseline;
    justify-content: space-between;

    gap: 20px;

    margin-top: 18px;
}

.project-title-row h2 {
    margin: 0;

    font-size: clamp(18px, 2vw, 27px);

    line-height: 1.2;

    letter-spacing: 0.03em;
}

.project-count {
    flex: 0 0 auto;

    color: var(--lavender);

    font-size: clamp(9px, 1vw, 12px);
}

#project-description {
    max-width: 54ch;

    margin: 12px 0 22px;

    color: var(--lavender);

    font-size: clamp(10px, 1.05vw, 13px);

    line-height: 1.8;
}


/* =========================
   ENTER BUTTON
   ========================= */

.enter-button {
    display: inline-block;

    border: 1px solid rgba(248, 243, 217, 0.7);

    color: var(--cream);

    background: rgba(5, 10, 53, 0.4);

    padding: 12px 17px;

    font: inherit;

    font-size: clamp(10px, 1vw, 13px);

    text-decoration: none;

    transition:
        background 120ms ease,
        color 120ms ease,
        transform 120ms ease;
}

.enter-button:hover,
.enter-button:focus-visible {
    background: var(--cream);

    color: var(--space);

    transform: translateY(-2px);
}


/* =========================
   MOBILE CONTROLS
   ========================= */

.mobile-controls,
.mobile-hint {
    display: none;
}

.controls-hint {
    flex: 0 0 auto;

    text-align: center;

    color: var(--dim);

    font-size: clamp(9px, 0.9vw, 11px);

    letter-spacing: 0.04em;
}


/* =========================
   MOBILE
   ========================= */

@media (max-width: 800px) {

    body {
        overflow: hidden;
    }

    .explore-page {
        width: min(92vw, 560px);

        padding:
            22px 0
            18px;
    }

    .page-header {
        grid-template-columns: 1fr auto;

        gap: 14px;
    }

    .page-header > div {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    .back-link {
        grid-column: 1;
        grid-row: 2;

        padding-top: 0;
    }

    .header-spacer {
        grid-column: 2;
        grid-row: 2;
    }


    /*
        On mobile we hide the big desktop list.
        The counter + previous/next controls make
        the existence of the full collection explicit.
    */
    .explorer {
        display: flex;

        flex-direction: column;

        justify-content: center;
        align-items: stretch;

        gap: 0;

        padding: 18px 0 12px;
    }

    .project-list-wrap {
        display: none;
    }

    .project-preview {
        width: 100%;
    }

    .preview-image-wrap,
    .preview-copy {
        width: 100%;
    }

    .preview-image-wrap {
        aspect-ratio: 16 / 10;
    }

    .project-title-row {
        margin-top: 14px;
    }

    #project-description {
        margin: 9px 0 17px;

        line-height: 1.65;
    }


    /*
        Mobile navigation is intentionally obvious.
        Nobody should have to discover an invisible
        keyboard shortcut like some fucking archaeologist.
    */
    .mobile-controls {
        display: flex;

        gap: 10px;

        width: 100%;

        flex: 0 0 auto;
    }

    .mobile-controls button {
        flex: 1;

        min-height: 42px;

        border: 1px solid var(--line);

        background: rgba(5, 10, 53, 0.45);

        color: var(--lavender);

        font: inherit;

        font-size: 9px;

        cursor: pointer;
    }

    .mobile-controls button:active {
        background: rgba(174, 183, 237, 0.12);

        color: var(--cream);
    }

    .mobile-controls button:focus-visible {
        outline: 1px dashed var(--cream);

        outline-offset: 3px;
    }

    .desktop-hint {
        display: none;
    }

    .mobile-hint {
        display: inline;
    }

    .controls-hint {
        margin-top: 11px;
    }
}


/* =========================
   SHORT DESKTOP SCREENS
   ========================= */

@media (max-height: 620px) and (min-width: 801px) {

    .explore-page {
        padding-top: 18px;
        padding-bottom: 14px;
    }

    .explorer {
        padding: 14px 0;
    }

    .project-list-wrap {
        height: min(60vh, 420px);
    }

    .project-item {
        flex-basis: 34px;
    }

    .preview-image-wrap {
        max-height: 42vh;
    }
}