/* 
Theme Name: Bear's Garland
Theme URI: https://www.zhukun.net/bears-garland
Author: Bear
Author URI: https://www.zhukun.net
Description: A Garland-inspired WordPress theme with modern features
Version: 1.0
License: GNU General Public License v2 or later
Text Domain: bears-garland
*/

/* CSS Variables */
:root {
    --gradient-dark: #156AA3;       /* 深蓝色 */
    --gradient-light: #7CC0EA;      /* 浅蓝色 */
    --page-background: #EDF5FA;     /* 页面背景色 */
    --text-color: #494949;          /* 文本色 */
    --meta-color: #898989;          /* 元信息文本色 */
    --link-color: #027AC6;          /* 链接色 */
    --link-hover: #0062A0;          /* 链接悬停色 */
    --border-color: #D2E6F3;        /* 边框颜色 */
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--page-background);
    background-image: linear-gradient(to right, rgba(0,0,0,0.05), rgba(0,0,0,0) 20%, rgba(0,0,0,0) 80%, rgba(0,0,0,0.05));
}

/* Typography */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover, a:focus {
    color: var(--link-hover);
    text-decoration: underline;
}

a:active {
    color: #144A75;
}

p {
    margin-bottom: 1.2em;
}

/* Layout */
.site-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 40px;
}

/* Header */
.site-header {
    background: var(--gradient-dark);
    background: linear-gradient(to bottom, var(--gradient-dark) 0%, var(--gradient-light) 100%);
    padding: 20px 0;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--gradient-dark);
}

.site-branding {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: left;
}

.site-title {
    margin: 0;
    font-size: 2.5em;
    font-weight: normal;
}

.site-title a {
    color: #fff;
    text-decoration: none;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.site-description {
    color: #fff;
    margin-top: 5px;
    opacity: 0.9;
}

/* Navigation */
.main-navigation {
    max-width: 1200px;
    margin: 20px auto 0;
    padding: 0 20px;
}

.main-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 2px;
}

.main-navigation li {
    position: relative;
}

.main-navigation a {
    color: #fff;
    text-decoration: none;
    padding: 8px 15px;
    display: block;
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
    transition: background 0.3s;
}

.main-navigation a:hover,
.main-navigation a:focus {
    background: rgba(0,0,0,0.2);
    text-decoration: none;
}

/* Sub-menu styles */
.main-navigation .menu-item-has-children > a::after {
    content: '▾';
    display: inline-block;
    margin-left: 5px;
    font-size: 0.8em;
    line-height: 1;
    transform: translateY(-1px); /* 微调垂直位置 */
}
.main-navigation .sub-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    min-width: 200px;
    z-index: 999;
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.main-navigation li:hover > .sub-menu {
    display: block;
}

.main-navigation .sub-menu li {
    width: 100%;
}

.main-navigation .sub-menu a {
    color: var(--text-color);
    background: transparent;
}

.main-navigation .sub-menu a:hover {
    background: var(--page-background);
    color: var(--gradient-dark);
}

.main-navigation .sub-menu li:last-child a {
    border-bottom-left-radius: 3px;
    border-bottom-right-radius: 3px;
}

/* Posts */
.post {
    background: #fff;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    overflow: hidden;
}

.entry-title {
    margin: 0 0 20px;
    color: var(--gradient-dark);
}

.entry-title a {
    color: var(--gradient-dark);
}

/* 文章内容样式 */
.entry-content {
    margin-bottom: 20px;
}

.entry-summary h1,
.entry-content h1 {
    font-size: 2.2em;
    margin: 1.2em 0 0.6em;
    color: var(--gradient-dark);
}

.entry-summary h2,
.entry-content h2 {
    font-size: 1.8em;
    margin: 1.1em 0 0.5em;
    color: var(--gradient-dark);
}

.entry-summary h3,
.entry-content h3 {
    font-size: 1.5em;
    margin: 1em 0 0.5em;
    color: var(--gradient-dark);
}

.entry-summary h4,
.entry-content h4 {
    font-size: 1.3em;
    margin: 0.9em 0 0.4em;
    color: var(--gradient-dark);
}

.entry-summary h5,
.entry-content h5 {
    font-size: 1.1em;
    margin: 0.8em 0 0.4em;
    color: var(--gradient-dark);
}

