/* ------------------------------------
 * Theme Name: Candy ACG
 * Description: A modern, flat, candy-colored theme for ACG sites.
 * Author: Kilo Code
 * Version: 1.0
 * --------------------------------- */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&family=Quicksand:wght@500;700&display=swap');

:root {
    --primary-color: #A0CFFF;      /* 糖果蓝 */
    --primary-dark: #76B4F5;
    --secondary-color: #B39DDB;    /* 糖果紫 */
    --accent-color: #FFB7C5;       /* 樱花粉 */
    --bg-color: #F3F6FD;           /* 浅淡背景 */
    --card-bg: #FFFFFF;
    --text-main: #555555;
    --text-light: #888888;
    --border-color: #EFEFEF;
    --radius-lg: 16px;
    --radius-sm: 8px;
    --shadow-sm: 0 2px 8px rgba(160, 207, 255, 0.1);
    --shadow-md: 0 4px 16px rgba(160, 207, 255, 0.2);
    --sidebar-width: 280px;
    --header-height: 70px;
}

/* Base */
* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Quicksand', 'Noto Sans SC', sans-serif;
    font-size: 15px;
    line-height: 1.7;
    margin: 0;
    padding-top: var(--header-height);
}

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

/* Layout System */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 15px;
}

.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -15px;
}

/* Header */
#header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
}

#header .container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    font-family: 'Quicksand', sans-serif;
}

#logo img {
    max-height: 40px;
    vertical-align: middle;
}

/* Nav */
#nav-menu {
    display: flex;
    gap: 20px;
}

#nav-menu a {
    color: var(--text-main);
    font-weight: 500;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
}

#nav-menu a:hover, #nav-menu a.current {
    color: var(--primary-dark);
    background: rgba(160, 207, 255, 0.1);
}

/* Main Layout Structure */
#body {
    padding: 30px 0;
}

.main-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
    transition: gap 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

body.sidebar-desktop-closed .main-layout {
    gap: 0;
}

/* Sidebar (Left Side) */
#secondary {
    width: var(--sidebar-width);
    flex-shrink: 0;
    order: -1;
    position: static;
    transform: none;
    /* Animate width, padding and opacity for a smooth collapse */
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.3s ease-out;
    overflow: hidden; /* Contain children during animation */
}

/* Main Content */
#main {
    flex-grow: 1;
    min-width: 0; /* Prevents overflow in flex containers */
}

/* --- Desktop Sidebar --- */
body.sidebar-desktop-closed #secondary {
    width: 0;
    padding-left: 0;
    padding-right: 0;
    opacity: 0;
    /* Use visibility to remove from accessibility tree when hidden */
    visibility: hidden;
}

/* Posts */
.post {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    gap: 20px;
    overflow: hidden;
}

.post:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.post-thumb {
    width: 220px;
    height: 160px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    position: relative;
}

.post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.post:hover .post-thumb img {
    transform: scale(1.1);
}

.post-article {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.post-title {
    margin: 0 0 10px;
    font-size: 20px;
}

.post-title a {
    color: var(--text-main);
}

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

.post-meta {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.post-meta li {
    display: inline-block;
    margin-right: 15px;
}

.post-content {
    color: var(--text-main);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.post-footer {
    margin-top: auto;
    text-align: right;
}

.btn-readmore {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 20px;
    font-size: 12px;
    transition: background 0.3s;
}

.btn-readmore:hover {
    background: var(--primary-dark);
    color: #fff;
}

/* Post Layout without Thumbnail */
.post.no-thumb .post-thumb {
    display: none;
}

/* Widget */
.widget {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 25px;
}

.widget-title {
    margin: 0 0 15px;
    font-size: 16px;
    color: var(--text-main);
    border-left: 4px solid var(--primary-color);
    padding-left: 10px;
}

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

.widget-list li {
    margin-bottom: 10px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 10px;
}

.widget-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Search Widget */
.widget-search input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.3s;
}

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

/* Footer */
#footer {
    background: #fff;
    padding: 40px 0;
    text-align: center;
    color: var(--text-light);
    margin-top: 40px;
}

/* Responsive */
/* --- Mobile Sidebar --- */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

@media (max-width: 992px) {
    .main-layout {
        flex-direction: column;
    }

    #main {
        width: 100% !important; /* Override desktop width */
    }
    
    #secondary {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: var(--sidebar-width);
        max-width: 80%;
        background: var(--card-bg);
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 0 20px rgba(0,0,0,0.1);
        padding: 20px;
        overflow-y: auto;
        order: 0; /* Reset order */
    }

    body.sidebar-mobile-open #secondary {
        transform: translateX(0);
    }

    body.sidebar-mobile-open #sidebar-overlay {
        display: block;
    }
    
    .post {
        flex-direction: column;
    }
    
    .post-thumb {
        width: 100%;
        height: 200px;
        margin-bottom: 15px;
    }
}

/* Toggle Button */
#sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-main);
    margin-right: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* 404 Page Style */
.main-404 {
    width: 100%;
    max-width: 600px;
    margin: 40px auto;
    text-align: center;
}

.main-404 .post-article {
    padding: 40px;
}

.main-404 .submit {
    margin-right: 10px;
}

/* Comments Style */
#comments {
    margin-top: 30px;
    padding: 30px;
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

#comments h3 {
    margin-bottom: 20px;
    font-size: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.comment-list {
    list-style: none;
    padding: 0;
}

.comment-list li {
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
}

.comment-list li:last-child {
    margin-bottom: 0;
}

.comment-author {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.comment-author .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 15px;
}

.comment-author .fn {
    font-weight: bold;
    font-style: normal;
}

.comment-meta {
    font-size: 12px;
    color: #999;
    margin-left: auto;
}

.comment-content {
    margin-left: 55px;
    font-size: 15px;
    line-height: 1.7;
}

.comment-reply {
    margin-left: 55px;
    margin-top: 10px;
}

.comment-reply a {
    font-size: 13px;
    color: var(--secondary-color);
    text-decoration: none;
}
.comment-reply a:hover {
    color: var(--accent-color);
}

/* Comment Form */
.respond {
    margin-top: 30px;
}

#comment-form p {
    margin-bottom: 15px;
}

#comment-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#comment-form .text,
#comment-form .textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    background-color: #f9f9f9;
    transition: border-color .3s;
}

#comment-form .text:focus,
#comment-form .textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

#comment-form .submit {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    background-color: var(--primary-color);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background-color .3s;
}

#comment-form .submit:hover {
    background-color: var(--secondary-color);
}

/* Fix for single post content truncation */
main > article.post .post-content {
    display: block;
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: visible;
}


/* Comment Content Truncation */
.comment-content.truncated {
    max-height: 250px; /* Approximately 10 lines */
    overflow: hidden;
    position: relative;
    transition: max-height 0.5s ease-in-out;
}

.comment-toggle-button {
    display: inline-block;
    margin-top: 10px;
    padding: 4px 12px;
    background: var(--primary-color);
    color: #fff;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    border: none;
    transition: background 0.3s;
}

.comment-toggle-button:hover {
    background: var(--primary-dark);
    color: #fff;
}
