/* ==========================================================================
   Google Sheets 互動教學網站 — 全站樣式系統
   ========================================================================== */
:root {
  --brand-primary: #0f9d58;
  --brand-dark: #0b6e4f;
  --brand-light: #e6f4ea;
  --brand-soft: #f0f9f4;
  --accent-blue: #1a73e8;
  --accent-blue-soft: #e8f0fe;
  --accent-amber: #f29900;
  --accent-amber-soft: #fef7e0;
  --accent-red: #d93025;
  --accent-red-soft: #fce8e6;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #475569;
  --text-subtle: #64748b;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --font-sans: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-page);
  color: var(--text-main);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

code {
  font-family: var(--font-mono);
  background: #f1f5f9;
  color: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

pre {
  font-family: var(--font-mono);
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 10px 0;
}

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

/* 導覽列 */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
  white-space: nowrap;
}

.nav-brand:hover {
  text-decoration: none;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 2px 6px rgba(15, 157, 88, 0.3);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-links a:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
  text-decoration: none;
}

.nav-links a.active {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
}

.nav-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-soft);
  border: 1px solid #b7e1cd;
  color: var(--brand-dark);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav-score-badge:hover {
  text-decoration: none;
  background: var(--brand-light);
}

/* 容器與頁首區塊 */
.container {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.hero {
  background: linear-gradient(135deg, #0b6e4f 0%, #0f9d58 60%, #1e8e3e 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.hero-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.3;
}

.hero p {
  margin: 0 0 18px;
  max-width: 780px;
  opacity: 0.94;
  font-size: 1rem;
}

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

/* 模組頁面抬頭與成績列 */
.page-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.page-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.level-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--brand-light);
  color: var(--brand-dark);
  margin-bottom: 8px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 1.75rem;
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
}

.module-score-box {
  min-width: 240px;
  background: var(--bg-page);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.score-row strong {
  font-size: 1.25rem;
  color: var(--brand-dark);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), #34a853);
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
}

/* 章節目錄膠囊 */
.toc-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.toc-bar span {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-subtle);
  align-self: center;
  margin-right: 4px;
}

.toc-pill {
  padding: 5px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-main);
  font-size: 0.85rem;
  font-weight: 500;
}

.toc-pill:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
  text-decoration: none;
}

/* 卡片與格線 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 22px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.32rem;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 2px solid var(--brand-light);
  padding-bottom: 10px;
}

.card h3 {
  margin: 18px 0 8px;
  font-size: 1.06rem;
  color: var(--brand-dark);
}

.roadmap-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.roadmap-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.roadmap-card h3 {
  margin: 6px 0 8px;
  font-size: 1.15rem;
}

.roadmap-card p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.roadmap-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-subtle);
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

/* 按鈕系統 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-dark);
}

.btn-white {
  background: #ffffff;
  color: var(--brand-dark);
}

.btn-white:hover {
  background: #f1f5f9;
}

.btn-outline {
  background: #ffffff;
  color: var(--text-main);
  border-color: var(--border-strong);
}

.btn-outline:hover {
  background: #f8fafc;
  border-color: var(--brand-primary);
  color: var(--brand-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.btn-ghost:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.83rem;
}

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

.btn-pill {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}

.btn-pill:hover {
  border-color: var(--brand-primary);
  color: var(--brand-dark);
}

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

/* 提示框 (Callouts) */
.callout {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin: 14px 0;
  border-left: 4px solid;
  font-size: 0.94rem;
}

.callout-tip {
  background: var(--brand-soft);
  border-color: var(--brand-primary);
  color: #0d4a2b;
}

.callout-warn {
  background: var(--accent-amber-soft);
  border-color: var(--accent-amber);
  color: #6b4200;
}

.callout-info {
  background: var(--accent-blue-soft);
  border-color: var(--accent-blue);
  color: #133c75;
}

/* 表格樣式（含試算表模擬風格） */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin: 12px 0;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #f1f5f9;
  color: #0f172a;
  font-weight: 700;
}

