/* ==========================================================================
   uhlig.it — personal homepage of Steffen Uhlig
   Hand-written CSS, no framework. Type: IBM Plex (self-hosted, OFL).
   ========================================================================== */

/* ---------- Fonts -------------------------------------------------------- */

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/ibm-plex-sans-latin-400-italic.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Sans";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Serif";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/ibm-plex-serif-latin-400-normal.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Serif";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/ibm-plex-serif-latin-400-italic.woff2") format("woff2");
}

@font-face {
    font-family: "IBM Plex Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
}

/* ---------- Design tokens ------------------------------------------------- */

:root,
[data-theme="light"] {
    color-scheme: light;
    --paper: #f6f8fa;
    --surface: #ffffff;
    --ink: #1c2833;
    --ink-muted: #55677a;
    --accent: #0f62fe;
    --accent-strong: #0043ce;
    --on-accent: #ffffff;
    --line: #dde5ec;
    --code-bg: #eceff3;
}

[data-theme="dark"] {
    color-scheme: dark;
    --paper: #0e1720;
    --surface: #16222e;
    --ink: #dfe8f0;
    --ink-muted: #8fa3b5;
    --accent: #78a9ff;
    --accent-strong: #a6c8ff;
    --on-accent: #0e1720;
    --line: #2a3b4c;
    --code-bg: #182634;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
        --paper: #0e1720;
        --surface: #16222e;
        --ink: #dfe8f0;
        --ink-muted: #8fa3b5;
        --accent: #78a9ff;
        --accent-strong: #a6c8ff;
        --on-accent: #0e1720;
        --line: #2a3b4c;
        --code-bg: #182634;
    }
}

:root {
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
    --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
        "Liberation Mono", monospace;
    --measure: 44rem;
    --radius: 8px;
}

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

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

html {
    font-size: 106.25%; /* 17px */
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.65;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.container {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
    padding-inline: 1.25rem;
}

/* Pages with a table of contents get more room */
.container:has(.page-with-toc) {
    max-width: 62rem;
}

/* ---------- Typography ----------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.25;
    letter-spacing: -0.01em;
    margin: 2.25rem 0 0.75rem;
}

h1 {
    font-size: 1.9rem;
    font-weight: 700;
    margin-top: 0;
}

h2 {
    font-size: 1.45rem;
    font-weight: 600;
}

h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

h4 {
    font-size: 1.05rem;
    font-weight: 600;
}

p {
    margin: 0 0 1.25rem;
}

a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.15em;
    transition: color 120ms ease-in-out;
}

a:hover {
    color: var(--accent-strong);
    text-decoration-thickness: 2px;
}

strong,
b {
    font-weight: 600;
}

small {
    font-size: 0.85rem;
}

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

blockquote {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 1.05rem;
    color: var(--ink-muted);
    border-left: 3px solid var(--accent);
    margin: 1.75rem 0;
    padding: 0.25rem 0 0.25rem 1.25rem;
}

blockquote > :last-child {
    margin-bottom: 0;
}

/* ---------- Code ------------------------------------------------------------ */

code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background-color: var(--code-bg);
    padding: 0.12em 0.35em;
    border-radius: 4px;
}

pre {
    background-color: var(--code-bg);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.55;
    margin: 1.75rem 0;
}

pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

/* ---------- Tables ---------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    margin: 1.75rem 0;
}

th,
td {
    text-align: left;
    padding: 0.5rem 0.75rem;
    vertical-align: top;
}

th {
    font-weight: 600;
    border-bottom: 2px solid var(--line);
}

td {
    border-bottom: 1px solid var(--line);
}

/* ---------- Media ----------------------------------------------------------- */

img {
    max-width: 100%;
    height: auto;
}

/* Center standalone images inside article paragraphs */
article p > img:only-child,
article p > img:first-child:last-child {
    display: block;
    margin: 0 auto;
}

figure {
    margin: 2rem 0;
}

figcaption {
    color: var(--ink-muted);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 0.5rem;
}

iframe {
    max-width: 100%;
}

.video-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    margin: 1.75rem 0;
}

.video-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: var(--radius);
}

/* ---------- Details / summary ------------------------------------------------ */

details {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1.25rem;
    margin: 1.75rem 0;
}

summary {
    cursor: pointer;
    font-weight: 600;
}

details[open] summary {
    margin-bottom: 0.75rem;
}

.made-with-ai {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--ink-muted);
}

/* ---------- Header ------------------------------------------------------------ */

.site-header {
    padding-block: 1.5rem;
}

