/* the styles for the elements */
* {
    margin: 0; 
    padding: 0;
    box-sizing: border-box; 
}
html {
    background-color: steelblue;
}
body {
    background-color: white;
	font-family: Arial, Helvetica, sans-serif;
    font-size: calc(90% + 0.3vw); 
    width: 100%;
    display: grid;
    grid-template-rows: repeat(4, auto);
    grid-template-columns: 1fr;
    grid-template-areas:
        "header"
        "navbar"
        "main"
        "footer";
}
a {
    font-weight: bold;
}
h1, h2, h3 { padding-top: .75em; } 
p, ul, blockquote { padding-top: .5em; } 
h1 { font-size: 160%; }
blockquote { padding-left: 2em; }

@font-face {
    font-family: AmericanCaptain;
    src: url("../fonts/American Captain.ttf");
}

/* add animation to icons */
aside li  {
    .icon {
        vertical-align: middle;
    }
    &:hover .icon {
        animation: spin 0.75s linear infinite; /* Spin continuously while hovering */
    }
}
@keyframes spin {
    from {
        transform: rotateY(0deg);
    }
    to {
        transform: rotateY(360deg);
    }
}

/* the styles for the header */
header {
    grid-area: header;
    background-image: linear-gradient(to bottom, white 0%, lightsteelblue 100%);
    padding: 1em 1.5em; 
    & img {        
        float: left; 
        margin-right: 1em;
        width: clamp(100px, 20%, 120px);        
    }
    & h2 {
        font-family: AmericanCaptain;
        font-size: 250%;
        font-style: italic;
        color: steelblue;
        padding-top: 0;
    }
    & h3 {
        font-size: 150%;
        padding-top: .25em;
    }
} 


/*** menu styles ***/ 
.navbar {
    grid-area: navbar;
    background-color: steelblue; 
    & ul {
        list-style-type: none; 
    } 
    & a {
        display: block; 
        padding: .25em 1em; 
        margin: .25em .5em .5em;
        text-decoration: none; 
        color: white;
    } 
    & a:hover, a:focus { 
        text-decoration: underline; 
    } 
    & a.current {
        border: 2px solid; 
        border-radius: 10px; 
        text-decoration: none;
    } 
} 
#checkbox-toggle { display: none; } /* checkbox always hidden */
.menu-btn {
    display: block; /* show menu button */
    padding: 0.25em 1em;
    color: white;
    font-size: 24px;
}
.menu-btn::after { content: "\2630"; } /* hamburger symbol */
#checkbox-toggle:checked ~ .menu {
    display: block;
}
#checkbox-toggle:checked ~ .menu-btn::after {
    content: "\2716"; /* close (X) symbol */
}
.menu {
    position: absolute; /* in relation to .navbar */
    left: 0;
    display: none; /* menu initially hidden */
    background-color: steelblue;
    & li:has(.submenu) {
        position: relative;
        & small::after {
            content: "\25b6"; /* right triangle */
        }
        & small {
            margin-left: .25em; /* add space */
        }
        &:hover > .submenu {
            display: block;
        }
    }
 }
.submenu {
    position: absolute; /* with respect to .submenu */
    top: 0;
    left: 100%;
    background-color: steelblue;
    color: white;
    width: 150%;
    display: none;
}

/* the styles for the main element  */
main {
    grid-area: main;
    display: grid;
    grid-template-rows: auto auto;
    grid-template-columns: 1fr;
    grid-template-areas:
        "section"
        "aside";

    padding: 0 1.5em 1em;
}

/* the styles for the section */
section {
    grid-area: section;
    & h3 {
        color: maroon;
    }
    & ul { 
        padding-left: 2em;
        list-style-type: square;
    }
    & li {
        padding-left: .25em;     /* space between bullet and text */ 
        padding-bottom: .25em;   /* space after list item */
    } 
    & a:link, a:visited { 
        color: maroon;
    }
    & a:hover, a:focus {
        color: steelblue;
    }
}

figure {
    float: left;
    margin: .75em 1em .25em 0;
    width: 60%;
    & img {
        width: 100%
    }
    & figcaption {
        display: block;
        font-weight: bold;
        border-bottom: 2px solid steelblue;
        padding-bottom: .25em;
    }
}

/* the styles for the sidebar */
aside {
    grid-area: aside;
    height: fit-content;
    padding: 1em 1.5em; 
    margin: 1em 0;
    border: 2px solid steelblue;
    border-radius: 25px;
    & h2 {
        padding: 0;
        color: maroon;
    }
    & ul {
        line-height: 1.5;
        list-style-type: none;
    }
    & li img {
        margin-right: .75em;
    }
    & a:link, a:visited { 
        color: steelblue
    }
    & a:hover, a:focus {
        color: maroon;
    }
}

/* the styles for the footer */
footer { 
    grid-area: footer;
	padding: 1em 1.5em;
    background-color: steelblue;
    & p {
        text-align: center;
        font-size: 85%;
        color: white;    
    }    
}

/* media query - for line length breakpoint */
@media only screen and (min-width: 630px) {
    main {
        display: grid;
        grid-template-rows: auto;
        grid-template-columns: 1fr 40%;
        grid-template-areas: "section aside";
        gap: 5%;
    } 
    aside {
        padding: 1em 1.5em; 
        margin: 1em 0 1em 1.5em;
    }
}

/* media query - for menu breakpoint */
@media only screen and (min-width: 860px) {
    /* show menu, adjust spacing, hide menu button */
    .menu {
        position: relative;
        display: grid;
        grid-template-rows: auto;
        grid-template-columns: repeat(5, auto);
        justify-content: space-around;
    } 
    .menu-btn { 
        display: none; 
    }

    /* make sure menu displays horizontally if menu is expanded when resized*/ 
    #checkbox-toggle:checked ~ .menu { 
        display: grid;
    }

    .menu li:has(.submenu) {
        position: relative;
        & small::after {
            content: "\25bc"; /* down triangle */
        }
    }
    .submenu {
        top: auto;
        left: 0;
        width: 140%;
    }
}

@media screen and (prefers-color-scheme: dark) {
    :root {
        --darksteelblue: #184a73;
    }
    a {
        color: lightsteelblue;
    }
    a:hover, aside a:focus {
        color: lightsalmon;
    }
    body {
        color: white;
        background-color: var(--darksteelblue);
    }
    header {
        background-image: linear-gradient(to bottom, lightsteelblue 0%, var(--darksteelblue) 100%);
        padding: 15px 3%;
        border-bottom: 2px solid lightsteelblue;   
        & h2 {
            color: lightsteelblue;
        }                                         
    } 
    main {
        background-color: black; 
    }
    .navbar {
        background-color: var(--darksteelblue);
    }
    .menu {
        background-color: var(--darksteelblue);
    }
    section h3 {
        color: lightsalmon;
    }
    aside h2 {
        color: lightsalmon;
    }
    footer {
        background-color: var(--darksteelblue);
    }

    /* use a filter to invert the icons */
    .icon {
        filter: invert(1);
    }
}