/* ============================================================
   旅行足迹地图 - 样式表
   含 4 套配色方案: dark / calm / vivid / vintage
   通过 <html data-theme="..."> 切换
   ============================================================ */

/* ---------- 字体 ---------- */
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Space+Grotesk:wght@400;500;700&display=swap');

/* ---------- 主题变量 ---------- */
:root,
[data-theme="dark"] {
    --bg:           #0d1117;
    --bg-soft:      #161b22;
    --bg-elev:      #1c2330;
    --panel:        rgba(22, 27, 34, 0.85);
    --border:       #2d333b;
    --text:         #e6edf3;
    --text-soft:    #9aa6b2;
    --text-dim:     #6b7681;
    --accent:       #58a6ff;
    --accent-2:     #d2a8ff;
    --gold:         #e3b341;
    --shadow:       0 8px 30px rgba(0, 0, 0, 0.5);
    --map-filter:   none;
    --grain-opacity: 0.04;
}

[data-theme="calm"] {
    --bg:           #f5f2ec;
    --bg-soft:      #fbf9f4;
    --bg-elev:      #ffffff;
    --panel:        rgba(255, 255, 255, 0.9);
    --border:       #e2dccf;
    --text:         #2e2a24;
    --text-soft:    #6b6357;
    --text-dim:     #9c9484;
    --accent:       #7a8b6f;
    --accent-2:     #b08968;
    --gold:         #c79a3f;
    --shadow:       0 8px 30px rgba(120, 110, 90, 0.15);
    --map-filter:   saturate(0.85) brightness(1.02);
    --grain-opacity: 0.03;
}

[data-theme="vivid"] {
    --bg:           #0a0e27;
    --bg-soft:      #141a3a;
    --bg-elev:      #1d2548;
    --panel:        rgba(20, 26, 58, 0.88);
    --border:       #2c3563;
    --text:         #f0f3ff;
    --text-soft:    #a8b2e0;
    --text-dim:     #6b76a8;
    --accent:       #ff4d8d;
    --accent-2:     #00e5ff;
    --gold:         #ffd166;
    --shadow:       0 8px 40px rgba(255, 77, 141, 0.25);
    --map-filter:   saturate(1.15);
    --grain-opacity: 0.05;
}

[data-theme="vintage"] {
    --bg:           #ede4d3;
    --bg-soft:      #e4d8c0;
    --bg-elev:      #f3ecdd;
    --panel:        rgba(243, 236, 221, 0.92);
    --border:       #c9b896;
    --text:         #4a3c28;
    --text-soft:    #7a6a4f;
    --text-dim:     #a3957a;
    --accent:       #a0522d;
    --accent-2:     #5c7a5c;
    --gold:         #b8860b;
    --shadow:       0 6px 24px rgba(120, 95, 60, 0.25);
    --map-filter:   sepia(0.35) saturate(0.9) brightness(1.0);
    --grain-opacity: 0.08;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Space Grotesk', 'Noto Serif SC', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    transition: background 0.5s ease, color 0.5s ease;
    overflow-x: hidden;
}

/* 颗粒质感叠层 */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, .serif { font-family: 'Noto Serif SC', serif; }

a { color: var(--accent); text-decoration: none; }

/* ---------- 页眉 ---------- */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.2rem 2rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-soft);
    position: relative;
    z-index: 500;
}
.site-header .brand { display: flex; flex-direction: column; }
.site-header .brand .title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.site-header .brand .subtitle {
    font-size: 0.85rem;
    color: var(--text-soft);
    font-family: 'Space Grotesk', sans-serif;
}
.header-actions { display: flex; align-items: center; gap: 1rem; }
.header-actions .home-link {
    color: var(--text-soft);
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    transition: all 0.2s;
}
.header-actions .home-link:hover { color: var(--text); border-color: var(--accent); }

