/*
Theme Name: Swiss Grid Journal Author: Antigravity Description: A minimalist,
International Typographic Style theme. Modernized v2.0. Version: 2.0.24 Text Domain: swiss-grid-journal */

/* =========================================
   1. CSS Variables & Reset
   ========================================= */
:root {
    /* Colors */
    --bg-color: #F9F9F9;
    --text-main: #1E1E1E;
    --text-meta: #737373;
    --border-color: #b0b0b0;
    /* Darkened */
    --accent-color: #FA3433;

    /* Typography */
    --font-main: 'Inter Tight', sans-serif;

    /* Fluid Typography (clamp) */
    --text-xs: clamp(0.7rem, 0.65rem + 0.2vw, 0.8rem);
    /* Meta, Footer */
    --text-sm: clamp(0.8rem, 0.75rem + 0.2vw, 0.9rem);
    /* Taglines */
    --text-base: clamp(1rem, 0.95rem + 0.2vw, 1.125rem);
    /* Body */
    --text-lg: clamp(1.2rem, 1.1rem + 0.5vw, 1.5rem);
    /* Subtitles, Section Headers */
    --text-xl: clamp(1.5rem, 1.3rem + 1vw, 2.5rem);
    /* Loop Titles */
    --text-2xl: clamp(2.5rem, 2rem + 2.5vw, 4rem);
    /* Main Page Titles */

    /* Spacing & Layout */
    --container-padding: clamp(1rem, 4vw, 3rem);
    --grid-gap: clamp(1rem, 2vw, 2rem);
    --header-height: 80px;
    --section-spacing: clamp(4rem, 8vw, 8rem);
}

/* Theme: Dark */
[data-theme="dark"] {
    --bg-color: #1E1E1E;
    --text-main: #F9F9F9;
    --text-meta: #A0A0A0;
    --border-color: #444444;
}

/* Theme: Red */
[data-theme="red"] {
    --bg-color: #FA3433;
    --text-main: #F9F9F9;
    --text-meta: rgba(255, 255, 255, 0.7);
    --border-color: rgba(255, 255, 255, 0.3);
}

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

html {
    background-color: var(--bg-color);
    /* Fix overscroll flash */
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* =========================================
   2. Layout & Grid Utilities
   ========================================= */

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

a {
    color: inherit;
    text-decoration: none;
}

/* =========================================
   PRELOADER (The Curtain)
   ========================================= */
.site-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-color);
    z-index: 99999;
    pointer-events: all;
    transition: opacity 0.8s cubic-bezier(0.25, 1, 0.5, 1);
    opacity: 1;
}

.site-preloader.loaded {
    opacity: 0;
    pointer-events: none;
}

/* HIDDEN: Red Loading Line (User Request) */
.site-loader-line {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    height: 4px;
    background-color: var(--text-main);
    width: 0%;
    transition: width 0.4s ease-out;
}

/* =========================================
   2. Layout & Grid Utilities
   ========================================= */
