/* ========== 全局重置與基礎 ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #e74c3c;
    --primary-dark: #c0392b;
    --accent: #f39c12;
    --accent-light: #ffeaa7;
    --bg: #fdf6f0;
    --bg-card: #ffffff;
    --text: #2d3436;
    --text-light: #636e72;
    --text-muted: #b2bec3;
    --border: #f0e6dd;
    --shadow: 0 2px 16px rgba(0,0,0,0.06);
    --shadow-hover: 0 6px 24px rgba(231,76,60,0.12);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    font-family: inherit;
}

/* ========== Header ========== */
.site-header {
    background: linear-gradient(135deg, var(--primary) 0%, #e25555 50%, var(--accent) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 20px rgba(231,76,60,0.25);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    filter: brightness(10);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 2px;
}

.logo-sub {
    font-size: 0.75rem;
    opacity: 0.85;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 4px;
}

.main-nav {
    display: flex;
    gap: 6px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    color: rgba(255,255,255,0.85);
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.btn-post {
    background: #fff;
    color: var(--primary);
    padding: 8px 20px;
    border-radius: 24px;
    font-weight: 700;
    font-size: 0.9rem;
    transition: var(--transition);
}

.btn-post:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ========== Category Bar ========== */
.category-bar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 68px;
    z-index: 90;
}

.category-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
}

.category-inner::-webkit-scrollbar {
    display: none;
}

.cat-tag {
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--bg);
    color: var(--text-light);
    border: 1px solid var(--border);
    white-space: nowrap;
    transition: var(--transition);
}

.cat-tag:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cat-tag.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ========== Posts Container ========== */
.posts-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 24px;
}

/* ========== Post Card ========== */
.post-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    animation: fadeInUp 0.5s ease both;
}

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

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

.post-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.post-body {
    padding: 18px 20px 14px;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.post-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-light);
}

.post-user-info {
    flex: 1;
}

.post-username {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
}

.post-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.post-cat-badge {
    font-size: 0.7rem;
    padding: 2px 10px;
    border-radius: 12px;
    background: var(--accent-light);
    color: #e17055;
    font-weight: 600;
}

.post-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
    line-height: 1.4;
}

.post-content {
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.65;
    margin-bottom: 10px;
}

.post-location {
    font-size: 0.78rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.post-location i {
    margin-right: 4px;
}

/* 互動按鈕列 */
.post-actions {
    display: flex;
    gap: 4px;
    padding: 10px 0;
    border-top: 1px solid var(--border);
}

.action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 0;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    color: var(--text-light);
    background: none;
    transition: var(--transition);
}

.action-btn:hover {
    background: var(--bg);
    color: var(--primary);
}

.action-btn.liked {
    color: var(--primary);
    font-weight: 600;
}

.action-btn .count {
    font-weight: 600;
}

/* ========== 評論區 ========== */
.comments-section {
    padding: 0 20px 16px;
    display: none;
}

.comments-section.open {
    display: block;
}

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

.comment-item {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    animation: fadeIn 0.3s ease;
}

.comment-item:last-child {
    border-bottom: none;
}

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

.comment-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.comment-body {
    flex: 1;
}

.comment-user {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--text);
}

.comment-text {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 2px;
    line-height: 1.5;
}

.comment-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
}

/* 評論輸入 */
.comment-input-row {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.comment-input-row input {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.82rem;
    outline: none;
    font-family: inherit;
    transition: var(--transition);
}

.comment-input-row input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

.comment-input-row button {
    padding: 8px 16px;
    border-radius: 20px;
    background: var(--primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    transition: var(--transition);
}

.comment-input-row button:hover {
    background: var(--primary-dark);
}

/* ========== 帖子詳情頁 ========== */
.detail-mode {
    display: block !important;
    max-width: 800px;
}

.post-detail-container {
    animation: fadeIn 0.4s ease;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 20px;
    transition: var(--transition);
}

.btn-back:hover {
    color: var(--primary);
    transform: translateX(-4px);
}

.post-detail-card {
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
}

.post-detail-image {
    width: 100%;
    height: auto;
    max-height: 450px;
    object-fit: cover;
    display: block;
}

/* ========== Modal ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    width: 90%;
    max-width: 520px;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    animation: modalIn 0.3s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--primary);
    color: #fff;
}

#postForm input,
#postForm textarea,
#postForm select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    margin-bottom: 12px;
    outline: none;
    transition: var(--transition);
    background: var(--bg);
}

#postForm input:focus,
#postForm textarea:focus,
#postForm select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(231,76,60,0.1);
}

#postForm textarea {
    resize: vertical;
    min-height: 80px;
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row select,
.form-row input {
    flex: 1;
}

.btn-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231,76,60,0.3);
}

/* ========== Footer ========== */
.site-footer {
    background: var(--text);
    color: rgba(255,255,255,0.7);
    padding: 28px 24px;
    text-align: center;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-inner p {
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.5);
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--accent);
}

/* ========== 響應式 ========== */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 8px;
    }

    .main-nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .nav-link {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .posts-container {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }

    .logo-sub {
        display: none;
    }
}

/* ========== 滾動條美化 ========== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
