/*!
 * Weather Globe Pro : 樣式表
 * 沿用原版深色玻璃質感與四主題，修正破版 Bug，新增骨架載入、
 * 無障礙 focus 樣式與響應式版面。
 */

/* ============================================================
   主題變數
   ============================================================ */
:root {
  --bg: #0d1117; --bg-card: #161b22; --bg-el: #21262d; --bg-hover: #1a2233;
  --bg-active: #0d2440; --border: #30363d; --border-inner: #21262d;
  --text: #e6edf3; --text-muted: #8b949e; --text-dim: #6e7681;
  --accent: #388bfd; --accent-light: #58a6ff; --accent-blue: #79c0ff;
  --text-time: #d2a8ff; --text-sun: #e3b341; --globe-bg: #000;
  --shadow: rgba(0,0,0,0.5);
  --fav: #f2cc60;
  --transition: background .25s ease, color .25s ease, border-color .25s ease;
  --radius: 12px; --radius-sm: 8px;
}
html[data-theme="light"] {
  --bg: #c2d8ed; --bg-card: #d8eaf8; --bg-el: #b0cce0; --bg-hover: #c8dff0;
  --bg-active: #9dc0da; --border: #7aaac8; --border-inner: #a4c4dc;
  --text: #0c2a42; --text-muted: #264c68; --text-dim: #3f6880;
  --accent: #1565c0; --accent-light: #1976d2; --accent-blue: #0d47a1;
  --text-time: #5c35a8; --text-sun: #7a4800; --globe-bg: #8ab8d8;
  --shadow: rgba(8,36,68,0.18); --fav: #b8860b;
}
html[data-theme="terrain"] {
  --bg: #f0e6d8; --bg-card: #fbf5ea; --bg-el: #e0d8c8; --bg-hover: #f5efe2;
  --bg-active: #d4c8b4; --border: #d4c8b4; --border-inner: #e0d8c8;
  --text: #5c4833; --text-muted: #8a725a; --text-dim: #9e8a72;
  --accent: #a1887f; --accent-light: #bcae9a; --accent-blue: #795548;
  --text-time: #795548; --text-sun: #8D6E63; --globe-bg: #d4c8b4;
  --shadow: rgba(92,72,51,0.15); --fav: #b8860b;
}
html[data-theme="gmt"] {
  --bg: #060d1a; --bg-card: #0d1a2e; --bg-el: #152340; --bg-hover: #1a2a50;
  --bg-active: #0a1e40; --border: #1a3a60; --border-inner: #142a50;
  --text: #a8d8f0; --text-muted: #5a8fb0; --text-dim: #3a6080;
  --accent: #00bcd4; --accent-light: #4dd0e1; --accent-blue: #80deea;
  --text-time: #4dd0e1; --text-sun: #81d4fa; --globe-bg: #020810;
  --shadow: rgba(0,0,0,0.7); --fav: #4dd0e1;
}

/* ============================================================
   基礎
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%; overflow: hidden;
  font-family: 'Noto Sans TC', 'Noto Sans SC', 'Noto Sans', sans-serif;
  background: var(--bg); color: var(--text); transition: var(--transition);
}
body { display: flex; flex-direction: column; padding: 12px; gap: 9px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* 無障礙：螢幕閱讀器專用文字 */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
/* 跳至主內容 */
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 10000; background: var(--accent); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
/* 統一 focus 樣式 */
:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Cesium 預設元件隱藏 */
.cesium-widget-credits, .cesium-viewer-toolbar, .cesium-viewer-animationContainer,
.cesium-viewer-timelineContainer, .cesium-viewer-fullscreenContainer, .cesium-viewer-geocoderContainer { display: none !important; }
.cesium-widget canvas { width: 100% !important; height: 100% !important; }

/* ============================================================
   頂列
   ============================================================ */
.top-bar { display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; gap: 12px; flex-wrap: wrap; }
.top-bar-left { display: flex; align-items: center; gap: 14px; }
.top-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
h1 { font-size: 1.2rem; font-weight: 700; cursor: pointer; user-select: none; transition: color .2s; }
h1:hover { color: var(--accent-light); }

.my-time { display: flex; flex-direction: column; line-height: 1.25; }
.my-time-label { font-size: .62rem; color: var(--text-dim); font-weight: 700; letter-spacing: .03em; }
.my-time-clock { font-size: .82rem; font-weight: 700; color: var(--text-time); font-variant-numeric: tabular-nums; }
.my-time-date { font-size: .66rem; color: var(--text-muted); }

/* 按鈕通用 */
.btn {
  background: var(--bg-el); border: 1px solid var(--border); color: var(--text-muted);
  font-family: inherit; font-size: .78rem; font-weight: 700;
  padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--accent-light); background: var(--bg-hover); }
.btn.active { background: var(--bg-active); border-color: var(--accent); color: var(--accent-blue); }

/* 音樂按鈕播放中：脈動邊框提示（與原版視覺一致） */
#music-btn.active {
  background: var(--bg-active);
  border-color: var(--accent);
  color: var(--accent-blue);
  animation: musicPulse 2.4s ease-in-out infinite;
}
@keyframes musicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(88, 166, 255, 0); }
  50%       { box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25); }
}

