@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Didact+Gothic&display=swap');

:root {
    --bg-color: #111;
    --text-color: #f8f9fa;
    --hover-opacity: 0.6;
    --accent-orange: #ff7043;
    --accent-turquoise: #4dd0e1;
    --accent-green: #2e7d4f;
    --period-color: #2e7d4f;
    --menu-hover-color: #4dd0e1;
    --toggle-border-color: #ff7043;
    --link-color: #4dd0e1;
}

[data-theme="light"] {
    --bg-color: #f8f9fa;
    --text-color: #111;
    --hover-opacity: 0.4;
    --accent-orange: #ff7043;
    --accent-green: #2e7d4f;
    --accent-turquoise: #00acc1;
    --period-color: #2e7d4f;
    --menu-hover-color: #ff7043;
    --toggle-border-color: #4dd0e1;
    --link-color: #ff7043;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
    font-family: 'Montserrat', 'Didact Gothic', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

body {
    cursor: crosshair;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
header {
    text-align: center;
    padding: 60px 20px 40px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    margin-bottom: 60px;
}

.header-logo {
    margin-bottom: 20px;
}

.header-logo-image {
    width: 60px;
    height: 60px;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    transition: transform 0.3s ease;
}

.header-logo a:hover .header-logo-image {
    transform: scale(1.1);
}

.site-title {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.site-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.site-title a:hover {
    opacity: var(--hover-opacity);
}

.site-tagline {
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    position: relative;
}

.site-tagline::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -50vw;
    right: -50vw;
    height: 2px;
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-green), var(--accent-turquoise));
    z-index: 1;
}

.site-tagline span {
    background: var(--bg-color);
    padding: 0 15px;
    position: relative;
    z-index: 2;
}

.accent-dot {
    color: var(--period-color);
}

nav {
    text-align: center;
    margin-bottom: 40px;
}

.navigation {
    display: flex;
    gap: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-item {
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 100%;
    left: -30px;
    right: -30px;
    height: 25px;
    z-index: 999;
}

.nav-item::after {
    content: '';
    position: absolute;
    top: calc(100% + 25px);
    left: -50px;
    right: -50px;
    height: 40px;
    z-index: 998;
}

.nav-item:hover::before,
.nav-item:hover::after {
    pointer-events: auto;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    position: relative;
    display: block;
    padding: 10px 15px;
}

.nav-link::before {
    content: '';
    color: var(--menu-hover-color);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 15px;
    right: 15px;
    height: 1px;
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-green), var(--accent-turquoise));
    opacity: 0;
    transition: opacity 0.2s ease;
}

.nav-link:hover::before,
.nav-item:hover .nav-link::before {
    content: '.';
    opacity: 1;
}

.nav-link:hover::after,
.nav-item:hover .nav-link::after {
    opacity: 1;
}

.nav-link:hover {
    opacity: var(--hover-opacity);
}

/* Dropdown Menus */
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease 0.3s, visibility 0.15s ease 0.3s;
    pointer-events: none;
    background: var(--bg-color);
    padding: 30px 40px;
    border: 1px solid rgba(128, 128, 128, 0.2);
    z-index: 1000;
    min-width: 350px;
}

.nav-item:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.1s ease 0s, visibility 0.1s ease 0s;
}

.dropdown-menu:hover {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.tree-structure {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-family: 'Didact Gothic', Arial, sans-serif;
}

.tree-item {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-color);
    line-height: 1.4;
    padding: 6px 0;
    transition: all 0.15s ease;
    cursor: pointer;
    border-radius: 2px;
}

.tree-item:hover {
    background: rgba(128, 128, 128, 0.05);
    padding-left: 5px;
}

.tree-item a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    width: 100%;
}

.tree-main {
    opacity: 0.9;
    margin-bottom: 2px;
}

.tree-main:hover {
    opacity: 1;
    color: var(--menu-hover-color);
}

.tree-sub {
    opacity: 0.7;
    font-size: 12px;
}

.tree-sub:hover {
    opacity: 0.9;
    color: var(--menu-hover-color);
}

