/* Reset */
* { margin:0; padding:0; }

/* Prevent custom web components from appearing during initial page rendering */
json-data:not(:defined),
is-loading:not(:defined),
has-error:not(:defined),
is-loaded:not(:defined) { display:none; }

/* CSS Variables */
:root {
    --duration: .6s;
    --delay: .2s;
}

/* Using 'Native font stack' - See Bootstrap 4 Docs for info on 'Native font stack' */
html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
h1 {
    font-family: 'Pacifico', cursive;
}

/* Main element layout */
html, body, #root { height:100%; margin:0; }

/* CSS Variables */
:root {
    --shadow-1: 0 1px 5px 0 rgba(0,0,0,.5);
    --shadow-2: 0 1px 5px 0 rgba(0,0,0,.8);
    --bg-color: hsl(210, 90%, 97%);
    --font-color: hsla(210, 90%, 25%, 1);
}

/* Page Elements */

body {
    display: flex;
    flex-direction: column;
    text-align: center;
    align-items: center;
    background-color: var(--bg-color);
    color: var(--font-color);
}

.error { background-color: red; border: 2px solid darkred; color: white; padding: 1em; margin: 1em; display: block; }

h1 {
    font-size: 4em;
    padding: 100px 0 30px 0;
    letter-spacing: 0.1em;
}

/*
    Colors are using HSL (Hue, Saturation, and Lightness)
    based on the RGB Color Wheel Tertiary Colors.
*/
h1 span { --h: 0; --s: 100%; --l: 50%; }
h1 span:nth-child(2n) { --h: 30; }
h1 span:nth-child(3n) { --h: 60; }
h1 span:nth-child(4n) { --h: 90; }
h1 span:nth-child(5n) { --h: 120; }
h1 span:nth-child(6n) { --h: 150; }
h1 span:nth-child(7n) { --h: 180; }
h1 span:nth-child(8n) { --h: 210; }
h1 span:nth-child(9n) { --h: 240; }
h1 span:nth-child(10n) { --h: 270; }
h1 span:nth-child(11n) { --h: 300; }
h1 span:nth-child(12n) { --h: 330; }

/*
    Color Calculations with CSS:
    https://una.im/css-color-theming/
    https://stackoverflow.com/questions/1625681/dynamically-change-color-to-lighter-or-darker-by-percentage-css-javascript

    3d Text Shadow technique from:
    https://css-tricks.com/creating-playful-effects-with-css-text-shadows/
    The article uses 0.25px increments however when testing on many
    devices only increments on 1px can be used with text-shadow.

    Outline Effect from:
    https://codepen.io/mandymichael/pen/VprZaq

    See also:
    https://freefrontend.com/css-3d-text-effects/
    https://bennettfeely.com/ztext/
    https://css-tricks.com/text-effects-css-little-contenteditable-trick/
*/
h1 span {
    color: hsl(var(--h), var(--s), var(--l));
    --darker: calc(var(--l) - 10%);
    --darkest: calc(var(--l) - 30%);
    --text-shadow: hsl(var(--h), var(--s), var(--darker));
    --outline: hsl(var(--h), var(--s), var(--darkest));
    text-shadow:
        -1px -1px      var(--outline),
        1px -1px       var(--outline),
        -1px 1px       var(--outline),
        1px 1px        var(--outline),
        2px 2px        var(--text-shadow),
        3px 3px        var(--text-shadow),
        4px 4px        var(--text-shadow),
        5px 5px        var(--text-shadow),
        6px 6px        var(--outline);
}

section.about {
    box-shadow: var(--shadow-1);
    padding: 20px;
    margin: 180px auto 0;
    border-radius: 20px;
    background-color: white;
    width: 100%;
    max-width: calc(100vw - 100px);
    position: relative;
    /* For older Safari on iOS (example, iPad 2): */
    flex: 1 0 auto;
}

section.about::before,
section.about::after {
    content: '';
    position: absolute;
    background-color: var(--bg-color);
    box-shadow: var(--shadow-2);
    display: block;
    border-radius: 50%;
}

section.about::before {
    width: 270px;
    height: 300px;
    filter: brightness(.98);
    left: calc(50% - 135px);
    top: -150px;
    z-index: -1;
}

section.about::after {
    display: none;
    height: 400px;
    filter: brightness(.96);
    top: -200px;
    z-index: -2;
}

@media (min-width: 350px) {
    section.about::after {
        display: block;
        width: 350px;
        left: calc(50% - 175px);
    }
}

@media (min-width: 600px) {
    section.about {
        max-width: calc(100vw - 140px);
        margin-bottom: 40px;
    }

    section.about::before {
        width: 300px;
        left: calc(50% - 150px);
    }

    section.about::after {
        width: 400px;
        left: calc(50% - 200px);
    }
}

@media (min-width: 800px) {
    section.about {
        padding: 30px 60px;
        max-width: 600px;
        margin-top: 240px;
        margin-bottom: 100px;
    }
}

section.about img.photo {
    max-width: 200px;
    max-height: 200px;
    background-color: white;
    border-radius: 50%;
    box-shadow: var(--shadow-2);
    position: absolute;
    top: -100px;
    left: calc(50% - 100px);
    transition: transform ease-in-out .2s;
    filter: brightness(120%);
}

section.about p {
    display: flex;
    text-align: left;
    padding: .6em 1em;
    line-height: 1.4em;
}