.container {
    width: 100%;
    max-width: 1920px;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

/* 12-Column Grid Wrapper */
.grid-wrapper {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    column-gap: var(--grid-gap);
    row-gap: var(--grid-gap);
}

/* Utility classes for grid spans */
.col-full {
    grid-column: 1 / -1;
}

.col-main {
    grid-column: 1 / -1;
}

@media (min-width: 768px) {
    .col-main {
        grid-column: 4 / -1;
    }

    .col-sidebar {
        grid-column: 1 / 4;
    }
}

/* =========================================
   3. Header & Navigation (V22)
   ========================================= */
.site-header {
    /* Auto height on mobile, Fixed on Desktop via grid */
    min-height: var(--header-height);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    position: relative;
    background-color: var(--bg-color);
    z-index: 100;
}

.header-inner {
    width: 100%;
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* Navigation Menu Styles */
.header-menu,
.header-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 1.5rem;
}

.header-menu li a {
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    color: var(--text-main);
    transition: opacity 0.2s ease;

    /* FIX: Force line-height 1 to match logo box model */
    line-height: 1;
}

.header-menu li a:hover {
    opacity: 0.6;
}

/* Theme Toggle */
.theme-toggle {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid var(--text-main);
    background-color: var(--text-main);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

[data-theme="light"] .theme-toggle {
    background: #1E1E1E;
    border-color: #1E1E1E;
}

[data-theme="dark"] .theme-toggle {
    background: #FA3433;
    border-color: #FA3433;
}

[data-theme="red"] .theme-toggle {
    background: #F9F9F9;
    border-color: #F9F9F9;
}


/* --- Responsive Header Layout --- */

/* Mobile (< 768px): Flexbox Stack */
@media (max-width: 767px) {
    .header-inner {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        /* Key for stacking */
    }

    .site-title {
        font-size: var(--text-lg);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: -0.03em;
        line-height: 1;
        margin-right: auto;
        order: 1;
    }

    .header-controls {
        display: flex;
        align-items: center;
        order: 2;
    }

    .site-navigation {
        order: 3;
        width: 100%;
        /* Force new line */
        margin-top: 0.75rem;
        /* Space under logo */
    }

    .header-menu {
        justify-content: flex-start;
    }
}

/* Desktop (>= 768px): CSS Grid (12 Cols) */
@media (min-width: 768px) {
    .site-header {
        height: var(--header-height);
    }

    .header-inner {
        display: grid;
        grid-template-columns: repeat(12, 1fr);
        column-gap: var(--grid-gap);
        align-items: center;
        padding-top: 0;
        padding-bottom: 0;
        height: 100%;
    }

    .site-title {
        font-size: var(--text-lg);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: -0.03em;
        line-height: 1;

        grid-row: 1;
        /* Force Row 1 */
        grid-column: 1 / 4;
    }

    .site-navigation {
        grid-row: 1;
        /* Force Row 1 */

        /* Grid: Start at Col 4, Span to 12 */
        grid-column: 4 / 12;
        justify-self: start;

        /* FIX: Robust Reset and Centering */
        margin: 0;
        width: auto;
        height: 100%;
        display: flex;
        align-items: center;
    }

    .header-controls {
        grid-row: 1;
        /* Force Row 1 */

        /* Grid: Col 12 (Last Col) */
        grid-column: 12 / 13;
        justify-self: end;
        display: flex;
        align-items: center;
    }
}

/* =========================================
   4. Post Lists & Content Rows
   ========================================= */
.post-list {
    display: flex;
    flex-direction: column;

    /* FIX: Match Single Post Spacing */
    padding-top: 4rem;
}

.post-row {
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    transition: opacity 0.2s ease;
}

/* REMOVED: border-bottom on last-child to avoid double line with Footer */
.post-row:last-child {
    border-bottom: none;
}

/* NEW: Remove border-top from the FIRST post to avoid double line with Header */
.post-row:first-child {
    border-top: none;
}

.post-row:hover {
    opacity: 0.7;
}

.post-link {
    display: grid;
    grid-template-columns: 1fr;
    /* Mobile: Stacked */
    gap: 0.5rem;

    /* FIX: Top Alignment requested by user */
    align-items: start;
}

@media (min-width: 768px) {
    .post-link {
        grid-template-columns: repeat(12, 1fr);
        gap: var(--grid-gap);
    }
}

.post-date {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-meta);
    text-transform: uppercase;
    letter-spacing: -0.02em;

    /* Optional: Tiny push to match cap-height of huge titles if needed, 
       but strictly 'start' is mathematically top-aligned. */
    margin-top: 0.2rem;
}

.entry-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.04em;
    margin: 0;
    margin-bottom: 1rem;
}

@media (min-width: 768px) {
    .post-date-col {
        grid-column: 1 / 4;
    }

    .post-title-col {
        grid-column: 4 / -1;
    }
}

/* =========================================
   5. Single Post
   ========================================= */
.single-post-container {
    padding-top: 4rem;
    padding-bottom: 4rem;
}

.single-header {
    margin-bottom: var(--section-spacing);
}

/* Page Title (H1) */
.single-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: 0.95;
    letter-spacing: -0.04em;
    margin-bottom: 4rem;
}

/* Post Meta (Footer) */
.post-footer-meta {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 2rem;
    align-items: baseline;
    padding-bottom: 0;
    grid-column: 1 / -1;
}

@media (min-width: 1024px) {
    .post-footer-meta {
        grid-column: 4 / 13;
    }
}