.tree-line {
    width: 20px;
    height: 1px;
    background: var(--menu-hover-color);
    margin-right: 14px;
    opacity: 0.4;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.tree-branch {
    width: 14px;
    height: 1px;
    background: var(--menu-hover-color);
    margin-right: 10px;
    margin-left: 24px;
    opacity: 0.3;
    flex-shrink: 0;
    transition: opacity 0.15s ease;
}

.tree-item:hover .tree-line,
.tree-item:hover .tree-branch {
    opacity: 0.8;
}

.tree-label {
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.tree-sublabel {
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Blog Posts Listing */
.posts-list {
    list-style: none;
}

.post-item {
    margin-bottom: 50px;
    padding-bottom: 40px;
    border-bottom: 1px solid rgba(128, 128, 128, 0.1);
}

.post-item:last-child {
    border-bottom: none;
}

.post-meta {
    font-size: 0.9rem;
    color: var(--menu-hover-color);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.post-title {
    font-size: 2rem;
    margin-bottom: 15px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.post-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

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

.post-summary {
    font-family: 'Didact Gothic', Arial, sans-serif;
    opacity: 0.9;
    margin-bottom: 15px;
}

.read-more {
    color: var(--link-color);
    text-decoration: none;
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    transition: opacity 0.2s ease;
}

.read-more:hover {
    opacity: var(--hover-opacity);
}

.tags {
    margin-top: 15px;
}

.tag {
    display: inline-block;
    background: rgba(128, 128, 128, 0.1);
    padding: 4px 12px;
    margin-right: 8px;
    margin-top: 8px;
    border-radius: 3px;
    font-size: 0.85rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
}

.tag:hover {
    background: var(--link-color);
    color: var(--bg-color);
}

/* Single Post */
.post-header {
    margin-bottom: 40px;
}

.post-layout {
    display: grid;
    /* Golden ratio: content is 1.618 times wider than sidebar */
    /* Content: ~710px, Sidebar: ~440px at max container width */
    grid-template-columns: 1.618fr 1fr;
    gap: 80px;
    align-items: start;
    max-width: 1200px;
    margin: 0 auto;
}

.post-content {
    font-family: 'Didact Gothic', Arial, sans-serif;
    font-size: 1.15rem;
    line-height: 1.75;
    min-width: 0;
    max-width: 75ch; /* Optimal reading line length */
}

/* Sidebar Annotations */
.post-sidebar {
    position: relative;
    font-family: 'Didact Gothic', Arial, sans-serif;
    min-height: 100%;
}

.sidebar-content {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.annotation {
    padding: 24px;
    padding-top: 20px;
    background: rgba(128, 128, 128, 0.05);
    border-left: 4px solid var(--accent-turquoise);
    border-radius: 4px;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.annotation-link {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-turquoise);
    color: var(--bg-color);
    border-radius: 50%;
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
    opacity: 0.6;
    transition: all 0.2s ease;
    border: none;
}

.annotation-link:hover {
    opacity: 1;
    transform: scale(1.1);
    background: var(--accent-orange);
}

.annotation.positioned {
    position: absolute;
    width: calc(100% - 0px);
    left: 0;
    margin-top: 0;
}

/* Non-positioned annotations (without anchors) stay in normal flow */
.annotation:not(.positioned) {
    position: relative;
    z-index: 1;
}

.annotation:hover {
    background: rgba(128, 128, 128, 0.08);
    border-left-color: var(--accent-orange);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateX(-2px);
}

/* Anchor markers in content */
.post-content .annotation-anchor {
    position: relative;
    scroll-margin-top: 100px;
}

.post-content .org-target {
    position: relative;
    padding-left: 8px;
}

.post-content .org-target::after {
    content: '◆';
    position: absolute;
    left: -16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    color: var(--accent-turquoise);
    opacity: 0.4;
    transition: all 0.3s ease;
    cursor: pointer;
}

.post-content .org-target:hover::after {
    opacity: 0.8;
    color: var(--accent-orange);
    transform: translateY(-50%) scale(1.3);
}

/* Make org-target clickable via wrapper */
.org-target-wrapper {
    position: relative;
    display: inline;
}

.org-target-link {
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 10px;
    color: var(--accent-turquoise);
    opacity: 0.5;
    transition: all 0.2s ease;
    z-index: 10;
}

.org-target-link:hover {
    opacity: 1;
    color: var(--accent-orange);
    transform: translateY(-50%) scale(1.2);
}

.annotation-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-turquoise);
    margin-bottom: 12px;
}

.annotation-text {
    font-size: 0.95rem;
    line-height: 1.65;
    opacity: 0.92;
}

.annotation-text p {
    margin-bottom: 0.75em;
}

.annotation-text p:last-child {
    margin-bottom: 0;
}

.annotation-text a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid var(--link-color);
    transition: opacity 0.2s ease;
}

.annotation-text a:hover {
    opacity: var(--hover-opacity);
}

.annotation-text code {
    background: rgba(128, 128, 128, 0.15);
    padding: 2px 5px;
    border-radius: 2px;
    font-size: 0.85em;
    font-family: 'Monaco', 'Courier New', monospace;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    font-family: 'Montserrat', sans-serif;
    margin-top: 2.5em;
    margin-bottom: 0.8em;
    font-weight: 500;
    letter-spacing: 0.02em;
    line-height: 1.3;
}

.post-content h1 { font-size: 2.2rem; }
.post-content h2 {
    font-size: 1.8rem;
    margin-top: 2em;
}
.post-content h3 {
    font-size: 1.4rem;
    margin-top: 1.8em;
}

.post-content h2:first-child,
.post-content h3:first-child {
    margin-top: 0;
}

.post-content p {
    margin-bottom: 1.5em;
}

.post-content a {
    color: var(--link-color);
    text-decoration: none;
    border-bottom: 1px solid var(--link-color);
    transition: opacity 0.2s ease;
}

.post-content a:hover {
    opacity: var(--hover-opacity);
}

.post-content code {
    background: rgba(128, 128, 128, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: 'Monaco', 'Courier New', monospace;
}

.post-content pre {
    background: rgba(128, 128, 128, 0.1);
    padding: 20px;
    border-radius: 5px;
    overflow-x: auto;
    margin-bottom: 1.5em;
}

.post-content pre code {
    background: none;
    padding: 0;
}

.post-content blockquote {
    border-left: 3px solid var(--accent-green);
    padding-left: 20px;
    margin: 1.5em 0;
    opacity: 0.9;
    font-style: italic;
}

.post-content ul,
.post-content ol {
    margin-left: 30px;
    margin-bottom: 1.5em;
}

.post-content li {
    margin-bottom: 0.5em;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 40px;
    left: 40px;
    background: transparent;
    border: 1px solid rgba(128, 128, 128, 0.3);
    color: rgba(128, 128, 128, 0.5);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    z-index: 1000;
}

.theme-toggle:hover {
    opacity: 1;
    transform: scale(1.1);
    border-color: var(--toggle-border-color);
    color: var(--text-color);
    box-shadow: 0 0 15px rgba(255, 112, 67, 0.4);
}

[data-theme="light"] .theme-toggle:hover {
    box-shadow: 0 0 15px rgba(77, 208, 225, 0.4);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid rgba(128, 128, 128, 0.1);
}

.pagination a {
    color: var(--link-color);
    text-decoration: none;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.05em;
    transition: opacity 0.2s ease;
}

.pagination a:hover {
    opacity: var(--hover-opacity);
}

.pagination .disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* Animations */
@keyframes highlight-pulse {
    0%, 100% {
        background: rgba(128, 128, 128, 0.05);
        border-left-color: var(--accent-turquoise);
    }
    50% {
        background: rgba(77, 208, 225, 0.15);
        border-left-color: var(--accent-orange);
    }
}

/* Responsive */
@media (max-width: 1100px) {
    .post-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .post-sidebar {
        position: static;
        border-top: 2px solid var(--accent-turquoise);
        padding-top: 40px;
        margin-top: 60px;
    }

    .sidebar-content {
        position: static;
    }

    .annotation {
        padding: 15px;
        position: static !important;
        width: auto !important;
        margin-bottom: 20px;
    }

    .annotation.positioned {
        position: static !important;
    }
}

@media (max-width: 768px) {
    header {
        padding: 40px 20px 30px;
        margin-bottom: 40px;
    }

    .site-title {
        font-size: 2rem;
    }

    .navigation {
        flex-direction: column;
        gap: 20px;
        align-items: center;
    }

    .nav-link {
        font-size: 18px;
    }

    .dropdown-menu {
        position: static;
        transform: none;
        margin-top: 15px;
        opacity: 0;
        max-height: 0;
        overflow: hidden;
        transition: all 0.3s ease;
        border: none;
        padding: 0;
        background: transparent;
        min-width: auto;
    }

    .nav-item:hover .dropdown-menu,
    .nav-item:focus-within .dropdown-menu {
        opacity: 1;
        max-height: 400px;
        padding: 20px 10px;
    }

    .tree-item {
        font-size: 12px;
    }

    .post-title {
        font-size: 1.5rem;
    }

    .theme-toggle {
        bottom: 20px;
        left: 20px;
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}