section.about p::before {
    content: attr(data-emoji);
    padding-right: .75em;
    padding-top: .5em;
    font-size: 2em;
}
@media (min-width: 800px) {
    section.about p::before {
        padding-right: 1em;
    }
}

section.about ul { list-style-type: none; margin-top: 20px; }
section.about li { display: inline-block; padding: 20px; }
section.about li img {
    width: 32px;
    height: 32px;
    transition: opacity ease-in-out .2s, transform ease-in-out .2s;
    opacity: .6;
}
section.about li img:hover {
    opacity: .3;
    transform: translateY(-8px);
}

.photos {
    list-style-type: none;
    margin-bottom: 60px;
}

.photos li {
    display: block;
    margin: 40px;
    box-shadow: var(--shadow-1);
    background-color: white;
    border-radius: 10px;
}

.photos image-gallery {
    width: 100%;
    height: 400px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.7);
    /*
        <image-gallery> use [tabindex] to allow full use of keyboard.
        However this causes an outline to appear when the image is
        clicked. This prevents the outline.
    */
    outline: none;
}

.photos image-gallery img {
    object-fit: cover;
    width: 100%;
    height: 100%;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}

@media (min-width: 600px) {
    .photos {
        display: flex;
        flex-wrap: wrap;
        align-items: flex-start;
        justify-content: center;
    }

    .photos image-gallery {
        width: 550px;
        height: 350px;
    }

    .photos li.vertical image-gallery {
        width: 400px;
        height: 500px;
    }

    .photos li.vertical image-gallery img {
        object-position: top;
    }
}

.photos p {
    padding: 20px;
    font-size: 1.4em;
    font-weight: bold;
}

.photos p .flag {
    display: inline-block;
    margin-left: 16px;
}

/* Show the loading screen only if it appears for longer than a second */
.loading {
    /* Layout and Style */
    background-color: blue;
    border: 2px solid darkblue;
    color: white;
    padding: 1em;
    margin: 1em;
    display: block;
    /* Animation */
    opacity: 0;
    animation-name: show-after-delay;
    animation-delay: 1s;
    animation-duration: 0s;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}
@keyframes show-after-delay {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Animation */

section.about img.photo {
    opacity: 0;
    animation: show var(--duration) ease-in-out var(--delay) 1 forwards;
}
section.about::before {
    opacity: 0;
    animation: show var(--duration) ease-in-out calc(var(--delay) * 2) 1 forwards;
}
section.about::after {
    opacity: 0;
    animation: show var(--duration) ease-in-out calc(var(--delay) * 3) 1 forwards;
}
h1 {
    opacity: 0;
    animation: show-from-right var(--duration) ease-in-out calc(var(--delay) * 4) 1 forwards;
}
section.about p {
    opacity: 0;
    animation: show-from-bottom var(--duration) ease-in-out calc(var(--delay) * 5) 1 forwards;
}

/*
    Only the first 2 images on mobile and laptop/regular-width desktop are
    animated on scroll; 2 Images provides a nice effect compared to animating
    all images which turned out to be visually distracting. For wide-screen
    desktops the images are not animated.
*/
.photos li:nth-child(1).animate {
    transform: translateX(-100px);
    animation: move-from-left var(--duration) ease-in-out forwards;
}
.photos li:nth-child(2).animate {
    transform: translateX(100px);
    animation: move-from-right var(--duration) ease-in-out forwards;
}
@media (min-width: 1740px) {
    .photos li:nth-child(1).animate,
    .photos li:nth-child(2).animate {
        transform: none;
        animation: none;
    }
}

[data-animate="move-from-left"] { transform: translateX(-100px); }
[data-animate="move-from-left"].move-from-left { animation: move-from-left var(--duration) ease-in-out forwards; }

[data-animate="move-from-right"] { transform: translateX(100px); }
[data-animate="move-from-right"].move-from-right { animation: move-from-right var(--duration) ease-in-out forwards; }

[data-animate="move-from-bottom"] { transform: translateY(50px); }
[data-animate="move-from-bottom"].move-from-bottom { animation: move-from-bottom var(--duration) ease-in-out forwards; }

[data-animate="move-from-bottom-left"] { transform: translate(-50px, 50px); }
[data-animate="move-from-bottom-left"].move-from-bottom-left { animation: move-from-bottom-left var(--duration) ease-in-out forwards; }

[data-animate="move-from-bottom-right"] { transform: translate(50px, 50px); }
[data-animate="move-from-bottom-right"].move-from-bottom-right { animation: move-from-bottom-right var(--duration) ease-in-out forwards; }

@keyframes show {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scale {
    from { transform: scale(.5); }
    to { transform: scale(1); }
}

@keyframes show-from-right {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes show-from-bottom {
    from { opacity: 0; transform: translateY(100px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes show-from-left {
    from { opacity: 0; transform: translateX(-100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes move-from-right {
    from { transform: translateX(100px); }
    to { transform: translateX(0); }
}

@keyframes move-from-left {
    from { transform: translateX(-100px); }
    to { transform: translateX(0); }
}

@keyframes move-from-bottom {
    from { transform: translateY(50px); }
    to { transform: translateX(0); }
}

@keyframes move-from-bottom-left {
    from { transform: translate(-50px, 50px); }
    to { transform: translateX(0); }
}

@keyframes move-from-bottom-right {
    from { transform: translate(50px, 50px); }
    to { transform: translateX(0); }
}
