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

body {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: none;
}

/* ==================================================
   MAIN LAYOUT — DESKTOP
   ================================================== */

#mainContainer {
    position: fixed;
    inset: 0;

    overflow: hidden;
    isolation: isolate;
}

/* ==================================================
   VIEW TRANSITIONS — DESKTOP
   ================================================== */

.view {
    position: absolute;
    inset: 0;
    z-index: 0;

    overflow-x: hidden;
    overflow-y: auto;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    /* transition:
        opacity 1s ease,
        visibility 0s linear 1s; */

    -webkit-overflow-scrolling: touch;
}

.view.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    /* transition:
        opacity 1s ease,
        visibility 0s linear 0s; */
}

/* ==================================================
   SECTION BACKGROUNDS
   ================================================== */

.view::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;

    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    pointer-events: none;
}

#projects::before {
    background-image: url("/images/homepage.jpg");
}

#about::before {
    background-image: url("/images/homepage2.jpg");
}

#contact::before {
    background-image: url("/images/homepage3.jpg");
}

/* ==================================================
   SHARED CONTROL RESET
   ================================================== */

.homeButton,
.contactButton,
.navButton,
.imageButton {
    appearance: none;
    -webkit-appearance: none;

    margin: 0;
    padding: 0;
    border: 0;

    background: transparent;
    box-shadow: none;

    line-height: 0;
    text-decoration: none;
}

/* ==================================================
   HEADER AND NAVIGATION — DESKTOP
   ================================================== */

.header {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 100;

    max-height: 100vh;

    overflow-x: hidden;
    overflow-y: auto;
}

.homeButton {
    display: block;

    width: 100%;
    max-width: 400px;
}

#nameHeading img {
    display: block;

    width: 100%;
    height: auto;
}

.nav {
    width: 100%;
    margin-top: 8px;

    display: flex;
    flex-direction: column;
    align-items: center;

    text-align: center;
}

.navButton {
    display: block;
    margin-top: 4px;

    cursor: default;
}

.navButton img {
    display: block;

    width: 100%;
    max-width: 150px;
    height: auto;

    margin-left: auto;
    margin-right: auto;

    filter: brightness(0);
}

#aboutButton img {
    width: 70%;
}

#contactButton img {
    width: 90%;
}

.navButton:hover,
.navButton.pixel-hovered {
    cursor: pointer;
}

.navButton:hover img {
    filter: brightness(100);
}

.navButton.active img {
    filter: brightness(1);
}

/* ==================================================
   DESKTOP LOOSE PROJECT GRID
   ================================================== */

.imageButtons {
    position: absolute;
    inset: 0 27vw 0 0;

    box-sizing: border-box;
    padding: 7vh 5vw 6vh;

    display: grid;

    grid-template-columns:
        minmax(160px, 1.2fr) minmax(170px, 1fr) minmax(130px, 0.8fr);

    grid-template-rows:
        minmax(220px, 1fr) minmax(220px, 1fr);

    align-items: center;
    justify-items: center;

    column-gap: clamp(30px, 5vw, 90px);
    row-gap: clamp(25px, 5vh, 70px);
}

.imageButton,
#route66Button,
#paintingButton,
#museumButton,
#newfButton,
#toolButton {
    position: relative;

    left: auto;
    top: auto;

    display: block;
    max-width: none;

    color: inherit;
    cursor: default;
}

.imageButton img {
    display: block;

    width: 100%;
    height: auto;

    scale: 1;
}

.imageButton img.pixel-hovered {
    scale: 1.1;
    cursor: pointer;
    filter: brightness(0.3);
}

/* Individual loose-grid placement */

#route66Button {
    grid-column: 1;
    grid-row: 1;

    width: clamp(180px, 18vw, 310px);

    transform: translate(2vw, 6vh);
}

#paintingButton {
    grid-column: 2;
    grid-row: 1;

    width: clamp(160px, 15vw, 260px);

    transform: translate(-1vw, 1vh);
}

#toolButton {
    grid-column: 3;
    grid-row: 1;

    width: clamp(60px, 15vw, 105px);

    transform: translate(-1vw, 8vh);
}

#newfButton {
    grid-column: 1;
    grid-row: 2;

    width: clamp(70px, 5vw, 120px);

    transform: translate(-2vw, -5vh);
}

#museumButton {
    grid-column: 2;
    grid-row: 2;

    width: clamp(95px, 7vw, 155px);

    transform: translate(3vw, -6vh);
}

#paintingButton .mainImage,
#toolButton .mainImage {
    display: block;

    width: 100%;
    height: auto;
}

#newfButton .mainImage {
    border: 6px ridge white;
    box-sizing: border-box;
}

/* ==================================================
   PROJECT DESCRIPTION PNGS — DESKTOP
   ================================================== */