/* 區段標籤 + 按鈕群 */
.ctrl-group { display: inline-flex; align-items: center; gap: 6px; }
.ctrl-label { font-size: .62rem; color: var(--text-dim); font-weight: 700; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { background: var(--bg-el); border: none; border-right: 1px solid var(--border); color: var(--text-muted); font-family: inherit; font-size: .72rem; font-weight: 700; padding: 6px 10px; cursor: pointer; transition: var(--transition); }
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--text); background: var(--bg-hover); }
.seg button.active { background: var(--bg-active); color: var(--accent-blue); }

/* 我的最愛數量 badge */
#fav-btn { position: relative; }
.fav-count { display: none; align-items: center; justify-content: center; position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px; background: var(--accent); color: #fff; border-radius: 8px; font-size: .6rem; font-weight: 700; }

/* ============================================================
   主版面
   ============================================================ */
.main-container { display: flex; gap: 16px; flex: 1; min-height: 0; }
#globeViz { flex: 1.5; border-radius: var(--radius); overflow: hidden; box-shadow: 0 8px 32px var(--shadow); background: var(--globe-bg); position: relative; display: flex; align-items: center; justify-content: center; }
.globe-fallback { color: var(--text-muted); font-size: .85rem; text-align: center; padding: 2rem; }

#card-panel { flex: 1.3; min-width: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; padding-right: 4px; }
#card-panel::-webkit-scrollbar { width: 4px; }
#card-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
#card-panel.spotlight-mode { justify-content: flex-start; }

/* ============================================================
   卡片
   ============================================================ */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 15px; transition: var(--transition), transform .15s ease; cursor: pointer; position: relative;
}
.card:hover { border-color: var(--accent-light); background: var(--bg-hover); transform: translateY(-1px); }
.card.spotlight { cursor: default; padding: 18px 20px; }
.card.spotlight:hover { transform: none; }

.card-header { display: flex; align-items: center; gap: 10px; }
.flag { width: 30px; border-radius: 3px; flex-shrink: 0; box-shadow: 0 1px 3px var(--shadow); }
.city-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.city-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.lang-label { font-size: .66rem; color: var(--text-dim); }
.card.spotlight .city-name { font-size: 1.3rem; }

.fav-btn { background: none; border: none; color: var(--text-dim); font-size: 1.15rem; cursor: pointer; line-height: 1; padding: 2px 4px; transition: color .15s, transform .15s; flex-shrink: 0; }
.fav-btn:hover { transform: scale(1.15); }
.fav-btn.active { color: var(--fav); }

.coords { font-size: .64rem; color: var(--text-dim); margin-top: 7px; font-variant-numeric: tabular-nums; }

.weather-row { display: flex; align-items: center; gap: 9px; margin-top: 9px; flex-wrap: wrap; }
.weather-icon { font-size: 1.7rem; }
.weather-temp { font-size: 1.5rem; font-weight: 700; color: var(--accent-blue); font-variant-numeric: tabular-nums; }
.card.spotlight .weather-temp { font-size: 2rem; }
.weather-desc { font-size: .8rem; color: var(--text-muted); }

.sun-row { font-size: .68rem; color: var(--text-sun); margin-top: 7px; }
.sun-sep { color: var(--text-dim); }

.time-str { font-size: .82rem; font-weight: 700; color: var(--text-time); margin-top: 7px; font-variant-numeric: tabular-nums; }
.card.spotlight .time-str { font-size: 1rem; }

.weather-details { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; }
.wd-item { font-size: .68rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 3px; }
.wd-val { color: var(--text); font-weight: 700; }

/* 7 日預報 */
.forecast-label { font-size: .68rem; color: var(--text-dim); font-weight: 700; margin: 12px 0 7px; }
.forecast-row { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.forecast-row::-webkit-scrollbar { height: 3px; }
.forecast-row::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.forecast-pill { flex-shrink: 0; background: var(--bg-el); border: 1px solid var(--border-inner); border-radius: var(--radius-sm); padding: 7px 9px; text-align: center; min-width: 56px; }
.fp-day { font-size: .62rem; color: var(--text-muted); font-weight: 700; }
.fp-icon { font-size: 1.1rem; margin: 3px 0; }
.fp-temp { display: flex; gap: 4px; justify-content: center; font-size: .66rem; font-variant-numeric: tabular-nums; }
.fp-lo { color: var(--text-dim); }
.fp-hi { color: var(--text); font-weight: 700; }
.fp-rain { font-size: .58rem; color: var(--accent-blue); margin-top: 2px; }

.back-btn { background: var(--bg-el); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: .82rem; font-weight: 700; padding: 8px 22px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); }
.back-btn:hover { border-color: var(--accent-light); background: var(--bg-hover); }

.no-results { text-align: center; color: var(--text-dim); font-size: .85rem; padding: 3rem 1rem; line-height: 1.7; }

/* ============================================================
   骨架載入
   ============================================================ */
