/* ==========================================================================
   Personal Theme - Dashboard Style
   ========================================================================== */

/* ---------- Variables ---------- */
:root {
    --accent: #149AA1;
    --accent-hover: #0f8289;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --sidebar-bg: #ffffff;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --sidebar-width: 260px;
    --grid-gap: 20px;
    --card-orange: #149AA1;
    --card-dark: #374151;
    --card-yellow: #fbbf24;
    --card-blue: #93c5fd;
    --card-pink: #f9a8d4;
    --card-charcoal: #1e293b;
    --card-teal: #10b981;
    --font-display: 'Plus Jakarta Sans', sans-serif;
    --font-heading: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Inter', sans-serif;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
}

[data-theme="dark"] {
    --bg: #0f172a;
    --surface: #1e293b;
    --sidebar-bg: #1a1a2e;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
    --shadow-xl: 0 20px 60px rgba(0,0,0,0.5);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); color: var(--text); background: var(--bg); line-height: 1.6; transition: background-color 0.4s, color 0.4s; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
ul, ol { list-style: none; }

/* ---------- App Layout ---------- */
.app-layout { display: flex; min-height: 100vh; }

/* ---------- Mobile Menu Button ---------- */
.mobile-menu-btn {
    display: none;
    position: absolute;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border: 1px solid var(--border);
}

/* ---------- Sidebar Overlay ---------- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    overflow: hidden;
    z-index: 100;
    transition: transform 0.3s ease, background-color 0.4s, border-color 0.4s;
}

.sidebar-profile { text-align: center; margin-bottom: 24px; }

.sidebar-logo {
    width: 140px;
    height: auto;
    margin: 0 auto;
    display: block;
    transition: opacity 0.3s;
}
.sidebar-logo:hover { opacity: 0.85; }

/* Header Logo */
.header-logo-img {
    height: 48px;
    width: auto;
    display: block;
}

/* Sidebar Navigation */
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; }

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    position: relative;
    transition: color 0.25s, background 0.25s, transform 0.25s, box-shadow 0.25s;
}

.sidebar-nav-item:hover {
    color: var(--text);
    background: var(--bg);
    box-shadow: inset 3px 0 0 var(--border);
}

.sidebar-nav-item.active {
    color: var(--cat-color, var(--accent));
    font-weight: 600;
    background: rgba(20,154,161,0.08);
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 8%, transparent);
    box-shadow: inset 3px 0 0 var(--cat-color, var(--accent));
    padding-left: 20px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: color 0.25s, transform 0.25s;
}
.nav-icon svg { width: 18px; height: 18px; }

.sidebar-nav-item:hover .nav-icon { animation: iconWiggle 0.4s ease; }
.sidebar-nav-item.active .nav-icon {
    color: var(--cat-color, var(--accent));
    transform: scale(1.15);
    background: rgba(20,154,161,0.12);
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 15%, transparent);
    width: 32px;
    height: 32px;
}

.nav-dot {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 16px;
    font-weight: 700;
    color: var(--cat-color, var(--accent));
    line-height: 1;
}
.nav-dot::before { content: '\203A'; }
@keyframes iconWiggle {
    0% { transform: rotate(0); }
    25% { transform: rotate(-6deg); }
    50% { transform: rotate(6deg); }
    75% { transform: rotate(-3deg); }
    100% { transform: rotate(0); }
}

/* Sidebar Footer */
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); flex-shrink: 0; }

/* Sidebar Social Icons */
.sidebar-social {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.social-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.social-icon:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: rgba(20,154,161,0.08);
}

.dark-mode-toggle { display: flex; align-items: center; justify-content: space-between; }
.toggle-label { font-size: 14px; color: var(--text-secondary); }

.toggle-switch {
    width: 48px;
    height: 26px;
    background: var(--border);
    position: relative;
    padding: 2px;
    transition: background 0.3s;
}

.toggle-knob {
    width: 22px;
    height: 22px;
    background: #fff;
    display: block;
    transition: transform 0.3s;
}

[data-theme="dark"] .toggle-switch { background: var(--accent); }
[data-theme="dark"] .toggle-knob { transform: translateX(22px); }

/* ---------- Main Content ---------- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 24px 40px;
    min-width: 0;
}

/* ---------- Top Bar ---------- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 24px;
}

.site-title {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.search-form {
    display: flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    max-width: 400px;
    flex: 1;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s, border-color 0.3s, max-width 0.3s;
}
.search-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(20,154,161,0.15);
    max-width: 440px;
}

.search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--font-body);
    color: var(--text);
    outline: none;
}

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

.search-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    flex-shrink: 0;
}

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

/* ---------- Content Tabs ---------- */
.content-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tabs-left { display: flex; gap: 0; }

