/* ============================================================
   我的歷代手機 — 樣式表
   深色主題、響應式、可離線 file:// 開啟
   ============================================================ */

:root {
  --bg:        #0e1116;
  --bg-soft:   #161b22;
  --bg-card:   #1b222c;
  --bg-card-h: #232c38;
  --border:    #2a3340;
  --text:      #e6edf3;
  --text-dim:  #9aa7b4;
  --text-mut:  #6b7785;
  --accent:    #4dabf7;
  --accent-2:  #ff8787;
  --radius:    14px;
  --shadow:    0 8px 30px rgba(0,0,0,.35);
  --maxw:      1180px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }


.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  display: flex; flex-direction: column; gap: 12px;
}
.card:hover { transform: translateY(-4px); background: var(--bg-card-h); border-color: #38465a; }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { flex: 1; min-width: 0; }

/* 圖片縮圖 + glyph 後備 */
.card-thumb {
  position: relative; width: 54px; height: 72px; flex-shrink: 0;
  border-radius: 8px; overflow: hidden;
  background: linear-gradient(160deg, #2b3543, #161d27); border: 1px solid #3a4658;
}
.card-thumb img, .detail-thumb img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #f4f5f7;
}
.glyph-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text-dim);
}
.card-thumb .glyph-fallback { font-size: 1.1rem; }
.detail-thumb {
  position: relative; width: 150px; height: 200px; flex-shrink: 0;
  border-radius: 14px; overflow: hidden;
  background: linear-gradient(160deg, #2b3543, #141a23); border: 1px solid #3a4658;
}
.detail-thumb .glyph-fallback { font-size: 2rem; }

.card h3 { font-size: 1.08rem; line-height: 1.3; }
.card .brand-line { color: var(--text-mut); font-size: .8rem; }
.year-badge {
  font-size: .78rem; font-weight: 700; color: var(--bg);
  background: var(--accent); padding: 2px 9px; border-radius: 999px; white-space: nowrap;
}

.spec-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: .82rem; }
.spec-mini div { color: var(--text-dim); }
.spec-mini b { color: var(--text); font-weight: 600; }

.card .summary { font-size: .86rem; color: var(--text-dim); }

.sar-tag {
  margin-top: auto; font-size: .76rem; color: var(--text-mut);
  display: flex; align-items: center; gap: 6px;
}
.sar-bar { flex: 1; height: 5px; background: #2a3340; border-radius: 3px; overflow: hidden; }
.sar-bar i { display: block; height: 100%; border-radius: 3px; }

/* ---------- Detail page ---------- */
.detail { padding: 36px 0 70px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-dim); font-size: .9rem; margin-bottom: 24px; }
.back-link:hover { color: var(--text); text-decoration: none; }

.detail-head { display: flex; gap: 26px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 12px; }

.detail-head .titles { flex: 1; min-width: 260px; }
.detail-head h1 { font-size: 1.9rem; line-height: 1.2; margin-bottom: 6px; }
.detail-head .sub { color: var(--text-dim); margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-size: .8rem; background: var(--bg-soft); border: 1px solid var(--border); color: var(--text-dim); padding: 4px 11px; border-radius: 999px; }
.chip.accent { background: rgba(77,171,247,.12); border-color: rgba(77,171,247,.4); color: #9ad0ff; }

.detail-summary {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 16px 18px; margin: 26px 0;
  color: var(--text); font-size: .98rem;
}

.detail-section { margin: 26px 0; }
.detail-section h2 {
  font-size: 1.25rem; margin-bottom: 18px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.detail-section h2::before {
  content: ""; display: inline-block; width: 4px; height: 18px;
  background: var(--accent); border-radius: 2px;
}
.detail-section p.body { color: var(--text-dim); font-size: 0.96rem; line-height: 1.65; }

/* spec table (優化版：卡片式收納、精簡間距、懸停效果) */
.spec-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 760px) { .spec-groups { grid-template-columns: 1fr; } }

.spec-table {
  width: 100%; border-collapse: collapse; font-size: 0.88rem;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  overflow: hidden;
}
.spec-table tr { border-bottom: 1px solid var(--border); transition: background 0.15s ease; }
.spec-table tr:last-child { border-bottom: none; }
.spec-table tr:hover { background: var(--bg-card-h); }
.spec-table th {
  text-align: left; width: 110px; vertical-align: top;
  color: var(--text-mut); font-weight: 600; padding: 9px 14px; white-space: nowrap;
}
.spec-table td { padding: 9px 14px 9px 4px; color: var(--text); vertical-align: top; }

/* history timeline */
.timeline { list-style: none; position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 18px 4px; }
.timeline li::before {
  content: ""; position: absolute; left: -26px; top: 6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--bg);
}
.timeline .t-date { font-weight: 700; color: var(--text); margin-right: 10px; }
.timeline .t-event { color: var(--text-dim); }

.raw-note {
  font-family: "Consolas", "Courier New", monospace;
  background: #0b0f14; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; color: var(--text-dim); font-size: .85rem; overflow-x: auto; white-space: pre-wrap;
}

