/* ===================================================================
   MathMagic 官網 — 公共樣式 common.css
   主題色：#0379E4  |  淺色主題  |  不使用 Google 字體
   =================================================================== */

:root {
  --mm-primary: #0379E4;
  --mm-primary-dark: #025fb4;
  --mm-primary-light: #e8f3fe;
  --mm-primary-soft: #f3f9ff;
  --mm-accent: #0763D3;
  --mm-ink: #0f1f33;
  --mm-text: #33455c;
  --mm-muted: #6b7c93;
  --mm-line: #e4ebf3;
  --mm-bg: #ffffff;
  --mm-bg-soft: #f6f9fc;
  --mm-radius: 16px;
  --mm-radius-sm: 10px;
  --mm-shadow-sm: 0 2px 10px rgba(15, 31, 51, .06);
  --mm-shadow: 0 14px 40px rgba(3, 121, 228, .12);
  --mm-shadow-lg: 0 30px 70px rgba(15, 31, 51, .14);
  --mm-nav-h: 76px;
  --mm-font: "Segoe UI", "Helvetica Neue", Helvetica, Arial,
             "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--mm-font);
  color: var(--mm-text);
  background: var(--mm-bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

a { color: var(--mm-primary); text-decoration: none; }

h1, h2, h3, h4 { color: var(--mm-ink); line-height: 1.3; margin: 0; }

.mm-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* 中英文混排：英文/數字自動與中文保持間距 */
.mm-latin { margin: 0 .12em; }

/* ---------- 通用按鈕 ---------- */
.mm-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 26px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
  white-space: nowrap;
}
.mm-btn svg { width: 18px; height: 18px; }
.mm-btn-primary {
  background: linear-gradient(135deg, var(--mm-primary), #36a0f5);
  color: #fff;
  box-shadow: 0 10px 26px rgba(3, 121, 228, .32);
}
.mm-btn-primary:hover { transform: translateY(-2px); box-shadow: 0 16px 34px rgba(3, 121, 228, .42); }
.mm-btn-ghost {
  background: #fff;
  color: var(--mm-primary);
  border-color: var(--mm-line);
}
.mm-btn-ghost:hover { border-color: var(--mm-primary); background: var(--mm-primary-soft); }

/* =====================================================================
   導航欄 header
   ===================================================================== */
.mm-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--mm-line);
}
.mm-nav {
  height: var(--mm-nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mm-brand { display: flex; align-items: center; gap: 12px; }
.mm-brand img { height: 42px; width: auto; }
.mm-brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.mm-brand-name { font-size: 19px; font-weight: 800; color: var(--mm-ink); letter-spacing: .2px; }
.mm-brand-by { font-size: 12px; color: var(--mm-muted); }

.mm-nav-links { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.mm-nav-links a {
  display: block;
  padding: 9px 16px;
  border-radius: 10px;
  color: var(--mm-text);
  font-size: 15px;
  font-weight: 500;
  transition: background .18s ease, color .18s ease;
}
.mm-nav-links a:hover { background: var(--mm-primary-soft); color: var(--mm-primary); }
.mm-nav-links a.active { color: var(--mm-primary); font-weight: 700; }

/* 頂部菜單項（鏈接或下拉按鈕統一外觀） */
.mm-nav-top {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 9px 14px; border: none; background: none; cursor: pointer;
  font-family: inherit; font-size: 15px; font-weight: 500; color: var(--mm-text);
  border-radius: 10px; transition: background .18s ease, color .18s ease;
}
.mm-nav-top svg { width: 15px; height: 15px; transition: transform .25s ease; }
.mm-nav-top:hover { background: var(--mm-primary-soft); color: var(--mm-primary); }
.mm-nav-top.active { color: var(--mm-primary); font-weight: 700; }

/* 下拉菜單 */
.mm-has-sub { position: relative; }
.mm-submenu {
  position: absolute; top: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(8px);
  min-width: 230px; background: #fff; border: 1px solid var(--mm-line);
  border-radius: 14px; box-shadow: var(--mm-shadow-lg); padding: 8px;
  opacity: 0; visibility: hidden; transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  z-index: 1001;
}
.mm-submenu::before {
  content: ""; position: absolute; top: -14px; left: 0; right: 0; height: 14px;
}
.mm-has-sub:hover .mm-nav-top svg { transform: rotate(180deg); }
.mm-has-sub:hover .mm-submenu,
.mm-has-sub:focus-within .mm-submenu {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}
.mm-submenu a {
  display: block; padding: 11px 16px; border-radius: 10px;
  color: var(--mm-text); font-size: 14.5px; font-weight: 500; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.mm-submenu a:hover { background: var(--mm-primary-soft); color: var(--mm-primary); }
.mm-submenu a.active { background: var(--mm-primary-light); color: var(--mm-primary); font-weight: 700; }

.mm-nav-actions { display: flex; align-items: center; gap: 12px; }

/* 語言切換（桌面下拉） */
.mm-lang { position: relative; }
.mm-lang-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1px solid var(--mm-line); background: #fff; cursor: pointer;
  font-family: inherit; font-size: 14px; font-weight: 600; color: var(--mm-text);
  border-radius: 10px; transition: background .18s ease, color .18s ease, border-color .18s ease;
}
.mm-lang-btn:hover { background: var(--mm-primary-soft); color: var(--mm-primary); border-color: #dcecfc; }
.mm-lang-btn svg { width: 15px; height: 15px; }
.mm-lang-btn svg:last-child { width: 13px; height: 13px; transition: transform .25s ease; }
.mm-lang:hover .mm-lang-btn svg:last-child { transform: rotate(180deg); }
.mm-lang-menu {
  position: absolute; top: calc(100% + 10px); right: 0; transform: translateY(8px);
  min-width: 190px; background: #fff; border: 1px solid var(--mm-line);
  border-radius: 14px; box-shadow: var(--mm-shadow-lg); padding: 8px;
  opacity: 0; visibility: hidden; transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
  z-index: 1001;
}
.mm-lang-menu::before { content: ""; position: absolute; top: -14px; left: 0; right: 0; height: 14px; }
.mm-lang:hover .mm-lang-menu,
.mm-lang:focus-within .mm-lang-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.mm-lang-menu a {
  display: block; padding: 10px 14px; border-radius: 10px;
  color: var(--mm-text); font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.mm-lang-menu a:hover { background: var(--mm-primary-soft); color: var(--mm-primary); }
.mm-lang-menu a.active { background: var(--mm-primary-light); color: var(--mm-primary); font-weight: 700; }

/* 漢堡按鈕 */
.mm-burger {
  display: none;
  width: 46px; height: 46px;
  border: 1px solid var(--mm-line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  position: relative;
}
.mm-burger span {
  position: absolute;
  left: 50%; top: 50%;
  width: 20px; height: 2px;
  background: var(--mm-ink);
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: transform .3s ease, opacity .25s ease;
}
.mm-burger span:nth-child(1) { transform: translate(-50%, -7px); }
.mm-burger span:nth-child(3) { transform: translate(-50%, 7px); }
.mm-burger.open span:nth-child(1) { transform: translate(-50%, 0) rotate(45deg); }
.mm-burger.open span:nth-child(2) { opacity: 0; }
.mm-burger.open span:nth-child(3) { transform: translate(-50%, 0) rotate(-45deg); }

/* 移動端彈出菜單 */
.mm-mobile-panel {
  position: fixed;
  top: var(--mm-nav-h);
  left: 0; right: 0;
  bottom: 0;
  z-index: 999;
  background: rgba(9, 24, 44, .42);
  backdrop-filter: blur(4px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
}
.mm-mobile-panel.open { opacity: 1; visibility: visible; }
.mm-mobile-inner {
  background: #fff;
  margin: 14px;
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--mm-shadow-lg);
  transform: translateY(-14px);
  transition: transform .3s ease;
  max-height: calc(100vh - var(--mm-nav-h) - 28px);
  overflow-y: auto;
}
.mm-mobile-panel.open .mm-mobile-inner { transform: translateY(0); }
.mm-mobile-inner a.mm-m-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-radius: 14px;
  color: var(--mm-ink);
  font-size: 16px;
  font-weight: 600;
  background: var(--mm-bg-soft);
  margin-bottom: 10px;
  transition: background .2s ease, transform .2s ease;
}
.mm-mobile-inner a.mm-m-link:hover { background: var(--mm-primary-light); transform: translateX(4px); }
.mm-mobile-inner a.mm-m-link svg { width: 18px; height: 18px; color: var(--mm-primary); }
.mm-mobile-inner button.mm-m-link {
  width: 100%; border: none; cursor: pointer; font-family: inherit; text-align: left;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-radius: 14px;
  color: var(--mm-ink); font-size: 16px; font-weight: 600;
  background: var(--mm-bg-soft); margin-bottom: 10px;
}
.mm-m-chev { display: inline-flex; }
.mm-m-chev svg { width: 18px; height: 18px; color: var(--mm-primary); transition: transform .25s ease; }
.mm-m-group.open .mm-m-chev svg { transform: rotate(180deg); }
.mm-m-group .mm-m-sub {
  max-height: 0; overflow: hidden; transition: max-height .3s ease;
  margin: -4px 0 10px; padding: 0 6px;
}
.mm-m-group.open .mm-m-sub { max-height: 640px; }
.mm-m-sublink {
  display: block; padding: 12px 16px; border-radius: 12px;
  color: var(--mm-text); font-size: 15px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.mm-m-sublink:hover { background: var(--mm-primary-light); color: var(--mm-primary); }
.mm-mobile-cta { display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }
.mm-mobile-cta .mm-btn { justify-content: center; padding: 15px; font-size: 16px; }

/* 移動端語言切換 */
.mm-mobile-lang { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--mm-line); }
.mm-mobile-lang-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--mm-muted); margin-bottom: 12px; }
.mm-mobile-lang-label svg { width: 16px; height: 16px; }
.mm-mobile-lang-links { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mm-mobile-lang-links a {
  display: block; text-align: center; padding: 12px 10px;
  border: 1px solid var(--mm-line); border-radius: 12px;
  color: var(--mm-text); font-size: 14.5px; font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.mm-mobile-lang-links a:hover { background: var(--mm-primary-soft); color: var(--mm-primary); border-color: #dcecfc; }
.mm-mobile-lang-links a.active { background: var(--mm-primary); color: #fff; border-color: var(--mm-primary); }

@media (max-width: 980px) {
  .mm-nav-links { display: none; }
  .mm-nav-actions .mm-btn { display: none; }
  .mm-nav-actions .mm-lang { display: none; }
  .mm-burger { display: block; }
}

/* =====================================================================
   頁腳 footer
   ===================================================================== */
.mm-footer {
  background: linear-gradient(180deg, #0c1d33 0%, #0a1626 100%);
  color: #aebdd1;
  padding: 64px 0 30px;
  margin-top: 0;
}
.mm-footer-top {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  justify-content: space-between;
  align-items: flex-start;
  padding-bottom: 40px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.mm-footer-brand { max-width: 420px; }
.mm-footer-brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.mm-footer-brand-row img { height: 40px; width: auto; }
.mm-footer-brand-name { font-size: 20px; font-weight: 800; color: #fff; line-height: 1.15; }
.mm-footer-brand-by { display: block; font-size: 13px; color: #7d8fa8; margin-top: -2px; }
.mm-footer-note { font-size: 13.5px; line-height: 1.85; color: #93a4bc; }

.mm-footer-contact { min-width: 240px; }
.mm-footer-contact h4 { color: #fff; font-size: 15px; margin-bottom: 18px; }
.mm-footer-contact-item { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; font-size: 14.5px; }
.mm-footer-contact-item .mm-fc-ico {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: rgba(3, 121, 228, .18);
  color: #4aa6f5;
}
.mm-footer-contact-item .mm-fc-ico svg { width: 18px; height: 18px; }
.mm-footer-contact-item a { color: #cdd8e7; }
.mm-footer-contact-item a:hover { color: #fff; }

.mm-footer-bottom {
  padding-top: 26px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  font-size: 13px;
  color: #7d8fa8;
}

@media (max-width: 720px) {
  .mm-footer { padding-top: 48px; }
  .mm-footer-top { flex-direction: column; gap: 32px; }
}

/* =====================================================================
   通用區塊標題
   ===================================================================== */
.mm-section { padding: 84px 0; }
.mm-section-head { text-align: center; max-width: 720px; margin: 0 auto 56px; }
.mm-eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--mm-primary);
  margin-bottom: 14px;
}
.mm-section-head h2 { font-size: 36px; font-weight: 800; margin-bottom: 16px; }
.mm-section-head p { font-size: 17px; color: var(--mm-muted); margin: 0; }

@media (max-width: 720px) {
  .mm-section { padding: 56px 0; }
  .mm-section-head h2 { font-size: 27px; }
}