tbody tr:hover {
  background: #f8fafc;
}

.sheet-table th.col-letter {
  background: #e2e8f0;
  color: #475569;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 8px;
}

.sheet-table td.row-num {
  background: #f1f5f9;
  color: #64748b;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  width: 38px;
  font-weight: 600;
}

tr.row-highlight {
  background: #fef9c3 !important;
}

tr.row-match {
  background: #dcfce7 !important;
}

tr.row-dim {
  opacity: 0.45;
}

td.num, th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

td.cell-err {
  background: var(--accent-red-soft);
  color: var(--accent-red);
  font-weight: 700;
  font-family: var(--font-mono);
}

td.cell-ok {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}

/* SVG 圖解區塊 */
.diagram-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 14px 0;
  text-align: center;
}

.diagram-box svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.diagram-caption {
  margin-top: 10px;
  font-size: 0.86rem;
  color: var(--text-subtle);
}

.svg-hotspot {
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.svg-hotspot:hover {
  opacity: 0.85;
}

/* 互動展示 Sandbox */
.demo-box {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 20px;
  margin: 16px 0;
}

.demo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.demo-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #1a73e8;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.demo-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  background: #fff;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
}

.control-group label {
  font-weight: 600;
  color: var(--text-muted);
}

select, input[type="text"], input[type="search"] {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
  color: var(--text-main);
}

select:focus, input[type="text"]:focus, input[type="search"]:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(15, 157, 88, 0.15);
}

.formula-preview {
  background: #0f172a;
  color: #86efac;
  font-family: var(--font-mono);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  overflow-x: auto;
  margin-bottom: 12px;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.kpi-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.kpi-label {
  font-size: 0.8rem;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.kpi-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--brand-dark);
}

/* SVG 動畫長條圖 */
.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 100px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.88rem;
}

.bar-track {
  background: #e2e8f0;
  height: 18px;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0f9d58, #34a853);
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* 實作作業與評分回饋系統 */
.assignments-section {
  margin-top: 32px;
}

.assignment-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease;
}

.assignment-card.status-passed {
  border-color: var(--brand-primary);
}

.assignment-card.status-wrong {
  border-color: #f59e0b;
}

.assignment-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.assignment-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: #0f172a;
}

.assignment-pts {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-muted);
}

.assignment-pts.earned {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.assignment-prompt {
  margin: 0 0 12px;
  color: var(--text-main);
  font-size: 0.95rem;
}

.formula-input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.formula-input {
  flex: 1;
  min-width: 240px;
  font-family: var(--font-mono) !important;
  font-size: 0.95rem !important;
  padding: 10px 12px !important;
}

.mcq-options {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.mcq-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.15s ease;
}

.mcq-option:hover {
  border-color: var(--brand-primary);
  background: var(--brand-soft);
}

.mcq-option input {
  margin-top: 4px;
}

.feedback-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  display: none;
  animation: fadeIn 0.2s ease;
}

.feedback-box.show {
  display: block;
}

.feedback-box.pass {
  background: var(--brand-soft);
  border: 1px solid #86efac;
  color: #0d4a2b;
}

.feedback-box.error {
  background: var(--accent-red-soft);
  border: 1px solid #fca5a5;
  color: #7f1d1d;
}

.feedback-box.hint {
  background: var(--accent-amber-soft);
  border: 1px solid #fde68a;
  color: #78350f;
}

.solution-box {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--accent-blue);
  font-size: 0.9rem;
  display: none;
}

.solution-box.show {
  display: block;
}

/* 頁尾上下頁導覽 */
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 36px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.site-footer {
  text-align: center;
  padding: 24px 20px;
  color: var(--text-subtle);
  font-size: 0.85rem;
  border-top: 1px solid var(--border-color);
  background: #fff;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .hero { padding: 26px 20px; }
  .page-header { padding: 20px; }
  .card { padding: 18px 16px; }
  .bar-row { grid-template-columns: 85px 1fr 80px; }
}

@media print {
  .navbar, .pager, .demo-controls, .btn { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }
}
