/* ============================================================
   Web3 的應用與實務 — 教科書共用 CSS
   深紫/金色系，與投影片配色一致
   ============================================================ */

:root {
  --bg-deep:    #0d0420;
  --bg-base:    #1a0a2e;
  --bg-page:    #f8f5ff;
  --bg-card:    #ffffff;
  --bg-sidebar: #0d0420;
  --primary:    #2d1b4e;
  --secondary:  #4a2d7a;
  --accent:     #f59e0b;
  --accent-lt:  #fbbf24;
  --text:       #1a0a2e;
  --text-dim:   #6b5b8a;
  --text-mute:  #9b8bb8;
  --text-light: #f5f0ff;
  --border:     #e0d8f0;
  --code-bg:    #1a0a2e;
  --link:       #7c3aed;
  --link-hover: #5b21b6;
}

/* ---------- 深色主題（由入口網頁透過 postMessage 切換）---------- */
html[data-theme="dark"] {
  --bg-page:    #0f0a1c;
  --bg-card:    #1a1230;
  --bg-deep:    #080413;
  --bg-base:    #150c26;
  --bg-sidebar: #080413;
  --text:       #ece7f8;
  --text-dim:   #b9aed6;
  --text-mute:  #8d80ad;
  --border:     #2e2348;
  --code-bg:    #080413;
  --link:       #a78bfa;
  --link-hover: #c4b5fd;
}

/* ---------- 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: white;
  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: #f3effa;
}

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(245, 158, 11, 0.08), rgba(124, 58, 237, 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);
}

/* ---------- 案例框 (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(45, 27, 78, 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(124, 58, 237, 0.06);
  border: 1px solid rgba(124, 58, 237, 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(13, 4, 32, 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(124, 58, 237, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--link);
  font-size: 0.9em;
}

/* ---------- 互動提示 ---------- */
.interaction {
  background: rgba(245, 158, 11, 0.08);
  border: 1px dashed rgba(245, 158, 11, 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;
}

/* ---------- 導航 ---------- */
.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(45, 27, 78, 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(245, 158, 11, 0.15); color: var(--accent); }
.course-card .badge.holiday { background: rgba(155, 139, 184, 0.15); color: var(--text-mute); }

/* ---------- 響應式 ---------- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-260px);
    transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .content { margin-left: 0; padding: 20px 24px 60px; }
  .sidebar-toggle {
    position: fixed;
    left: 0; top: 50%;
    transform: translateY(-50%);
    z-index: 101;
    background: var(--bg-sidebar);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: var(--accent-lt);
    padding: 12px 8px;
    cursor: pointer;
    font-size: 18px;
  }
}

@media (min-width: 901px) {
  .sidebar-toggle { display: none; }
}

/* ---------- 深色模式：標題與強調字改用亮紫 ----------
   主色 --primary 是深紫（#2d1b4e），直接壓在深色底上對比不足，
   因此深色模式下只把「文字用」的地方換成亮紫，區塊底色不動。 */
html[data-theme="dark"] .content h1,
html[data-theme="dark"] .content h2,
html[data-theme="dark"] .content h3,
html[data-theme="dark"] .content h4,
html[data-theme="dark"] .content strong,
html[data-theme="dark"] .case-study h4,
html[data-theme="dark"] .course-card h3 {
  color: #c4b5fd;
}

html[data-theme="dark"] .nav-footer .home-link:hover {
  color: #c4b5fd;
}