/* Import Inter font for premium typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    --bg: #0b0f14;
    --panel: #0f1620;
    --text: #e8eef6;
    --muted: #9fb0c3;
    --line: rgba(255, 255, 255, .08);
    --accent: #7dd3fc;
    --accent-dim: rgba(125, 211, 252, 0.12);
    --purple-dim: rgba(167, 139, 250, 0.10);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

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

/* Focus indicators for accessibility */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 4px;
}

/* Skip to content link for accessibility */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: var(--bg);
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 100;
}

.skip-link:focus {
    top: 0;
}

/* Reading progress bar */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #a78bfa);
    z-index: 9999;
    transition: width 0.1s ease-out;
}

/* Navbar enhancements */
.navbar {
    border-bottom: 1px solid var(--line);
    background: rgba(11, 15, 20, .95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all var(--transition);
}

.navbar.scrolled {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

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

/* Hero with enhanced gradients */
.hero {
    padding: 4.5rem 0 2.5rem;
    border-bottom: 1px solid var(--line);
    background:
            radial-gradient(80% 80% at 10% 10%, var(--accent-dim), transparent 60%),
            radial-gradient(60% 60% at 90% 20%, var(--purple-dim), transparent 55%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(255,255,255,0.02)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.5;
    pointer-events: none;
}

.hero > * {
    position: relative;
    z-index: 1;
}

.kicker {
    color: var(--muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.85rem;
    font-weight: 600;
}

.title {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.subtext {
    color: var(--muted);
    max-width: 60ch;
    font-size: 1.05rem;
    line-height: 1.6;
}

/* Card enhancements with microinteractions */
.card {
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .02));
    border: 1px solid var(--line);
    border-radius: 16px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.card p, .card li {
    color: var(--text);
}

.card .kicker {
    color: var(--muted);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(125, 211, 252, 0.05), transparent);
    transition: left 0.5s ease;
}

.card:hover {
    border-color: rgba(125, 211, 252, .35);
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(125, 211, 252, 0.15);
}

.card:hover::before {
    left: 100%;
}

/* Fade-in animation for cards */
.card {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger the card animations */
.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }
.card:nth-child(6) { animation-delay: 0.6s; }

/* Scroll-triggered animations */
.fade-in-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.fade-in-scroll.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Badge tags */
.badge-tag {
    border: 1px solid var(--line);
    color: var(--muted);
    background: rgba(255, 255, 255, .03);
    transition: all var(--transition);
    font-weight: 500;
}

.badge-tag:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(125, 211, 252, .08);
}

/* Horizontal rule */
.hr-soft {
    border-top: 1px solid var(--line);
    opacity: 1;
}

/* Post content styling */
.post {
    max-width: 860px;
}

.post h1, .post h2, .post h3 {
    letter-spacing: -0.02em;
    font-weight: 700;
}

.post h2 {
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.post h3 {
    margin-top: 2rem;
    margin-bottom: 0.75rem;
}

.post p, .post li {
    color: rgba(232, 238, 246, .92);
    font-size: 1.05rem;
    line-height: 1.75;
}

.post blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.5rem;
    margin: 2rem 0;
    color: rgba(232, 238, 246, .92);
    font-style: italic;
}

.post .pull {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
    line-height: 1.6;
}

/* Table of Contents */
.toc {
    background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .02));
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: sticky;
    top: 80px;
}

.toc-title {
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.toc-list li {
    margin-bottom: 0.5rem;
}

.toc-list a {
    color: var(--muted);
    font-size: 0.95rem;
    transition: all var(--transition);
    display: block;
    padding: 0.25rem 0;
}

.toc-list a:hover,
.toc-list a.active {
    color: var(--accent);
    padding-left: 0.5rem;
}

/* Code blocks */
.post pre {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1.5rem;
    overflow-x: auto;
    position: relative;
}

.post code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
}

.post :not(pre) > code {
    background: rgba(125, 211, 252, 0.1);
    color: var(--accent);
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Copy button for code blocks */
.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--line);
    color: var(--muted);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
}

.code-copy-btn:hover {
    background: rgba(125, 211, 252, 0.15);
    border-color: var(--accent);
    color: var(--accent);
}

.code-copy-btn.copied {
    color: #10b981;
    border-color: #10b981;
}

/* Related posts section */
.related-posts {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--line);
}

/* Button enhancements */
.btn {
    transition: all var(--transition);
    font-weight: 600;
}

.btn-outline-light:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    transform: translateX(-4px);
}

.btn-light:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
    transform: translateX(4px);
}

/* Footer */
.footer {
    border-top: 1px solid var(--line);
    color: var(--muted);
    margin-top: 4rem;
}

.small-muted {
    color: var(--muted);
}

/* Share buttons */
.share-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: 2rem;
}

.share-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.9rem;
}

.share-btn:hover {
    background: rgba(125, 211, 252, 0.1);
    border-color: var(--accent);
    color: var(--accent);
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* 404 Page */
.error-page {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-content {
    text-align: center;
}

.error-code {
    font-size: 8rem;
    font-weight: 900;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero {
        padding: 3rem 0 2rem;
    }

    .toc {
        position: static;
    }

    .error-code {
        font-size: 5rem;
    }
}

/* Print styles */
@media print {
    .navbar,
    .footer,
    .share-buttons,
    .reading-progress,
    .toc {
        display: none;
    }

    .post {
        max-width: 100%;
    }
}