/* 
  ==========================================================================
   HEXO THEME: CUSTOM PREMIUM (RE-BRANDED)
   TOTAL RECONSTRUCTION v2.0
  ========================================================================== 
*/

:root {
    /* 1. Color Palette (HSL for precision) */
    --p-h: 235;
    /* Primary Hue (Indigo) */
    --p-s: 75%;
    --p-l: 60%;

    --primary: hsl(var(--p-h), var(--p-s), var(--p-l));
    --primary-hover: hsl(var(--p-h), var(--p-s), calc(var(--p-l) - 10%));
    --primary-gradient: linear-gradient(135deg, hsl(235, 75%, 60%) 0%, hsl(280, 70%, 55%) 100%);

    --bg: #f8fafc;
    --surface: rgba(255, 255, 255, 0.85);
    --border: rgba(15, 23, 42, 0.08);

    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-white: #ffffff;

    /* 2. Glassmorphism Tokens */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --glass-blur: 12px;

    /* 3. Spacing & Shadows */
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.12);
    --shadow-nav: 0 4px 30px rgba(0, 0, 0, 0.03);

    /* 4. Layout Dimensions */
    --container: 1200px;
    --nav-h: 64px;

    /* 5. Fluid Typography */
    --fz-base: 16px;
    --h1: clamp(1.8rem, 8vw, 3.2rem);
    --h2: clamp(1.5rem, 6vw, 2.2rem);
    --h3: clamp(1.2rem, 4vw, 1.6rem);
}

[data-theme='dark'] {
    --bg: #0b0f1a;
    --surface: rgba(15, 23, 42, 0.85);
    --border: rgba(255, 255, 255, 0.08);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
}

/* --- 1. GLOBAL RESET --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: var(--fz-base);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: 'Outfit', 'Inter', -apple-system, system-ui, sans-serif;
    line-height: 1.8;
    letter-spacing: -0.011em;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

p {
    margin-bottom: 1.6rem;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -0.025em;
    scroll-margin-top: calc(var(--nav-h) + 20px);
    overflow-wrap: break-word;
}

img {
    max-width: 100%;
    display: block;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
    transition: all 0.3s ease;
}

/* --- 2. GRID ARCHITECTURE (Fluid 2-Column) --- */
.main-body {
    max-width: var(--container);
    margin: 0 auto;
    width: 100%;
    padding: 0 24px;
    display: grid;
    /* Redesigned to 2-column: Content (left/expand) + Sidebar (right) */
    grid-template-columns: 1fr 320px;
    grid-template-areas: "center right";
    gap: 32px;
    flex: 1;
    align-items: start;
}

.content {
    grid-area: center;
    min-width: 0;
}

.right-sidebar {
    grid-area: right;
}

@media (max-width: 1024px) {
    .main-body {
        grid-template-columns: 1fr;
        grid-template-areas:
            "center"
            "right";
        gap: 24px;
    }
}

/* --- 3. COMPONENTS --- */

/* Top Navigation Bar */
.top-bar {
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-nav);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
}

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

.nav-left {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Desktop Menu is now part of nav-right */
.nav-menu {
    display: flex;
    gap: 32px;
    align-items: center;
    margin-right: 24px;
}

.desktop-only {
    display: flex;
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1.5px;
    font-family: 'Outfit', sans-serif;
}

.nav-menu {
    display: flex;
    gap: 28px;
    align-items: center;
}

.nav-menu a {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-muted);
    position: relative;
    padding: 4px 0;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-gradient);
    transition: width 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    border-radius: 2px;
}

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

.nav-menu a:hover::after {
    width: 100%;
}

/* Nav Icons/Buttons */
.nav-btn,
.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    outline: none;
}

.nav-btn:hover,
.theme-toggle:hover {
    background: rgba(var(--p-h), var(--p-s), var(--p-l), 0.1);
    color: var(--primary);
    transform: translateY(-2px);
}

.mobile-only {
    display: none;
}

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

.main-footer {
    padding: 60px 24px;
    text-align: center;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
}

.footer-stats {
    margin-top: 12px;
    font-size: 0.85rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    opacity: 0.8;
}

.stat-sep {
    opacity: 0.3;
}

/* Hero Section */
.hero {
    width: 100%;
    padding: clamp(60px, 10vw, 120px) 24px;
    background: var(--primary-gradient);
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
    margin-bottom: 40px;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('https://www.transparenttextures.com/patterns/carbon-fibre.png') opacity(0.1);
}

.hero h1 {
    font-size: var(--h1);
    margin-bottom: 16px;
    position: relative;
    text-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.hero p {
    font-size: 1.2rem;
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

/* Post Container & Detail */
.post-detail {
    background: var(--surface);
    border: var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(24px, 5vw, 60px);
    box-shadow: var(--shadow-soft);
    min-width: 0;
    /* Critical for grid stability */
}

.post-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
}

.post-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

#busuanzi_container_page_pv,
#busuanzi_container_site_pv,
#busuanzi_container_site_uv,
.leancloud_visitors {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
}

.fa-fire {
    color: #ff4757;
}

.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
}

.post-content h2 {
    margin-top: 3.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    position: relative;
}

.post-content h2::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 60px;
    height: 2px;
    background: var(--primary);
}

/* Specific Content Block Fixes */
.post-content blockquote {
    margin: 3rem 0;
    padding: 1.5rem 2.5rem;
    background: var(--bg);
    border-left: 6px solid var(--primary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--text-muted);
}

.post-content table {
    width: 100%;
    margin: 3rem 0;
    border-collapse: collapse;
    display: block;
    overflow-x: auto;
}

.post-content th,
.post-content td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.post-content th {
    background: var(--bg);
    font-weight: 700;
}

