:root {
    --border-thickness: 2px;
    --border-color: #222;
    
    --project-item-width: 320px;
    --project-item-width-tablet: 320px;
    --project-item-width-mobile: 300px;
    --project-item-height: 256px;
    --project-item-height-tablet: 256px;
    --project-item-height-mobile: 240px;
    --project-first-size-mult: 1.75;
}

* {
    font-size: 20px; /* I like big letters */
    font-family: 'Times New Roman', Times, serif;
}

body {
    background: linear-gradient(lightcyan, aliceblue); /* Subtle, but pleasant */
    margin: 0px;
}

h1, h2 {
    font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
    margin: auto;
}

h1 {
    font-size: 4em;
}

h2 {
    font-size: 2.75em;
}

h3 {
    font-size: 1.25em;
}

header {
    background-color: lightblue;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    position: relative;
    border-width: 0 0 var(--border-thickness) 0;
    border-style: solid;
    border-color: var(--border-color);
}

header figure {
    display: flex;
    flex-direction: column;
}

#portrait
{
    display: block;
    max-width: 250px;
    margin: auto;
    border: 6px ridge chocolate;
    box-shadow: 10px 8px 3px gray;
}

#header-right
{
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Used inside #header-right to space address element correctly */
.vertical-spacer
{
    width: 100%;
    margin-top: auto;
    margin-bottom: auto;
    flex: 0 1 auto;
}

#address {
    height: 33%;
    margin-left: 20px;
}

#address p {
    font-size: 2em;
    margin: 0;
    line-height: 1.5;
}

nav.vertical-spacer
{
    margin-bottom: 0;
}

nav ul {
    margin-right: 20px;
    text-align: right;
}

nav li {
    list-style: none;
    margin-left: 16px;
    display: inline;
}

nav a {
    color: #222;
    text-decoration: none;
}

main {
    margin: 15px;
}

#project-showcase {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto auto auto; /* This whay only one row will be resized when hovering over project */
    place-items: start center;
    justify-content: space-between;
}

.project {
    margin: 10px;
    /* A grid item... */
    grid-column-start: auto;
    grid-column-end: auto;
    grid-row-start: auto;
    grid-row-end: auto;

    /* That's itself a flexbox! */
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Special treatment for first project */
.project:first-child {
    width: calc(var(--project-item-width) * var(--project-first-size-mult));
    grid-column-start: auto;
    grid-column-end: span 2;
    grid-row-start: auto;
    grid-row-end: span 2;
    align-self: flex-start;
}

.project h3 {
    text-align: center;
}

.project a {
    display: block;
    /* Conunterintuitive, but image sizing in absolute terms is done here.
       <img> child grabs all space allocated to its parent as specified in .project img selector */
    width: var(--project-item-width);
    height: var(--project-item-height);
    flex: 1 1 auto;
}

.project:first-child a {
    width: calc(var(--project-item-width) * var(--project-first-size-mult));
    height: calc(var(--project-item-height) * var(--project-first-size-mult));
}

.project img {
    /* Needs to be 100% after adjusting for border */
    width: calc(100% - calc(2 * var(--border-thickness)));
    height: calc(100% - calc(2 * var(--border-thickness)));
    object-fit: cover; /* Fill space, clipping image if you have to instead of stretching */
    border: var(--border-thickness) solid var(--border-color);
}

.project p {
    display: none; /* Not placed on page in normal circumnstances */
    padding-left: 5px;
}

.project:hover p {
    display: initial;
}

footer {
    margin: auto;
}

footer h2 {
    font-family: 'Times New Roman', Times, serif;
    font-size: 1.2em;
    font-weight: lighter;
    text-align: center;
}

/* Tablets */
@media screen and (max-width: 992px)
{
    header
    {
        /* Screen is too small for horizontal flexbox, so do vertical instead */
        flex-direction: column;
    }

    #address p {
        /* Since address is below portrait, the text looks better centered */
        text-align: center;
    }

    #project-showcase {
        display: flex; /* flexbox is simpler than grid */
        flex-wrap: wrap;
    }

    /* Smaller project tiles */
    .project {
        width: var(--project-item-width-tablet);
    }

    .project:first-child {
        width: calc(var(--project-item-width-tablet) * var(--project-first-size-mult));
        justify-self: stretch;
        flex-grow: 1;
    }

    .project a {
        width: 100%;
        height: var(--project-item-height-tablet);
        margin: 0 auto;
    }

    .project:first-child a {
        height: calc(var(--project-item-height-tablet) * var(--project-first-size-mult));
    }
}

/* Mobile */
@media screen and (max-width: 768px)
{
    #project-showcase
    {
        display: block; /* ...and block is simpler than flexbox */
    }

    /* Even smaller project tiles */
    .project {
        width: var(--project-item-width-mobile);
        margin: 0 auto;
    }

    .project a {
        width: 100%;
        height: var(--project-item-height-mobile);
        margin: 0 auto;
    }

    .project:first-child {
        width: calc(var(--project-item-width-mobile) * var(--project-first-size-mult));
    }

    .project:first-child a {
        height: calc(var(--project-item-height-mobile) * var(--project-first-size-mult));
    }
}