/* ============================================================
   數位科技與 AI 應用 — 教科書共用 CSS
   清新科技藍/活力暖橘配色，與投影片配色一致
   元件庫對齊 Web3 課程教科書（quote / case-study / status-2026 / interaction）
   ============================================================ */

:root {
  --bg-deep:      #0c2340;
  --bg-base:      #112d4e;
  --bg-page:      #f4f7fb;
  --bg-card:      #ffffff;
  --bg-sidebar:   #0a192f;
  --primary:      #065a82;
  --secondary:    #1c7293;
  --accent:       #f97316;
  --accent-lt:    #fb923c;
  --teal:         #0284c7;
  --text:         #1e293b;
  --text-dim:     #475569;
  --text-mute:    #94a3b8;
  --text-light:   #f8fafc;
  --border:       #e2e8f0;
  --code-bg:      #0f172a;
  --link:         #0284c7;
  --link-hover:   #0369a1;
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.05);
}

/* ---------- 深色主題（由入口網頁透過 postMessage 切換）---------- */
html[data-theme="dark"] {
  --bg-page:      #0b1220;
  --bg-card:      #151d2e;
  --bg-deep:      #060b14;
  --bg-base:      #0e1729;
  --bg-sidebar:   #060b14;
  --text:         #e8eef7;
  --text-dim:     #b3c1d4;
  --text-mute:    #8b9bb0;
  --border:       #253148;
  --code-bg:      #060b14;
  --link:         #4db8e8;
  --link-hover:   #7dd3f5;
  --shadow-sm:    0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,0.5), 0 2px 4px -2px rgba(0,0,0,0.4);
  --shadow-lg:    0 10px 15px -3px rgba(0,0,0,0.55), 0 4px 6px -4px rgba(0,0,0,0.4);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.8;
  font-size: 16px;
}

/* ---------- Layout ---------- */
.layout {
  display: block;
  min-height: 100vh;
  width: 100%;
}

.sidebar,
.sidebar-toggle {
  display: none !important;
}

/* ---------- Main Content ---------- */
.content {
  margin: 0 auto;
  padding: 40px 36px 120px;
  max-width: 920px;
}

/* ---------- Typography ---------- */
.content h1 {
  font-size: 2.2em;
  font-weight: 900;
  color: var(--primary);
  margin-bottom: 8px;
  line-height: 1.3;
}

.content .week-meta {
  font-size: 0.85em;
  color: var(--text-dim);
  margin-bottom: 32px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--accent);
}

.content h2 {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--primary);
  margin-top: 48px;
  margin-bottom: 16px;
  padding-left: 16px;
  border-left: 5px solid var(--accent);
  line-height: 1.4;
}

.content h3 {
  font-size: 1.25em;
  font-weight: 700;
  color: var(--secondary);
  margin-top: 32px;
  margin-bottom: 12px;
}

.content h4 {
  font-size: 1.05em;
  font-weight: 700;
  color: var(--text);
  margin-top: 20px;
  margin-bottom: 8px;
}

.content p {
  margin-bottom: 16px;
  color: var(--text);
  line-height: 1.85;
}

.content strong {
  color: var(--primary);
  font-weight: 700;
}

.content a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
}

.content a:hover {
  color: var(--link-hover);
  border-bottom-color: var(--link-hover);
}

/* ---------- Lists ---------- */
.content ul, .content ol {
  margin-left: 0;
  padding-left: 0;
  margin-bottom: 16px;
}

.content ul li, .content ol li {
  list-style: none;
  position: relative;
  padding-left: 1.6em;
  margin-bottom: 8px;
  line-height: 1.8;
}

.content ul li::before {
  content: '';
  position: absolute;
  left: 0.3em;
  top: 0.7em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.content ol {
  counter-reset: ol-counter;
}

.content ol li {
  counter-increment: ol-counter;
}

.content ol li::before {
  content: counter(ol-counter);
  position: absolute;
  left: 0;
  top: 0.05em;
  width: 1.5em;
  height: 1.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
  color: white;
  font-weight: 700;
  font-size: 0.75em;
  border-radius: 50%;
}

/* ---------- Tables ---------- */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9em;
}

.content th {
  background: var(--primary);
  color: #ffffff;
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  border: 1px solid var(--primary);
}

.content td {
  padding: 10px 16px;
  border: 1px solid var(--border);
  vertical-align: top;
}

.content tr:nth-child(even) {
  background: #f0f7fb;
}

html[data-theme="dark"] .content th {
  background: #112238;
  color: #f8fafc;
  border: 1px solid var(--border);
}

html[data-theme="dark"] .content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

html[data-theme="dark"] .content tr:hover {
  background: rgba(255, 255, 255, 0.07);
}

html[data-theme="dark"] .content td {
  border-color: var(--border);
  color: var(--text);
}

/* ---------- Blockquote / 重點框 ---------- */
.content blockquote {
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.08), rgba(6, 90, 130, 0.06));
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 16px 24px;
  margin: 20px 0;
  font-size: 1.05em;
}

.content blockquote p {
  margin-bottom: 0;
}

.content blockquote strong {
  color: var(--accent);
}

/* ---------- 引用框 (Quote) ---------- */
.quote {
  position: relative;
  background: linear-gradient(135deg, rgba(249, 115, 22, 0.06), rgba(6, 90, 130, 0.04));
  border-left: 4px solid var(--accent);
  border-radius: 0 12px 12px 0;
  padding: 18px 24px 18px 28px;
  margin: 20px 0;
}

.quote .quote-text {
  font-size: 1.05em;
  font-style: italic;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 8px;
}

.quote .quote-source {
  font-size: 0.85em;
  color: var(--text-dim);
  font-weight: 500;
}

.quote .quote-source::before {
  content: '— ';
}