.meta-value {
    font-size: var(--text-xs);
    color: var(--text-meta);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.back-link {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    font-weight: 600;
}

/* Main Content */
.post-content-wrapper {
    grid-column: 1 / -1;
}

@media (min-width: 1024px) {
    .post-content-wrapper {
        grid-column: 4 / 13;
        max-width: 800px;
    }
}

.entry-content {
    font-size: var(--text-base);
    line-height: 1.5;
}

.entry-content p {
    margin-bottom: 1.5rem;
}

.entry-content h2,
.entry-content h3 {
    font-size: var(--text-xl);
    line-height: 1.1;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.entry-content ol,
.entry-content ul {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.entry-content li {
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

/* --- Links in Article Body --- */
.entry-content a {
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--border-color);
    opacity: 0.85;
    transition: text-decoration-color 0.2s ease, opacity 0.2s ease;
}

.entry-content a:hover {
    text-decoration-color: var(--text-main);
    opacity: 1;
}

/* --- Lead Paragraph --- */
.entry-content .lead {
    font-size: var(--text-lg);
    line-height: 1.4;
    font-weight: 400;
    margin-bottom: 2rem;
    color: var(--text-main);
}

/* --- Blockquote --- */
.entry-content blockquote {
    border: none;
    padding: 0;
    margin: 2.5rem 0;
    font-style: normal;
    font-size: var(--text-lg);
    line-height: 1.4;
    font-weight: 400;
    color: var(--text-main);
}

.entry-content blockquote p {
    margin-bottom: 1rem;
}

.entry-content blockquote p:last-of-type {
    margin-bottom: 0;
}

/* Author attribution row: circle + name */
.entry-content blockquote cite,
.entry-content blockquote footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
    font-style: normal;
    font-size: var(--text-sm);
    color: var(--text-main);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* Circle avatar */
.entry-content blockquote cite::before,
.entry-content blockquote footer::before {
    content: '';
    display: block;
    width: 1.25rem;
    height: 1.25rem;
    min-width: 1.25rem;
    border-radius: 50%;
    background-color: var(--text-main);
}

/* --- Callout (accent box) --- */
.entry-content .callout {
    background-color: var(--text-main);
    color: var(--bg-color);
    padding: 1.5rem 2rem;
    margin: 2.5rem 0;
    font-size: var(--text-base);
    line-height: 1.5;
    font-weight: 500;
}

.entry-content .callout p:last-child {
    margin-bottom: 0;
}

/* --- Aside Note (sidebar-style) --- */
.entry-content .aside-note {
    border-top: 2px solid var(--border-color);
    border-bottom: 2px solid var(--border-color);
    padding: 1.25rem 0;
    margin: 2.5rem 0;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-meta);
}

.entry-content .aside-note p:last-child {
    margin-bottom: 0;
}

/* --- Table --- */
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 2rem 0;
    font-size: var(--text-sm);
    line-height: 1.4;
}

.entry-content thead {
    border-bottom: 2px solid var(--text-main);
}

.entry-content th {
    text-align: left;
    padding: 0.75rem 1rem 0.75rem 0;
    font-weight: 700;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.02em;
    color: var(--text-meta);
}

.entry-content td {
    padding: 0.75rem 1rem 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.entry-content tbody tr:last-child td {
    border-bottom: 2px solid var(--text-main);
}

/* --- Two Columns --- */
/* Only splits into columns when there are 2+ separate child elements (e.g. two <p> tags) */
.entry-content .two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    margin: 2rem 0;
    align-items: start;
}

@media (max-width: 768px) {
    .entry-content .two-columns {
        grid-template-columns: 1fr;
    }
}


/* --- Styled Lists (UL — square markers) --- */
.entry-content ul {
    list-style: none;
    padding-left: 0;
}

.entry-content ul>li {
    padding-left: 1.25rem;
    position: relative;
}

.entry-content ul>li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.55em;
    width: 6px;
    height: 6px;
    background-color: var(--text-main);
}

/* --- Styled Lists (OL — bold numbers) --- */
.entry-content ol {
    list-style: none;
    padding-left: 0;
    counter-reset: item;
}

.entry-content ol>li {
    padding-left: 2rem;
    position: relative;
    counter-increment: item;
}

.entry-content ol>li::before {
    content: counter(item);
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 800;
    font-size: var(--text-base);
    color: var(--text-main);
    line-height: 1.5;
}

/* --- Code --- */
.entry-content code {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background-color: var(--border-color);
    padding: 0.15em 0.4em;
    border-radius: 2px;
}

[data-theme="dark"] .entry-content code {
    background-color: #2a2a2a;
}

.entry-content pre {
    margin: 2rem 0;
    padding: 1.5rem;
    background-color: var(--text-main);
    color: var(--bg-color);
    overflow-x: auto;
    font-size: var(--text-sm);
    line-height: 1.6;
}

.entry-content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
    color: inherit;
}

/* --- Big Text Accent --- */
.entry-content .big-text {
    font-size: var(--text-xl);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    margin: 2.5rem 0;
}

