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

:root {
    color-scheme: light dark;
    --bg: #fefefe;
    --fg: #1a1a1a;
    --muted: #666;
    --accent: #06c;
    --rule: #e5e5e5;
    --code-bg: #f4f4f4;
    --like: #e0245e;
    --mastodon: #8b5cf6;
    --codeberg: #3b82f6;
    --rss: #f97316;
    --about: #14b8a6;
    --radius: clamp(0.8rem, 2vw, 1rem);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #141414;
        --fg: #e8e8e8;
        --muted: #999;
        --accent: #6cb6ff;
        --rule: #2a2a2a;
        --code-bg: #1e1e1e;
        --like: #ff5c8a;
        --rss: #e67e22;
        --about: #16a085;
        --mastodon: #8e44ad;
        --codeberg: #3498db;
    }
}

/* ---- Base ---- */

@view-transition {
    navigation: auto;
}

/* Settings per rem */
html {
    font-size: 18px;
}

body {
    max-width: 38rem;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    font-family:
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    font-size: 1rem;
    line-height: 1.65;
    color: var(--fg);
    background: var(--bg);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

@media (max-width: 600px) {
    body {
        padding-top: 1.5rem;
    }
}

header {
    margin-bottom: 1rem;
}

footer {
    margin-top: auto;
    padding-top: 1rem;
    text-align: center;
}

h1,
h2,
h3,
h4 {
    line-height: 1.25;
    font-weight: 600;
}
h1 {
    font-size: 1.75rem;
    margin-top: 0;
}
h2 {
    font-size: 1.35rem;
}
h3 {
    font-size: 1.1rem;
}

p,
ul,
ol,
blockquote,
pre,
figure {
    margin-bottom: 1.25rem;
}
ul,
ol {
    padding-left: 1.5rem;
}
li {
    margin-bottom: 0.25rem;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 0.2rem;
}
a:hover {
    text-decoration: none;
}

hr {
    border: 0;
    border-top: 1px solid var(--rule);
    margin: 2.5rem 0;
}

small,
time,
footer {
    color: var(--muted);
    font-size: 0.875rem;
}

/* ---- Media ---- */
img,
video {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius);
}

figure img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 0.5rem;
    display: block;
}

figure {
    margin: 1.5rem 0;
}
figcaption {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

code,
pre,
kbd,
samp {
    font-family:
        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9em;
}
code {
    background: var(--code-bg);
    padding: 0.15em 0.35em;
    border-radius: 3px;
}
pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    line-height: 1.5;
}
pre code {
    background: none;
    padding: 0;
    font-size: 1em;
}

blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--muted);
    font-style: italic;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}
th,
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--rule);
    text-align: left;
}
th {
    font-weight: 600;
}

::selection {
    background: var(--accent);
    color: #fff;
}

nav {
    --box-font: clamp(0.75rem, 2.6vw, 1.1rem);
    --box-left-ratio: 1.6;
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    grid-template-rows: auto auto;
    height: auto;
    margin-bottom: 1.5rem;
    gap: clamp(8px, 2.5vw, 16px);
    grid-template-areas:
        "left left left top-mid top-mid top-mid top-mid top-right top-right"
        "left left left bottom-mid bottom-mid bottom-mid bottom-right bottom-right bottom-right";
}

.box {
    border-radius: var(--radius);
    font-weight: 900;
    text-transform: uppercase;
    line-height: 1.1;
    color: var(--bg);
    text-decoration: none;

    display: flex;
    align-items: flex-end;
    justify-content: start;
    position: relative;
    overflow: hidden;

    font-size: var(--box-font);
    letter-spacing: clamp(0.5px, 0.3vw, 2px);
    padding: clamp(0.6rem, 2.5vw, 1rem) clamp(0.7rem, 3vw, 1.2rem);
    -webkit-tap-highlight-color: transparent;
    transition:
        transform 0.1s ease,
        filter 0.1s ease;
}

.box:active {
    transform: scale(0.96);
    filter: brightness(0.9);
}

.box-left {
    grid-area: left;
    font-size: calc(var(--box-font) * var(--box-left-ratio));
    position: relative;
    aspect-ratio: 1 / 1;
}

.box-left .box-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    z-index: -1;
    border-radius: inherit;
}

.box-top-middle {
    grid-area: top-mid;
    background-color: var(--codeberg);
}

.box-bottom-middle {
    grid-area: bottom-mid;
    background-color: var(--mastodon);
}

.box-top-right {
    grid-area: top-right;
    background-color: var(--rss);
}

.box-bottom-right {
    grid-area: bottom-right;
    background-color: var(--about);
}
