/* ===== CSS VARIABLES ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition:
        background-color 0.2s,
        color 0.2s,
        border-color 0.2s,
        text-decoration-color 0.2s,
        opacity 0.2s;
    font-family: "Roboto Local";
    font-feature-settings:
        "liga" 0,
        "clig" 0,
        "kern" 0;
    /*outline: 1px solid orangered;*/
}

:root {
    --h1: clamp(2.25rem, 4vw, 3rem);
    --h2: clamp(1.5rem, 3vw, 2rem);
    --h3: clamp(1.1875rem, 2.5vw, 1.25rem);
    --h4: clamp(0.9375rem, 2vw, 1rem);
    --h5: clamp(0.875rem, 1.8vw, 0.95rem);
    --body: clamp(0.97rem, 2vw, 1.05rem);
    --space-xs: clamp(0.25rem, 1vw, 0.5rem);
    --space-s: clamp(0.7rem, 1.67vw, 1rem);
    --space: clamp(1rem, 4vw, 2rem);
    --space-l: clamp(1.5rem, 6vw, 3rem);
    --space-xl: clamp(3rem, 8vw, 6rem);
    --bubble: #739bd0;
    --bg: #111828;
    --header: #e2e8f0;
    --text: #a2afc1;
    --article: #a2afc110;
    --article-box: #0000001a;
}

/* ===== BASE STYLES ===== */
::selection {
    background-color: var(--text);
    color: var(--bg);
}

html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    font-size: var(--body);
    line-height: 1.6;
    color: var(--text);
    margin: var(--space-xl) auto;
    display: flex;
    flex-direction: column;
    gap: var(--space);
    max-width: clamp(320px, 90vw, 1280px);
    padding: 0 var(--space-l);
    position: relative;
}

/* ===== TYPOGRAPHY ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--header);
    margin-bottom: var(--space-s);
}

h1 {
    font-size: var(--h1);
}

h2 {
    font-size: var(--h3);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    scroll-margin-top: var(--space);
    position: sticky;
    top: 0;
    padding: var(--space-s) 0;
    background-color: var(--bg);
    z-index: 10;
    margin-top: calc(var(--space-xl) * 1.5);
    margin-bottom: var(--space-xs);
}

h3 {
    font-size: var(--h4);
}

h4 {
    font-size: var(--h5);
    margin-bottom: var(--space-xs);
}

b {
    color: var(--header);
}

ul,
ol {
    margin-left: 1em;
}

li > ul,
li > ol {
    margin-top: var(--space-s);
}

label {
    display: block;
    font-weight: 400;
    color: var(--header);
}

a {
    color: var(--header);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: var(--text);
}

/* ===== LAYOUT ===== */
aside {
    flex: 2;
    display: flex;
    flex-direction: column;
    margin-bottom: var(--space);
}

aside footer {
    margin-top: var(--space-s);
}

aside nav {
    display: none;
}

main {
    flex: 3;
    min-width: 0;
}

/* ===== HEADER ===== */
header div {
    margin-bottom: var(--space-s);
}

header p {
    margin-bottom: var(--space-s);
    height: 3.4em;
    display: flex;
    align-items: flex-start;
}

main header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space);
}

main header a,
main header button {
    padding: var(--space-s);
    color: var(--text);
    text-decoration: none;
    font-weight: 400;
}

main header a:hover,
main header button:hover {
    text-decoration: underline;
}

header p span[data-cursor="true"] {
    display: none;
    color: var(--header);
    animation: cursor-blink 0.8s infinite;
}

@keyframes cursor-blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* ===== ARTICLES ===== */
main section p {
    font-size: calc(var(--body) * 0.9);
    margin-top: var(--space-s);
    margin-bottom: 0;
}

main article {
    display: flex;
    flex-direction: column;
    margin-bottom: var(--space-s);
    align-items: flex-start;
    padding: calc(var(--space) / 2);
    margin-left: calc(-1 * var(--space) / 2);
    margin-right: calc(-1 * var(--space) / 2);
    border: 1px solid transparent;
    border-radius: 8px;
    transition:
        border-color 0.2s,
        background-color 0.2s,
        box-shadow 0.2s;
}

main article:not(:last-child) {
    position: relative;
    margin-bottom: var(--space);
}

