/* General Styling */
@font-face {
    font-family: "Blog Math";
    src: url('/fonts/math/STIXTwoMath-Regular.ttf') format('truetype');
    font-display: swap;
}

:root {
    --primary-text: #333;
    --secondary-text: #757575;
    --background: #fff;
    --accent-color: #0066cc;
    --border-color: #eaeaea;
    --code-background: #f5f5f5;
    --header-bg: #fff;
    --card-bg: #fff;
    --card-hover-bg: #f9f9f9;
}

[data-theme="dark"] {
    --primary-text: #e0e0e0;
    --secondary-text: #a0a0a0;
    --background: #121212;
    --accent-color: #64b5f6;
    --border-color: #333;
    --code-background: #2c2c2c;
    --header-bg: #1e1e1e;
    --card-bg: #1e1e1e;
    --card-hover-bg: #252525;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--primary-text);
    background-color: var(--background);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    width: 100%;
    box-sizing: border-box;
    flex: 1;
}

/* Header & Footer */
header, footer {
    text-align: center;
    padding: 1.0rem 1rem;
    background-color: var(--header-bg);
}

header {
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
}

header h1 {
    margin: 0;
    line-height: 1.5;
}

header h1 a {
    text-decoration: none;
    color: var(--primary-text);
    font-size: 1.6rem;
}

header nav {
    margin: 0.5rem 0;
}

header nav a {
    /*font-family: 'CustomHeadingFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    */
    font-size: 1.2rem; /* Etwas kleiner als die Haupt-Überschriften */
    color: var(--primary-text);
    text-decoration: none;
    margin: 0 0.75rem;
    transition: color 0.2s ease-in-out;
}

header nav a:hover {
    color: var(--accent-color);
    text-decoration: underline wavy var(--accent-color);
    text-underline-offset: 4px;
}

.description {
    font-style: italic;
}

#theme-toggle {
    background: none;
    border: 1px solid var(--secondary-text);
    color: var(--secondary-text);
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: color 0.2s, border-color 0.2s;
}

#theme-toggle:hover {
    color: var(--primary-text);
    border-color: var(--primary-text);
}

footer {
    border-top: 1px solid var(--border-color);
    color: var(--secondary-text);
    font-size: 0.9rem;
    margin-top: 2rem;
}

footer a {
    color: var(--secondary-text);
    text-decoration: none;
    transition: color 0.2s ease-in-out;
}

footer a:hover {
    color: var(--primary-text);
    text-decoration: underline wavy var(--accent-color);
    text-underline-offset: 3px;
}

/* Post List on Index Page */
.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list li {
    margin-bottom: 1.5rem;
}

.post-preview {
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background: var(--card-bg);
}

