:root {
    --font-headline: 'Mozilla Headline', Arial, Helvetica, sans-serif;
    --font-txt: 'Mozilla Text', Arial, Helvetica, sans-serif;
    
    --color-white: #ffffff;
    --color-gray: #d9d9d9;
    --color-black: #000000;
    
    --border-width: 4px;
    --border-style: solid;
    --border-color: var(--color-white);
    
    --entry-padding: 3rem;
    
    --txt-wrapper-padding-lr: 2rem;
    --txt-wrapper-min-width: 29rem;
    --txt-wrapper-max-width: calc(32rem + (var(--txt-wrapper-padding-lr) * 2));
    --txt-wrapper-min-height: calc(var(--txt-wrapper-min-width) * 297 / 210);
    --txt-wrapper-max-height: min(calc(var(--txt-wrapper-max-width) * 297 / 210), 100%);
    
    --txt-wrapper-rotation-l-default: -2deg;
    --txt-wrapper-rotation-l-hover: calc(2 * var(--txt-wrapper-rotation-l-default));
    --txt-wrapper-rotation-r-default: calc(-1 * var(--txt-wrapper-rotation-l-default));
    --txt-wrapper-rotation-r-hover: calc(-2 * var(--txt-wrapper-rotation-l-default));
}

body {
    margin: 0;
    padding: 0;
    
    overflow: hidden;
    
    hyphens: auto;
    color: var(--color-white);
    
    background-color: var(--color-black);
}





/*------------------*/
/*      Entries     */
/*------------------*/

#entries-container {
    display: flex;
    
    width: 100vw;
    height: 100vh;
    
    margin: 0;
    padding: 0;
    
    overflow-x: scroll;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.entry {
    display: flex;
    justify-content: center;
    align-items: center;
    
    margin: 0;
    padding: var(--entry-padding);
    
    box-sizing: border-box;
    flex: 0 0 100%;
    
    overflow: hidden;
    
    position: relative;
    
    list-style-type: none;
    
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
}

.entry:nth-child(even) {
    flex-direction: row-reverse;
}

.img-wrapper, 
.txt-wrapper-wrapper, 
.txt-wrapper {    
    transform-origin: bottom;
    transition: all 350ms ease-out;
}

.img-wrapper {
    display: grid;
    grid-template-rows: repeat(auto-fit, minmax(0, 0)); /*necessary for overlap but gives grid-items a height of 0*/
    
    aspect-ratio: 708/1080; /*forces image height into the aspect ratio with the help of the image witdth*/
    max-width: 100%;
    max-height: calc(100vh - (var(--entry-padding) * 2));
    
    transform: translate(0, 0) scale(1) rotate(0deg);
}

#entry-start .img-wrapper {
    aspect-ratio: 1554/1080;
}


@media only screen and (orientation: portrait), (max-width: 1232px) {
    #entry-start .img-wrapper {
        aspect-ratio: 708/1080;
    }
}


.entry img {
    width: 100%;
    position: relative; /*necessary to make javascript parallax work*/
    transition: all 300ms ease-out;
}

#overlay .img-wrapper, 
#entry-info .img-wrapper{
    display: grid;
    grid-template-rows: 50% 50%;
    grid-template-columns: 50% 50%;
    
    aspect-ratio: unset;
    width: 100vw;
    max-width: unset;
    height: 100vh;
    max-height: unset;
    
    position: absolute;
    top: 0;
    left: 0;
    
    transform-origin: unset;
    transform: unset;
    
    transition: unset;
    
    z-index: 0;
}

#overlay img, 
#entry-info img {
    width: unset;
    max-width: 100%;
    max-height: 100%;
}

#overlay img:nth-child(1), 
#entry-info img:nth-child(1) {
    justify-self: flex-start;
    align-self: flex-start;
}

#overlay img:nth-child(2), 
#entry-info img:nth-child(2) {
    justify-self: flex-end;
    align-self: flex-start;
}