#paintingButton .description,
#route66Button .description,
#toolButton .description,
#newfButton .description,
#museumButton .description {
    position: absolute;
    z-index: 2;

    height: auto;

    /* opacity: 0; */
    /* visibility: hidden; */
    pointer-events: none;

    /* transition: */
    /* opacity 0.5s ease, */
    /* visibility 0s linear 0.5s; */
}

#paintingButton .description {
    left: 50%;
    top: -17%;

    width: 90%;
    margin-top: 5vh;

    transform: translateX(-50%);
}

#route66Button .description {
    left: 28%;
    top: -20%;

    width: 100%;

    transform: translateX(-50%);
}

#toolButton .description {
    left: 40%;
    top: -60%;

    width: 100%;

    transform: translateX(-50%);
}

#newfButton .description {
    left: -60%;
    top: -30%;

    width: 250%;

    transform: rotate(8deg);
}

#museumButton .description {
    left: 78%;
    top: 89%;

    width: 150%;

    transform: translateX(-50%);
}

/* ==================================================
   PROJECT CAPTIONS — DESKTOP
   ================================================== */

.imageButton .caption {
    position: absolute;
    z-index: 2;

    left: 50%;
    top: 42%;

    width: max-content;
    max-width: 150px;

    margin: 10px 0 0;

    transform: translateX(-50%);

    font-family: "Lora", serif;
    font-size: 10pt;
    font-weight: 400;
    line-height: 1.2rem;

    color: white;
    text-align: center;
    text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.5);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition:
        opacity 0.5s ease,
        visibility 0s linear 0.5s;
}

#paintingButton .caption {
    top: 60%;
    max-width: 100px;
}

#museumButton .caption {
    top: 25%;
}

#newfButton .caption {
    top: 30%;
}

#toolButton .caption {
    top: 25%;
}

/* Hover reveals */

#museumButton:has(.mainImage.pixel-hovered) .description,
#museumButton:has(.mainImage.pixel-hovered) .caption,
#newfButton:has(.mainImage.pixel-hovered) .description,
#newfButton:has(.mainImage.pixel-hovered) .caption,
#paintingButton:has(.mainImage.pixel-hovered) .description,
#paintingButton:has(.mainImage.pixel-hovered) .caption,
#route66Button:has(.mainImage.pixel-hovered) .description,
#route66Button:has(.mainImage.pixel-hovered) .caption,
#toolButton:has(.mainImage.pixel-hovered) .description,
#toolButton:has(.mainImage.pixel-hovered) .caption {
    opacity: 1;
    visibility: visible;

    transition:
        opacity 0.5s ease,
        visibility 0s linear 0s;
}

#museumButton:has(.mainImage.pixel-hovered) .description,
#newfButton:has(.mainImage.pixel-hovered) .description,
#paintingButton:has(.mainImage.pixel-hovered) .description,
#route66Button:has(.mainImage.pixel-hovered) .description,
#toolButton:has(.mainImage.pixel-hovered) .description {
    filter: invert(1);
}

/* ==================================================
   ABOUT — DESKTOP
   ================================================== */

#about {
    display: flex;
    justify-content: center;
    align-items: center;
}

.aboutText {
    position: relative;

    width: 500px;
    max-width: 50vw;
    margin: 0;

    font-family: "Lora", serif;
    font-size: 10pt;
    font-weight: 400;
    line-height: 1.2rem;

    color: black;
    text-align: left;
}

.aboutText::before {
    content: "";
    position: absolute;
    inset: -30px -50px;
    z-index: -1;

    /*
    background: rgba(255, 255, 255, 0.95);
    filter: blur(40px);
    opacity: 0.65;
    pointer-events: none;
    */
}

/* ==================================================
   CONTACT — DESKTOP
   ================================================== */

#contact {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    gap: 0;
}

.contactButton {
    margin-top: 20px;
}

.contactButton img {
    display: block;

    width: auto;
    max-width: 100%;
    max-height: 50px;
    height: auto;

    filter: invert(0);
}

.contactButton:hover img {
    filter: invert(1);
}

#linkedInLink img,
#githubLink img {
    transform: scale(0.8);
}

/* ==================================================
   TABLET
   ================================================== */