.sources-list { list-style: none; }
.sources-list li { padding: 6px 0; font-size: 0.92rem; word-break: break-all; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.screenshot-link { color: var(--accent); font-size: 0.85rem; font-weight: 600; text-decoration: none; background: var(--bg-soft); padding: 2px 8px; border-radius: 6px; border: 1px solid var(--accent); transition: background 0.15s, color 0.15s; }
.screenshot-link:hover { background: var(--accent); color: var(--bg); }

/* prev/next nav (精簡緊湊版：單列橫排、收緊高度、不佔據多餘空間) */
.detail-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; }
.detail-nav a {
  flex: 1; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 16px; color: var(--text-dim);
  display: flex; align-items: center; justify-content: flex-start; gap: 8px;
  text-decoration: none; transition: background 0.15s, border-color 0.15s;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.detail-nav a.next { justify-content: flex-end; }
.detail-nav a:hover { background: var(--bg-card-h); border-color: var(--accent); }
.detail-nav .nl { font-size: 0.8rem; color: var(--text-mut); flex-shrink: 0; }
.detail-nav .nt { color: var(--text); font-weight: 600; font-size: 0.9rem; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 620px) {
  .detail-nav a { padding: 8px 12px; gap: 4px; }
  .detail-nav .nl { display: none; /* 小螢幕隱藏「上一支/下一支」文字，直接顯示機型名稱更清爽 */ }
}

/* ---------- 首頁開門見山標題列 ---------- */
.page-intro { padding: 34px 0 18px; }
.page-intro h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); margin-bottom: 12px; }
.page-intro h1 .accent { color: var(--accent); }
.intro-stats { display: flex; gap: 22px; flex-wrap: wrap; color: var(--text-mut); font-size: .9rem; }
.intro-stats b { color: var(--text); font-size: 1.05rem; }

/* ---------- Comparison table ---------- */
.compare-section { padding: 4px 0 40px; }
.table-hint { color: var(--text-mut); font-size: .78rem; margin: 0 2px 8px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
table.compare { width: 100%; border-collapse: collapse; font-size: .8rem; min-width: 960px; }
table.compare th, table.compare td { padding: 7px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.compare thead th { background: var(--bg-soft); color: var(--text-mut); font-weight: 600; font-size: .76rem; position: sticky; top: 0; z-index: 5; }
table.compare th.sortable, table.compare th.reset-sort { cursor: pointer; user-select: none; }
table.compare th.sortable:hover, table.compare th.reset-sort:hover { color: var(--text); background: var(--bg-card-h); }
.sort-ind { color: var(--text-mut); font-size: .7rem; opacity: .45; }
.sort-ind.on { color: var(--accent); opacity: 1; }
table.compare tbody tr { transition: background .12s; }
table.compare tbody tr:hover { background: var(--bg-card-h); cursor: pointer; }
table.compare tbody tr:nth-child(even) { background: rgba(255,255,255,.018); }
table.compare tbody tr:nth-child(even):hover { background: var(--bg-card-h); }

/* 縮圖欄 */
.col-img { width: 44px; padding-right: 4px !important; }
.tbl-thumb {
  position: relative; width: 34px; height: 45px; border-radius: 6px; overflow: hidden;
  background: linear-gradient(160deg,#2b3543,#161d27); border: 1px solid #3a4658;
}
.tbl-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #f4f5f7; }
.tbl-thumb .glyph-fallback { font-size: .75rem; }

/* 機型欄：品牌 (第一行) / 型號 (第二行) */
.col-name { min-width: 130px; }
.t-brand { display: block; color: var(--text); font-size: 0.88rem; font-weight: normal; margin-bottom: 2px; }
.t-model { display: block; font-weight: 600; color: var(--text); font-size: 0.88rem; }
.t-year { color: var(--text-mut); font-size: 0.82rem; }

/* 處理器欄：型號 + 跑分 */
.soc-name { display: block; color: var(--text); }
.soc-score { display: block; color: var(--accent); font-size: .7rem; margin-top: 2px; font-variant-numeric: tabular-nums; }
.soc-score.none { color: var(--text-mut); }

/* SAR 色塊 */
.sar-chip { display: inline-block; min-width: 36px; text-align: center; padding: 2px 8px; border-radius: 6px; color: #10151c; font-weight: 700; font-size: .78rem; }

/* 入手欄 */
.col-buy { min-width: 84px; }
.buy-yr { display: inline-block; color: var(--text-mut); font-size: 0.78rem; margin-right: 3px; }
.buy-price { display: inline-block; color: var(--text); font-weight: 700; }
.buy-fold { display: block; color: var(--accent-2); font-size: .72rem; margin-top: 2px; }
.buy-contract { display: block; color: #9ad0ff; font-size: .8rem; margin-top: 1px; }
.buy-none { display: block; color: var(--text-mut); font-size: .8rem; margin-top: 1px; }

/* ---------- 詳細頁：購買資訊 ---------- */
.buy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; }
.buy-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.buy-box.accent { border-color: rgba(77,171,247,.45); background: rgba(77,171,247,.1); }
.buy-box .bk { color: var(--text-mut); font-size: .78rem; margin-bottom: 4px; }
.buy-box .bv { color: var(--text); font-size: 1.15rem; font-weight: 700; }
.buy-channel { color: var(--text-dim); font-size: .88rem; margin-top: 12px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 30px 0; color: var(--text-mut); font-size: .85rem; }
.site-footer a { color: var(--text-dim); }

/* ---------- 回到頂部懸浮按鈕 ---------- */
.btn-totop {
  position: fixed; bottom: 30px; right: 30px; z-index: 99;
  width: 45px; height: 45px; border-radius: 50%;
  background: rgba(27, 34, 44, 0.75); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 1.2rem; font-weight: 700;
  cursor: pointer; display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); transition: background 0.2s, color 0.2s, transform 0.2s;
  box-shadow: var(--shadow);
}
.btn-totop:hover {
  background: var(--accent); color: var(--bg); border-color: var(--accent);
  transform: translateY(-3px);
}

/* ---------- Responsive ---------- */
@media (max-width: 620px) {
  .nav-cats { display: none; }
  .hero { padding: 44px 0 30px; }
  .spec-mini { grid-template-columns: 1fr; }
  .btn-totop { bottom: 20px; right: 20px; width: 40px; height: 40px; font-size: 1.1rem; }
}

/* fade-in */
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