#overlay img:nth-child(3), 
#entry-info img:nth-child(3) {
    justify-self: flex-start;
    align-self: flex-end;
}

#overlay img:nth-child(4), 
#entry-info img:nth-child(4) {
    justify-self: flex-end;
    align-self: flex-end;
}

.txt-wrapper-wrapper {
    width: fit-content;
    height: fit-content;
    
    transform: translate(-5%, 0) scale(1) rotate(var(--txt-wrapper-rotation-r-default));
    
    z-index: 1;
}

.entry:nth-child(even) .txt-wrapper-wrapper, 
#entry-info .txt-wrapper-wrapper {
    transform: translate(5%, 0) scale(1) rotate(var(--txt-wrapper-rotation-l-default));
}

.txt-wrapper {
    border: var(--border-width) var(--border-style) var(--border-color);
    padding: 5.6rem var(--txt-wrapper-padding-lr) 3rem;
    
    box-sizing: border-box;
    aspect-ratio: 210/297;
    min-width: var(--txt-wrapper-min-width);
    max-width: var(--txt-wrapper-max-width);
    height: fit-content;
    min-height: var(--txt-wrapper-min-height);
    max-height: var(--txt-wrapper-max-height);
    
    overflow: scroll;
    
    background-color: var(--color-black);
}

h1 {
    margin: 0 0 4.4rem;
    
    letter-spacing: -2%;
    line-height: 0.9;
    font-family: var(--font-headline);
    font-size: 6.5rem;
}

h2 {
    margin: 0 0 1.3rem 0.26rem;
    
    letter-spacing: 0%;
    line-height: 1.2;
    font-family: var(--font-headline);
    font-weight: 500;
    font-size: 1.8rem;
}

p {
    margin: 0 0 1.3rem 0.24rem;
    
    letter-spacing: 1%;
    line-height: 1.45;
    font-family: var(--font-txt);
    font-weight: 400;
    font-size: 1.1rem;
    color: var(--color-gray);
}





/*------------------*/
/*     Envelopes    */
/*------------------*/

#hand {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(5rem, 0));
    justify-content: center;
    
    width: 100vw;
    max-width: 100vw;
    
    position: absolute;
    bottom: -7rem;
    
    z-index: 2;
}

.envelope {
    display: grid;
    grid-template-rows: repeat(auto-fit, minmax(0, 0));
    
    aspect-ratio: 1/1.5;
    width: 7.5rem;
    max-width: 7.5rem;
    
    transform: translate(0, 0) scale(1) rotate(5deg);
    
    background-color: var(--color-black);
    
    transition: all 200ms ease-out; 
}

.envelope:hover {
    transform: translate(0, -15%) scale(1.1) rotate(5deg);
}

.envelope:hover .thumb {
    transform-origin: bottom;
    transform: translate(0, -50%) scale(1) rotate(2deg);
}

.envelope:hover .blank {
    transform-origin: bottom;
    transform: translate(0, -50%) scale(1) rotate(-2deg);
}

.envelope:hover .envelope-latch {
    opacity: 0;
}

.envelope:active {
    transform: translate(0) scale(1) rotate(5deg);
}

.envelope-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(1rem, 0));
    
    padding: 1rem;
    
    box-sizing: border-box;
    aspect-ratio: inherit;
    width: inherit;
}

.envelope-content .thumb, 
.envelope-content .blank {
    border: var(--border-width) var(--border-style) var(--border-color);
    
    aspect-ratio: 708/1080;
    width: fit-content;
    height: 75%;
    
    background-color: var(--color-black);
    
    transition: all 200ms ease-out;
}

.envelope img {
    width: 100%;
}

.envelope-body {
    border: var(--border-width) var(--border-style) var(--border-color);
    
    box-sizing: border-box;
    aspect-ratio: inherit;
    width: inherit;
    
    clip-path: polygon(0% 0%, 50% 25%, 100% 0%, 100% 100%, 0% 100%);
    
    background-color: var(--color-black);
}