.card.skeleton { cursor: default; pointer-events: none; }
.card.skeleton:hover { transform: none; border-color: var(--border); background: var(--bg-card); }
.sk-line { background: linear-gradient(90deg, var(--bg-el) 25%, var(--bg-hover) 50%, var(--bg-el) 75%); background-size: 200% 100%; border-radius: 5px; animation: sk 1.4s ease-in-out infinite; }
.sk-title { height: 16px; width: 45%; margin-bottom: 9px; }
.sk-sub { height: 10px; width: 30%; margin-bottom: 14px; }
.sk-big { height: 28px; width: 60%; margin-bottom: 12px; }
.sk-row { height: 12px; width: 80%; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ============================================================
   搜尋
   ============================================================ */
.filter-section { display: flex; align-items: center; gap: 12px; flex-shrink: 0; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 180px; max-width: 280px; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
#search-input { width: 100%; background: var(--bg-el); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: .8rem; padding: 8px 12px 8px 32px; border-radius: var(--radius-sm); outline: none; transition: border-color .15s; }
#search-input:focus { border-color: var(--accent); }
.search-drop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); z-index: 200; max-height: 280px; overflow-y: auto; box-shadow: 0 8px 24px var(--shadow); display: none; }
.search-drop.open { display: block; }
.search-drop-item { display: flex; align-items: center; gap: 9px; padding: 8px 11px; cursor: pointer; border-bottom: 1px solid var(--border-inner); transition: background .1s; }
.search-drop-item:last-child { border-bottom: none; }
.search-drop-item:hover { background: var(--bg-hover); }
.sdi-flag { width: 22px; border-radius: 2px; flex-shrink: 0; }
.sdi-name { flex: 1; font-size: .8rem; font-weight: 700; color: var(--text); }
.sdi-wx { display: inline-flex; align-items: center; gap: 4px; font-size: .76rem; color: var(--text-muted); }

/* 洲別分頁 */
.continent-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.ctab { background: var(--bg-el); border: 1px solid var(--border); color: var(--text-muted); font-family: inherit; font-size: .74rem; font-weight: 700; padding: 7px 13px; border-radius: var(--radius-sm); cursor: pointer; transition: var(--transition); display: inline-flex; align-items: center; }
.ctab:hover { color: var(--text); border-color: var(--accent-light); }
.ctab.active { background: var(--bg-active); border-color: var(--accent); color: var(--accent-blue); }
.mob-continent-select { display: none; background: var(--bg-el); border: 1px solid var(--border); color: var(--text); font-family: inherit; font-size: .8rem; padding: 8px 10px; border-radius: var(--radius-sm); }

/* ============================================================
   離線橫幅
   ============================================================ */
.offline-banner { display: none; position: fixed; top: 0; left: 0; right: 0; z-index: 9000; background: var(--bg-active); color: var(--accent-blue); border-bottom: 1px solid var(--accent); text-align: center; font-size: .76rem; font-weight: 700; padding: 6px; }
.offline-banner.show { display: block; animation: slideDown .3s ease; }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ============================================================
   Modal (同意 / 關於) — 修正原版破版 Bug：補上選擇器
   ============================================================ */
.modal-backdrop { display: none; position: fixed; inset: 0; z-index: 9500; background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--bg-card); border: 1px solid var(--border); border-radius: 16px; max-width: 440px; width: 100%; padding: 1.8rem 1.8rem 1.4rem; box-shadow: 0 16px 56px var(--shadow); position: relative; text-align: center; animation: modalIn .22s cubic-bezier(.22,1,.36,1); }
@keyframes modalIn { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-logo { height: 64px; width: auto; margin-bottom: .7rem; }
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: .8rem; }
.modal-body { font-size: .82rem; color: var(--text-muted); line-height: 1.75; margin-bottom: 1.2rem; }
.modal-actions { display: flex; justify-content: center; gap: 10px; }   /* ← 原版此處缺選擇器，已修正 */
.modal-link { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; font-weight: 700; color: var(--accent-light); text-decoration: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 16px; transition: var(--transition); }
.modal-link:hover { background: var(--bg-hover); border-color: var(--accent-light); }
.modal-copy { font-size: .68rem; color: var(--text-dim); margin-top: 1rem; }

/* ============================================================
   載入畫面
   ============================================================ */
#app-loader { position: fixed; inset: 0; z-index: 10000; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; transition: opacity .4s ease; }
#app-loader.hide { opacity: 0; pointer-events: none; }
.loader-spinner { width: 44px; height: 44px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-text { font-size: .8rem; color: var(--text-muted); font-weight: 700; }

/* ============================================================
   響應式
   ============================================================ */
@media (max-width: 880px) {
  body { padding: 9px; gap: 7px; }
  .main-container { flex-direction: column; }
  #globeViz { flex: none; height: 42vh; min-height: 260px; }
  #card-panel { flex: none; height: auto; overflow-y: visible; }
  .continent-tabs { display: none; }
  .mob-continent-select { display: block; }
  .top-bar-right { gap: 6px; }
  .ctrl-label { display: none; }
}
@media (max-width: 520px) {
  h1 { font-size: 1rem; }
  .search-wrap { max-width: none; }
  .btn { padding: 6px 10px; font-size: .72rem; }
}
