:root {
    --font-size-title: 2rem;
    --font-size-button: 2rem;
    --font-size-big: 1.5rem;
    --font-size-indicator: 1.5rem;
    --font-size-medium: 1.2rem;
    --font-size-fineprint: 0.65rem;
    --color-bg-main: #152f56;
    --color-post-great: #4f4c;
    --color-post-good: #fff4;
    --color-post-bad: #f44c;
    --color-favorited: #ff4;
    --color-highlight-bg: #25477b;
    --color-highlight-bg-light: #d5e5f3;
    --color-text: white;
    --color-fineprint: #7d92a6;
    --color-tag: #b4c7d9;
    --color-link: #b4c7d9;
    --color-error: #d82828;
    --color-drop-shadow: #0006;
    --color-border: #5980bb;
    --drop-shadow-small: 0 2px 8px var(--color-drop-shadow);
    --drop-shadow-large: 0 3px 12px var(--color-drop-shadow);
    --big-border: 0.15em solid var(--color-border);
    --big-border-radius: 1em;
    --small-border-radius: 0.5em;
    --post-padding: 0.5em;
    --post-margin: 0.5em;
    --post-img-size: calc(min(
        196px,
        50vw - (var(--post-padding) * 2 + var(--post-margin) * 2)
    ));
}

@media (max-width: 32rem) {
    :root {
        --font-size-button: 1.5rem;
        --font-size-big: 1.2rem;
        --font-size-medium: 1rem;
    }
}

body {
    background-color: var(--color-bg-main);
	color: var(--color-text);
	font-family: "Roboto";
    margin: 0;

    a {
        color: var(--color-link);
    }
}

button, input[type="submit"] {
    cursor: pointer;
}

input {
    box-sizing: border-box;
}

.inputs-row, .inputs-group {
    display: flex;
    justify-content: center;
    align-items: baseline;
    flex-wrap: wrap;
}

.inputs-row {
    margin-block: 0.1lh;
}

.inputs-param {
    display: inline-block;
    padding-inline: 0.25em;
}

.tags-box {
    position: relative;
    max-width: 100%;
    margin: auto;

    input {
        width: 100%;
        font-size: inherit;
    }

    ul {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + .25lh);
        z-index: 20;
        margin: 0;
        padding: 2px;
        list-style: none;
        max-height: 15rem;
        overflow-y: auto;
        background: white;
        box-shadow: var(--drop-shadow-small);
        border-radius: 5px;
        border: 1px solid var(--color-border);
        font-size: initial;
    }

    ul[hidden] {
        display: none;
    }

    li {
        color: initial;
        padding: 3px 4px;
        border-radius: 4px;
        cursor: default;

        &.active {
            color: var(--color-tag);
            background: var(--color-highlight-bg);
        }

        .tag-count {
            float: right;
        }
    }
}

header {
    position: sticky;
    top: 0;
    z-index: 10;

	background-color: var(--color-highlight-bg);
    box-shadow: var(--drop-shadow-small);
	font-size: var(--font-size-big);
	margin: 0.75lh 0;
    padding: 0.5lh 0;

    display: flex;
    justify-content: space-between;
    align-items: center;

    input {
        color: initial;
    }

    .back-button {
        font-size: var(--font-size-button);
        width: 3em;
        text-align: center;
        color: var(--color-link);
        text-decoration: none;
    }

    .flex-spacer {
        width: 3em;
    }

    form {
        width: 75%;
        max-width: 25em;
        display: flex;
        flex-direction: column;

        .inputs-row {
            width: 100%;
        }

        .tags-box,
        input.post-list-box,
        input.post-id-box,
        input.tag-name-box
        {
            flex: auto;
            width: 2em;
            margin-inline: 0.25em;
            font-size: inherit;
        }

        input.post-id-box {
            flex: 0 1;
            width: 6em;
            max-width: 40%;
        }

        label {
            font-size: var(--font-size-medium);
        }

        select, input[inputmode="numeric"], input[type="checkbox"] {
            flex: none;
            font-size: var(--font-size-medium);
        }

        select { width: 3em; }
        input[inputmode="numeric"] { width: 2em; }
    }
}


/* Login Page */
.login-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

#login-content {
    width: 22rem;
    max-width: 100%;
    border: var(--big-border);
	border-radius: var(--big-border-radius);
    background-color: var(--color-highlight-bg);
    box-shadow: var(--drop-shadow-large);

    form {
        margin-block: 1.5lh;

        input, button {
            display: block;
            font-size: var(--font-size-medium);
        }

        input {
            margin: 0.5lh auto;
            width: 15rem;
        }

        button {
            margin: 0.75lh auto;
        }
    }
}


/* Home page */
.home-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