/* ---------- 主题切换器 ---------- */
.theme-switcher { display: flex; gap: 0.5rem; }
.theme-dot {
    width: 22px; height: 22px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
}
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: var(--text); }
.theme-dot[data-set="dark"]    { background: linear-gradient(135deg, #0d1117, #58a6ff); }
.theme-dot[data-set="calm"]    { background: linear-gradient(135deg, #f5f2ec, #7a8b6f); }
.theme-dot[data-set="vivid"]   { background: linear-gradient(135deg, #0a0e27, #ff4d8d); }
.theme-dot[data-set="vintage"] { background: linear-gradient(135deg, #ede4d3, #a0522d); }

/* ---------- 布局 ---------- */
.layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - 78px);
}
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; grid-template-rows: 50vh 50vh; }
}

/* ---------- 侧栏 ---------- */
.sidebar {
    overflow-y: auto;
    padding: 1.5rem;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* 统计面板 */
.stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    text-align: center;
    transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.stat-card .num {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    font-family: 'Space Grotesk', sans-serif;
    line-height: 1;
}
.stat-card .label {
    font-size: 0.8rem;
    color: var(--text-soft);
    margin-top: 0.3rem;
}

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin: 1.5rem 0 0.8rem;
    font-family: 'Space Grotesk', sans-serif;
}

/* 行程卡片 */
.trip-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-left: 4px solid var(--trip-color, var(--accent));
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.trip-card:hover { transform: translateX(4px); box-shadow: var(--shadow); }
.trip-card.active { box-shadow: 0 0 0 2px var(--trip-color, var(--accent)); }
.trip-card .trip-name { font-weight: 600; font-size: 1.05rem; }
.trip-card .trip-meta {
    display: flex;
    gap: 0.8rem;
    font-size: 0.78rem;
    color: var(--text-soft);
    margin-top: 0.4rem;
    flex-wrap: wrap;
}
.trip-card .trip-type-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    background: var(--trip-color, var(--accent));
    color: #fff;
    font-size: 0.7rem;
}
.trip-card .loc-count { color: var(--text-dim); }

/* 行程下的地点列表 */
.loc-list { margin-top: 0.7rem; padding-left: 0.5rem; display: none; }
.trip-card.active .loc-list { display: block; }
.loc-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
    font-size: 0.9rem;
    color: var(--text-soft);
    cursor: pointer;
    border-bottom: 1px dashed var(--border);
}
.loc-item:last-child { border-bottom: none; }
.loc-item:hover { color: var(--text); }
.loc-item .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--trip-color, var(--accent));
    flex-shrink: 0;
}

/* ---------- 地图 ---------- */
.map-wrap { position: relative; }
#map { width: 100%; height: 100%; background: var(--bg); }
.leaflet-tile-pane { filter: var(--map-filter); }

/* 自定义标记 */
.marker-pin {
    width: 18px; height: 18px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* ---------- 星级 ---------- */
.stars { display: inline-flex; gap: 1px; color: var(--gold); }
.stars .star { position: relative; width: 1em; font-size: 1em; color: var(--text-dim); }
.stars .star .fill {
    position: absolute; left: 0; top: 0;
    overflow: hidden; color: var(--gold); white-space: nowrap;
}

/* ---------- 详情弹层 ---------- */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}
.detail-overlay.open { display: flex; }
.detail-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 18px;
    max-width: 720px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    animation: pop 0.3s ease;
}
@keyframes pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.detail-cover {
    width: 100%; height: 240px; object-fit: cover;
    border-radius: 18px 18px 0 0;
    background: var(--bg-elev);
}
.detail-body { padding: 1.5rem 2rem 2rem; }
.detail-body h2 { font-size: 1.6rem; margin-bottom: 0.3rem; }
.detail-loc-meta { color: var(--text-soft); font-size: 0.9rem; margin-bottom: 0.8rem; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.8rem 0; }
.tag {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    padding: 0.2rem 0.7rem;
    border-radius: 14px;
    font-size: 0.78rem;
    color: var(--text-soft);
}
.detail-note {
    margin-top: 1rem;
    line-height: 1.8;
    color: var(--text);
}
.detail-note img { max-width: 100%; border-radius: 8px; }
.detail-note h1, .detail-note h2, .detail-note h3 { margin: 1rem 0 0.5rem; }
.detail-note p { margin-bottom: 0.8rem; }
.detail-note blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--text-soft);
    margin: 0.8rem 0;
}
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}
.gallery img {
    width: 100%; height: 90px; object-fit: cover;
    border-radius: 8px; cursor: pointer;
    transition: transform 0.2s;
}
.gallery img:hover { transform: scale(1.05); }
.close-btn {
    position: absolute;
    top: 1rem; right: 1rem;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
}

/* ---------- 灯箱 ---------- */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92%; max-height: 92%; border-radius: 8px; }

/* ---------- 空状态 ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
}
