@import url("https://fonts.googleapis.com/css2?family=Fira+Code&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap");

:root {
    --body-vertical-padding: 3rem;
    --body-horizontal-padding: 3rem;

    --code-font-size: 0.9rem;
    --code-font-family: "Fira Code", monospace;

    --h1-size: 3rem;
    --h2-size: 2rem;
    --h3-size: 1.5rem;
    --line-height: 1.5;

    --post-header-margin-bottom: 3rem;

    --profile-picture-size: 10rem;
    --main-content-max-size: 50rem;

    --link-transition-time: 0.35s;
    --link-transition-function: cubic-bezier(0.25, 0.1, 0, 2.05);

    --background-color: #242829;
    --font-color: #eeeeee;
    --main-color: #4a90e2;        
    --accent-color: #303544;
    --selection-color: #85b9e4;        
    --code-background-color: #52598c20;
    --blockquote-background-color: #52598c40;
}

@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #242829;
        --font-color: #eeeeee;
        --main-color: #4a90e2;        
        --accent-color: #303544;
        --selection-color: #85b9e4;        
        --code-background-color: #52598c20;
        --blockquote-background-color: #52598c40;
    }
}

@media screen and (min-width: 992px) {
    :root {
        --body-horizontal-padding: 5rem;
    }
}

@media screen and (min-width: 1200px) {
    :root {
        --body-horizontal-padding: 10rem;
    }
}

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

::-moz-selection {
    background: var(--selection-color);
}

/* --- RESET SOME PROPERTIES ------------------------------------------------ */

* {
    margin: 0;
    padding: 0;
    font-family: "Open Sans", sans-serif;
    color: var(--font-color);
}

ul,
ol,
dl {
    list-style: none;
    padding-inline: 0;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* --- BODY AND BASE ELEMENTS STYLING --------------------------------------- */

body {
    overflow-x: hidden;
    padding: var(--body-vertical-padding)
        max(
            var(--body-horizontal-padding),
            calc(env(safe-area-inset-left) + 1rem),
            calc(env(safe-area-inset-right) + 1rem)
        );
    background-color: var(--background-color);
    line-height: var(--line-height);
}

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

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

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

.limit-max-width-and-center {
    max-width: var(--main-content-max-size);
    margin-left: auto;
    margin-right: auto;
}

hr {
    margin-top: 2rem;
    margin-bottom: 2rem;
    color: var(--blockquote-background-color);
    appearance: none;
    -moz-appearance: none;
    -webkit-appearance: none;
    border: solid 1px;
    box-shadow: none;
}

/* --- LINKS ---------------------------------------------------------------- */

a > h1,
a > h2,
a > h3,
a > h4,
a > h5,
a > h6 {
    /* This is needed to disaplay nice titles with the same undeline effect
     * as normal text */
    display: inline;
    padding-left: 0.2rem;
    padding-right: 0.2rem;
}

a:not(:has(> *)) {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
}

a {
    text-decoration: none;
    font-weight: 700;
}

a:not(.clip) {
    /* Highlighted effect */
    background-image: linear-gradient(to right, var(--main-color), var(--main-color));
    background-size: 100% 45%;
    background-repeat: no-repeat;
    background-position: bottom;
    transition: var(--link-transition-time);
    transition-timing-function: var(--link-transition-function);
}

a:not(.clip):hover {
    background-size: 100% 80%;
    transition: var(--link-transition-time);
    transition-timing-function: var(--link-transition-function);
}

/* --- HOMEPAGE ------------------------------------------------------------- */

#homepage-header {
    margin-bottom: calc(var(--h1-size) * 2);
    text-align: left;
}

#homepage-profile-section {
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

#homepage-profile-picture {
    height: var(--profile-picture-size);
    width: var(--profile-picture-size);
    border-radius: 25%;
    flex-shrink: 0;
}

#homepage-title {
    margin-bottom: 1rem;
}

#homepage-subtitle {
    font-style: italic;
    font-weight: lighter;
}

#homepage-text-content {
    flex: 1;
}

/* Responsive: stack vertically on smaller screens */
@media screen and (max-width: 768px) {
    #homepage-header {
        text-align: center;
    }
    
    #homepage-profile-section {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    #homepage-profile-picture {
        margin-bottom: 0.5rem;
    }
}

