@layer base, layout, page;


:root{
    --color-bg: #CCC;
    --color-nav: #323232;
    --color-footer: #464646;
    --color-text: #DDD;
    --color-content-area-bg: #F8FAE3;
    --color-content-area-border: var(--color-nav);
    --color-content-area-text: var(--color-nav);
    --color-button-text: #CC7A4F;
    --color-button-bg: var(--color-nav);
    --content-width: 100%;
}

@layer base{
    *, *::before, *::after {
        box-sizing: border-box;
    }

    html {
        scroll-padding-top: 2.5rem;
        scroll-behavior: smooth; 
    }

    body{
        margin: 0;
        color: var(--color-text);
        font-family: "Inter", sans-serif;
        background: url(../media/BackgroundTile.webp) top left / 4rem repeat scroll;
        background-color: var(--color-bg);
    }

    a{
        text-decoration: none;
        font-size: 1rem;
        color: var(--color-text);
        
        &:is(:visited, :hover, :active, :focus){
            color: var(--color-text);
        }
    }

    li.active{
        & a{
            color: var(--color-button-text);
        }
    }
    
    .button{
        color: var(--color-button-text);
        font-weight: bold;
        background-color: var(--color-button-bg);
        padding-top: 0.75rem;
        padding-bottom: 0.75rem;
        border-radius: 0.5rem;
        text-align: center;
        box-shadow: 4px 4px 4px rgba(from var(--color-button-text) r g b / 0.5);

        &:hover{
            box-shadow: 4px 4px 4px rgba(from var(--color-button-text) r g b / 0.9); 
        }

        &:is(:visited, :hover, :active, :focus){
            color: var(--color-button-text);
        }
    }
}