.post-preview h3 {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.post-preview h3 a {
    color: var(--primary-text);
    text-decoration: none;
}

.post-preview h3 a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.post-list .meta {
    margin: 0;
    font-size: 0.9rem;
    color: var(--secondary-text);
}

.post-excerpt {
    margin: 0.75rem 0 0;
}

/* Single Post Article */
article h1 {
    font-size: 2.4rem;
    margin-bottom: 0.25rem;
}

article h2 {
    font-size: 1.9rem;
    margin-bottom: 0.5rem;
}

article .meta {
    font-size: 0.85rem;
    color: var(--secondary-text);
    margin-bottom: 2.5rem;
}

.post-content {
    font-size: 1.1rem;
}

header h1, article h1, article h2, .post-list h3, .post-content h1, .post-content h2, .post-content h3 {
    /*font-family: 'CustomHeadingFont', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; /* Eigene Schrift zuerst */
}

.post-content h1, .post-content h2, .post-content h3 {
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

.post-content h2 {
    font-size: 1.5rem;
}

.post-content h3 {
    font-size: 1.25rem;
}

/* Allgemeines Link-Styling im Inhalt */
.post-content a {
    color: var(--accent-color);
    text-decoration: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23007bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.72'%3E%3C/path%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.72-1.72'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right center;
    padding-right: 20px; /* Platz für das Icon */
}

[data-theme="dark"] .post-content a {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364b5f6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.72'%3E%3C/path%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.72-1.72'%3E%3C/path%3E%3C/svg%3E");
}

.post-content a:hover {
    text-decoration: underline wavy var(--accent-color);
    text-underline-offset: 3px; /* Abstand der Welle zum Text */
}

.post-content pre, .post-content code {
    background-color: var(--code-background);
    border-radius: 4px;
}

.post-content pre {
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.post-content code {
    padding: 0.2em 0.4em;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Native Datentabellen behalten; nur der umgebende Bereich scrollt. */
.data-table-wrapper {
    max-width: 100%;
    margin: 1.5rem 0;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.data-table-wrapper:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 3px;
}

.data-table-wrapper > table {
    width: 100%;
    min-width: 36rem;
    border-collapse: collapse;
    font-size: 0.95rem;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.data-table-wrapper > table th,
.data-table-wrapper > table td {
    padding: 0.7rem 1rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border-color);
}

.data-table-wrapper > table th {
    font-weight: 500;
    background: var(--code-background);
}

.data-table-wrapper > table tbody tr:last-child td {
    border-bottom: none;
}

/* Styling für Pygments Code-Hervorhebung */
.codehilite {
    background: var(--code-background);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 1rem;
    overflow-x: auto;
}

.codehilite pre,
.codehilite code {
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
}

.codehilite .linenos,
.codehilite td.linenos,
.codehilite span.linenos {
    color: var(--secondary-text);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: none;
    padding-right: 0.75rem;
    text-align: right;
}

.codehilite table {
    border-spacing: 0;
}

.mermaid-diagram {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

.codehilite pre {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
}

.math-display {
    overflow-x: auto;
    margin: 1rem 0;
    padding: 0.25rem 0;
}

.post-content math {
    font-family: "Blog Math", math;
}

article h1 {
    overflow-wrap: anywhere;
}

.math-display:focus-visible {
    outline: 2px solid var(--secondary-text);
    outline-offset: 2px;
}

/* Mobile First */
@media (max-width: 600px) {
    header h1 a {
        font-size: 1.4rem;
    }

    article h2 {
        font-size: 1.6rem;
    }

    .post-content {
        font-size: 1rem;
    }
}

/* Themen und Beitragsarchive */
a {
    color: var(--accent-color);
    text-underline-offset: 0.2em;
}

a:focus-visible, button:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 4px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -10rem;
    padding: 0.6rem 1rem;
    background: var(--background);
    z-index: 10;
}

.skip-link:focus {
    top: 1rem;
}

header nav, .category-links, .topic-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1rem;
}

header nav a {
    margin: 0;
    padding: 0.2rem;
}

header .description {
    margin: 0.25rem 0;
}

.category-links, .topic-links {
    justify-content: flex-start;
    margin: 1.5rem 0 2.5rem;
}

.category-links a, .amateurfunk-page .topic-links a {
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.65rem 0.9rem;
    background: var(--card-bg);
    text-decoration: none;
}

.category-links a:hover, .amateurfunk-page .topic-links a:hover {
    background-color: var(--card-hover-bg);
    text-decoration: underline;
}

.category-count, .breadcrumb, .empty-state, .post-tags {
    color: var(--secondary-text);
}

.amateurfunk-page {
    max-width: 52rem;
    margin: 0 auto;
}

.amateurfunk-page .post-content a {
    background-image: none;
    padding-right: 0;
}

.amateurfunk-page .post-content .topic-links a {
    padding: 0.65rem 0.9rem;
}

.latest-posts {
    border-top: 1px solid var(--border-color);
    margin-top: 2.5rem;
    padding-top: 1rem;
}

.post-category, .post-tags {
    margin: 0.5rem 0;
}

article > .post-content {
    margin-top: 2rem;
}

.post-preview, .post-tags, .category-links a, .topic-links a,
main > section > h1, .project-page > h1, .post-content {
    overflow-wrap: anywhere;
}

[id] {
    scroll-margin-top: 1rem;
}

@media (max-width: 600px) {
    article h1 {
        font-size: 2rem;
        line-height: 1.25;
    }

    .post-preview {
        padding: 1rem;
    }
}