main article:not(:last-child)::after {
    content: "";
    position: absolute;
    bottom: calc(-1 * var(--space) / 2);
    left: calc(var(--space) / 2);
    right: calc(var(--space) / 2);
    height: 2px;
    border-radius: 1px;
    background-color: var(--text);
    opacity: 0.2;
    display: block;
}

main article div {
    flex-shrink: 0;
}

main article div:first-child {
    text-align: left;
    padding-right: 0;
    padding-bottom: var(--space-xs);
}

main article div:first-child h3 {
    font-size: calc(var(--body) * 0.9);
    font-weight: 400;
    color: var(--text);
    opacity: 0.8;
    margin-bottom: var(--space-s);
}

main article div:last-child {
    padding-left: 0;
}

main article div:last-child h3 {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text);
    font-size: calc(var(--body) * 0.9);
    font-weight: 700;
    margin-bottom: var(--space-s);
    line-height: 1.3;
    text-align: left;
}

main article div:last-child h3:has(img) {
    font-size: var(--body);
    color: var(--header);
    margin-bottom: var(--space-xs);
}

main article div:last-child h3:has(img) img {
    width: 1.3em;
    height: 1.3em;
}

main article div:last-child p {
    margin-top: var(--space-s);
    margin-bottom: 0;
    font-size: calc(var(--body) * 0.9);
}

main article div:last-child li {
    margin-bottom: var(--space-s);
    font-size: calc(var(--body) * 0.9);
}

main article div:last-child li:last-child {
    margin-bottom: 0;
}

/* ===== ICONS ===== */
aside footer img,
h2 img {
    width: 100%;
    max-width: calc(var(--body) * 2);
    height: auto;
}

aside footer img {
    width: 2em;
    height: 2em;
}

h2 img {
    width: 1.6em;
    height: 1.6em;
}

aside footer a {
    display: inline-block;
    transition:
        opacity 0.2s,
        transform 0.1s;
    position: relative;
}

aside footer a:not(:last-child) {
    margin-right: var(--space-s);
}

/* ===== FOOTER ===== */
main footer {
    font-size: 0.8em;
    margin-top: var(--space-xl);
    opacity: 0.7;
    text-align: center;
}

main footer p {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.2em;
    flex-wrap: wrap;
}

main footer span {
    display: block;
    visibility: hidden;
    margin-bottom: var(--space-xs);
}

body main footer span {
    visibility: visible;
}

main footer img {
    width: 1em;
    height: 1em;
    vertical-align: middle;
    opacity: 1;
}