#home-content {
	width: 30em;
    max-width: 100%;
    border: var(--big-border);
	border-radius: var(--big-border-radius);
    background-color: var(--color-highlight-bg);
    box-shadow: var(--drop-shadow-large);

    .segment {
        margin-block: 1.75rlh;
    }

    h1,
    h2,
    .tags-box > input,
    input.post-id-box,
    input.post-list-box,
    input.tag-name-box
    {
        display: block;
        margin: 0.5rlh auto 0;
        font-size: var(--font-size-big);
    }

    h1 {
        font-size: var(--font-size-big);
        text-align: center;
    }

    h2 {
        font-size: var(--font-size-medium);
        text-align: center;
    }

    .inputs-row {
        margin-top: 0.5lh;

        label, select, input {
            font-size: 1rem;
        }

        form {
            margin-inline: 0.25em;
        }
    }

    footer {
        font-size: var(--font-size-fineprint);
        text-align: center;
        color: var(--color-fineprint);

        form {
            margin-top: 1lh;
        }
    }

    .tags-box, input.post-list-box { width: 75%; }
    input.post-id-box { width: 50%; }
}

@media (max-width: 35em) {
    #home-content {
        width: 100%;
        margin-bottom: 0;
        padding-inline: 0;
        border: none;
        border-radius: 0;
    }
}



/* Search page */
h1 {
    text-align: center;
    font-size: var(--font-size-title);
}

article {
    margin-bottom: 10em;
}

.next-counts {
    color: var(--color-fineprint);
    margin-inline: auto;
    text-align: center;
}

.next-button {
    display: block;
    font-size: var(--font-size-button);
    margin-inline: auto;
    text-decoration: none;
    text-align: center;
}

.post-listing {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 2rem auto;
    max-width: 1440px;

    a {
        text-decoration: none;
    }
}

.post-wrapper {
    position: relative;
    margin: var(--post-margin);
}

.explain-btn {
    position: absolute;
    right: -0.25em;
    bottom: -0.25em;
    display: block;
    font-size: var(--font-size-indicator);
    width: 1.5em;
    height: 1.5em;
    border-radius: 0.75em;
    text-align: center;
    line-height: 1.5em;
    font-weight: bold;
    z-index: 5;
    background-color: var(--color-link);
    color: var(--color-bg-main);
    opacity: 0;
}

@media (hover: none) {
    .explain-btn {
        opacity: 1;
    }
}

.explain-btn:hover {
    opacity: 1;
}

.post {
    padding: var(--post-padding);
    border-radius: var(--small-border-radius);
    width: var(--post-img-size);
    height: var(--post-img-size);
    background-color: var(--color-highlight-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: var(--drop-shadow-small);

    img {
        display: block;
        margin: 0 auto;
        width: var(--post-img-size);
        height: var(--post-img-size);
        object-fit: contain;
    }
}

.post-great {
    outline: 2px solid var(--color-post-great);
}

.post-good {
    outline: 2px solid var(--color-post-good);
}

.post-bad {
    outline: 2px solid var(--color-post-bad);
}

.post-favorite::before {
    content: "★";
    position: absolute;
    color: var(--color-favorited);
    top: 0.25em;
    right: 0.5em;
    font-size: var(--font-size-indicator);
    text-shadow: 0 1px 2px black;
}


/* Explain page */
.post-error {
    margin: 3em auto;
    text-align: center;
    color: var(--color-error);
    font-size: var(--font-size-medium);
}

.post-feature {
	margin: 3em auto 0;
	width: calc(var(--post-img-size) * 1.5);
    background: var(--color-highlight-bg);
    border-radius: var(--big-border-radius);
    padding: 3em 0 2em;
    box-shadow: var(--drop-shadow-large);

    img {
        display: block;
        margin: 0 auto;
        width: var(--post-img-size);
        height: var(--post-img-size);
        object-fit: contain;
        border-radius: var(--small-border-radius);
    }

    a {
        display: block;
        text-align: center;
        margin-top: 1em;
        color: var(--color-link);
        border-radius: var(--big-border-radius);
    }
}

.ban-reason {
    width: 25em;
    margin: 2em auto;

    h2 {
        text-align: center;
        color: var(--color-error);
    }
}


.ban-reason li a {
    color: var(--color-tag);
}

.tag-tables {
    display: flex;
    justify-content: space-evenly;
    align-items: flex-start;
    width: 55em;
    max-width: 100%;
    margin: 0 auto;

    h2 {
        text-align: center;
        color: var(--color-fineprint);
        margin-top: 2em;
    }
}

@media (max-width: 32rem) {
    .tag-tables {
        flex-direction: column;
        align-items: center;
    }
}

.tag-ranking {
    margin: 0 1em;
    table-layout: fixed;
    border-collapse: collapse;

    tr {
        height: 1.2lh;
    }

    td, th {
        padding-inline: 0.25em;
    }

    td, td a {
        color: var(--color-tag);
    }

    td:nth-child(1), th:nth-child(1) {
        text-align: right;
    }

    td:nth-child(2), th:nth-child(2) {
        text-align: center;
    }

    td:nth-child(3), th:nth-child(3) {
        text-align: left;
    }
}


/* Refreshing page */
.refresh-layout {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    .refresh-status {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        width: 30em;
        max-width: 100%;
        height: 10lh;
        max-height: 100%;
        background-color: var(--color-highlight-bg);
        border-radius: var(--big-border-radius);
        border: var(--big-border);

        #status-message {
            text-align: center;
        }
    }
}