/* --- PREVIEWS ------------------------------------------------------------- */

#posts-previews {
    /* Add a little space in the tag preview page between breadcrumbs
     * and previews */
    margin-top: var(--h3-size);
}

#posts-previews .post-preview:not(:last-child) {
    margin-bottom: calc(1.5 * var(--h1-size));
}

/* --- TAGS ----------------------------------------------------------------- */

.post-tags {
    display: inline;
    line-height: calc(1.3 * var(--line-height));
}

.post-tag {
    display: inline;
    background-color: var(--accent-color);
    font-size: 0.9rem;
    border-radius: 1rem;
    padding: 0.2rem 0.5rem;
    margin-right: 0.3rem;
}

.post-tag > a {
    background-image: none;
}

/* --- BREADCRUMBS ---------------------------------------------------------- */

.breadcrumbs {
    margin-bottom: var(--line-height);
}

.breadcrumb-link {
}

/* --- POSTS ---------------------------------------------------------------- */

/* All titles in posts should be aligned with the start of the line */
.post h1,
.post h2,
.post h3,
.post h4,
.post h5,
.h1-title,
.h2-title,
.h3-title,
.h4-title,
.h5-title,
.h6-title {
    text-align: start;
}

.post-title,
.tag-title {
    margin-left: -100%;
    margin-right: -100%;
    margin-bottom: var(--h1-size);
    margin-top: -100%;

    padding-bottom: calc(var(--h1-size) / 2);
    padding-top: calc(100% + var(--h2-size));
    padding-left: 100%;
    padding-right: 100%;
}

.post-title::selection {
    background: var(--background-color);
}

.post-title::-moz-selection {
    background: var(--background-color);
}

.tag-title::selection {
    background: var(--background-color);
}

.tag-title::-moz-selection {
    background: var(--background-color);
}

.post header {
    margin-bottom: var(--post-header-margin-bottom);
}

.post-subtitle {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    row-gap: 0.5rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
}

.post-date {
    font-style: italic;
}

.post-preview-abstract,
.post-body {
    text-align: justify;
}

.post pre {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 2rem;

    background-color: var(--code-background-color);
    overflow-x: scroll;
}

.post pre code {
    font-family: var(--code-font-family);
    font-size: var(--code-font-size);
}

.post pre code span {
    font-family: var(--code-font-family);
    font-size: var(--code-font-size);
}

.post p code {
    font-family: var(--code-font-family);
    font-size: var(--code-font-size);
    padding: 0 0.2rem;
    background-color: var(--blockquote-background-color);
}

.post blockquote {
    padding-left: 2rem;
    padding-right: 2rem;
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
    border-left: solid 0.8rem var(--main-color);
    background-color: var(--blockquote-background-color);
}

.post p {
    margin-top: 0.8rem;
    margin-bottom: 0.8rem;
    hyphens: auto;
}

.post-body ul {
    list-style: "-> " outside;
    padding-inline-start: 2rem;
}

.post-body ul li {
    font-family: var(--code-font-family);
}

/* Drop hyphenation on big screens */
@media screen and (min-width: 992px) {
    .post p {
        hyphens: none;
    }
}

@media screen and (min-width: 1200px) {
    .post p {
        hyphens: none;
    }
}

.post-heading > * {
    display: inline;
}

.h2-title {
    margin-top: 4rem;
    margin-bottom: 2rem;
}

.h3-title {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.clip {
    margin-inline-end: 0.8rem;
    background-image: none;
    color: transparent;
    text-shadow: 0 0 0 var(--font-color);
    font-size: 0.8rem;
}

/* --- CODE HIGHLIGHT ------------------------------------------------------- */

.hljs-number {
    color: rgb(219, 148, 14);
}

.hljs-string {
    color: rgb(94, 173, 94);
}

.hljs-comment {
    color: rgb(167, 167, 167);
}

.hljs-keyword,
.hljs-built_in {
    color: rgb(255, 69, 138);
}

.hljs-title {
    color: rgb(56, 146, 240);
}

.hljs-variable,
.hljs-operator {
    color: var(--text-color);
}