@media (max-width: 1100px) and (min-width: 701px) {

    html,
    body {
        width: 100%;
        height: auto;
        min-height: 100%;

        overflow-x: hidden;
        overflow-y: auto;
    }

    body {
        position: static;

        min-height: 100vh;

        overscroll-behavior-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /*
       Release the fixed desktop container so the active
       section can create actual document height.
    */
    #mainContainer {
        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 100vh;

        overflow: visible;
        isolation: isolate;
    }

    /*
       Centered tablet header in normal document flow.
    */
    .header {
        position: relative;

        top: auto;
        right: auto;
        bottom: auto;
        left: auto;

        width: 100%;
        height: auto;
        max-height: none;

        box-sizing: border-box;
        padding: 18px 24px 34px;

        display: flex;
        flex-direction: column;
        align-items: center;

        overflow: visible;
    }

    .homeButton {
        width: min(46vw, 200px);
        max-width: none;
    }

    /*
       Tablet navigation in one horizontal row.
    */
    .nav {
        width: min(78vw, 620px);
        margin-top: 12px;

        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;

        gap: 24px;
    }

    .navButton {
        width: auto;
        margin: 0;
    }

    .navButton img {
        width: auto;
        max-width: none;
        height: 38px;

        margin: 0;
    }

    #projectsButton img {
        height: 45px;
    }

    #aboutButton img,
    #contactButton img {
        width: auto;
    }

    /*
       Inactive views are completely removed from layout.
       Only the active view contributes page height.
    */
    .view {
        display: none;

        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 0;

        overflow: visible;

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transition: none;
    }

    .view.active {
        display: block;

        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 0;

        overflow: visible;

        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    #about.view.active,
    #contact.view.active {
        display: flex;
    }

    .view::before {
        position: fixed;
    }

    /*
       Tablet project grid.
    */
    .imageButtons {
        position: relative;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 0;

        box-sizing: border-box;
        padding: 25px 7vw 90px;

        display: grid;
        grid-template-columns: repeat(2, minmax(180px, 1fr));

        align-items: start;
        justify-items: center;

        column-gap: 0px;
        row-gap: 65px;

        overflow: visible;
    }

    .imageButton,
    #route66Button,
    #paintingButton,
    #museumButton,
    #newfButton,
    #toolButton {
        position: relative;

        left: auto;
        top: auto;

        grid-column: auto;
        grid-row: auto;

        width: 100%;
        max-width: 230px;

        transform: none;

        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;

        color: inherit;
        cursor: pointer;
    }

    #route66Button,
    #paintingButton {
        max-width: 250px;
    }

    /*
       Always show project title PNGs on tablet.
    */
    .imageButton .description {
        position: static;

        left: auto;
        top: auto;

        width: auto;
        max-width: 190px;
        max-height: 55px;
        height: auto;

        margin: 0 0 10px;

        opacity: 1;
        visibility: visible;

        transform: none;
        object-fit: contain;

        filter: none;
        pointer-events: none;
    }

    .imageButton .mainImage,
    #paintingButton .mainImage,
    #toolButton .mainImage {
        display: block;

        width: auto;
        max-width: 100%;
        max-height: 160px;
        height: auto;

        object-fit: contain;

        scale: 1;
        transform: none;
        filter: none;
    }

    #route66Button .mainImage,
    #paintingButton .mainImage {
        max-height: 185px;
    }

    .imageButton .caption {
        position: static;

        left: auto;
        top: auto;

        width: auto;
        max-width: 220px;

        margin: 10px 0 0;

        transform: none;

        color: white;
        text-align: center;

        opacity: 1;
        visibility: visible;
    }

    /*
       About and Contact below tablet header.
    */
    #about.view.active {
        justify-content: center;
        align-items: flex-start;

        box-sizing: border-box;
        padding: 35px 8vw 90px;
    }

    .aboutText {
        width: 100%;
        max-width: 560px;
    }

    #contact.view.active {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;

        box-sizing: border-box;
        padding: 35px 8vw 90px;
    }

    .contactButton {
        margin-top: 22px;
    }
}

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

