/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.05);
    --shadow-hover: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-card: #1f1f1f;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #60a5fa;
    --accent-hover: #3b82f6;
    --border: #2d2d2d;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Headings use Space Grotesk */
h1, h2, h3, h4, h5, h6,
.logo {
    font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Anti-copy protection */
.protected {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.narrow {
    max-width: 800px;
}

/* Header */
header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: var(--bg-card)ee;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.03em;
    transition: color 0.2s;
}

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

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

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

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.header-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.2s;
}

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

/* Theme Toggle */
.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 1.2rem;
}

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

/* Main Content */
main {
    padding: 60px 0;
    min-height: calc(100vh - 200px);
}

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 32px;
    margin-bottom: 60px;
}

/* Article Card */
.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.article-card:hover::before {
    transform: scaleX(1);
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-hover);
    border-color: var(--accent);
}

.article-card h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.3;
}

.article-card .excerpt {
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.6;
    font-size: 0.95rem;
}

.article-card .meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.article-card .date {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.article-card .read-more {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: gap 0.2s;
}

.article-card .read-more:hover {
    gap: 10px;
}

.mature-badge {
    display: inline-block;
    background: #ef4444;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 32px;
    margin-bottom: 60px;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-hover));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.project-card:hover::before {
    transform: scaleX(1);
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow-hover);
    border-color: var(--accent);
}

.project-card h2 {
    font-size: 1.6rem;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 700;
}

.project-description {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
    margin-bottom: 24px;
    flex-grow: 1;
}

.project-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    align-self: flex-start;
}

.project-btn:hover {
    background: var(--accent-hover);
    gap: 12px;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin: 60px 0;
}

.pagination button,
.pagination a {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
    color: var(--text-primary);
    text-decoration: none;
}

.pagination button:hover:not(:disabled),
.pagination a:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination .current {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Single Article */
.article-header {
    text-align: center;
    margin-bottom: 48px;
    padding-bottom: 32px;
    border-bottom: 2px solid var(--border);
}

.article-header h1 {
    font-size: 3.2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
}

.article-meta {
    color: var(--text-muted);
    font-size: 0.95rem;
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
}

.article-content {
    font-size: 1.125rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 60px;
}

.article-content p {
    margin-bottom: 24px;
}

.article-content h2,
.article-content h3 {
    color: var(--text-primary);
    margin-top: 40px;
    margin-bottom: 20px;
    font-weight: 700;
}

.article-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s;
}

.article-content a:hover {
    border-bottom-color: var(--accent);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 32px;
    transition: all 0.2s;
}

.back-link:hover {
    color: var(--accent);
    gap: 12px;
}

/* Archive Lock */
.archive-lock {
    max-width: 500px;
    margin: 100px auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    box-shadow: 0 8px 24px var(--shadow);
}

.archive-lock h1 {
    font-size: 2.2rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.archive-lock p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 1.05rem;
}

.archive-lock input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    margin-bottom: 16px;
    transition: border-color 0.2s;
    font-family: 'Inter', sans-serif;
}

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

.archive-lock button {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.archive-lock button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.error-message {
    background: #fee;
    color: #c00;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* Admin Styles */
.admin-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 32px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
}

.btn {
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-danger {
    background: #ef4444;
}

.btn-danger:hover {
    background: #dc2626;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

.form-group textarea {
    min-height: 400px;
    resize: vertical;
    font-family: 'Monaco', 'Menlo', monospace;
    line-height: 1.5;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.post-list {
    list-style: none;
}

.post-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.post-item h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.post-item .post-info {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.post-actions {
    display: flex;
    gap: 12px;
}

/* Footer */
footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 32px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 200px;
    padding: 8px 36px 8px 12px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s;
    font-family: 'Inter', sans-serif;
}

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

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    transition: color 0.2s;
}

.search-btn:hover {
    color: var(--accent);
}

.archive-result {
    opacity: 0.95;
}

.archive-result:hover {
    opacity: 1;
}

/* Reading time */
.reading-time {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Category Badges */
.category-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    color: white;
    margin-right: 8px;
    margin-bottom: 8px;
    transition: opacity 0.2s, transform 0.2s;
}

.category-badge:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

/* Categories Filter */
.categories-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.category-filter-btn {
    padding: 8px 20px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.category-filter-btn:hover {
    border-color: var(--cat-color, var(--accent));
    background: var(--cat-color, var(--accent));
    color: white;
    transform: translateY(-2px);
}

.category-filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .header-nav {
        position: fixed;
        top: 0;
        right: -100%;
        width: 280px;
        height: 100vh;
        background: var(--bg-card);
        flex-direction: column;
        padding: 80px 24px 24px;
        gap: 24px;
        box-shadow: -4px 0 20px var(--shadow-hover);
        transition: right 0.3s ease;
        align-items: flex-start;
        border-left: 1px solid var(--border);
    }

    .header-nav.active {
        right: 0;
    }

    .nav-link {
        font-size: 1.1rem;
        width: 100%;
        padding: 12px 0;
        border-bottom: 1px solid var(--border);
    }

    .search-box {
        width: 100%;
        order: -1;
    }

    .search-input {
        width: 100%;
    }

    .search-input:focus {
        width: 100%;
    }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .projects-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .article-header h1 {
        font-size: 2.2rem;
    }

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

    .archive-lock {
        padding: 32px 24px;
        margin: 40px 24px;
    }

    .archive-lock h1 {
        font-size: 1.8rem;
    }

    .container {
        padding: 0 20px;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1.2rem;
    }

    .article-header h1 {
        font-size: 1.85rem;
    }

    .projects-grid {
        gap: 20px;
    }

    .project-card {
        padding: 24px;
    }
}

/* Smooth transitions */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}