.entry-summary h6,
.entry-content h6 {
    font-size: 1em;
    margin: 0.7em 0 0.4em;
    color: var(--gradient-dark);
}

.entry-summary ul,
.entry-summary ol,
.entry-content ul,
.entry-content ol {
    margin: 0 0 1.5em 2em;
}

.entry-summary blockquote,
.entry-content blockquote {
    margin: 1.5em 0;
    padding: 1em 1.5em;
    border-left: 4px solid var(--gradient-dark);
    background: var(--page-background);
    font-style: italic;
}

.entry-summary code,
.entry-content code {
    background: #f4f4f4;
    padding: 2px 5px;
    border-radius: 3px;
    font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace;
    font-size: 0.9em;
}

.entry-summary pre,
.entry-summary div,
.entry-content pre,
.entry-content div {
    max-width: 100% !important;
    word-wrap: break-word;       /* 允许长单词或 URL 地址换行到下一行 */
    overflow-x: hidden;
}

.entry-summary pre,
.entry-content pre {
    background: #f4f4f4;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #ddd;
    margin: 1.5em 0;
    white-space: pre-wrap;       /* 保留空格换行，但文本会换行 */
    overflow-x: auto;            /* 如果内容过宽，显示水平滚动条 */
}

.entry-summary pre code,
.entry-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.entry-summary table,
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
    display: block;
    overflow-x: auto;
}

.entry-summary th,
.entry-summary td,
.entry-content th,
.entry-content td {
    border: 1px solid var(--border-color);
    padding: 8px;
    text-align: left;
}

.entry-summary th,
.entry-content th {
    background: var(--page-background);
}

.entry-summary img,
.entry-content img {
    max-width: 100%;
    height: auto;
    margin: 1.5em 0;
}

.entry-summary figure,
.entry-content figure {
    margin: 1.5em 0;
}

.entry-summary figcaption,
.entry-content figcaption {
    text-align: center;
    font-size: 0.9em;
    color: var(--meta-color);
}