@media (max-width: 700px) {

    html,
    body {
        width: 100%;
        height: auto;
        min-height: 100%;

        overflow-x: hidden;
        overflow-y: auto;
    }

    body {
        position: static;

        min-height: 100vh;

        overscroll-behavior-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #mainContainer {
        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 100vh;

        overflow: visible;
        isolation: isolate;
    }

    /*
       Mobile header in normal flow.
    */
    .header {
        position: relative;

        top: auto;
        right: auto;
        bottom: auto;
        left: auto;

        width: 100%;
        height: auto;
        max-height: none;

        box-sizing: border-box;
        padding: 12px 12px 34px;

        display: flex;
        flex-direction: column;
        align-items: center;

        overflow: visible;
    }

    .homeButton {
        width: min(43vw, 170px);
        max-width: none;
    }

    .nav {
        width: 100%;
        margin-top: 4px;

        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: center;

        gap: 9px;
    }

    .navButton {
        width: auto;
        margin: 0;
    }

    .navButton img {
        width: auto;
        max-width: none;
        height: 40px;

        margin: 10px;
    }

    #projectsButton img {
        height: 48px;
    }

    #aboutButton img,
    #contactButton img {
        width: auto;
    }

    /*
       Inactive mobile sections occupy no space.
    */
    .view {
        display: none;

        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 0;

        overflow: visible;

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        transition: none;
    }

    .view.active {
        display: block;

        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 0;

        overflow: visible;

        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    #about.view.active,
    #contact.view.active {
        display: flex;
    }

    .view::before {
        position: fixed;
    }

    /* ==================================================
       MOBILE PROJECT COLUMN
       ================================================== */

    #projects {
        overflow: visible;
    }

    .imageButtons {
        position: static;
        inset: auto;

        width: 100%;
        height: auto;
        min-height: 0;

        box-sizing: border-box;
        padding: 10px 20px 90px;

        display: flex;
        flex-direction: column;
        align-items: center;

        gap: 48px;

        overflow: visible;
    }

    .imageButton,
    #route66Button,
    #paintingButton,
    #museumButton,
    #newfButton,
    #toolButton {
        position: relative;

        left: auto;
        top: auto;

        grid-column: auto;
        grid-row: auto;

        width: min(68vw, 260px);
        max-width: none;

        transform: none;

        display: flex;
        flex-direction: column;
        align-items: center;

        color: inherit;

        opacity: 1;
        visibility: visible;

        cursor: pointer;
    }

    .imageButton .description {
        position: static;

        left: auto;
        top: auto;

        width: auto;
        max-width: min(65vw, 240px);
        max-height: 48px;
        height: auto;

        margin: 0 0 10px;

        opacity: 1;
        visibility: visible;

        transform: none;
        object-fit: contain;

        filter: none;
        pointer-events: none;
    }

    .imageButton .mainImage,
    #paintingButton .mainImage,
    #toolButton .mainImage {
        display: block;

        width: auto;
        max-width: 100%;
        max-height: 150px;
        height: auto;

        object-fit: contain;

        scale: 1;
        transform: none;
        filter: none;
    }

    #route66Button .mainImage,
    #paintingButton .mainImage {
        max-height: 175px;
    }

    .imageButton .caption {
        position: static;

        left: auto;
        top: auto;

        width: auto;
        max-width: 220px;

        margin: 8px 0 0;

        transform: none;

        color: white;
        text-align: center;

        opacity: 1;
        visibility: visible;
    }

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

    #about.view.active {
        justify-content: flex-start;
        align-items: center;

        box-sizing: border-box;
        padding: 10px 25px 80px;
    }

    .aboutText {
        width: 100%;
        max-width: 500px;

        font-size: 10pt;
        line-height: 1.35rem;
    }

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

    #contact.view.active {
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;

        box-sizing: border-box;
        padding: 10px 25px 80px;
    }

    .contactButton {
        margin-top: 18px;
    }

    .contactButton img {
        width: auto;
        max-width: 75vw;
        max-height: 42px;
        height: auto;
    }
}

/* ==================================================
   TOUCH DEVICES
   ================================================== */

@media (hover: none),
(pointer: coarse) {

    .imageButton img.pixel-hovered {
        scale: 1;
        filter: none;
    }

    .navButton:hover img {
        filter: brightness(0);
    }

    .navButton.active img {
        filter: brightness(1);
    }

    .contactButton:hover img {
        filter: invert(0);
    }

    .imageButton .description,
    .imageButton .caption {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 1100px) {
    .imageButton .description {
        display: block !important;
        position: static !important;

        left: auto !important;
        top: auto !important;

        width: auto !important;
        max-width: 190px !important;
        max-height: 55px !important;
        height: auto !important;

        margin: 0px !important;

        opacity: 1 !important;
        visibility: visible !important;

        transform: none !important;
        filter: none !important;

        object-fit: contain;
        pointer-events: none;
    }

    #museumButton img {
        transform: scale(0.6) !important;
        margin-bottom: -40px !important;
    }

    #paintingButton img {
        margin-bottom: -40px !important;
    }

    #newfButton img {
        transform: scale(0.9) !important;
    }

    #route66Button img {
        transform: scale(1.2) !important;
    }

    #nameHeading {}

    #about:not(.active),
    #contact:not(.active) {
        display: none !important;
    }

    #about.active {
        display: flex !important;
    }

    #contact.active {
        display: flex !important;
    }
}

/* ==================================================
   SECTION CROSS-DISSOLVE
   ================================================== */

::view-transition-image-pair(root) {
    isolation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.2s;
    animation-timing-function: linear;

    /*
       Prevent the partially transparent old and new
       snapshots from exposing the white page beneath.
    */
    mix-blend-mode: plus-lighter;
}

::view-transition-old(root) {
    animation-name: sectionFadeOut;
}

::view-transition-new(root) {
    animation-name: sectionFadeIn;
}

@keyframes sectionFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.header {
    view-transition-name: site-header;
}

::view-transition-old(site-header),
::view-transition-new(site-header) {
    animation: none;
}