/* ==================== */
/* 全局樣式 */
/* ==================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: #0F4C28;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    font-family: system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
    font-size: 16px;
    line-height: 1.65;
}

.container {
    margin: 0 auto;
    width: 100%;
}

/* ==================== */
/* 動畫效果 */
/* ==================== */
/* 雪花飄落動畫 */
.snowflake {
    position: fixed;
    top: -10px;
    color: white;
    font-size: 1em;
    font-family: Arial, sans-serif;
    text-shadow: 0 0 5px #fff;
    pointer-events: none;
    z-index: 1;
    animation: fall linear infinite;
}

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(360deg);
        opacity: 0.3;
    }
}

/* ==================== */
/* 頭頂招牌 */
/* ==================== */
.header {
    text-align: center;
    background: #8B0000;
    padding: 30px 15px;
    color: #FFFFF0;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    overflow: hidden;
    position: relative;
    font-weight: bold;
}

.header::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            45deg,
            rgba(139, 94, 60, 0.1) 0px,
            rgba(139, 94, 60, 0.1) 2px,
            transparent 2px,
            transparent 4px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(166, 124, 82, 0.1) 0px,
            rgba(166, 124, 82, 0.1) 2px,
            transparent 2px,
            transparent 4px
        );
}

.header h1 {
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-size: 2.5rem;
    z-index: 2;
    position: relative;
}

.welcome-text {
    font-size: 1.1rem;
    color: #FFFFF0;
    margin: 10px 0;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    z-index: 2;
    position: relative;
}

