/**
 * 六年級數學「比與比值」教學互動網站 樣式表 (UDL 無障礙友善設計)
 */

:root {
  --primary: #2b6cb0;
  --primary-hover: #1e4e8c;
  --secondary: #4a5568;
  --success: #2f855a;
  --warning: #dd6b20;
  --danger: #e53e3e;
  --bg-main: #f7fafc;
  --card-bg: #ffffff;
  --text-main: #2d3748;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  font-size: 16px;
}

/* 頂部導航列 */
.navbar {
  background-color: #ffffff;
  border-bottom: 2px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 20px;
  font-weight: bold;
  color: var(--primary);
  text-decoration: none;
}

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

.student-tag {
  background-color: #edf2f7;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.student-tag input {
  border: 1px solid #cbd5e0;
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 14px;
  width: 70px;
}

/* 主容器 */
.container {
  max-width: 1080px;
  margin: 24px auto;
  padding: 0 20px 60px 20px;
}

/* 視圖切換機制 */
.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

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

/* 按鈕風格 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--secondary);
  color: #fff;
}
.btn-secondary:hover {
  background-color: #2d3748;
}

.btn-success {
  background-color: var(--success);
  color: #fff;
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background-color: #edf2f7;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 18px;
  border-radius: 12px;
}

.btn-option {
  width: 100%;
  padding: 16px 20px;
  background: #ffffff;
  border: 2px solid #cbd5e0;
  border-radius: 12px;
  font-size: 18px;
  text-align: left;
  transition: all 0.2s;
}
.btn-option:hover {
  border-color: var(--primary);
  background-color: #ebf8ff;
  transform: translateX(4px);
}

/* 卡片與佈局 */
.card {
  background-color: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.hero-banner {
  background: linear-gradient(135deg, #2b6cb0 0%, #4299e1 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-lg);
}

.hero-banner h1 {
  font-size: 32px;
  margin-bottom: 12px;
}

.hero-banner p {
  font-size: 18px;
  opacity: 0.95;
  max-width: 800px;
}

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

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

/* 學習專用調飲模擬器 */
.sim-container {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  align-items: center;
  justify-content: center;
  padding: 20px 0;
}

.cup-wrapper {
  position: relative;
  width: 180px;
  height: 240px;
  border: 4px solid #4a5568;
  border-top: none;
  border-radius: 0 0 30px 30px;
  background: rgba(255, 255, 255, 0.6);
  overflow: hidden;
  box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.liquid-visual {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: #c96e24;
  height: 40%;
  transition: all 0.4s ease;
  border-radius: 0 0 26px 26px;
}

.cup-marks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  border-left: 2px dashed rgba(0,0,0,0.15);
}

/* 四宮格表格 */
.grid-table-quiz {
  width: 100%;
  max-width: 500px;
  margin: 16px auto;
  border-collapse: collapse;
  text-align: center;
}

.grid-table-quiz th, .grid-table-quiz td {
  border: 3px solid #4a5568;
  padding: 16px;
  font-size: 20px;
  font-weight: bold;
}

.grid-table-quiz th {
  background-color: #edf2f7;
  color: var(--primary);
}

.input-quiz-blank {
  width: 100px;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  padding: 8px;
  border: 3px dashed var(--primary);
  border-radius: 8px;
  background: #fffaf0;
}

/* 徽章與狀態 */
.badge {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: bold;
}
.badge-success { background: #c6f6d5; color: #22543d; }
.badge-warning { background: #feebc8; color: #7b341e; }
.badge-danger  { background: #fed7d7; color: #742a2a; }
.badge-info    { background: #bee3f8; color: #2a4365; }

/* 警示與提示框 */
.alert {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-top: 16px;
}
.alert-success { background: #f0fff4; border: 2px solid #9ae6b4; color: #22543d; }
.alert-warning { background: #fffaf0; border: 2px solid #fbd38d; color: #744210; }
.alert-danger  { background: #fff5f5; border: 2px solid #feb2b2; color: #742a2a; }
.alert-info    { background: #ebf8ff; border: 2px solid #bee3f8; color: #2a4365; }

/* 步驟清單 */
.step-list {
  padding-left: 20px;
  margin-top: 10px;
}
.step-list li {
  margin-bottom: 8px;
  font-size: 16px;
}

/* 教師後台表格 */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}
.admin-table th, .admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.admin-table th {
  background-color: #f7fafc;
  font-weight: bold;
  color: var(--secondary);
}

/* 彈窗 Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 90%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.hidden {
  display: none !important;
}

/* 工具類 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: bold; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.whitespace-pre-line { white-space: pre-line; }

/* 步驟化學習例題膠囊導航 (Stepper Pills) */
.stepper-pill {
  padding: 8px 16px;
  border-radius: 20px;
  border: 2px solid var(--border-color);
  background: #ffffff;
  color: var(--text-main);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.stepper-pill:hover {
  border-color: var(--primary);
  background: #ebf8ff;
  transform: translateY(-1px);
}
.stepper-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 3px 8px rgba(43, 108, 176, 0.35);
}

/* 形成性評量學生身分列 */
.quiz-student-banner {
  background: #ebf8ff;
  border: 2px solid #bee3f8;
  border-radius: var(--radius-md);
}

/* 微小動畫 */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
.animate-shake {
  animation: shake 0.4s ease-in-out;
}

/* 首頁兩大行動門戶卡片效果 */
.portal-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.portal-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12) !important;
}

/* ========================================================
   浮動計算機按鈕與彈出視窗
   ======================================================== */
.floating-calc-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1500;
  background: linear-gradient(135deg, #2b6cb0 0%, #3182ce 100%);
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 30px;
  padding: 12px 22px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(43, 108, 176, 0.45);
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}
.floating-calc-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 24px rgba(43, 108, 176, 0.55);
  background: linear-gradient(135deg, #1a4971 0%, #2b6cb0 100%);
}

.calculator-card {
  background: #ffffff;
  border-radius: 20px;
  padding: 22px;
  width: 92%;
  max-width: 360px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.3);
  border: 2px solid #e2e8f0;
}
.calc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.calc-close-btn {
  background: #edf2f7;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  color: #718096;
  transition: all 0.2s;
}
.calc-close-btn:hover {
  background: #feb2b2;
  color: #c53030;
}
.calc-display-wrap {
  background: #1a202c;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}
.calc-history {
  color: #a0aec0;
  font-size: 13px;
  min-height: 18px;
  text-align: right;
  font-family: 'Courier New', monospace;
}
.calc-screen {
  color: #68d391;
  font-size: 28px;
  font-weight: bold;
  text-align: right;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.calc-keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.calc-btn {
  font-size: 18px;
  font-weight: bold;
  padding: 12px 6px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f7fafc;
  color: #2d3748;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.calc-btn:hover {
  background: #edf2f7;
  transform: translateY(-1px);
}
.calc-btn:active {
  transform: translateY(1px);
}
.calc-btn-op {
  background: #ebf8ff;
  color: #2b6cb0;
  border-color: #bee3f8;
}
.calc-btn-op:hover {
  background: #bee3f8;
}
.calc-btn-action {
  background: #fff5f5;
  color: #e53e3e;
  border-color: #feb2b2;
}
.calc-btn-action:hover {
  background: #fed7d7;
}
.calc-btn-eq {
  background: #38a169;
  color: #ffffff;
  border-color: #2f855a;
}
.calc-btn-eq:hover {
  background: #2f855a;
}

/* ========================================================
   特教 2×2 比例四宮格全新視覺樣式
   ======================================================== */
.four-grid-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 16px 0;
}
.four-grid-table-box {
  border: 3px solid #3182ce;
  border-radius: 14px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 14px rgba(49, 130, 206, 0.15);
}
.four-grid-tbl {
  width: 100%;
  border-collapse: collapse;
}
.four-grid-tbl th {
  background: linear-gradient(180deg, #2b6cb0 0%, #2c5282 100%);
  color: #ffffff;
  padding: 12px 24px;
  font-size: 17px;
  font-weight: bold;
  text-align: center;
  letter-spacing: 0.5px;
}
.four-grid-tbl td {
  padding: 16px 24px;
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  color: #2d3748;
  border: 2px solid #e2e8f0;
  min-width: 120px;
}
.four-grid-tbl td.cell-known {
  background: #ebf8ff;
  color: #2b6cb0;
}
.four-grid-tbl td.cell-target {
  background: #fffaf0;
  color: #dd6b20;
  border: 3px dashed #dd6b20;
  cursor: pointer;
  transition: all 0.3s ease;
}
.four-grid-tbl td.cell-target.solved {
  background: #f0fff4;
  color: #2f855a;
  border: 3px solid #38a169;
  animation: bounce 0.4s ease;
}

/* 箭頭倍數引導框 */
.arrow-bridge-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f7fafc;
  border: 2px dashed #a0aec0;
  border-radius: 12px;
  padding: 14px 20px;
  min-width: 180px;
}
.arrow-bridge-tag {
  background: #3182ce;
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  padding: 4px 12px;
  border-radius: 20px;
  margin: 6px 0;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ========================================================
   例題 6～10 步驟計算與箭頭流動樣式
   ======================================================== */
.calc-step-card {
  background: #f0fff4;
  border: 2px solid #9ae6b4;
  border-radius: 14px;
  padding: 20px;
  margin: 16px 0;
  box-shadow: 0 4px 12px rgba(56, 161, 105, 0.08);
}
.step-arrow-diagram {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 16px 0;
  background: #ffffff;
  padding: 16px;
  border-radius: 12px;
  border: 2px dashed #bee3f8;
}
.ratio-term-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 16px;
  background: #ebf8ff;
  border: 2px solid #3182ce;
  border-radius: 10px;
  font-weight: bold;
  font-size: 20px;
  color: #2b6cb0;
}
.arrow-indicator-col {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 15px;
  font-weight: bold;
  color: #c53030;
}
.arrow-symbol {
  font-size: 24px;
  line-height: 1;
  color: #e53e3e;
  animation: pulse 1.5s infinite;
}

/* ========================================================
   標準數學直式分數樣式 (國小特教專用高可讀性排版)
   ======================================================== */
.math-frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  font-size: 0.95em;
  line-height: 1.1;
  margin: 0 4px;
  padding: 0 2px;
  font-family: inherit;
}
.math-frac .frac-num {
  border-bottom: 2px solid currentColor;
  padding-bottom: 2px;
  font-weight: bold;
  display: block;
}
.math-frac .frac-den {
  padding-top: 2px;
  font-weight: bold;
  display: block;
}
.math-mixed {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
}
.math-mixed .mixed-int {
  font-size: 1.15em;
  font-weight: bold;
  margin-right: 4px;
  line-height: 1;
}

/* 分數填空專用輸入框樣式 */
.frac-input-group {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 4px;
}
.frac-input {
  width: 56px;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  padding: 4px;
  border: 2px solid #3182ce;
  border-radius: 6px;
  background: #ffffff;
}
.frac-input.frac-num-input {
  border-bottom-color: #2b6cb0;
}
.frac-input.frac-den-input {
  border-top-color: #2b6cb0;
}
.frac-input-bar {
  width: 100%;
  height: 2px;
  background: #2b6cb0;
  margin: 2px 0;
}
.frac-input.correct {
  border-color: #38a169;
  background: #f0fff4;
  color: #22543d;
}
.frac-input.incorrect {
  border-color: #e53e3e;
  background: #fff5f5;
  color: #742a2a;
}

/* 評量技巧與修改提示卡片樣式 */
.quiz-technique-card {
  background: #ebf8ff;
  border: 2px solid #63b3ed;
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 10px;
  font-size: 16px;
}
.quiz-correction-card {
  background: #fffaf0;
  border: 2px solid #f6ad55;
  border-radius: 10px;
  padding: 12px 16px;
  margin-top: 10px;
  font-size: 16px;
}

/* 教師後台重整與編輯 Modal 樣式 */
.admin-actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

/* 形成性評量 姓名門檻卡與活動挑選大廳卡片 */
.quiz-gate-card {
  max-width: 600px;
  margin: 30px auto;
  background: #fffdfa;
  border: 2px solid #f6ad55;
  box-shadow: 0 6px 20px rgba(246, 173, 85, 0.18);
  border-radius: var(--radius-lg);
}
.quiz-lobby-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  border-radius: var(--radius-lg);
}
.quiz-lobby-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.09);
}



