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

:root {
    --bg: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #555;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --card-bg: #f8f9fa;
    --border: #e2e8f0;
    --code-bg: #282c34;
    --tag-bg: #eff6ff;
    --tag-text: #3b82f6;
    --radius: 8px;
    --max-width: 800px;
    --nav-height: 60px;
    --transition: 0.3s ease;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
}

html.dark {
    --bg: #0f172a;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #60a5fa;
    --accent-hover: #93bbfd;
    --card-bg: #1e293b;
    --border: #334155;
    --code-bg: #1e293b;
    --tag-bg: #1e3a5f;
    --tag-text: #60a5fa;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.5);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    transition: background var(--transition), color var(--transition);
}

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

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

/* === Reading Progress Bar === */
#reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), #8b5cf6);
    z-index: 1000;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* === Back to Top === */
#back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: all var(--transition);
    z-index: 99;
}

#back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

#back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

/* === Header / Nav === */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.85);
}

html.dark .header {
    background: rgba(15, 23, 42, 0.85);
}

.nav-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 1.5rem;
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
}

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

.nav-menu {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
}

.nav-menu a {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition);
}

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

.theme-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: transform var(--transition);
}

.theme-toggle:hover {
    transform: rotate(30deg);
}

/* === Main === */
.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: calc(100vh - var(--nav-height) - 80px);
}

/* === Profile Section === */
.home-profile {
    text-align: center;
    padding: 3rem 0;
}

.profile-card {
    animation: fadeInUp 0.6s ease;
}

.profile-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.profile-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.typed-cursor {
    color: var(--accent);
    font-weight: 600;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.profile-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 500;
    transition: all var(--transition);
    font-size: 0.95rem;
}

.btn:hover {
    background: var(--accent-hover);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* === Recent Posts === */
.recent-posts {
    padding: 2rem 0;
}

.recent-posts h2 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.posts-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.post-card {
    padding: 1.5rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

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

.post-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

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

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

.post-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.post-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.post-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: var(--tag-bg);
    color: var(--tag-text);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

/* === Single Post === */
.post-single {
    animation: fadeIn 0.4s ease;
}

.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.post-title {
    font-size: 2rem;
    line-height: 1.3;
    margin-bottom: 0.75rem;
}

.breadcrumbs {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.breadcrumbs a {
    color: var(--text-secondary);
}

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

/* === TOC === */
.toc {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 2rem;
}

.toc summary {
    font-weight: 600;
    cursor: pointer;
    color: var(--text);
}

.toc nav {
    margin-top: 0.75rem;
}

.toc ul {
    list-style: none;
    padding-left: 1rem;
}

.toc li {
    margin: 0.3rem 0;
}

.toc a {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

/* === Post Content === */
.post-content {
    font-size: 1.05rem;
    line-height: 1.8;
}

.post-content h2 {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}

.post-content h3 {
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem;
}

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

.post-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.post-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    background: var(--card-bg);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--text-secondary);
}

.post-content code {
    background: var(--card-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: "JetBrains Mono", "Fira Code", monospace;
}

.post-content pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 1rem 0;
    position: relative;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: #abb2bf;
    font-size: 0.875rem;
}

.code-copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition);
}

.post-content pre:hover .code-copy-btn {
    opacity: 1;
}

.code-copy-btn:hover {
    background: rgba(255,255,255,0.2);
}

.post-content ul, .post-content ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.post-content li {
    margin: 0.3rem 0;
}

/* === Post Nav === */
.post-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    gap: 1rem;
}

.post-nav a {
    padding: 0.5rem 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    font-size: 0.9rem;
    max-width: 45%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.post-nav .next {
    margin-left: auto;
}

/* === About Page === */
.about-content {
    animation: fadeIn 0.4s ease;
}

.about-content h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.about-content h2 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    color: var(--accent);
}

.about-content p {
    margin-bottom: 1rem;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.skill-item {
    padding: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.9rem;
    transition: all var(--transition);
}

.skill-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* === Archives === */
.archives-list {
    list-style: none;
}

.archives-list li {
    display: flex;
    align-items: baseline;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.archives-list time {
    color: var(--text-secondary);
    font-size: 0.85rem;
    min-width: 100px;
    flex-shrink: 0;
}

.archives-list a {
    color: var(--text);
    font-weight: 500;
}

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

/* === Footer === */
.footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    text-align: center;
}

.footer-container {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a, .pagination span {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.pagination a:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination .current {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* === Search Overlay === */
#search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10vh;
}

#search-overlay.active {
    display: flex;
}

.search-container {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    box-shadow: var(--shadow-hover);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

#search-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.1rem;
    background: var(--card-bg);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition);
}

#search-input:focus {
    border-color: var(--accent);
}

#search-results {
    margin-top: 1.5rem;
    max-height: 50vh;
    overflow-y: auto;
}

.search-hint {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.search-empty {
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
}

.search-result-item {
    display: block;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: background var(--transition);
}

.search-result-item:hover {
    background: var(--card-bg);
}

.search-result-item h4 {
    margin-bottom: 0.3rem;
    color: var(--text);
}

.search-result-item p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.search-result-tags {
    font-size: 0.8rem;
    color: var(--tag-text);
}

/* === Animations === */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

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

/* === Shortcodes === */
.info-box {
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
    border-left: 4px solid;
}

.info-box.tip {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.info-box.warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
}

.info-box.danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

.info-box strong {
    display: block;
    margin-bottom: 0.5rem;
}

/* === Responsive === */
@media (max-width: 768px) {
    .profile-title { font-size: 1.5rem; }
    .post-title { font-size: 1.5rem; }
    .nav-menu { gap: 1rem; }
    .nav-menu a { font-size: 0.8rem; }
    .footer-container { flex-direction: column; gap: 0.5rem; }
    .post-nav { flex-direction: column; }
    .post-nav a { max-width: 100%; }
    #back-to-top { bottom: 1rem; right: 1rem; }
}
