/* =============================================================
 * 嵌入式電腦視覺系統 ｜ 114-2
 * 共用樣式表 (course.css)
 * 沿用 embedded-systems-course 配色,微調為 CV 課程主題
 * ========================================================== */

:root {
  --ink: #1f2933;
  --muted: #5f6b7a;
  --line: #d8dee8;
  --soft: #f6f8fb;
  --panel: #fff;
  --accent: #135f9f;          /* 主強調色:深藍 */
  --accent2: #0f766e;         /* 副強調色:teal */
  --warn: #a35d00;
  --danger: #b42318;
  --bg: #f3f6fa;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Microsoft JhengHei", "Noto Sans TC", "PingFang TC", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
}

/* === 全頁容器 === */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 22px 56px;
}

/* === 頂部 (麵包屑 + 操作按鈕) === */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.crumbs {
  font-size: 14px;
  color: var(--muted);
}

.crumbs a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.crumbs a:hover {
  text-decoration: underline;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* === 按鈕 === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(19, 95, 159, 0.08);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: #0f4f87;
}

/* === Hero (頁面開頭區) === */
header.hero {
  padding: 26px 0 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--accent2);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.04em;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.25;
  letter-spacing: 0;
}

header.hero p {
  max-width: 780px;
  margin: 10px 0 0;
  color: var(--muted);
}

/* === 主版面:sidebar + main === */
.layout {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 22px;
  margin-top: 24px;
}

.sidebar {
  position: sticky;
  top: 16px;
  align-self: start;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.sidebar h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.sidebar a {
  display: block;
  padding: 7px 8px;
  border-radius: 5px;
  color: #36536c;
  text-decoration: none;
  font-size: 14px;
}

.sidebar a:hover {
  background: var(--soft);
  color: var(--accent);
}

main {
  min-width: 0;
}

/* === Section 卡片 === */
.section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 16px;
}

.section h2 {
  font-size: 22px;
  margin: 0 0 10px;
}

.section h3 {
  font-size: 17px;
  margin: 16px 0 8px;
  color: #243b53;
}

.section p {
  margin: 0 0 10px;
}

/* === 內部小卡片 === */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.card.soft {
  background: var(--soft);
}

.card h3 {
  margin-top: 0;
  font-size: 16px;
}

/* === 教材檔案列表 === */
.file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.file-list li {
  padding: 11px 12px;
  margin: 8px 0;
  background: var(--soft);
  border-radius: 6px;
}

.file-list a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.file-list a:hover {
  text-decoration: underline;
}

/* === Tag === */
.tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e7f4ef;
  color: var(--accent2);
  font-size: 12px;
  font-weight: 800;
}

.tag.warn {
  background: #fff1d6;
  color: var(--warn);
}

.tag.secondary {
  background: #edf2f7;
  color: #52606d;
}

.tag.danger {
  background: #fff3f2;
  color: var(--danger);
}

/* === 編號流程 === */
.flow {
  counter-reset: step;
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.flow li {
  position: relative;
  margin: 10px 0;
  padding-left: 36px;
}

.flow li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  text-align: center;
  line-height: 24px;
  font-size: 13px;
  font-weight: 800;
}

/* === 檢核清單 === */
.checklist {
  list-style: none;
  padding: 0;
  margin: 8px 0;
}

.checklist li {
  padding: 8px 10px;
  margin: 7px 0;
  border-left: 4px solid var(--accent2);
  background: #f7fbfa;
  border-radius: 5px;
}

/* === 提示框 === */
.notice {
  padding: 13px 15px;
  border-left: 4px solid #d99a22;
  background: #fff8e6;
  border-radius: 6px;
  color: #4f3b13;
}

.danger {
  padding: 13px 15px;
  border-left: 4px solid var(--danger);
  background: #fff3f2;
  border-radius: 6px;
  color: #5f1914;
}

.info {
  padding: 13px 15px;
  border-left: 4px solid var(--accent);
  background: #eff6fc;
  border-radius: 6px;
  color: #1f3b53;
}

/* === 表格 === */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  background: #fff;
  font-size: 14px;
}

th, td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f4f8;
  font-weight: 800;
}

/* === 連結網格 (參考資源) === */
.link-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.resource {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  text-decoration: none;
  color: var(--accent);
  font-weight: 800;
}

.resource:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(19, 95, 159, 0.08);
}

.resource span {
  display: block;
  color: var(--muted);
  font-weight: 400;
  font-size: 13px;
  margin-top: 2px;
}

/* === 週次/Part 卡片 === */
.week-card {
  display: block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 15px;
  transition: all 0.15s ease;
}

.week-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(19, 95, 159, 0.08);
  transform: translateY(-1px);
}

.week-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(19, 95, 159, 0.08);
}

.week-card h2 {
  font-size: 18px;
  margin: 0 0 5px;
}

.week-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* === 底部上下週導覽 === */
.footer-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.muted {
  color: var(--muted);
}

/* === 程式碼區塊 === */
pre, code {
  font-family: "JetBrains Mono", "Consolas", "Monaco", monospace;
  font-size: 13px;
}

code {
  background: #eef3f7;
  padding: 2px 6px;
  border-radius: 4px;
  color: #243b53;
}

pre {
  background: #15233a;
  color: #e6edf3;
  padding: 14px 16px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 10px 0;
}

pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

/* === Pipeline ASCII 圖 === */
.pipeline {
  background: #15233a;
  color: #b7d7d7;
  padding: 14px 16px;
  border-radius: 6px;
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  margin: 10px 0;
}

/* === 響應式 === */
@media (max-width: 880px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
  .grid,
  .grid.three,
  .link-grid {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 27px;
  }
  .page {
    padding: 22px 16px 42px;
  }
}

/* === Layer 1 保護:禁右鍵+禁選取 (照用戶選的) === */
body.protected {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* 但程式碼還是要可選取,讓學生抄程式 */
body.protected pre,
body.protected pre *,
body.protected code {
  -webkit-user-select: text;
  user-select: text;
}

/* === Footer === */
footer.site-footer {
  margin-top: 40px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