.site-header .container {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.wordmark {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
}

.wordmark .tld {
    color: var(--accent);
}

.wordmark:hover {
    color: var(--ink);
}

.wordmark:hover .tld {
    color: var(--accent-strong);
}

.site-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1.25rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.site-nav a {
    color: var(--ink-muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.site-nav a:hover {
    color: var(--accent);
}

.site-nav a[aria-current="page"] {
    color: var(--ink);
    font-weight: 600;
}

/* ---------- Main ---------------------------------------------------------------- */

.site-main {
    flex: 1;
    padding-bottom: 3rem;
}

/* ---------- Hero (homepage) ------------------------------------------------------- */

.hero {
    padding-block: 2.5rem 1rem;
}

.hero h1 {
    font-size: clamp(2rem, 6vw, 2.6rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 1rem;
}

.hero p {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.6;
    max-width: 34rem;
}

/* ---------- Post index ------------------------------------------------------------- */

.post-list {
    margin-top: 1rem;
}

.post-item {
    display: grid;
    grid-template-columns: 9rem 1fr;
    gap: 0 1.5rem;
    padding: 1.4rem 0;
}

.post-item + .post-item {
    border-top: 1px solid var(--line);
}

.post-date {
    color: var(--ink-muted);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    padding-top: 0.3em;
    white-space: nowrap;
}

.post-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

.post-title a {
    color: var(--ink);
    text-decoration: none;
}

.post-title a:hover {
    color: var(--accent);
}

.post-meta {
    color: var(--ink-muted);
    font-size: 0.85rem;
    margin: 0.2rem 0 0;
}

.post-meta a {
    color: var(--ink-muted);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.post-meta a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.post-description {
    margin: 0.5rem 0 0;
}

.more-link {
    display: inline-block;
    margin-top: 1.5rem;
    font-weight: 600;
    text-decoration: none;
}

.more-link:hover {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

@media (max-width: 640px) {
    .post-item {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .post-date {
        padding-top: 0;
    }
}

/* ---------- Article page -------------------------------------------------------------- */

.post-header {
    margin-bottom: 2rem;
}

.post-header h1 {
    margin-bottom: 0.5rem;
}

.breadcrumb ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
    margin: 0 0 1.5rem;
    padding: 0;
    font-size: 0.85rem;
    color: var(--ink-muted);
}

.breadcrumb li + li::before {
    content: "/";
    margin-right: 0.5rem;
    color: var(--line);
}

.breadcrumb a {
    color: var(--ink-muted);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--accent);
}

/* Right-side table of contents */
.page-with-toc {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 2.5rem;
    align-items: start;
}

.page-with-toc aside {
    position: sticky;
    top: 2rem;
}

.page-with-toc aside nav {
    font-size: 0.85rem;
}

.page-with-toc aside nav ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.page-with-toc aside nav ul ul {
    padding-left: 1rem;
    border-left: 1px solid var(--line);
    margin-top: 0.25rem;
}

.page-with-toc aside nav li {
    margin-bottom: 0.25rem;
}

.page-with-toc aside nav a {
    text-decoration: none;
    color: var(--ink-muted);
    display: block;
    padding: 0.125rem 0;
}

.page-with-toc aside nav a:hover {
    color: var(--accent);
}

@media (max-width: 991px) {
    .page-with-toc {
        grid-template-columns: 1fr;
    }

    .page-with-toc aside {
        display: none;
    }
}

/* ---------- Search ---------------------------------------------------------------------- */

.search-form {
    display: flex;
    gap: 0.6rem;
    margin: 1.5rem 0;
}

.search-form input {
    flex: 1;
    font: inherit;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.55rem 0.9rem;
}

.search-form input:focus {
    border-color: var(--accent);
    outline: none;
}

.search-form button {
    font: inherit;
    font-weight: 600;
    color: var(--on-accent);
    background-color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.55rem 1.2rem;
    cursor: pointer;
    transition: background-color 120ms ease-in-out;
}

.search-form button:hover {
    background-color: var(--accent-strong);
}

#search-status {
    color: var(--ink-muted);
    font-size: 0.85rem;
}

/* ---------- Tags ------------------------------------------------------------------------- */

.tag-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.9rem;
    margin-top: 1.5rem;
}

.tag-tile {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.9rem 1.1rem;
    transition: border-color 120ms ease-in-out;
}

.tag-tile:hover {
    border-color: var(--accent);
}

.tag-tile h2 {
    font-size: 1rem;
    margin: 0;
}

.tag-tile h2 a {
    color: var(--ink);
    text-decoration: none;
}

.tag-tile h2 a:hover {
    color: var(--accent);
}

.tag-tile small {
    color: var(--ink-muted);
}

/* ---------- 404 --------------------------------------------------------------------------- */

.not-found {
    text-align: center;
    padding-block: 4rem;
}

.not-found h1 {
    font-size: 4rem;
    margin: 0;
}

/* ---------- Footer ------------------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--line);
    margin-top: 2rem;
    padding-block: 1.5rem;
}

.site-footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.5rem;
}

.site-footer small {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
    color: var(--ink-muted);
}

.site-footer small a {
    color: var(--ink-muted);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.site-footer small a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font: inherit;
    font-size: 0.85rem;
    color: var(--ink-muted);
    background: none;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    cursor: pointer;
    transition:
        color 120ms ease-in-out,
        border-color 120ms ease-in-out;
}

.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.theme-toggle svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: inline;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"])
        .theme-toggle
        .icon-sun {
        display: inline;
    }

    :root:not([data-theme="light"]):not([data-theme="dark"])
        .theme-toggle
        .icon-moon {
        display: none;
    }
}