/* ---------- 文獻引用標記 ---------- */
.ref {
  font-size: 0.8em;
  color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace;
  background: rgba(6, 90, 130, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ---------- 章節導語 ---------- */
.section-lead {
  font-size: 1.05em;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 20px;
  padding-left: 16px;
  border-left: 2px solid var(--border);
}

/* ---------- 章節結語橋接 ---------- */
.section-bridge {
  background: rgba(249, 115, 22, 0.05);
  border-radius: 10px;
  padding: 14px 20px;
  margin: 24px 0 32px;
  font-size: 0.95em;
  color: var(--text-dim);
}

.section-bridge::before {
  content: '➡ ';
  font-weight: 700;
  color: var(--accent);
}

/* ---------- 案例框 (Case Study) ---------- */
.case-study {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 28px;
  margin: 24px 0;
  box-shadow: 0 4px 20px rgba(6, 90, 130, 0.06);
}

.case-study .case-label {
  display: inline-block;
  font-size: 0.7em;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--accent);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.case-study h4 {
  color: var(--primary);
  font-size: 1.15em;
  margin-top: 0;
  margin-bottom: 16px;
}

.case-study .case-section {
  margin-bottom: 16px;
}

.case-study .case-section:last-child {
  margin-bottom: 0;
}

.case-study .case-section h5 {
  font-size: 0.85em;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 6px;
}

.case-study .case-section p {
  font-size: 0.95em;
  margin-bottom: 0;
  line-height: 1.75;
}

/* ---------- 2026 現狀框 ---------- */
.status-2026 {
  background: rgba(6, 90, 130, 0.06);
  border: 1px solid rgba(6, 90, 130, 0.2);
  border-radius: 10px;
  padding: 14px 20px;
  margin: 16px 0;
  font-size: 0.9em;
}

.status-2026::before {
  content: '📍 2026 現狀';
  display: block;
  font-weight: 700;
  font-size: 0.8em;
  color: var(--link);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.status-2026 p {
  margin-bottom: 0;
  color: var(--text-dim);
}

/* ---------- 程式碼 ---------- */
.content pre {
  background: var(--code-bg);
  border-radius: 10px;
  padding: 18px 24px;
  margin: 20px 0;
  overflow-x: auto;
  box-shadow: 0 4px 16px rgba(12, 35, 64, 0.2);
}

.content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9em;
}

.content pre code {
  color: #e6f1ff;
  line-height: 1.6;
}

.content :not(pre) > code {
  background: rgba(6, 90, 130, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--link);
  font-size: 0.9em;
}

/* ---------- 互動提示 ---------- */
.interaction {
  background: rgba(249, 115, 22, 0.08);
  border: 1px dashed rgba(249, 115, 22, 0.4);
  border-radius: 8px;
  padding: 10px 16px;
  margin: 16px 0;
  font-size: 0.9em;
  color: var(--text-dim);
}

.interaction::before {
  content: '💬 課堂互動';
  font-weight: 700;
  color: var(--accent);
  margin-right: 8px;
}

/* ---------- 參考文獻區 ---------- */
.references {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 2px solid var(--border);
}

.references h3 {
  font-size: 1.1em;
  color: var(--primary);
  margin-bottom: 12px;
}

.references ol li {
  font-size: 0.85em;
  color: var(--text-dim);
  line-height: 1.6;
  margin-bottom: 6px;
}

.references ol li::before {
  background: var(--text-mute);
  font-size: 0.7em;
}

/* ---------- 導航 ---------- */
.nav-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.nav-footer a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9em;
  font-weight: 500;
  border: none;
  transition: background 0.2s;
}

.nav-footer a:hover {
  background: var(--secondary);
  color: white;
}

.nav-footer a.disabled {
  background: var(--border);
  color: var(--text-mute);
  pointer-events: none;
}

.nav-footer .home-link {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.nav-footer .home-link:hover {
  background: var(--bg-card);
  color: var(--primary);
}

/* ---------- 首頁專用 ---------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 32px;
}

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 24px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.2s, box-shadow 0.2s;
  border-left: 4px solid var(--accent);
}

.course-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(6, 90, 130, 0.1);
  color: var(--text);
}

.course-card.holiday {
  border-left-color: var(--text-mute);
  opacity: 0.6;
}

.course-card .week-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75em;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.course-card h3 {
  font-size: 1.05em;
  color: var(--primary);
  margin-top: 4px;
  margin-bottom: 4px;
}

.course-card .date {
  font-size: 0.8em;
  color: var(--text-dim);
}

.course-card .badge {
  display: inline-block;
  font-size: 0.7em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 6px;
}

.course-card .badge.exam { background: rgba(249, 115, 22, 0.15); color: var(--accent); }
.course-card .badge.holiday { background: rgba(148, 163, 184, 0.15); color: var(--text-mute); }

/* ---------- 小字 ---------- */
.tiny {
  font-size: 0.85em;
  line-height: 1.7;
}

/* ---------- 折疊式答案框（活動用：避免劇透） ---------- */
details.answer-box {
  margin: 16px 0;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: rgba(249, 115, 22, 0.04);
  padding: 4px 16px;
}
details.answer-box[open] {
  padding: 4px 16px 16px;
}
details.answer-box > summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 700;
  color: var(--primary);
  list-style: none;
  user-select: none;
}
details.answer-box > summary::-webkit-details-marker { display: none; }
details.answer-box > summary::before {
  content: "▶ ";
  font-size: 0.8em;
  color: var(--accent);
  display: inline-block;
  transition: transform 0.2s ease;
}
details.answer-box[open] > summary::before {
  content: "▼ ";
}

/* ---------- 響應式 ---------- */
@media (max-width: 900px) {
  .content { padding: 20px 24px 60px; }
}
