:root {
    --l-base: 40rem;
    --l-wider: 48rem;

    --bez-ease: cubic-bezier(0.82, 0, 0.12, 1);
    --t-link-hover: 0.2s;

    --c-azure: rgb(54, 189, 247);
    --c-azure-light: rgba(54, 189, 247, 0.56);
    --c-gray: #777;
    --c-bg-gray: #f7f7f7;

    --f-all: avenir next, avenir, sans-serif;
    --f-mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Monaco,
        Liberation Mono, Lucida Console, monospace;
}

/**
 * reset
 */
body {
    margin: 0;
}

html {
    font-size: 14px;
    font-family: var(--f-all);
}

/**
 * layout
 */
body {
    display: flex;
    flex-direction: column;
    /* ios safarai calculate 100vh as screen size + titlebar */
    min-height: 100dvh;
}

body>* {
    min-width: var(--l-base);
    margin-left: auto;
    margin-right: auto;
}

#main {
    flex: 1;
}

#header,
#links,
#content>* {
    margin-left: auto;
    margin-right: auto;
}

#header {
    margin-top: 8rem;
    margin-bottom: 2rem;
}

footer {
    margin-bottom: 8rem;
    margin-top: 2rem;
}

#main {
    margin-bottom: 8rem;
}

/**
 * nav
 */
#header nav a {
    transition:
        color var(--t-link-hover) var(--bez-ease),
        opacity var(--t-link-hover) var(--bez-ease) 0.5s;
}

#header nav a:not(.active) {
    opacity: 0;
}

#header nav a#nav-home {
    opacity: 1;
}

#header nav:hover a:not(.active) {
    opacity: 1;
}

.page-home #header nav a {
    opacity: 1;
}

#header nav a {
    color: var(--c-gray);

    position: relative;
    text-decoration: none;
}

#header nav a.active {
    color: var(--c-azure);
}

#header nav a:hover {
    color: var(--c-azure-light);
}

#header nav a.active:hover {
    color: var(--c-azure);
}

#header nav a:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--c-azure-light);
    transform: scaleX(0);
    transition: transform 0.2s var(--bez-ease) 0s;
}

#header nav a.active:before {
    background-color: var(--c-azure);
}

#header nav a:hover:before {
    visibility: visible;
    transform: scaleX(1);
}

#header nav a.active:before {
    transform: scaleX(1);
}

#header nav #nav-home:before {
    display: none;
}

/**
 * nav: home dot
 */
#header nav {
    position: relative;
}

#header nav #nav-home {
    position: absolute;
    top: 1px;
    left: -26px;
    width: 12px;
    height: 12px;
}

#header nav #nav-home-dot {
    transition: fill 0.2s var(--bez-ease);
    fill: var(--c-gray);
}

#header nav #nav-home:hover #nav-home-dot {
    fill: var(--c-azure-light);
}

#header nav #nav-home.active #nav-home-dot {
    fill: var(--c-azure);
}

/**
 * main:links
 */
#links {
    padding: 0;
    max-width: var(--l-base);
}

#links li {
    list-style-type: none;
    display: flex;
    justify-content: space-between;
}

#links li:not(:first-child) {
    padding-top: 1rem;
}

#links a {
    color: var(--c-azure);

    text-decoration: none;
}

#links a:hover {
    text-decoration: underline;
}

#links .date {
    color: var(--c-gray);
}

#links .tag:not(:first-child) {
    margin-top: 2rem;
}

/**
 * homepage only link animation
 */
.page-home #links a {
    position: relative;
    text-decoration: none;
}

.page-home #links a:before {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    bottom: 0;
    left: 0;
    background-color: var(--c-azure);
    transform: scaleX(0);
    transition: transform 0.2s var(--bez-ease) 0s;
}

.page-home #links a:hover:before {
    visibility: visible;
    transform: scaleX(1);
}

/**
 * main::content
 */
#content {
    color: var(--c-gray);
}

#content>* {
    max-width: var(--l-base);
}

#content a {
    color: var(--c-azure);
    text-decoration: none;
}

#content a:hover {
    text-decoration: underline;
}

#content .gallery {
    max-width: var(--l-base);
    display: flex;
    flex-flow: row nowrap;
}

#content .gallery figure {
    margin: 0;
    padding: 3px;
    padding-top: 0;
}

#content .gallery figure:first-child {
    padding-left: 0;
}

#content .gallery figure:last-child {
    padding-right: 0;
}

#content .gallery img {
    max-width: 100%;
}

#content video {
    max-width: var(--l-wider);
    display: block;
}

#content blockquote {
    box-sizing: border-box;
    max-width: var(--l-wider);
    background-color: var(--c-bg-gray);
    padding: 1rem;
    font-style: italic;
}

#content code {
    font-family: var(--f-mono);
    font-size: 12px;
}

#content p code {
    background-color: var(--c-bg-gray);
    padding: 2px 4px;
}

#content hr {
    border-top: none;
    margin-top: 1.4rem;
    margin-bottom: 1.4rem;
    max-width: var(--l-wider);
}

#content ul {
    padding-left: 1rem;
}

#content>ul {
    padding-left: 0;
}

#content ol.footnotes-list {
    padding-left: 1rem;
}

/**
 * main::tags
 */
#tags {
    max-width: var(--l-base);
    margin-left: auto;
    margin-right: auto;
    margin-top: 4rem;
}

#tags span {
    text-decoration: none;
    display: inline-block;
    padding: 5px;
    margin: 2px;
    background-color: #f9f9f9;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/**
 * footer
 */
footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
}

.footer-left{
    text-align: left;
}

.footer-right{
    text-align: right;
}

footer a {
    color: var(--c-azure);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/**
 * mobile
 */
@media only screen and (max-width: 768px) {
    :root {
        --l-base: calc(100vw - 2rem);
    }

    html {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    #header nav a:not(.active) {
        opacity: 1;
    }

    #header nav #nav-home {
        position: relative;
        top: 1px;
        left: 0;
        margin-right: 6px;
    }

    #header {
        margin-top: 7rem;
        margin-bottom: 1rem;
    }

    #main {
        margin-bottom: 2rem;
    }

    #tags {
        margin-top: 1rem;
    }

    footer {
        margin-top: 1rem;
        margin-bottom: 7rem;
    }

    #links li {
        flex-flow: column nowrap;
    }

    #content>ul {
        padding-left: 1rem;
    }
}