@layer layout{
    /* make base grid for mobile just one column with the required rows to fit items*/
    .grid-layout {
        display: grid;
        grid-template-columns: 1fr; 
        min-height: 100vh;
        min-height: 100dvh;
        grid-template-rows: repeat(3, minmax(min-content, max-content)) minmax(min-content, 1fr) min-content; 
        
        /* Header is first row, also all styling since it is used on all pages exactly the same*/
        & header{
            grid-column: 1 / -1; 
            grid-row: 1 / 2;
            justify-items: center;
            
            & .header-bubble{
                display: flex;
                flex-direction: row;
                justify-content: center;
                align-items: center;
                gap: 2rem;
                text-align: center;
                background-color: var(--color-nav);
                width: 100%;
                border-bottom: 2px solid var(--color-text);
                padding: 0 1rem; 

                & img{
                    height: 3rem;
                    width: 3rem;
                    align-self: center;
                }

                & h1{
                    align-self: center;
                    font-size: 2rem;
                    font-weight: normal;
                    letter-spacing: 0.1rem;
                }  
            }
            
        }

        /* menu button styling stuff for mobile hamburger menu also second row*/
        & .menu-toggle{
            grid-row: 2 / 3;
            height: 2.5rem;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            gap: 0.3rem;
            background-color: var(--color-nav);
            border: none;
            cursor: pointer;
            width: 100%;
            position: sticky;
            top: 0;

            & span {
                width: 1.5rem;
                height: 0.125rem;
                background-color: var(--color-text);
                border-radius: 0.25rem;
            }
        }
            
        /* Mobile menu that is sticky and shows up under the hamburger menu even when in the sticky state unlike the class lab that causes the menu button to be hidden behind the elements if scrolled too far
        Third row after the menu button for skinny screens*/
        & nav {
            grid-column: 1 / 2;
            grid-row: 3 / 4;
            display: none;
            background-color: var(--color-nav);
            position: sticky;
            top: 2.5rem;

            & ul{
                display: flex;
                flex-direction: column;
                list-style: none;
                padding: 0;
                margin: 0;
                align-items: center;
                width: 100%;
            }

            & li{
                text-align: center;

                & a{
                    white-space: nowrap;
                    padding: 0.75rem;
                    display: block;
                    position: relative;
                    & img{
                        display: none;
                        width: 65%;
                        height: auto;
                    }
                    
                    &::after{
                        content: "";
                        position: absolute;
                        bottom: 6px;
                        width: 75%;
                        left: calc(25% / 2);
                        height: 4px;
                        border-radius: 2px;
                        background: var(--color-text);
                        transform: scaleX(0);
                        transform-origin: center;
                        transition: transform 0.5s ease;
                    }

                    &:hover::after{
                        transform: scaleX(1);
                    }
                }
            }

            &.nav-open {
                display: block;
            }
        }

        /* Main in 4th row super simple*/
        & main{
            grid-column: 1 / -1; 
            grid-row: 4 / 5; 
            justify-items: center;
            padding: 0 1rem 1rem;
            margin-top: 1rem;
        }

        /* Footer last row also very straight forward the same on every page */
        & footer{
            grid-column: 1 / -1;
            grid-row: 5 / 6; 
            background-color: var(--color-footer);
            padding: 1rem;
            justify-items: center;
            & .footer-info{
                display: grid;
                grid-template-columns: minmax(min-content, max-content) minmax(2rem, 8rem) minmax(min-content, max-content);
                grid-template-rows: repeat(2, minmax(min-content, max-content));

                & p{
                    font-size: 1rem;
                    margin: 0;
                }

                & ul{
                    list-style: none;
                    padding: 0;
                    margin: 0;
                    font-size: 1rem;
                }

                & .contact{
                    display: grid;
                    grid-template-columns: subgrid;
                    grid-template-rows: subgrid;
                    grid-column: 1 / 2;
                    grid-row: 1 / -1;

                    & h2{
                        grid-row: 1 / 2;
                    }
                    
                    & address{
                        grid-row: 2 / 3;
                        font-size: 1rem;
                        display: flex;
                        flex-direction: column;
                        justify-content: space-between;
                        gap: 1rem;
                    }
                }

                & .helpful-links{
                    display: grid;
                    grid-template-columns: subgrid;
                    grid-template-rows: subgrid;
                    grid-column: 3 / 4;
                    grid-row: 1 / -1;

                    & h2{
                        grid-row: 1 / 2;
                    }

                    & ul{
                        grid-row: 2 / 3;
                        display: flex;
                        flex-direction: column;
                        justify-content: space-between;
                    }
                }
            }
        }
    }

    /* Case for a portrait device with enough space to display the full horizontal nav */
    @media (orientation: portrait) and (min-width: 35rem){
        .grid-layout {
            grid-template-rows: repeat(2, minmax(min-content, max-content)) minmax(min-content, 1fr) min-content;
            
            & .menu-toggle{display: none;}

            & nav{
                display: block;
                grid-row: 2 / 3; 
                margin-bottom: 1rem;
                justify-items: center;
                top: 0;
                
                & ul{
                    flex-direction: row;
                    position: sticky;
                    top: 0;
                    align-items: flex-end;
                    justify-content: space-around;
                    max-width: var(--content-width);
                    padding: 0 1rem;
                }

                & li.active{background-color: rgba(0, 0, 0, 0.25);}
            }

            & main{
                grid-row: 3 / 4;
                margin: 0;
            }
        }
    }

    /* Case for landscape also include a scroll bar if the window is too small to display all the nav at once so that the nav can be sticky and so there is no more length to the page then nessisary dictated to the size of the content on the page */
    @media (orientation: landscape){
        .grid-layout {
            grid-template-columns: 4.5rem 1fr;
            grid-template-rows: minmax(6rem, max-content) minmax(calc(100vh - 6rem), 1fr) min-content;
            
            & .menu-toggle{display: none;}

            & header{
                grid-column: 2 / -1;
                padding: 1rem;
                
                & .header-bubble{
                    border-radius: 2rem;
                    width: fit-content;
                    padding-right: 2rem;
                    padding-left: 2rem; 
                }
                
            }

            & nav{
                display: grid;
                grid-template-columns: subgrid;
                grid-template-rows: subgrid;
                grid-row: 1 / 3;
                margin: 0;
                position: static;
                
                & ul{
                    grid-row: 2 / 3;
                    flex-direction: column;
                    position: sticky;
                    top: 0;
                    align-items: normal;
                    justify-content: flex-start;

                    /* Dealing with edge case where the screen does not have enough room to display 
                    all of  the nav so the user does not need to scroll to the bottom of the 
                    container to force the nav into veiw */
                    max-height: 100vh;
                    max-height: 100dvh;
                    overflow-y: auto;
                }

                & li{
                    & a{
                        white-space: normal;
                        padding: 0.3rem 0 0.75rem 0;
                        & img{
                            display: inline;
                        }

                    }

                    &.active{background-color: rgba(0, 0, 0, 0.25);}
                }

            }

            & main{
                grid-column: 2 / -1;
                grid-row: 2 / 3;
                margin: 0;
            }

            & footer{grid-row: 4 / 5;}

        }
    }
}

@media (prefers-color-scheme: dark){
    :root{
        --color-bg: #474747;
        --color-nav: #1E1E1E;
        --color-footer: #323232;
        --color-text: #FFF;
    }

}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
    }
}