.envelope-latch {
    border: var(--border-width) var(--border-style) var(--border-color);
    
    clip-path: polygon(0% 0%, 100% 0%, 50% 100%); 
    
    box-sizing: border-box;
    aspect-ratio: 1/0.375;
    width: inherit;
    
    background-color: var(--color-white);
    
    transition: all 100ms linear;
}





/*------------------*/
/*      Overlay     */
/*------------------*/

main #entries-container, 
main #hand{
    opacity: 1;
    animation: 4s linear 0s main-fade;
}

@keyframes main-fade {
    0% {opacity: 0;}
    50% {opacity: 0;}
    100% {opacity: 1;}
}

#overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    
    position: absolute;
    top: 0;
    left: 0;
    
    width: 100vw;
    height: 100vh;
}

#overlay h1 {
    margin: 0;
    opacity: 0;
    animation: 4s linear 0s ele-fade;
}

#overlay img {
    opacity: 0;
    animation: 4s linear 0s ele-fade;
}

@keyframes ele-fade {
    0% {opacity: 0;}
    25% {opacity: 1;}
    50% {opacity: 1;}
    100% {opacity: 0;}
}





/*------------------*/
/*   Media Queries  */
/*------------------*/

/*max-height: txt-wrapper-min-height + (entry-padding-tb * 2); (no var() possible, therefore hard-coded value*/ 
@media only screen and (max-width: 90.625rem), (max-height: 54rem) {
    .txt-wrapper-wrapper {
        position: absolute;
        
        right: calc(-1 * (var(--txt-wrapper-min-width) - var(--entry-padding))); 
        
        transform: translate(0) scale(1) rotate(var(--txt-wrapper-rotation-l-default));
    }
    
    .entry:nth-child(even) .txt-wrapper-wrapper, 
    #entry-info .txt-wrapper-wrapper {
        transform: translate(0) scale(1) rotate(var(--txt-wrapper-rotation-l-default));
    }
    
    .txt-wrapper-wrapper:hover {
        right: calc(-1 * var(--txt-wrapper-padding-lr));
        
        /*transform-origin bottom center (see .txt-wrapper outside media-queries)*/
        transform: translate(0) scale(1) rotate(var(--txt-wrapper-rotation-l-hover));
    }
    
    .entry:nth-child(even) .txt-wrapper-wrapper:hover, 
    #entry-info .txt-wrapper-wrapper:hover {
        transform: translate(0) scale(1) rotate(var(--txt-wrapper-rotation-l-hover));
    }
    
    .txt-wrapper {
        max-height: calc(100vh - (var(--entry-padding) * 2));
        min-height: unset;
    }
    
    @media (any-hover: none) {
        .txt-wrapper-wrapper {
            display: flex;
            align-items: center;
            
            padding-right: var(--entry-padding);
            
            width: 100%;
            height: 100%;
            
            right: unset;
            transform: unset;
            
            overflow: scroll;
        }
        
        .txt-wrapper-wrapper:hover {
            right: unset;
            transform: unset;
        }
        
        .txt-wrapper {
            position: absolute;
            right: calc(-1 * (var(--txt-wrapper-min-width) - var(--entry-padding)));
            
            transform: translate(0) scale(1) rotate(var(--txt-wrapper-rotation-l-default));
        }
    }
    
    h1 {
        margin: 0 0 3.6rem;
        
        letter-spacing: -2%;
        line-height: 0.9;
        font-size: 4.8rem;
    }
}