/* --- Section Label (divider + uppercase label) --- */
.entry-content .section-label {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-meta);
    margin: 3rem 0 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* --- Pixel Art Block --- */
.pixel-art-block {
    margin: 3rem 0;
}

/* --- AI Discussion Prompt --- */
.ai-prompt-section {
    margin-top: 3rem;
    margin-bottom: 0;
}

.ai-prompt-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    height: 60px;
    padding: 0 2rem;
    background-color: var(--text-main);
    color: var(--bg-color);
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    border: 2px solid var(--text-main);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: all 0.2s ease;
}

.ai-prompt-toggle::-webkit-details-marker {
    display: none;
}

.ai-prompt-toggle:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.ai-prompt-body {
    margin-top: 1.5rem;
}

.ai-prompt-block {
    position: relative;
    background-color: var(--border-color);
    padding: 2rem;
}

.ai-prompt-text {
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-main);
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    background: none;
    padding: 0;
}

.ai-prompt-copy-btn {
    display: inline-block;
    background: var(--bg-color);
    border: none;
    color: var(--text-meta);
    font-family: 'Inter', sans-serif;
    font-size: var(--text-sm);
    font-weight: 600;
    letter-spacing: -0.02em;
    padding: 0.5rem 1rem;
    margin-bottom: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.ai-prompt-copy-btn:hover {
    color: var(--text-main);
}

.ai-prompt-copy-btn.copied {
    color: var(--text-main);
}

/* =========================================
   6. Comments Section
   ========================================= */
.comments-section {
    margin-top: 0;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
    grid-column: 1 / -1;
    padding-bottom: 0;
}

@media (min-width: 1024px) {
    .comments-section {
        grid-column: 4 / 13;
    }
}

.comments-title {
    font-size: var(--text-2xl);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    margin-bottom: 3rem;
}

.comment-list {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.comment-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.comment-meta {
    font-size: var(--text-xs);
    text-transform: none;
    letter-spacing: -0.01em;
    font-weight: 700;
    color: var(--text-main);
}

.reply-indicator {
    font-size: 11px;
    color: var(--text-meta);
    opacity: 0.8;
    margin-left: 0.5rem;
    font-weight: 400;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.comment-reply {
    margin-left: calc(var(--comment-level) * 2rem);
    border-left: 1px solid var(--border-color);
    padding-left: 1.5rem;
}

@media (max-width: 768px) {
    .comment-item.comment-reply {
        margin-left: calc(clamp(0, var(--comment-level), 1) * 1rem);
        padding-left: 0.75rem;
        margin-bottom: 1rem;
    }
}

.comment-content {
    font-size: var(--text-base);
    line-height: 1.5;
    max-width: 65ch;
}

/* Telegram Discussion Button */
.telegram-discussion-wrapper {
    margin-top: 3rem;
    display: flex;
    justify-content: flex-start;
}

.telegram-discussion-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    height: 60px;
    padding: 0 2rem;
    background-color: var(--text-main);
    color: var(--bg-color);
    font-size: var(--text-sm);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    border: 2px solid var(--text-main);
    transition: all 0.2s ease;
    cursor: pointer;
}

.telegram-discussion-button:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

/* =========================================
   7. Footer & Blur Effect
   ========================================= */
.site-footer {
    border-top: 1px solid var(--border-color);
    margin-top: 0;
    padding-bottom: 2rem;
    /* Add space for scroll reach */
}

.site-footer .grid-wrapper {
    padding-top: 4rem;
    padding-bottom: 4rem;
    align-items: start;
}

.footer-col {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.footer-value {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: 1;
    display: inline-block;
}

/* Strict Columns on 12-col grid */
.footer-col-left {
    grid-column: 1 / 4;
    text-align: left;
}

.footer-col-center {
    grid-column: 4 / 9;
    text-align: left;
}

.footer-col-right {
    grid-column: 9 / 13;
    text-align: right;
}

/* =========================================
   8. Latest Publications (New V6)
   ========================================= */
.latest-publications-section {
    margin-top: 2rem;
    border-top: 0;
    padding-top: 2rem;
}

/* Hide center footer text on mobile */
@media (max-width: 767px) {
    .footer-col-center {
        display: none !important;
    }
}

/* =========================================
   9. Pixel Art SVG Blocks
   ========================================= */
.pixel-art-block {
    margin: 3rem 0;
    width: 100%;
    max-width: 100%;
    column-span: all;
    grid-column: 1 / -1;
    clear: both;
}

.pixel-art-block svg {
    width: 100%;
    height: auto;
    display: block;
    aspect-ratio: 16 / 10;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}