/* ============================================
   Custom CSS for maltsev-dev.github.io
   Modern design with dark/light mode support
   ============================================ */

/* --- CSS Variables & Theme --- */
:root {
    /* Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a68;
    --text-muted: #6c757d;
    --accent: #f59140;
    --accent-hover: #e07b2a;
    --accent-alpha: rgba(245, 145, 64, 0.1);
    --border-color: #dee2e6;
    --code-bg: #f6f8fa;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Theme */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16162a;
    --bg-tertiary: #1f1f38;
    --text-primary: #e8e8e8;
    --text-secondary: #b8b8c8;
    --text-muted: #8888a0;
    --accent: #f59140;
    --accent-hover: #ff9f52;
    --accent-alpha: rgba(245, 145, 64, 0.15);
    --border-color: #2d2d44;
    --code-bg: #242438;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: var(--radius-md);
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5, h6 { font-size: 1.125rem; }

p {
    margin-bottom: 1.25rem;
}

/* --- Layout --- */
.site-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
}

.main-content {
    flex: 1;
    padding: 40px 0;
}

/* --- Header --- */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    gap: 20px;
}

.logo-link {
    display: block;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    padding: 8px 16px;
    background: var(--accent-alpha);
    border-radius: var(--radius-sm);
    border: 2px solid var(--accent);
    display: inline-block;
    transition: var(--transition);
}

.logo-link:hover .logo {
    background: var(--accent);
    color: var(--bg-primary);
}

.main-nav {
    display: flex;
    gap: 8px;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: 4px;
}

.nav-link {
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    color: var(--accent);
    background: var(--accent-alpha);
}

.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

/* --- Hero Section --- */
.hero {
    text-align: center;
    padding: 60px 24px 40px;
    background: linear-gradient(135deg, var(--accent-alpha) 0%, transparent 100%);
    border-radius: var(--radius-lg);
    margin-bottom: 40px;
}

.hero-title {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.hero-title .accent {
    color: var(--accent);
}

.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

/* --- Posts List --- */
.posts-list {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.post-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.post-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0;
    transition: var(--transition);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent);
}

.post-card:hover::before {
    opacity: 1;
}

.post-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 12px;
}

.post-card-title {
    font-size: 1.375rem;
    margin: 0;
    flex: 1;
}

.post-card-title a {
    color: var(--text-primary);
}

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

.post-card-date {
    font-size: 0.875rem;
    color: var(--text-muted);
    white-space: nowrap;
    font-weight: 500;
}

.post-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--accent-alpha);
    color: var(--accent);
    border-radius: 20px;
    font-size: 0.825rem;
    font-weight: 600;
    transition: var(--transition);
}

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

.tag-small {
    padding: 2px 8px;
    font-size: 0.75rem;
}

.post-card-excerpt {
    color: var(--text-secondary);
    margin-bottom: 18px;
    line-height: 1.6;
}

.read-more-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--accent);
    padding: 8px 0;
}

.read-more-link svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s ease;
}

.read-more-link:hover svg {
    transform: translateX(4px);
}

/* --- Pagination --- */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    transition: var(--transition);
}

.pagination-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.pagination-btn svg {
    width: 18px;
    height: 18px;
}

.pagination-info {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

/* --- Post Content --- */
.post-container {
    padding: 20px 0;
}

.post-header {
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--accent-alpha);
}

.post-title {
    font-size: 2.5rem;
    margin-bottom: 16px;
    line-height: 1.2;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.post-date {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.post-date svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}

.post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

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

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

.post-content a {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.post-content a:hover {
    text-decoration-thickness: 2px;
}

/* --- Code Blocks --- */
.post-content pre {
    background: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    overflow-x: auto;
    margin: 24px 0;
    position: relative;
}

.post-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
}

.post-content :not(pre) > code {
    background: var(--accent-alpha);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.9em;
}

.copy-code-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.copy-code-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

/* --- Tables --- */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 32px 0;
    overflow-x: auto;
    display: block;
}

.post-content table thead {
    background: var(--accent);
}

