/* home.css — 首頁
 *
 * 版面立場：**顏色不做層次，字級與留白做層次。**
 * 整頁只有一個 accent（--primary），而且只出現在可以點的東西上。
 * 需要被讀出來的是那些量到的數字，所以數字一律 mono + tabular-nums，
 * 其他東西往後退。
 */

body {
  overflow-y: auto;
  font-size: 15px;
}

.home {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px 96px;
}

/* ── 頁首細條 ───────────────────────────────
   放 wordmark 與幾個常用去處。捲動時不跟著，
   免得在讀教材時一直有東西壓在上面。 */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 20px 0 18px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 56px;
}

.topbar .wordmark {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  text-decoration: none;
}

.topbar nav {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.topbar nav a {
  font-size: 13px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.12s;
}

.topbar nav a:hover {
  color: var(--text);
}

/* ── Hero ───────────────────────────────────
   靠左。置中的標題在中文長句下折行位置很難看，
   而且置中會讓底下靠左的卡片陣列接不上。 */

.hero {
  max-width: 720px;
  margin-bottom: 60px;
}

.hero h1 {
  font-size: 31px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  margin: 0 0 14px;
  text-wrap: balance;
}

.tagline {
  font-size: 17px;
  line-height: 1.65;
  color: var(--text-dim);
  margin: 0 0 28px;
  max-width: 62ch;
}

/* 三個數字。用細線隔開而不是各自做成色塊。 */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0 26px;
  margin: 0 0 30px;
  padding: 0;
  list-style: none;
}

.stats li {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding-right: 26px;
  border-right: 1px solid var(--border-soft);
}

.stats li:last-child {
  border-right: none;
  padding-right: 0;
}

.stats b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stats span {
  font-size: 12.5px;
  color: var(--text-faint);
}

/* 一個實心主要動作，其餘退成文字連結 */
.hero-links {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin: 0;
}

.hero-links a {
  font-size: 13.5px;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.12s;
}

.hero-links a:hover {
  color: var(--text);
}

.hero-links .btn-primary {
  padding: 8px 16px;
  border-radius: 7px;
  background: var(--primary);
  color: #0b1220;
  font-weight: 600;
}

.hero-links .btn-primary:hover {
  background: #63a6ff;
  color: #0b1220;
}

/* ── 專案卡 ─────────────────────────────────
   GIF 齊邊貼頂，不再在卡框裡再包一層圖框。
   整張卡可點（.card-title 的 ::after 撐滿），
   「說明」用 z-index 疊回上面保持可點。 */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 88px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.15s, background 0.15s;
}

.card:hover {
  border-color: var(--border);
  background: #1c1f28;
}

.card:focus-within {
  border-color: var(--primary);
}

.card-demo {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 16px 0;
  flex: 1;
}

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

.card-num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

/* 難度：三格，填滿幾格就是幾級。
   比 🟢🟡🔴 好的地方是不必先學會顏色代表什麼——
   格數本身就是刻度。緊貼編號放，兩個一起讀成「這是第幾個、多難」。 */
.card-diff {
  display: flex;
  gap: 3px;
  align-items: center;
}

.card-diff i {
  width: 12px;
  height: 4px;
  border-radius: 1px;
  background: var(--grid);
}

.card-diff i.on {
  background: var(--text-dim);
}

.card-title {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.012em;
  margin: 0;
  line-height: 1.4;
}

.card-title a {
  color: var(--text);
  text-decoration: none;
}

/* 整張卡都可點 */
.card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
}

.card:hover .card-title a {
  color: #eaeef6;
}

.card-hook {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
  margin: 0;
}

.card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 12px 16px 13px;
  font-size: 11.5px;
  color: var(--text-faint);
}

.card-concept {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-foot a,
.card-tests {
  position: relative;   /* 疊在 .card-title a::after 之上 */
  z-index: 1;
  flex: none;
}

.card-foot a {
  color: var(--text-dim);
  text-decoration: none;
}

.card-foot a:hover {
  color: var(--primary);
}

.card-tests {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* ── 說明區塊 ───────────────────────────────*/

.notes {
  max-width: 68ch;
  line-height: 1.85;
}

.notes h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--text);
  margin: 56px 0 14px;
  text-wrap: balance;
}

.notes h2:first-child {
  margin-top: 0;
}

.notes p {
  font-size: 14.5px;
  margin: 0 0 14px;
  color: var(--text-dim);
}

.notes a {
  color: var(--primary);
  text-decoration: none;
  border-bottom: 1px solid rgba(76, 154, 255, 0.3);
}

.notes a:hover {
  border-bottom-color: var(--primary);
}

/* 行內 code 不再是黃色。它只是「這是個識別字」，
   不需要一個語意色去搶注意力。 */
.notes code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--text);
  background: var(--bg-input);
  padding: 1.5px 5px;
  border-radius: 4px;
}

.notes b {
  color: var(--text);
  font-weight: 600;
}

/* ── 表格：只留表頭線與列細線，不畫格子 ─────*/

.cmp-table-wrap {
  overflow-x: auto;
  margin: 0 0 18px;
}

.cmp-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
  line-height: 1.55;
}

.cmp-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 0 16px 8px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.cmp-table td {
  padding: 9px 16px 9px 0;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  vertical-align: baseline;
}

.cmp-table tr:last-child td {
  border-bottom: none;
}

.cmp-table th:last-child,
.cmp-table td:last-child {
  padding-right: 0;
}

/* 只有「第一欄是專案編號」的表格才把它設成 mono。
   教材層次那張表第一欄是文字連結，套上去會又難讀又不像連結。 */
.cmp-table.nums td:first-child {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
  white-space: nowrap;
}

/* 量到的差異——整頁真正要被讀出來的東西 */
.cmp-table b {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}

/* 表格裡的連結還是要看得出可以點 */
.cmp-table a {
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.cmp-table a:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.foot {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 64px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--text-faint);
}

.foot a {
  color: var(--text-faint);
  text-decoration: none;
}

.foot a:hover {
  color: var(--text-dim);
}

.foot .foot-end {
  margin-left: auto;
  font-family: var(--mono);
}

@media (max-width: 640px) {
  .home {
    padding: 0 18px 64px;
  }
  .hero h1 {
    font-size: 26px;
  }
  .tagline {
    font-size: 15.5px;
  }
  .foot .foot-end {
    margin-left: 0;
  }
}