/* ==================== */
/* 選單列 */
/* ==================== */
.menu {
    background-color: #165B33;
    padding: 15px;
    margin-bottom: 20px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.menu a {
    color: #FFFFF0;
    text-decoration: none;
    padding: 5px 10px;
    transition: all 0.3s ease;
    font-weight: bold;
    z-index: 2;
}

.menu a:hover, 
.menu a.active {
    color: #FFFFF0;
    background-color: #0F4C28;
    border-radius: 3px;
}

/* ==================== */
/* 文章列表 */
/* ==================== */
.content {
    max-width: 815px;
    padding: 0 15px;
    margin: 40px auto 0 auto;
    position: relative;
    z-index: 2;
}

.post-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.post-card {
    padding: 20px;
    background: white;
    border-radius: 10px;
    transition: transform 0.2s ease;
}

.post-title {
    color: #C41E3A;
    font-size: clamp(1.4rem, 3vw, 1.5rem);
    margin-bottom: 10px;
    padding-right: 44px; /* 預留右側空間給節慶圖示 */
    border-bottom: 2px solid #165B33;
    border-image: repeating-linear-gradient(
        90deg,
        #ff4d4d 0 10px,
        transparent 10px 14px,
        #ffd54f 14px 24px,
        transparent 24px 28px,
        #4caf50 28px 38px,
        transparent 38px 42px
    ) 1;
    padding-bottom: 5px;
    font-weight: bold;
    position: relative;
}

.post-title::after {
    content: "⛄";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.post-title a {
    color: inherit;
    text-decoration: none;
}

.post-title a:hover {
    color: inherit;
    text-decoration: underline;
}

.post-meta {
    font-size: 0.9rem;
    color: #8b5e3c;
    margin-bottom: 16px;
    font-weight: bold;
}

.post-content p {
    color: black;
    margin-top: 16px;
    line-height: 1.8;
}

.post-content a {
    color: blue;
    text-decoration: none;
}

.post-content a:focus,
.post-content a:hover {
    text-decoration: underline;
}

.post-content ul, 
.post-content ol {
    margin-top: 10px;
    padding-left: 30px;
    list-style-position: outside;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.post-content ul > li > ul, 
.post-content ol > li > ul {
    margin: 8px 0;
}

.post-content ul > li > p, 
.post-content ol > li > p {
    margin: 8px 0;
}

.blog-list li {
    margin-top: 10px;
}

.post-content img {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    padding: 6px;
    margin-top: 14px;
}

.post-content figure {
    margin: 1rem auto;
    text-align: center;
}

/* 標題樣式 */
.post-content h3 {
    margin: 1.2em 0 0.5em 0;
    color: #155a15;
    font-size: 1.3rem;
}

.post-content h4 {
    margin: 1.2em 0 0.4em 0;
    color: #155a15;
    font-size: 1.1rem;
}

/* 程式碼區塊 */
.post-content code {
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 3px 5px;
    font-family: monospace;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.post-content pre code {
    background-color: #fafafa;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 16px 0;
    font-family: "Fira Code", Consolas, monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    display: block;
    overflow-x: auto;
}

/* 引用區塊 */
.post-content blockquote {
    border-left: 4px solid #d4a276;
    padding-left: 1em;
    margin-left: 0;
}

/* 表格 */
.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    font-size: 0.95rem;
    background-color: #fffef9;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #d4a276;
    border-radius: 6px;
    overflow: hidden;
}

.post-content thead {
    background-color: #f7e7d3;
    color: #5B3C1E;
}

.post-content thead th {
    text-align: left;
    padding: 12px 16px;
    font-weight: bold;
    border-bottom: 1px solid #d4a276;
}

.post-content tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0e0cb;
    color: #333;
}

.post-content tbody tr:nth-child(even) {
    background-color: #fdf6ef;
}

.post-content tbody tr:hover {
    background-color: #f3e7d9;
}

/* 分隔線 */
.post-content hr {
    border: 0;
    height: 0;
    border-top: 2px dashed #d4a276;
    margin: 18px 0;
    opacity: 0.9;
}

/* ==================== */
/* 分頁（索引頁） */
/* ==================== */
.pagination {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.pagination a {
    color: #165B33;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 8px;
    background-color: white;
    border: 2px solid #165B33;
    font-weight: 600;
    transition: background-color 0.3s ease, color 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.pagination a:hover {
    background-color: #165B33;
    color: white;
    box-shadow: 0 4px 8px rgba(22, 91, 51, 0.3);
}

.pagination a.disabled {
    color: #999;
    background-color: #f5f5f5;
    border-color: #ddd;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
    opacity: 0.6;
}

/* ==================== */
/* 底部資訊 */
/* ==================== */
.footer {
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    font-weight: 500;
    background: linear-gradient(180deg, transparent 0%, rgba(15, 76, 40, 0.3) 100%);
    position: relative;
}

/* ==================== */
/* 搜尋功能樣式 */
/* ==================== */
.search-container {
    position: relative;
    margin-bottom: 0;
}

.search-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

#searchBox {
    flex: 1;
    min-width: 200px;
    max-width: 500px;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #d4a276;
    border-radius: 6px;
    background-color: white;
    color: #5B3C1E;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#searchBox:focus {
    border-color: #8b5e3c;
    box-shadow: 0 4px 8px rgba(139, 94, 60, 0.2);
    transform: translateY(-1px);
}

#searchBox:focus::placeholder {
    opacity: 0;
    transition: opacity 0.2s ease;
}

#searchBox::placeholder {
    color: #a67c52;
    font-style: italic;
    transition: opacity 0.2s ease;
}

#results {
    list-style: none;
    margin-top: 0;
    padding: 0;
}

#results:not(:empty) {
    margin-top: 20px;
}

#results li {
    background: white;
    margin-bottom: 12px;
    padding: 16px 20px;
    border-radius: 8px;
    border: 1px solid #e8d5c0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

#results li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(45deg, #8b5e3c, #a67c52);
}

#results li:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #d4a276;
}

#results li a {
    color: #5B3C1E;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 8px;
    transition: color 0.2s ease;
}

#results li a:hover {
    color: #8b5e3c;
    text-decoration: underline;
}

#results li p {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0;
}

#results li .result-date {
    color: #a67c52;
    font-size: 0.9rem;
    position: absolute;
    top: 16px;
    right: 20px;
    margin: 0;
    font-weight: bold;
}

#results li mark {
    background: linear-gradient(120deg, #ffeb3b 0%, #ffc107 100%);
    color: #5B3C1E;
    border-radius: 1px;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.search-empty {
    text-align: center;
    color: #8b5e3c;
    font-style: italic;
    padding: 40px 20px;
    background: #f9f5f0;
    border-radius: 8px;
    /*border: 2px dashed #d4a276;*/
}

.search-loading {
    text-align: center;
    color: #FFFFF0;
    padding: 20px;
    font-style: italic;
}

.search-stats {
    color: #FFFFF0;
    font-size: 0.9rem;
    margin-top: 0;
    text-align: center;
    font-style: italic;
    display: none;
}

.search-stats:not(:empty) {
    display: block;
    margin-top: 10px;
}

/* 搜尋建議樣式 */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d4a276;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
}

