:root {
    --primary-color: #89C2FF; /* 主色調藍色 */
    --secondary-color: #A2D2FF; /* 飽和度較高的藍色 */
    --accent-color: #BDE0FE; /* 輔助淺藍色 */
    --light-bg: #FAF7F2; /* 米白色 */
    --white: #FFFFFF;
    --text-dark: #3A4A5C; /* 深藍灰色文字 */
    --text-light: #6B7A8A; /* 淺藍灰色文字 */
    --shadow: 0 4px 15px rgba(162, 210, 255, 0.15);
    --shadow-hover: 0 8px 25px rgba(162, 210, 255, 0.25);
    --border-color: #D6E8FF; /* 淺藍色邊框 */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka', 'Poppins', sans-serif;
    background: var(--light-bg);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* ========== LOADER ========== */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--light-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    gap: 1rem;
}

.spinner {
    border: 6px solid var(--accent-color);
    border-top-color: var(--secondary-color);
    border-right-color: var(--secondary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1.5s linear infinite;
}

.loader p {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
    animation: bounce 2s infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* ========== HEADER ========== */
header {
    background: var(--primary-color);
    color: var(--white);
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.header-content .logo-text {
    color: var(--white);
}

.header-content {
    position: relative;
    z-index: 1;
}

.logo {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
}

.tagline {
    font-size: 0.95rem;
    opacity: 0.85;
    font-weight: 400;
    letter-spacing: 0.5px;
    color: var(--white);
}

/* ========== HERO ========== */
.hero {
    background-color: #FFFFFF;
    padding: 4rem 1rem;
    text-align: center;
    border-bottom: 2px dashed var(--border-color);
}

.hero-content h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    animation: slideDown 0.8s ease-out;
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

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

.search-container {
    display: flex;
    justify-content: center;
    gap: 0;
    margin: 0 auto;
    max-width: 500px;
}

.search-container input {
    flex: 1;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 20px 0 0 20px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--white);
    color: var(--text-dark);
    transition: all 0.3s ease;
}

.search-container input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(162, 210, 255, 0.5);
}

.search-container button {
    padding: 1rem 1.8rem;
    border: none;
    background: var(--secondary-color);
    color: var(--white);
    cursor: pointer;
    border-radius: 0 20px 20px 0;
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.search-container button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(189, 224, 254, 0.6);
}

.search-container button:active {
    transform: scale(0.95);
}

/* ========== MAIN CONTENT ========== */
.content {
    display: flex;
    padding: 3rem 1rem;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* ========== SIDEBAR ========== */
.categories {
    flex-basis: 25%;
    background: var(--white);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    height: fit-content;
    border: 2px solid var(--border-color);
    animation: slideIn 0.6s ease-out;
}

.categories h2 {
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.categories ul {
    list-style: none;
}

.categories li {
    margin-bottom: 0.5rem;
}

.categories a {
    text-decoration: none;
    color: var(--text-dark);
    display: block;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.categories a:hover {
    background: var(--light-bg);
    color: var(--primary-color);
    transform: translateX(5px);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========== ARTICLES ========== */
.latest-articles {
    flex-basis: 75%;
    animation: slideIn 0.6s ease-out 0.1s both;
}

.latest-articles h2 {
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
    font-size: 1.3rem;
}

.article-card {
    background: var(--white);
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    animation: fadeIn 0.6s ease-out forwards;
    overflow: hidden; /* Ensure cover image corners are rounded */
    display: flex;
    flex-direction: column;
}

.article-link {
    text-decoration: none;
    color: inherit;
}

.article-cover {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}

.article-preview-content {
    padding: 2rem;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--border-color);
}

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

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.article-tag {
    background: var(--primary-color);
    color: var(--white);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
}

.article-date {
    color: var(--text-light);
    font-size: 0.9rem;
}

.article-card h3 {
    color: var(--secondary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.article-card p {
    color: var(--text-light); /* This was a duplicate, but it's fine */
    line-height: 1.7;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* ========== ARTICLE ACTIONS ========== */
.article-actions {
    display: flex;
    padding: 0 2rem 2rem 2rem;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.article-actions button {
    padding: 0.7rem 1.2rem;
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.like-btn {
    background: transparent;
    color: var(--secondary-color);
}

.like-btn:hover {
    background: #EBF4FF; /* 非常淡的藍色 */
    color: var(--secondary-color);
    transform: scale(1.05);
}

.like-btn.liked {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
}

.share-btn {
    background: transparent;
    color: var(--secondary-color);
}

.share-btn:hover {
    background: var(--secondary-color);
    color: var(--white);
    border-color: var(--secondary-color);
}

.comment-btn {
    background: transparent;
    color: var(--secondary-color);
}

.comment-btn:hover {
    background: var(--secondary-color);
    color: var(--white);
    border-color: var(--secondary-color);
}

/* ========== FEATURED SECTION ========== */
.featured {
    background: #FFFFFF;
    padding: 3rem 1rem;
    text-align: center;
    border-top: 2px dashed var(--border-color);
    border-bottom: 2px dashed var(--border-color);
}

.featured h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 2rem;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.featured-card {
    background: var(--white);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
    transition: all 0.3s ease;
}

.featured-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.featured-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: spin 4s linear infinite;
}

.featured-card h3 {
    color: var(--secondary-color);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.featured-card p {
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ========== FOOTER ========== */
footer {
    background: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

.footer-content p {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

/* ========== ARTICLE PAGE ========== */
.article-page {
    max-width: 1000px;
    margin: 3rem auto;
    padding: 0 1rem;
}

.full-article {
    background: var(--white);
    padding: 3rem;
    border-radius: 20px;
    box-shadow: var(--shadow);
    animation: fadeIn 0.6s ease-out;
}

.back-to-home { /* 美化後的回到首頁按鈕 */
    display: inline-block;
    margin-bottom: 1.5rem;
    padding: 0.6rem 1.2rem;
    background-color: var(--light-bg);
    border: 2px solid var(--border-color);
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    border-radius: 50px;
    transition: all 0.3s ease;
}

.back-to-home:hover {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: var(--white);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.full-article-header {
    text-align: center;
    padding: 3rem 2rem;
    margin: -3rem -3rem 2rem -3rem; /* 抵銷父層的 padding，讓背景填滿 */
    border-radius: 20px 20px 0 0;
    background: var(--secondary-color); /* 加上藍紫色背景 */
    color: var(--white);
}

.full-article-header h1 {
    font-size: 2.8rem;
    color: var(--white); /* 改為白色 */
    font-weight: 700; /* 加上粗體 */
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

.full-article-header .subtitle {
    font-size: 1.3rem;
    color: var(--white);
    opacity: 0.85;
    margin-bottom: 1.5rem;
}

.article-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.9rem;    
    color: var(--white);
    opacity: 0.8;
}

.image-gallery-container {
    margin-bottom: 2.5rem;
}

.image-gallery {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 1rem; /* For scrollbar */
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
}

.image-gallery.grabbing {
    cursor: grabbing;
}

.image-gallery::-webkit-scrollbar {
    height: 8px;
}

.image-gallery::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.image-gallery::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 10px;
}

.image-gallery::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.image-gallery img {
    flex: 0 0 calc(33.333% - 0.666rem); /* Show 3 on desktop */
    width: calc(33.333% - 0.666rem);
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 15px;
    scroll-snap-align: start;
}

.article-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--text-dark);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .content {
        flex-direction: column;
    }

    .categories {
        flex-basis: 100%;
    }

    .latest-articles {
        flex-basis: 100%;
    }

    .hero-content h1 {
        font-size: 1.8rem;
    }

    .search-container {
        flex-direction: column;
        gap: 0.8rem; /* 在手機版為搜尋框和按鈕增加間距 */
    }

    .search-container input {
        border-radius: 20px;
    }

    .search-container button {
        border-radius: 20px;
    }

    .logo {
        font-size: 1.5rem;
    }

    .article-actions {
        flex-direction: column;
    }

    .article-actions button {
        width: 100%;
    }

    .full-article {
        padding: 1.5rem;
    }

    .full-article-header h1 {
        font-size: 2rem;
    }

    .image-gallery img {
        flex: 0 0 90%; /* Show 1 on mobile */
        width: 90%;
    }
}

/* ========== FLOATING ACTION BUTTON (FAB) ========== */
.fab-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 1000;
}

.fab-main-button {
    width: 60px;
    height: 60px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--white);
    font-size: 2rem;
    font-weight: 300;
    cursor: pointer;
    line-height: 55px; /* 微調 line-height 來達成視覺置中 */
    box-shadow: var(--shadow-hover);
    transition: transform 0.3s ease;
}

.fab-container.active .fab-main-button {
    transform: rotate(45deg);
}

.fab-options {
    position: absolute;
    bottom: 70px; /* Position above the main button */
    right: 5px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.fab-container.active .fab-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.fab-option {
    width: 50px;
    height: 50px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.fab-option:hover {
    background-color: var(--primary-color);
    transform: scale(1.1);
}

/* ========== LIGHTBOX ========== */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100000;
    animation: lightboxFadeIn 0.3s ease-out forwards;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    object-fit: contain;
    transform: scale(0.95);
    animation: lightboxZoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    user-select: none;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 25px;
    color: white;
    font-size: 3rem;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.8;
}

.lightbox-close:hover {
    transform: scale(1.1);
    opacity: 1;
}

.lightbox-overlay.leaving {
    animation: lightboxFadeOut 0.3s ease-in forwards;
}

.lightbox-overlay.leaving .lightbox-image {
    animation: lightboxZoomOut 0.3s ease-in forwards;
}

@keyframes lightboxZoomIn {
    to { transform: scale(1); }
}

@keyframes lightboxZoomOut {
    from { transform: scale(1); }
    to { transform: scale(0.9); }
}

@keyframes lightboxFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes lightboxFadeOut {
    to { opacity: 0; }
}