@media only screen and (max-width: 60rem), (max-height: 41rem)  {
    #entries-container {
        display: block;
    }
    
    .entry {
        flex-wrap: wrap;
        gap: 1rem;
        
        padding: 1rem 1rem 10rem 1rem;
    }
    
    .txt-wrapper-wrapper {
        position: static;
        transform: unset;
    }
    
    .entry:nth-child(even) .txt-wrapper-wrapper, 
    #entry-info .txt-wrapper-wrapper {
        transform: unset;
    }
    
    .txt-wrapper-wrapper:hover {
        transform: unset;
    }
    
    .entry:nth-child(even) .txt-wrapper-wrapper:hover, 
    #entry-info .txt-wrapper-wrapper:hover {
        transform: unset;
    }
    
    .txt-wrapper {
        margin: 0 auto;
        padding: 4rem 1rem 3rem;
        
        aspect-ratio: unset;
        min-width: unset;
        max-height: unset;
        
        position: static;
    }
    
    #entry-info .txt-wrapper {
        max-height: calc(100vh - (var(--entry-padding) * 2));
    }
    
    h1 {
        margin-bottom: 2rem;
        font-size: 2.8rem;
    }
    
    .envelope {
        display: none;
    }
    
    @media (any-hover: none) {
        .txt-wrapper-wrapper {
            display: block;
            
            padding: 0;
            
            height: fit-content;
        }
        
        .txt.wrapper-wrapper:hover {
            transform: unset;
        }
        
        .txt-wrapper {
            transform: unset;
        }
        
        .envelope:hover {
            transform: translate(-1.4rem, -15%) scale(1.1) rotate(5deg);
        }

        .envelope:hover .thumb {
            transform-origin: bottom;
            transform: translate(0, -50%) scale(1) rotate(2deg);
        }

        .envelope:hover .blank {
            transform-origin: bottom;
            transform: translate(0, -50%) scale(1) rotate(-2deg);
        }

        .envelope:hover .envelope-latch {
            opacity: 0;
        }

        .envelope:active {
            transform: translate(-1.4rem) scale(1) rotate(5deg);
        }

        #hand {
            grid-template-columns: repeat(auto-fit, minmax(3rem, 0));
        }

        .envelope {
            transform: translate(-1.4rem, 0) scale(1) rotate(5deg);
        }
    }
}



@media only screen and (max-width: 32rem) {
    #hand {
        grid-template-columns: repeat(auto-fit, minmax(2rem, 0));
    }
    
    .envelope {
        transform: translate(-3.1rem, 0) scale(1) rotate(5deg);
    }
    
    @media only screen and (any-hover: none) {
        .envelope:hover {
            transform: translate(-1.4rem, -15%) scale(1.1) rotate(5deg);
        }

        .envelope:hover .thumb {
            transform-origin: bottom;
            transform: translate(0, -50%) scale(1) rotate(2deg);
        }

        .envelope:hover .blank {
            transform-origin: bottom;
            transform: translate(0, -50%) scale(1) rotate(-2deg);
        }

        .envelope:hover .envelope-latch {
            opacity: 0;
        }

        .envelope:active {
            transform: translate(-1.4rem) scale(1) rotate(5deg);
        }

        #hand {
            grid-template-columns: repeat(auto-fit, minmax(3rem, 0));
        }

        .envelope {
            transform: translate(-1.4rem, 0) scale(1) rotate(5deg);
        }
    }
}



@media only screen and (max-width: 21rem) {
    #entries-container {
        scrollbar-width: auto;
    }
    
    #hand {
        display: none;
    }
}

@media only screen and (any-hover: none) {
    
}



/*------------------*/
/*      Script      */
/*------------------*/

/*#hand .envelope {
    opacity: 0.5;
}*/

/*absolute positioning disables scrolling txt-wrappers NEDDS FIX!*/
/*@media (scripting: enabled) {
    .entry {
        width: 100%;
        height: 100%;
        
        position: absolute;
    }
}*/

/*.inactive .img-wrapper {
    border: var(--border-width) var(--border-style) var(--border-color);
    background-color: var(--color-black);
}

.inactive img {
    position: static;
}*/