.entry-meta {
    color: var(--meta-color);
    font-size: 0.9em;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.post-password-form input[type="password"] {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    margin-left: 5px;
    margin-right: 10px;
}

.post-password-form input[type="submit"] {
    background: var(--gradient-dark);
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 3px;
    cursor: pointer;
}

.post-password-form input[type="submit"]:hover {
    background: var(--link-hover);
}

.comments-link::before {
    content: '💬';
    margin-right: 5px;
}

.tags-links {
    margin-left: 5px;
}

/* Sidebar */
.sidebar {
    background: #fff;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.widget {
    margin-bottom: 30px;
}

.widget:last-child {
    margin-bottom: 0;
}

.widget-title {
    color: var(--gradient-dark);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.widget ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.widget li {
    padding: 5px 0;
    border-bottom: 1px solid var(--border-color);
}

.widget li:last-child {
    border-bottom: none;
}

/* Search Form (Global) */
.search-form {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.search-field {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    font-size: 0.9em;
    transition: border-color 0.3s;
}

.search-field:focus {
    outline: none;
    border-color: var(--gradient-dark);
}

.search-submit {
    white-space: nowrap;
    background: var(--gradient-dark);
    color: #fff;
    border: none;
    padding: 8px 12px;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.3s;
}

.search-submit:hover {
    background: var(--link-hover);
}

/* Comments */
.comments-area {
    background: #fff;
    padding: 30px;
    margin-top: 30px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.comment-reply-title {
    margin-top: 0;
    color: var(--gradient-dark);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.commentlist {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: none;
}

.commentlist > .comment {
    list-style-type: none;
}

.comment {
    margin: 20px 0;
    padding: 20px;
    background: var(--page-background);
    /* border-radius: 5px; */
    border-bottom: 2px solid var(--border-color);
}

.comment:last-child {
    border-bottom: none;
}

/* Nested Comments */
.comment .children {
    margin-left: 30px;
    list-style: none;
}

.comment .children .comment {
    background: #fff;
    border-left: 2px solid var(--gradient-dark);
}

.comment .children .children .comment {
    background: var(--page-background);
    border-left: 2px solid var(--gradient-light);
}

.comment .children .children .children .comment {
    background: #fff;
    border-left: 2px solid var(--border-color);
}

.comment-meta {
    margin-bottom: 10px;
    font-size: 0.9em;
    color: var(--meta-color);
}

.comment-author .avatar {
    float: left;
    margin-right: 10px;
    border-radius: 50%;
}

.comment-author .fn {
    font-style: normal;
    font-weight: bold;
    color: var(--gradient-dark);
}

.comment-metadata {
    font-size: 0.8em;
}

.comment-content {
    clear: both;
    padding-top: 10px;
}

.comment-form label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-color);
}

.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.comment-form input[type="submit"] {
    background: var(--gradient-dark);
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.comment-form input[type="submit"]:hover {
    background: var(--link-hover);
}

.comment-form .comment-form-cookies-consent label {
    display: inline;
}

.comment-notes {
    font-size: 0.9em;
    color: var(--meta-color);
    margin-bottom: 15px;
}

.logged-in-as {
    font-size: 0.9em;
    margin-bottom: 15px;
}

/* Post Navigation */
.post-navigation {
    margin: 30px 0;
    padding: 20px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.nav-links {
    display: flex;
    justify-content: space-between;
}

.nav-previous,
.nav-next {
    flex: 0 0 48%;
}

.nav-previous {
    text-align: left;
}

.nav-next {
    text-align: right;
}

.nav-subtitle {
    display: block;
    font-size: 0.8em;
    color: var(--meta-color);
    margin-bottom: 5px;
}

.nav-title {
    font-size: 1.1em;
    color: var(--gradient-dark);
}

/* Page Navigation */
.pagination {
    position: relative;
    margin: 30px 0;
    text-align: center;
    min-height: 40px;
}

.pagination .nav-links {
    display: inline-block;
    padding: 0 60px;
}

.page-numbers {
    display: inline-block;
    padding: 5px 10px;
    margin: 0 2px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
    min-width: 30px;
    text-align: center;
}

.page-numbers.current {
    background: var(--gradient-dark);
    color: #fff;
    border-color: var(--gradient-dark);
}

.page-numbers.prev,
.page-numbers.next {
    position: absolute;
    top: 0;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 3px;
}

.page-numbers.prev {
    left: 0;
}

.page-numbers.next {
    right: 0;
}

/* Footer */
.site-footer {
    background: #fff;
    padding: 20px;
    text-align: center;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

.site-info {
    color: var(--meta-color);
    font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .site-container {
        grid-template-columns: 1fr;
    }
    
    .site-header {
        padding: 15px 0;
    }
    
    .site-title {
        font-size: 2em;
    }
    
    .main-navigation ul {
        flex-direction: column;
    }
    
    .main-navigation li {
        width: 100%;
    }
    
    .main-navigation a {
        padding: 10px 15px;
    }

    /* Sub-menu styles */
    .main-navigation .menu-item-has-children > a::after {
        content: '▾';
        display: inline-block;
        margin-left: 5px;
        font-size: 0.8em;
        line-height: 1;
        transform: translateY(-1px); /* 微调垂直位置 */
    }
    .main-navigation .sub-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        background: #fff;
        border: 1px solid var(--border-color);
        min-width: 200px;
        z-index: 999;
        border-radius: 3px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    }

    .main-navigation li:hover > .sub-menu {
        display: block;
    }

    .main-navigation .sub-menu li {
        width: 100%;
    }

    .main-navigation .sub-menu a {
        color: var(--text-color);
        background: transparent;
    }

    .main-navigation .sub-menu a:hover {
        background: var(--page-background);
        color: var(--gradient-dark);
    }

    .main-navigation .sub-menu li:last-child a {
        border-bottom-left-radius: 3px;
        border-bottom-right-radius: 3px;
    }
    
    .post {
        padding: 20px;
    }
    
    .entry-title {
        font-size: 1.5em;
    }

    .nav-links {
        flex-direction: column;
        gap: 20px;
    }

    .nav-previous,
    .nav-next {
        flex: 0 0 100%;
        text-align: center;
    }

    .comment .children {
        margin-left: 15px;
    }

    .pagination {
        text-align: center;
        margin: 30px 0;
    }

    .pagination .nav-links {
        padding: 40px 0 0;
    }

    .page-numbers.prev,
    .page-numbers.next {
        top: 0;
        left: 50%;
        transform: translateX(-50%);
    }

    .page-numbers.next {
        top: auto;
        bottom: 0;
    }
}

/* Accessibility */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}