.tab-item {
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--accent); border-bottom-color: transparent; }

.tabs-right {
    display: flex;
    gap: 0;
    padding: 3px;
    background: var(--surface);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.tabs-right::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--accent);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}
.tabs-right.popular-active::before {
    transform: translateX(100%);
}

.filter-btn {
    padding: 6px 20px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.25s;
    position: relative;
    z-index: 1;
    background: transparent;
    white-space: nowrap;
}

.filter-btn.active {
    color: #fff;
    background: transparent;
}

/* ---------- Posts Grid ---------- */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--grid-gap);
    margin-bottom: 40px;
    animation: gridFadeIn 0.4s ease;
    perspective: 1200px;
}

/* Archive page entrance */
.archive-page .posts-grid {
    animation: pageZoomIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---------- Homepage & Category Animations ---------- */
@keyframes gridFadeIn {
    from { opacity: 0; transform: perspective(1000px) translateZ(-30px); }
    to { opacity: 1; transform: perspective(1000px) translateZ(0); }
}
@keyframes cardFlipIn {
    0% {
        opacity: 0;
        transform: perspective(800px) rotateY(-8deg) translateY(20px) scale(0.95);
    }
    60% {
        opacity: 1;
        transform: perspective(800px) rotateY(2deg) translateY(-4px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: perspective(800px) rotateY(0) translateY(0) scale(1);
    }
}
@keyframes tabIndicator {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}
@keyframes pageZoomIn {
    from {
        opacity: 0;
        transform: perspective(1200px) translateZ(-80px) rotateX(2deg);
    }
    to {
        opacity: 1;
        transform: perspective(1200px) translateZ(0) rotateX(0);
    }
}

.tab-item.active {
    position: relative;
}
.tab-item.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    animation: tabIndicator 0.3s ease;
    transform-origin: left;
}

/* ---------- Post Card ---------- */
.post-card {
    background: var(--surface);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s ease, background-color 0.4s;
    animation: cardFlipIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
    transform-origin: center bottom;
}
.post-card:nth-child(1) { animation-delay: 0s; }
.post-card:nth-child(2) { animation-delay: 0.06s; }
.post-card:nth-child(3) { animation-delay: 0.12s; }
.post-card:nth-child(4) { animation-delay: 0.18s; }
.post-card:nth-child(5) { animation-delay: 0.24s; }
.post-card:nth-child(6) { animation-delay: 0.3s; }
.post-card:nth-child(7) { animation-delay: 0.36s; }
.post-card:nth-child(8) { animation-delay: 0.42s; }
.post-card:nth-child(9) { animation-delay: 0.48s; }

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

.card-featured { grid-column: span 2; }

.card-image {
    display: block;
    overflow: hidden;
    aspect-ratio: 16/10;
}

.card-featured .card-image { aspect-ratio: 2/1; }

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.post-card:hover .card-image img { transform: scale(1.05); }

.card-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.card-featured .card-body { padding: 24px; }

.card-category {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin-bottom: 8px;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.card-featured .card-title { font-size: 24px; }

.card-title a { transition: color 0.2s; }
.card-title a:hover { color: var(--accent); }

.card-excerpt {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
    margin-bottom: 12px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    padding-top: 12px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* Card Color Variants - No Image */
.post-card.card-orange:not(.has-image) { background: var(--card-orange); }
.post-card.card-orange:not(.has-image) .card-body { color: #fff; }
.post-card.card-orange:not(.has-image) .card-title a { color: #fff; }
.post-card.card-orange:not(.has-image) .card-excerpt { color: rgba(255,255,255,0.85); }
.post-card.card-orange:not(.has-image) .card-category { color: rgba(255,255,255,0.7); }
.post-card.card-orange:not(.has-image) .card-footer { color: rgba(255,255,255,0.6); border-color: rgba(255,255,255,0.2); }

.post-card.card-dark:not(.has-image) { background: var(--card-dark); }
.post-card.card-dark:not(.has-image) .card-body { color: #fff; }
.post-card.card-dark:not(.has-image) .card-title a { color: #fff; }
.post-card.card-dark:not(.has-image) .card-excerpt { color: rgba(255,255,255,0.8); }
.post-card.card-dark:not(.has-image) .card-category { color: var(--accent); }
.post-card.card-dark:not(.has-image) .card-footer { color: rgba(255,255,255,0.5); border-color: rgba(255,255,255,0.15); }

.post-card.card-yellow:not(.has-image) { background: var(--card-yellow); }
.post-card.card-yellow:not(.has-image) .card-title a { color: #1a1a1a; }
.post-card.card-yellow:not(.has-image) .card-excerpt { color: #44403c; }
.post-card.card-yellow:not(.has-image) .card-category { color: #92400e; }
.post-card.card-yellow:not(.has-image) .card-footer { color: #78716c; border-color: rgba(0,0,0,0.1); }

.post-card.card-blue:not(.has-image) { background: var(--card-blue); }
.post-card.card-blue:not(.has-image) .card-title a { color: #1e3a5f; }
.post-card.card-blue:not(.has-image) .card-excerpt { color: #1e3a5f; }
.post-card.card-blue:not(.has-image) .card-category { color: #1e40af; }
.post-card.card-blue:not(.has-image) .card-footer { color: #475569; border-color: rgba(0,0,0,0.1); }

.post-card.card-pink:not(.has-image) { background: var(--card-pink); }
.post-card.card-pink:not(.has-image) .card-title a { color: #831843; }
.post-card.card-pink:not(.has-image) .card-excerpt { color: #9d174d; }
.post-card.card-pink:not(.has-image) .card-category { color: #be185d; }
.post-card.card-pink:not(.has-image) .card-footer { color: #9d174d; border-color: rgba(0,0,0,0.1); }

.post-card.card-charcoal:not(.has-image) { background: var(--card-charcoal); }
.post-card.card-charcoal:not(.has-image) .card-body { color: #fff; }
.post-card.card-charcoal:not(.has-image) .card-title a { color: #fff; }
.post-card.card-charcoal:not(.has-image) .card-excerpt { color: rgba(255,255,255,0.75); }
.post-card.card-charcoal:not(.has-image) .card-category { color: var(--accent); }
.post-card.card-charcoal:not(.has-image) .card-footer { color: rgba(255,255,255,0.5); border-color: rgba(255,255,255,0.1); }

.post-card.card-teal:not(.has-image) { background: var(--card-teal); }
.post-card.card-teal:not(.has-image) .card-body { color: #fff; }
.post-card.card-teal:not(.has-image) .card-title a { color: #fff; }
.post-card.card-teal:not(.has-image) .card-excerpt { color: rgba(255,255,255,0.85); }
.post-card.card-teal:not(.has-image) .card-category { color: rgba(255,255,255,0.7); }
.post-card.card-teal:not(.has-image) .card-footer { color: rgba(255,255,255,0.6); border-color: rgba(255,255,255,0.2); }

/* ---------- Reading Progress Bar ---------- */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: transparent;
    z-index: 1001;
    pointer-events: none;
}
.reading-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.1s linear;
}

/* ---------- Single Post ---------- */
.single-back { margin-bottom: 24px; }
.single-back a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.single-back a:hover { color: var(--accent); }

/* Single Layout - 2 Column Grid */
.single-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 56px;
}
.single-layout--full { grid-template-columns: 1fr; max-width: 900px; }
.single-main { min-width: 0; }

.single-article { max-width: none; }

.single-header { margin-bottom: 32px; }

.single-categories { display: flex; gap: 8px; margin-bottom: 12px; }
.single-cat {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    padding: 4px 10px;
    background: rgba(20,154,161,0.1);
}

.single-title {
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 16px;
}

.single-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.meta-avatar {
    width: 28px;
    height: 28px;
    object-fit: cover;
    flex-shrink: 0;
}
.meta-avatar--placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}

.meta-sep { color: var(--text-muted); }

.single-featured-image {
    margin-bottom: 32px;
    overflow: hidden;
}

.single-featured-image img { width: 100%; }

/* Single Content - Typography */
.single-content {
    font-size: 18px;
    line-height: 1.85;
    margin-bottom: 32px;
}

/* Drop Cap - first paragraph first letter */
.single-content > p:first-of-type::first-letter {
    float: left;
    font-family: var(--font-heading);
    font-size: 3.4em;
    font-weight: 800;
    line-height: 0.8;
    padding: 4px 10px 4px 0;
    color: var(--accent);
}

.single-content h2 {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 700;
    margin: 40px 0 16px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    scroll-margin-top: 24px;
}
.single-content h3 {
    font-family: var(--font-heading);
    font-size: 21px;
    font-weight: 600;
    margin: 32px 0 12px;
    scroll-margin-top: 24px;
}
.single-content p { margin-bottom: 20px; }
.single-content ul, .single-content ol { margin: 0 0 20px 24px; }
.single-content ul { list-style: disc; }
.single-content ol { list-style: decimal; }
.single-content li { margin-bottom: 6px; }
.single-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 20px 28px;
    margin: 28px 0;
    background: var(--surface);
    font-style: italic;
    color: var(--text-secondary);
}
.single-content pre {
    background: var(--card-charcoal);
    color: #e2e8f0;
    padding: 24px;
    overflow-x: auto;
    margin: 28px 0;
    font-size: 14px;
    line-height: 1.6;
}
.single-content code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
}
.single-content :not(pre) > code {
    background: var(--bg);
    padding: 2px 6px;
    border: 1px solid var(--border);
}
.single-content img { margin: 28px 0; }
.single-content a { color: var(--accent); text-decoration: underline; }

.single-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.tag-badge {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 12px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.tag-badge:hover { border-color: var(--accent); color: var(--accent); }

.single-share {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 0;
    border-top: 1px solid var(--border);
    font-size: 14px;
    color: var(--text-secondary);
}
.share-link {
    font-weight: 600;
    color: var(--text);
    transition: color 0.2s;
}
.share-link:hover { color: var(--accent); }

/* ---------- Single Sidebar (Right) ---------- */
.single-sidebar {
    position: sticky;
    top: 24px;
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    min-width: 280px;
}
.single-sidebar::-webkit-scrollbar { width: 3px; }
.single-sidebar::-webkit-scrollbar-thumb { background: var(--border); }

/* ---------- TOC Widget ---------- */
.article-toc {
    padding: 0;
}
.article-toc__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.article-toc__title {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.article-toc__top {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: color 0.2s, border-color 0.2s;
}
.article-toc__top:hover { color: var(--accent); border-color: var(--accent); }

.article-toc__progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.article-toc__progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    position: relative;
    overflow: hidden;
}
.article-toc__progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress, 0%);
    background: var(--accent);
    transition: width 0.15s linear;
}
.article-toc__progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 28px;
    text-align: right;
}

.article-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.article-toc__list li { margin-bottom: 2px; }
.article-toc__link {
    display: block;
    font-size: 13px;
    line-height: 1.4;
    padding: 6px 12px;
    color: var(--text-secondary);
    border-left: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    text-decoration: none;
}
.article-toc__link:hover { color: var(--text); }
.article-toc__link.active {
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 600;
}
.article-toc__link.read {
    color: var(--text-muted);
}
.article-toc__link--sub {
    padding-left: 24px;
    font-size: 12px;
}

/* ---------- Share Widget (Sidebar) ---------- */
.article-share-widget {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.share-icon {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    text-decoration: none;
}
.share-icon:hover { color: var(--accent); border-color: var(--accent); }
.share-icon--copy.copied {
    color: #10b981;
    border-color: #10b981;
    background: rgba(16,185,129,0.08);
}

/* ---------- Related / Section ---------- */
.related-section, .comments-section { margin-top: 48px; }
.section-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}
.related-grid { grid-template-columns: repeat(3, 1fr); }

/* ---------- Comments ---------- */
.comment {
    display: flex;
    gap: 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--border);
}
.comment-avatar { width: 40px; height: 40px; flex-shrink: 0; object-fit: cover; }
.comment-header { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.comment-author { font-size: 14px; }
.comment-date { font-size: 12px; color: var(--text-muted); }
.comment-text { font-size: 14px; line-height: 1.6; color: var(--text-secondary); }
.comment-replies { padding-left: 56px; }

/* Comment Form */
.comment-form-wrapper { margin-top: 32px; padding-top: 32px; border-top: 1px solid var(--border); }
.comment-form-title { font-size: 18px; font-weight: 600; color: var(--text-primary); margin-bottom: 20px; }
.comment-form .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.comment-form .form-group { margin-bottom: 0; }
.comment-form .form-input,
.comment-form .form-textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border);
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.comment-form .form-input:focus,
.comment-form .form-textarea:focus { border-color: var(--accent); }
.comment-form .form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.comment-form .form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }
.comment-form .form-note { font-size: 12px; color: var(--text-muted); }
.comment-submit-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: none;
    cursor: pointer;
    transition: opacity 0.2s;
    flex-shrink: 0;
}
.comment-submit-btn:hover { opacity: 0.85; }
.comment-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.form-message { margin-top: 12px; padding: 10px 14px; font-size: 13px; line-height: 1.5; }
.form-message.success { background: rgba(16, 185, 129, 0.1); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.2); }
.form-message.error { background: rgba(239, 68, 68, 0.1); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.2); }
.comment-form .form-input.has-error,
.comment-form .form-textarea.has-error { border-color: #ef4444; }
@media (max-width: 600px) {
    .comment-form .form-row { grid-template-columns: 1fr; }
    .comment-form .form-footer { flex-direction: column; align-items: flex-start; }
}

/* ---------- Page Template ---------- */
.page-wrapper { max-width: 800px; }
.page-title {
    font-family: var(--font-heading);
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 24px;
}
.page-content { font-size: 17px; line-height: 1.8; }
.page-content p { margin-bottom: 16px; }

/* ---------- Contact Form ---------- */
.contact-form-wrapper { margin-top: 40px; max-width: 600px; }
.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-family: var(--font-body);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--accent); }
.btn-submit {
    padding: 12px 32px;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-submit:hover { background: var(--accent-hover); }

/* ---------- Archive Header ---------- */
.archive-header { margin-bottom: 24px; }
.archive-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}
.archive-desc { font-size: 15px; color: var(--text-secondary); margin-bottom: 24px; }

/* ---------- Archive Inline Title ---------- */
.archive-inline-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    padding-bottom: 12px;
}

/* ---------- Search ---------- */
.search-header { margin-bottom: 32px; }
.search-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 16px;
}
.search-form-large { max-width: 600px; }
.search-form-large .search-input { padding: 14px 20px; font-size: 16px; }
.search-count { margin-top: 12px; font-size: 14px; color: var(--text-secondary); }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
}
.empty-state h2 {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}
.empty-state a { color: var(--accent); font-weight: 600; }

/* ---------- 404 ---------- */
.error-page {
    text-align: center;
    padding: 100px 20px;
}
.error-code {
    font-family: var(--font-heading);
    font-size: 120px;
    font-weight: 800;
    color: var(--accent);
    line-height: 1;
    margin-bottom: 16px;
}
.error-title {
    font-family: var(--font-heading);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}
.error-text { font-size: 16px; color: var(--text-secondary); margin-bottom: 24px; }
.btn-home {
    display: inline-block;
    padding: 12px 32px;
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-home:hover { background: var(--accent-hover); }

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px 0;
}
.page-link {
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border);
    color: var(--text);
    transition: all 0.2s;
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-info { font-size: 13px; color: var(--text-muted); }

/* ---------- Site Footer ---------- */
.site-footer {
    margin-top: 60px;
    padding: 24px 0;
    border-top: 1px solid var(--border);
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}
.footer-copy { white-space: nowrap; }
.footer-right-group {
    display: flex;
    align-items: center;
    gap: 20px;
}
.footer-social {
    display: flex;
    gap: 6px;
}
.footer-right {
    display: flex;
    gap: 20px;
}
.footer-right a {
    color: var(--text-secondary);
    transition: color 0.2s;
}
.footer-right a:hover {
    color: var(--accent);
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .single-layout { grid-template-columns: 1fr; }
    .single-sidebar { display: none; }
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 24px 24px; }
    .mobile-menu-btn { display: flex; }
    .top-bar { padding-left: 52px; }
    .posts-grid { grid-template-columns: repeat(2, 1fr); }
    .card-featured { grid-column: span 2; }
    .related-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .main-content { padding: 16px; }
    .top-bar { flex-direction: column; align-items: flex-start; gap: 12px; padding-left: 52px; }
    .search-form { max-width: 100%; width: 100%; }
    .posts-grid { grid-template-columns: 1fr; }
    .card-featured { grid-column: span 1; }
    .related-grid { grid-template-columns: 1fr; }
    .content-tabs { flex-direction: column; align-items: flex-start; }
    .tabs-left { flex-wrap: wrap; }
    .single-title { font-size: 26px; }
    .single-meta { flex-wrap: wrap; }
    .single-content { font-size: 16px; }
    .single-content > p:first-of-type::first-letter {
        float: none;
        font-size: inherit;
        font-weight: inherit;
        padding: 0;
        color: inherit;
    }
    .footer-inner { flex-direction: column; gap: 12px; text-align: center; }
    .footer-right { gap: 16px; }
}

/* ---------- Scrollbar ---------- */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); }

/* ---------- Selection ---------- */
::selection { background: var(--accent); color: #fff; }

/* ---------- Dark Mode Extras ---------- */
[data-theme="dark"] .single-content > p:first-of-type::first-letter {
    color: var(--accent);
}
[data-theme="dark"] .share-icon:hover {
    background: rgba(20,154,161,0.1);
}
[data-theme="dark"] .single-content :not(pre) > code {
    background: var(--surface);
    border-color: var(--border);
}
[data-theme="dark"] .sidebar-nav-item.active {
    background: rgba(20,154,161,0.1);
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 10%, transparent);
}
[data-theme="dark"] .sidebar-nav-item:hover {
    background: rgba(255,255,255,0.04);
}
[data-theme="dark"] .sidebar-nav-item.active .nav-icon {
    background: rgba(20,154,161,0.15);
    background: color-mix(in srgb, var(--cat-color, var(--accent)) 18%, transparent);
}

/* ---------- View Transitions (category navigation) ---------- */
@view-transition {
    navigation: auto;
}
::view-transition-old(root) {
    animation: 0.3s cubic-bezier(0.22, 1, 0.36, 1) fade-and-scale-out;
}
::view-transition-new(root) {
    animation: 0.3s cubic-bezier(0.22, 1, 0.36, 1) fade-and-scale-in;
}
@keyframes fade-and-scale-out {
    to { opacity: 0; filter: blur(2px); transform: scale(0.97); }
}
@keyframes fade-and-scale-in {
    from { opacity: 0; filter: blur(2px); transform: scale(1.03); }
}

/* ---------- Avatar Breathe ---------- */
@keyframes avatarBreathe {
    0%, 100% { box-shadow: 0 0 0 0 rgba(20,154,161,0); }
    50% { box-shadow: 0 0 0 6px rgba(20,154,161,0.15); }
}

/* ---------- Smooth Dark Mode Transitions ---------- */
.sidebar,
.main-content,
.post-card,
.search-form,
.top-bar,
.site-footer,
.toggle-switch {
    transition-property: background-color, color, border-color;
    transition-duration: 0.4s;
}

/* ---------- Cursor Glow (Dark Mode) ---------- */
.cursor-glow {
    position: fixed;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(20,154,161,0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s;
}
[data-theme="dark"] .cursor-glow { opacity: 1; }

/* ---------- Scroll Reveal ---------- */
.scroll-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}
.scroll-reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Card Image Parallax ---------- */
.card-image {
    overflow: hidden;
}
.card-image img {
    will-change: transform;
}

/* ---------- Card Light Reflection (Dark Mode) ---------- */
.post-card:not(.has-image)::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.post-card:not(.has-image) { position: relative; }
.post-card:not(.has-image):hover::after { opacity: 1; }

/* ---------- Footer Reveal ---------- */
.site-footer {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.5s ease, transform 0.5s ease, background-color 0.4s, border-color 0.4s;
}
.site-footer.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ---------- Reading Time Bar ---------- */
.card-reading-bar {
    height: 2px;
    background: var(--border);
    margin-top: auto;
    opacity: 0.6;
    transition: opacity 0.3s;
}
.post-card:hover .card-reading-bar { opacity: 1; }
.card-reading-fill {
    height: 100%;
    background: var(--accent);
    min-width: 4px;
}

/* ---------- Shadow Depth ---------- */
.post-card { box-shadow: var(--shadow-sm); }
.sidebar { box-shadow: var(--shadow-md); }

/* ---------- Typography Polish ---------- */
.section-title { letter-spacing: -0.02em; }
.single-title { letter-spacing: -0.02em; }
.card-featured .card-title { letter-spacing: -0.02em; }

/* ---------- Search Typing Cursor ---------- */
.search-input.typing-active::placeholder {
    color: var(--accent);
    opacity: 0.6;
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .mobile-menu-btn, .sidebar-overlay, .top-bar, .content-tabs,
    .single-share, .pagination, .search-form, .site-footer,
    .reading-progress, .single-sidebar, .article-share-widget { display: none !important; }
    .main-content { margin-left: 0 !important; padding: 0 !important; }
    .app-layout { display: block; }
    .single-layout { grid-template-columns: 1fr !important; }
}