/* ===== BUTTONS ===== */
button {
    padding: 0.6em;
    display: inline-block;
    font-weight: 400;
    color: inherit;
    background: transparent;
    border: none;
    font-size: inherit;
    line-height: inherit;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

button:hover,
button:focus {
    font-weight: 400;
    text-decoration: none;
    text-decoration-color: transparent;
    color: inherit;
    background-color: transparent;
    outline: none;
}

button:focus-visible {
    outline: 2px solid var(--header);
    outline-offset: 2px;
}

button img {
    transition: transform 0.3s;
    width: 1.3em;
    height: 1.3em;
}

button:hover img {
    transform: rotate(180deg);
}

button a {
    color: var(--text);
    font-weight: 400;
    text-decoration: none;
}

[data-theme="dark"] button img {
    filter: invert(1) brightness(1.2) hue-rotate(200deg);
}

[data-theme="light"] button img {
    filter: brightness(0.7);
}

/* ===== BACKGROUND ANIMATIONS ===== */
body::before,
body::after {
    content: "";
    position: absolute;
    filter: blur(75px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.08;
    background-color: var(--bubble);
    border-radius: 50% 40% 60% 30%;
    animation: float ease-in-out infinite;
}

body::before {
    width: clamp(200px, 25vw, 400px);
    height: clamp(200px, 25vw, 400px);
    top: clamp(1rem, 5vh, 3rem);
    left: clamp(1rem, 5vw, 3rem);
    animation-duration: 20s;
}

body::after {
    width: clamp(150px, 20vw, 300px);
    height: clamp(150px, 20vw, 300px);
    bottom: clamp(1rem, 5vh, 3rem);
    right: clamp(1rem, 5vw, 3rem);
    animation-duration: 15s;
    animation-delay: -7s;
}

@keyframes float {
    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(clamp(20px, 4vw, 60px), clamp(-30px, -6vw, -80px))
            rotate(3deg);
    }
    50% {
        transform: translate(clamp(-15px, -3vw, -40px), clamp(25px, 5vw, 70px))
            rotate(-2deg);
    }
    75% {
        transform: translate(
                clamp(-25px, -5vw, -50px),
                clamp(-15px, -3vw, -30px)
            )
            rotate(1.5deg);
    }
}

/* ===== DESKTOP STYLES ===== */
@media (min-width: 1024px) {
    html {
        overscroll-behavior-y: none;
    }

    body {
        flex-direction: row;
    }

    h2 {
        margin-top: var(--space-xl);
    }

    a:hover {
        text-decoration-color: var(--header);
    }

    aside {
        position: sticky;
        top: var(--space-xl);
        max-height: calc(100vh - 2 * var(--space-xl));
        min-height: calc(100vh - 2 * var(--space-xl));
        margin-bottom: 0;
        overflow-y: auto;
        justify-content: space-between;
    }

    aside footer {
        margin-top: auto;
    }

    aside nav {
        position: static;
        background-color: transparent;
        padding: 0;
        margin-bottom: var(--space);
        display: flex;
        flex-direction: column;
        margin-top: var(--space-l);
        width: fit-content;
        opacity: 1;
        transition: opacity 0.3s;
    }

    aside nav a {
        color: var(--text);
        text-decoration: none;
        font-size: calc(var(--body) * 0.8);
        letter-spacing: 1.5px;
        font-weight: 700;
        padding: var(--space-xs) 0;
        position: relative;
        transition: all 0.2s;
        padding-left: calc(2 * (var(--space-s) + var(--space-xs)));
        opacity: 0.7;
    }

    aside nav a::before {
        content: "";
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: calc(2 * var(--space-s));
        height: 2px;
        background-color: var(--text);
        transition: all 0.2s;
        border-radius: 1px;
    }

    aside nav a:hover {
        padding-left: calc(2 * var(--space));
        color: var(--header);
    }

    aside nav a:hover::before {
        background-color: var(--header);
        width: calc(2 * var(--space-s) * 1.5);
    }

    aside nav a[data-active="true"] {
        padding-left: calc(2 * (var(--space) + var(--space-xs)));
        opacity: 1;
    }

    aside nav a[data-active="true"]::before {
        background-color: var(--header);
        width: calc(2 * var(--space-s) * 2);
    }

    body:has(aside footer a:hover) aside footer a:not(:hover) {
        opacity: 0.4;
    }

    aside footer a:hover {
        transform: translateY(-8px);
    }

    aside footer a::before {
        content: "";
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transition: height 0.1s;
    }

    aside footer a:hover::before {
        height: calc(100% + 8px);
    }

    aside footer a::after {
        content: attr(data-tooltip);
        position: absolute;
        bottom: calc(100% + 5px);
        left: 50%;
        transform: translateX(-50%);
        color: var(--text);
        font-size: 0.8rem;
        white-space: nowrap;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
        z-index: 20;
    }

    aside footer a:hover::after {
        opacity: 1;
    }

    main h2 {
        background-color: transparent;
        position: static;
        padding: 0;
        z-index: auto;
    }

    main footer {
        margin-top: 25vw;
    }

    main article {
        flex-direction: row;
        margin-bottom: var(--space);
        transition:
            border-color 0.2s,
            background-color 0.2s,
            box-shadow 0.2s,
            opacity 0.3s;
    }

    main article:hover {
        background-color: var(--article);
        box-shadow: 0 4px 12px var(--article-box);
    }

    main article:not(:last-child) {
        margin-bottom: var(--space-s);
    }

    main article:not(:last-child)::after {
        display: none;
    }

    main article div:first-child {
        flex: 1;
        text-align: right;
        padding-right: var(--space-s);
        padding-bottom: 0;
    }

    main article div:last-child {
        flex: 3;
        padding-left: var(--space-s);
    }

    section:has(article:hover) article:not(:hover) {
        opacity: 0.5;
    }

    body::before,
    body::after {
        position: fixed;
    }

    @media (max-height: 700px) {
        aside nav {
            opacity: 0;
            max-height: 0;
            margin-top: 0;
            margin-bottom: 0;
            overflow: hidden;
            transition:
                opacity 0.3s,
                max-height 0.3s,
                margin 0.3s;
        }
    }
}
