/* Application stylesheet.
   Defines layout, color palette, and responsive behavior for the app.
   Uses CSS variables for theming and supports dark and light modes. */

/* Color variables for dark and light modes. All colors are referenced via these variables. */
:root {
    /* Dark mode color scheme (default) */
    --back: black;
    --fore: #e3e3e3;
    --border: #777;
    --system: #9cdcda;
    --review: #bebebe;
    --pending: #111111;
    --processing: #111111;
    --delisted: #051d3a;
    --reported: rgb(75, 10, 75);
    --rejected: rgb(37, 4, 4);
    --banned: rgb(105, 10, 10);
    --disabled: #444;
}

/* Light mode color scheme (activated by system preference) */
@media (prefers-color-scheme: light) {
    :root {
        --back: white;
        --fore: black;
        --border: #ccc;
        --system: black;
        --review: rgb(63, 63, 63);
        --pending: #eeeeee;
        --processing: #eeeeee;
        --delisted: rgb(97, 156, 223);
        --reported: rgb(243, 186, 243);
        --rejected: rgb(250, 226, 226);
        --banned: rgb(231, 102, 102);
        --disabled: #ccc;
    }
}

/* Base layout for body and common elements. */
body {
    margin: 8px auto;
    width: max-content;
    max-width: calc(100% - 16px);
}

/* Form element styling for consistent appearance. */
textarea {
    width: min(calc(100% - 12px), 600px);
    height: 4em;
    padding: 5px;
}

/* Firefox-specific textarea width adjustment. */
@-moz-document url-prefix() {
    textarea {
        width: min(calc(100% - 14px), 600px);
    }
}

/* Typography and form controls. Consistent font and color. */
body,
textarea,
input,
select,
button,
::file-selector-button {
    font-family: Consolas, monospace;
    font-size: 12px;
    color: var(--fore);
    background: var(--back);
    accent-color: var(--system);
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

::selection {
    background: var(--system);
    color: var(--back);
}

input:disabled {
    color: var(--disabled);
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
    min-width: 0;
    appearance: none;
}

button,
select {
    margin: 7px 0;
}

button#post-button {
    font-weight: bold;
}

input[type="text"],
input[type="password"] {
    margin: 4px 0;
}

input,
textarea,
select,
button,
::file-selector-button {
    border-radius: 5px;
    border-color: var(--border);
}

/* Link and navigation styles. */
a {
    color: var(--system);
}

nav {
    float: right;
}

nav a {
    text-decoration: none;
}

h1 a {
    text-decoration: none;
    color: var(--fore);
}

h1 {
    font-size: 1em;
}

/* Status messages and system elements. */
.system {
    color: var(--system);
}

.status {
    color: var(--review);
    overflow-wrap: anywhere;
}

.status a {
    text-decoration: none;
}

details.review form {
    display: inline;
}

/* List page post layout and styling. */
main.list div#posts {
    display: flex;
    flex-wrap: wrap;
    gap: calc(1vh + 1vw + 16px);
    margin: 12px 0;
    align-items: center;
}

main.list div.post {
    flex: clamp(300px, 34vh, 800px);
}

main.list {
    margin-bottom: 50px;
}

main.solo div.post details.review {
    height: 45px;
}

div.post {
    display: grid;
    justify-content: center;
    gap: 8px;
    margin: 0 -8px;
    padding: 0 8px;
}

/* Post status backgrounds. */
div.pending,
div.delisted,
div.reported,
div.rejected,
div.banned {
    padding-top: 8px;
    padding-bottom: 8px;
}

div.pending {
    background: var(--pending);
}

div.processing {
    background: var(--processing);
}

div.delisted {
    background: var(--delisted);
}

div.reported {
    background: var(--reported);
}

div.rejected {
    background: var(--rejected);
}

div.banned {
    background: var(--banned);
}

/* Post content elements. */
div.post-body {
    overflow-y: clip;
    overflow-wrap: anywhere;
    max-width: 600px;
}

div.media {
    margin: 0 auto;
    min-width: 300px;
    max-width: max-content;
    text-align: center;
}

div.media img,
div.media video,
div.youtube-thumbnail img {
    max-width: max(300px, calc(100% + 16px));
    max-height: max(92vh, 800px);
    margin: 0 -8px;
    height: auto;
    width: auto;
}

main.list div.media img,
main.list div.media video,
main.list div.youtube-thumbnail img {
    /* Reduce brightness in dark mode to avoid discomfort. */
    filter: brightness(0.87);
}

/* Restore standard brightness in light mode. */
@media (prefers-color-scheme: light) {
    main.list div.media img,
    main.list div.media video,
    main.list div.youtube-thumbnail img {
        filter: unset;
    }
}

main.solo div.youtube-thumbnail img {
    max-height: 600px;
}

main.list div.media img,
main.list div.media video,
main.list div.youtube-thumbnail img {
    max-height: clamp(300px, 50vh, 1200px);
}

div.arrow a {
    text-decoration: none;
    font-size: 1.2em;
}

div.see-more a {
    text-decoration: none;
}

div#user a {
    text-decoration: none;
}

p#notice {
    color: var(--system);
}

p#next-page {
    text-align: right;
    margin-right: 5vw;
}

p#next-page a {
    text-decoration: none;
    color: var(--system);
}

/* Loading spinner. Hidden by default, shown via JavaScript. */
div#spinner {
    width: 10px;
    height: 10px;
    border: 2px solid var(--fore);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spinner 0.85s linear infinite;
    display: none;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Layout helpers. */
div.row {
    margin-top: 4px;
    display: flex;
    gap: 6px;
    align-items: center;
}

div.row button[type="submit"] {
    margin: unset;
}

div.youtube {
    margin: 0 auto;
    width: fit-content;
}

div.youtube-logo img {
    height: 1.7em;
    filter: brightness(0.2) invert(1);
}

@media (prefers-color-scheme: light) {
    div.youtube-logo img {
        filter: saturate(0) brightness(0.2);
    }
}

div.checkbox-container {
    display: flex;
    align-items: center;
}

div.checkbox-container label {
    margin-left: 2px;
}

/* Form layouts using grid for label alignment. */
fieldset.grid {
    display: grid;
    grid-template-columns: max-content max-content;
    column-gap: 5px;
    align-items: center;
}

fieldset.grid label {
    text-align: right;
}

fieldset.grid div.checkbox-container,
fieldset.grid button[type="submit"] {
    grid-column: 2;
    justify-self: start;
}

/* Form field sizing. */
input[type="password"] {
    width: 31ch;
}

input#username {
    width: 17ch;
}

.hidden {
    display: none;
}