.post-content table th,
.post-content table td {
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.post-content table th {
    color: var(--bg-primary);
    font-weight: 600;
}

.post-content table tbody tr {
    transition: var(--transition);
}

.post-content table tbody tr:hover {
    background: var(--accent-alpha);
}

/* --- Blockquotes --- */
.post-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 16px 24px;
    margin: 28px 0;
    background: var(--accent-alpha);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.post-content blockquote p:last-child {
    margin-bottom: 0;
}

/* --- Post Navigation --- */
.post-navigation {
    margin-top: 60px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.nav-inner {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.post-navigation .nav-link {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.post-navigation .nav-link:hover {
    border-color: var(--accent);
    background: var(--accent-alpha);
}

.post-navigation .nav-link.nav-prev {
    text-align: left;
}

.post-navigation .nav-link.nav-next {
    text-align: right;
    justify-self: end;
}

.nav-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-title {
    font-weight: 600;
    color: var(--text-primary);
}

/* --- Archive Page --- */
.archive-header {
    text-align: center;
    margin-bottom: 48px;
}

.archive-title {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.archive-subtitle {
    color: var(--text-secondary);
    font-size: 1.125rem;
}

.archive-list {
    display: flex;
    flex-direction: column;
}

.archive-year {
    margin-bottom: 40px;
}

.year-heading {
    font-size: 1.75rem;
    padding: 12px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

.year-posts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.archive-post-item {
    display: grid;
    grid-template-columns: 140px 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.archive-post-item:hover {
    border-color: var(--accent);
    transform: translateX(8px);
}

.archive-post-date {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.archive-post-link {
    color: var(--text-primary);
    font-weight: 500;
}

.archive-post-link:hover {
    color: var(--accent);
}

.archive-post-tags {
    display: flex;
    gap: 6px;
}

/* --- Tag Page --- */
.tag-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px;
    background: var(--accent-alpha);
    border-radius: var(--radius-lg);
    border: 2px solid var(--accent);
}

.tag-title {
    font-size: 3rem;
    margin-bottom: 8px;
    color: var(--accent);
}

.tag-subtitle {
    color: var(--text-secondary);
}

.back-to-home {
    margin-top: 40px;
    text-align: center;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    transition: var(--transition);
}

.back-link:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-primary);
}

.back-link svg {
    width: 18px;
    height: 18px;
}

/* --- Static Pages --- */
.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 2.25rem;
}

.page-body {
    line-height: 1.8;
}

/* --- Footer --- */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 32px 0;
    margin-top: auto;
}

.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.copyright {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.copyright-sep {
    color: var(--border-color);
}

.copyright img {
    display: inline;
    vertical-align: middle;
}

.social-links {
    display: flex;
    gap: 12px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
}

.social-link:hover {
    background: var(--accent);
    color: var(--bg-primary);
    transform: translateY(-3px);
}

.social-link svg {
    width: 20px;
    height: 20px;
}

/* --- Theme Toggle --- */
.theme-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 50px;
    height: 50px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    z-index: 1000;
}

.theme-toggle:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: scale(1.1);
}

.theme-toggle svg {
    width: 22px;
    height: 22px;
    position: absolute;
    transition: var(--transition);
}

.sun-icon {
    opacity: 1;
}

.moon-icon {
    opacity: 0;
}

[data-theme="dark"] .sun-icon {
    opacity: 0;
}

[data-theme="dark"] .moon-icon {
    opacity: 1;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
    
    .header-inner {
        padding: 12px 16px;
    }
    
    .main-nav {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .hero {
        padding: 40px 16px 24px;
    }
    
    .hero-title {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
    
    .post-card {
        padding: 20px;
    }
    
    .post-card-header {
        flex-direction: column;
    }
    
    .post-title,
    .archive-title,
    .tag-title {
        font-size: 1.75rem;
    }
    
    .post-content {
        font-size: 1rem;
    }
    
    .nav-inner {
        grid-template-columns: 1fr;
    }
    
    .post-navigation .nav-link.nav-next {
        justify-self: start;
    }
    
    .archive-post-item {
        grid-template-columns: 1fr;
        gap: 8px;
        text-align: center;
    }
    
    .archive-post-tags {
        justify-content: center;
    }
    
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
    
    .copyright {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .theme-toggle {
        width: 44px;
        height: 44px;
        bottom: 16px;
        right: 16px;
    }
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.post-card,
.archive-post-item {
    animation: fadeIn 0.4s ease-out;
}

/* --- Print Styles --- */
@media print {
    .header,
    .footer,
    .theme-toggle,
    .pagination,
    .post-navigation {
        display: none;
    }
    
    .post-content {
        font-size: 12pt;
    }
    
    a {
        color: #000;
    }
}