.search-suggestion {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0e0cb;
    transition: background-color 0.2s ease;
}

.search-suggestion:hover {
    background-color: #f7e7d3;
}

.search-suggestion:last-child {
    border-bottom: none;
}

/* ==================== */
/* 留言板樣式 */
/* ==================== */

/* 留言板表單 */
#guestbooks___guestbook-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 輸入框容器 */
.guestbooks___input-container,
#guestbooks___challenge-answer-container {
    display: flex;
    flex-direction: column;
}

/* 驗證碼容器間距 */
#guestbooks___challenge-answer-container {
    gap: 8px;
}

/* 所有輸入框和文字區域（共用樣式） */
#guestbooks___guestbook-form input,
#guestbooks___guestbook-form textarea,
#guestbooks___challenge-answer-container input {
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid #e0d5c7;
    border-radius: 6px;
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: inherit;
}

/* 文字區域行高 */
#guestbooks___guestbook-form textarea {
    line-height: 1.6;
}

/* 輸入框和文字區域焦點狀態 */
#guestbooks___guestbook-form input:focus,
#guestbooks___guestbook-form textarea:focus,
#guestbooks___challenge-answer-container input:focus {
    border: 2px solid #0F4C28;
}

/* 輸入框和文字區域佔位符文字 */
#guestbooks___guestbook-form input::placeholder,
#guestbooks___guestbook-form textarea::placeholder,
#guestbooks___challenge-answer-container input::placeholder {
    color: #7a6f5d;
    font-style: italic;
    opacity: 0.7;
    font-weight: bold;
}

/* 提交按鈕 */
#guestbooks___guestbook-form button[type="submit"] {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    background-color: #165B33;
    border: 2px solid #165B33;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-family: inherit;
}

/* 提交按鈕懸停狀態 */
#guestbooks___guestbook-form button[type="submit"]:hover {
    background-color: #0F4C28;
    border-color: #0F4C28;
}

/* 錯誤訊息 */
#guestbooks___error-message {
    color: #C41E3A;
    font-size: 0.9rem;
    margin-top: 8px;
    padding: 8px 12px;
    background-color: #fff5f5;
    border-left: 4px solid #C41E3A;
    border-radius: 4px;
    display: none;
}

/* 錯誤訊息顯示（當有內容時） */
#guestbooks___error-message:not(:empty) {
    display: block;
}

/* 留言標題 */
#guestbooks___guestbook-messages-header {
    color: #155a15;
    font-size: 1.3rem;
    font-weight: bold;
}

/* 留言容器 */
#guestbooks___guestbook-messages-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 20px;
}

/* 單則留言 */
#guestbooks___guestbook-messages-container .guestbook-message {
    padding: 16px 20px;
    background-color: #f9f5f0;
    border: 1px solid #0F4C28;
    border-left: 3px solid #155a15;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* 留言標題區塊（包含名稱和日期） */
#guestbooks___guestbook-messages-container .guestbook-message p {
    margin-bottom: 12px;
}

#guestbooks___guestbook-messages-container .guestbook-message p b {
    font-size: 0.9rem;
}

/* 留言者名稱連結 */
#guestbooks___guestbook-messages-container .guestbook-message p b a,
#guestbooks___guestbook-made-with a {
    color: #C41E3A;
}

/* 留言者名稱連結懸停狀態 */
#guestbooks___guestbook-messages-container .guestbook-message p b a:hover,
#guestbooks___guestbook-made-with a:hover {
    color: #8B0000;
}

/* 留言日期 */
#guestbooks___guestbook-messages-container .guestbook-message p small {
    color: #7a6f5d;
    font-size: 0.8rem;
}

/* 留言內容 */
#guestbooks___guestbook-messages-container .guestbook-message blockquote {
    line-height: 1.8;
    white-space: pre-wrap;
}

/* 回覆留言 */
#guestbooks___guestbook-messages-container .guestbook-message-reply {
    margin-left: 60px;
    margin-top: -20px;
    border-left: 3px solid #8B0000;
    border-top: none;
}

/* ==================== */
/* 響應式設計 */
/* ==================== */
@media (max-width: 600px) {
    .content {
        max-width: unset;
        margin: 0;
        padding: 0 8px;
        position: relative;
        z-index: 2;
    }

    .post-card {
        padding: 15px;
    }
}
