/* RESET CSS */
/* https://piccalil.li/blog/a-more-modern-css-reset/ */
/* https://www.joshwcomeau.com/css/custom-css-reset/ */

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -moz-text-size-adjust: none;
    -webkit-text-size-adjust: none;
    text-size-adjust: none;
}

body {
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

input, button, textarea, select { font: inherit; }
h1, h2, h3, h4, button, input, label { line-height: 1.1; }
h1, h2, h3, h4 { text-wrap: balance; }
p, li, dd { text-wrap: pretty; }

ul[role="list"] { list-style-type: none; }

img, picture, video, canvas, svg, textarea, input {
    display: block;
    max-width: 100%;
}

textarea:not([rows]) { min-height: 10em; }
:target { scroll-margin-block: 5ex; }

/* GLOBAL CSS */

@font-face {
    font-family: "Ioskeley";
    src: url("/assets/fonts/Ioskeley Mono Optimized.woff2");
}

@keyframes flicker-opacity {
    0%   { opacity: 1; }
    50%  { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes flicker-background {
    0%   { background-color: white; }
    50%  { background-color: transparent; }
    100% { background-color: white; }
}

@keyframes fade-in {
    0%   { opacity: 0; }
    100% { opacity: 1; }
}

:root {
    --background-color: oklch(0.25 0.05 270);
    --outline: 2px solid rgba(255, 255, 255, 0.7);
    --padding-text-md: 0.5rem 1rem;
    --padding-text-lg: 0.5rem 2rem;
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 4rem;

    --flicker-from-white: flicker-background 0.1s 2;
    --flicker-from-bg: flicker-background 0.15s 1;
}

body {
    height: 100vh;
    background-color: var(--background-color);
    font-family: Ioskeley, monospace;
    font-size: 1.25rem;
    color: white;
}

/* ELEMENTS */

article {
    & h1, h2, h3 {
        padding: var(--padding-text-md);
        background-color: white;
        color: var(--background-color);
        margin-block: var(--spacing-lg) var(--spacing-md);
    }

    & h1 {
        font-family: system-ui, sans-serif;
        font-stretch: ultra-expanded;
        margin-top: 0;
    }

    & h2, h3 {
        width: max-content;
        font-size: inherit;
    }

    & p, ul, details, dl { margin-block: var(--spacing-sm); }
    & ul {
        margin-left: var(--spacing-md);
        list-style-type: disc;
        & > * + * { margin-top: var(--spacing-sm); }
    }

    & dd { margin-left: var(--spacing-md); }
    & dt {
        font-weight: bold;
        &:not(:first-child) { margin-top: var(--spacing-sm); }
    }
}

a:not(.filled) {
    background-color: transparent;
    text-underline-position: under;
    color: white;
    color: oklch(
        from var(--background-color)
        0.9
        calc(c + 0.2)
        calc(h + 10)
    );

    &:hover {
        background-color: white;
        color: var(--background-color);
        animation: var(--flicker-from-bg);
    }
}

a[target="_blank"]:not(:has(img))::after {
    content: " ↗";
    font-family: system-ui, sans-serif;
}

button {
    border: none;
    padding: var(--padding-text-md);
    background-color: white;
    color: var(--background-color);
    cursor: pointer;
    &:hover { animation: var(--flicker-from-white); }
}

input, textarea {
    width: 100%;
    padding: var(--spacing-sm);
    border: var(--outline);
    background-color: transparent;
    color: white;
}

input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, 0.7); }
input:focus, textarea:focus {
    border: var(--outline);
    outline: none;
    z-index: 1000;
}

form label {
    display: block;
    padding-bottom: var(--spacing-xs);
}

summary { cursor: pointer; }

/* LAYOUTS */

.nav-main {
    display: grid;
    grid-template-columns: 1fr min(65ch, 100%) 1fr;
    gap: var(--spacing-lg);
    height: 100vh;
    padding-block: var(--spacing-lg);
    & main { overflow-y: scroll; }
}

.sidebar {
    max-width: max-content;
    margin-left: auto;

    & a {
        display: block;
        padding: var(--padding-text-md);
        text-decoration: none;
        &:not(.filled) { color: white; };
        &:not(.filled):hover { color: var(--background-color); };
    }
}

.splash {
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: max-content;
    height: 100vh;
    margin-inline: auto;

    & h1 {
        text-wrap: nowrap;
        font-size: clamp(3rem, 10vw, 8rem);
        font-weight: 800;
    }
}

.buttons {
    display: flex;
    gap: var(--spacing-xs);
    width: max-content;
    margin-inline: auto;
    image-rendering: pixelated;
    & > a:hover { outline: var(--outline); }
}

/* UTILITIES */

.padding-md { padding: var(--padding-text-md); }
.padding-lg { padding: var(--padding-text-lg); }

.flow-sm { & > * + * { margin-top: var(--spacing-sm); } }
.flow-md { & > * + * { margin-top: var(--spacing-md); } }
.flow-right {
    display: block;
    width: fit-content;
    margin-left: auto;
}
.flow-left {
    display: block;
    width: fit-content;
    margin-right: auto;
}

.active { box-shadow: -2px 0 0 white; }
.filled {
    background-color: white;
    color: var(--background-color);
    text-decoration: none;
    a&:hover { animation: var(--flicker-from-white); }
}

.font-expanded {
    font-family: system-ui, sans-serif;
    font-stretch: ultra-expanded;
}

.trickle > * {
    opacity: 0;
    animation: flicker-opacity 0.1s forwards;
    &:nth-child(1) { animation-delay: 100ms; }
    &:nth-child(2) { animation-delay: 200ms; }
    &:nth-child(3) { animation-delay: 300ms; }
    &:nth-child(4) { animation-delay: 400ms; }
    &:nth-child(5) { animation-delay: 500ms; }
    &:nth-child(6) { animation-delay: 600ms; }
    &:nth-child(7) { animation-delay: 700ms; }
}

article.trickle > * { animation: fade-in 0.2s forwards; }

/* COMPONENTS */

.columns {
    display: flex;
    gap: var(--spacing-sm);
    & > * { flex-grow: 1; }
}

.card {
    padding: var(--spacing-sm);
    border: var(--outline);
}

.post {
    & span { margin-left: auto; }
    & header {
        display: flex;
        align-items: baseline;
        gap: var(--spacing-sm);
    }
}

.posts { margin-top: var(--spacing-lg); }

/* PAGE SPECIFIC */

#background {
    position: fixed;
    width: 100vw;
    height: 100vh;
    z-index: -1;
}

#controls {
    width: max-content;

    & #background-control {
        & input { display: none; }
        & label {
            display: block;
            padding: var(--padding-text-md);
            cursor: pointer;

            &:hover {
                background-color: white;
                color: var(--background-color);
                animation: var(--flicker-from-bg);
            }

            input:checked + & {
                background-color: white;
                color: var(--background-color);
                mix-blend-mode: screen;
            }
        }
    }

    & button {
        display: block;
        width: 100%;
    }
}