/* Reward Section */
.post-reward {
    margin: 60px 0;
    padding: 32px;
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px dashed var(--primary);
    text-align: center;
}

.reward-btns {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 24px 0;
}

.reward-btn {
    padding: 10px 24px !important;
    border-radius: 30px !important;
    border: 1.5px solid var(--primary) !important;
    background: transparent !important;
    color: var(--primary) !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.reward-btn:hover {
    background: var(--primary-gradient) !important;
    color: white !important;
    border-color: transparent !important;
    box-shadow: 0 8px 15px rgba(var(--p-h), var(--p-s), var(--p-l), 0.2);
}

/* Comments */
.comments-section {
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid var(--border);
}

.comments-section h3 {
    margin-bottom: 32px;
}

#vcomments {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 24px;
    border: var(--border);
}

/* --- 4. ADVANCED COMPONENTS --- */

/* Code Blocks */
figure.highlight {
    background: #1e1e1e;
    color: #d4d4d4;
    border-radius: var(--radius-md);
    margin: 3rem 0;
    overflow: hidden;
    position: relative;
}

figure.highlight table {
    display: table;
    border: none;
    margin: 0;
}

figure.highlight .gutter {
    padding: 24px 16px;
    background: #1a1a1b;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    color: #4b5263;
    text-align: right;
    user-select: none;
}

figure.highlight .code {
    padding: 24px;
    width: 100%;
}

figure.highlight pre {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
}

.copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: transparent;
}

/* Search Modal */
.search-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.search-box {
    background: var(--surface);
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    border-radius: var(--radius-lg);
    padding: 32px;
    border: var(--glass-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-float);
    animation: searchFadeIn 0.3s ease-out;
}

@keyframes searchFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

#search-input {
    width: 100%;
    background: var(--bg);
    border: 2px solid var(--border);
    padding: 14px 20px;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.3s;
}

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

/* Mobile Drawer */
.mobile-menu-drawer {
    position: fixed;
    top: 0;
    left: -100%;
    width: 300px;
    height: 100%;
    background: var(--surface);
    backdrop-filter: blur(30px);
    z-index: 3000;
    transition: left 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    padding: 100px 32px;
    box-shadow: var(--shadow-float);
}

.mobile-menu-drawer.active {
    left: 0;
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2999;
    display: none;
}

.drawer-overlay.active {
    display: block;
}

/* Post Cards (Home Page) */
.post-card {
    background: var(--surface);
    border: var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-soft);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: slideUp 0.8s cubic-bezier(0.165, 0.84, 0.44, 1) backwards;
}

.post-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-float);
    border-color: var(--primary);
}

.post-category-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--primary-gradient);
    color: white;
    padding: 6px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 0 0 0 var(--radius-md);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.post-card-title {
    font-size: 1.6rem;
    margin: 0;
    line-height: 1.3;
}

.post-card-title a {
    color: var(--text-main);
    transition: color 0.3s;
}

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

.post-card-excerpt {
    color: var(--text-muted);
    line-height: 1.7;
    font-size: 1.05rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card-footer {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
}

.read-more-btn {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s;
}

.read-more-btn:hover {
    transform: translateX(5px);
}

.read-more-btn i {
    font-size: 0.8rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

article:nth-child(1) {
    animation-delay: 0.1s;
}

article:nth-child(2) {
    animation-delay: 0.2s;
}

article:nth-child(3) {
    animation-delay: 0.3s;
}

/* Widgets */
.warticle {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--radius-lg);
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    animation: slideUp 0.8s cubic-bezier(0.165, 0.84, 0.44, 1) backwards;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

article:nth-child(1) {
    animation-delay: 0.1s;
}

article:nth-child(2) {
    animation-delay: 0.2s;
}

article:nth-child(3) {
    animation-delay: 0.3s;
}

article:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-float);
}

.widget {
    background: var(--surface);
    border: var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-soft);
    animation: slideUp 0.6s ease-out backwards;
}

.toc-widget {
    position: sticky;
    top: calc(var(--nav-h) + 24px);
    z-index: 10;
    max-height: calc(100vh - var(--nav-h) - 80px);
    overflow-y: auto;
}

.toc-content {
    font-size: 0.9rem;
    position: relative;
    padding-left: 4px;
}

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

.toc-content .toc-item {
    margin-bottom: 8px;
}

.toc-content .toc-link {
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: block;
    line-height: 1.4;
    padding: 2px 0;
    border-left: 2px solid transparent;
    padding-left: 12px;
}

.toc-content .toc-link:hover,
.toc-content .toc-link.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(var(--p-h), var(--p-s), var(--p-l), 0.05);
}

.toc-content .toc-child {
    padding-left: 12px;
    list-style: none;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 20px;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.widget-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.widget-content ul {
    list-style: none;
}

.widget-content li {
    margin-bottom: 12px;
}

.widget-content a {
    color: var(--text-muted);
    font-size: 0.95rem;
    display: block;
}

.widget-content li:hover a {
    color: var(--primary);
    transform: translateX(5px);
}

/* --- 5. MOBILE OVERRIDES --- */
@media (max-width: 768px) {
    :root {
        --fz-base: 14px;
        --nav-h: 64px;
        --h1: 1.8rem;
    }

    .nav-container {
        padding: 0 16px;
    }

    .nav-menu {
        display: none;
    }

    .mobile-only {
        display: flex;
    }

    .main-body {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 0 12px;
    }

    .post-detail {
        padding: 24px 16px;
        border-radius: 0;
    }

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

    .reward-btns {
        flex-direction: column;
        width: 100%;
    }

    .reward-btn {
        width: 100% !important;
        margin: 0;
    }

    .search-box {
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 60px 20px;
    }

    /* Fix Live2D Overlap */
    #live2d-widget,
    .live2d-widget-container,
    #waifu {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 60px 16px;
    }

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