/**
 * HCF VISUAL LAB - Mobile Menu (Awakening-style)
 * 比照 awakening-design.com.tw 手機選單結構：
 *   MENU ≡ → 實色 CLOSE ✕ 方塊｜微斜「紙張」面板｜大字英文紅標題 + 中文小標
 *   子連結以「/」分隔｜區塊間手繪波浪虛線｜底部社群 + 方塊 CTA｜區塊逐一淡入
 * 套 HCF 深色 VI：黑曜底 + 深色面板 + 品牌紅標題。
 */

:root {
  --mm-red: #C81015;
  --mm-gold: #D4AF37;
  --mm-bg: rgba(7, 7, 10, 0.96);
  --mm-sheet: #111116;
  --mm-line: rgba(255, 255, 255, 0.1);
  --mm-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Header 按鈕：MENU ≡ ⇄ CLOSE ✕ ---------- */
#mobile-menu-btn {
  position: relative;
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  color: #fff;
  font-family: 'Inter', 'Noto Sans TC', sans-serif;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  line-height: 1;
  cursor: pointer;
  transition: background 0.35s ease, color 0.35s ease, border-color 0.35s ease;
  -webkit-tap-highlight-color: transparent;
}
#mobile-menu-btn .mm-label { display: inline-block; min-width: 3.6em; text-align: right; }
#mobile-menu-btn .mm-lines {
  position: relative;
  width: 26px;
  height: 14px;
  display: block;
}
#mobile-menu-btn .mm-lines i {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.45s var(--mm-ease), opacity 0.25s ease, top 0.3s ease;
}
#mobile-menu-btn .mm-lines i:nth-child(1) { top: 0; }
#mobile-menu-btn .mm-lines i:nth-child(2) { top: 6px; }
#mobile-menu-btn .mm-lines i:nth-child(3) { top: 12px; }

#mobile-menu-btn.is-open {
  background: #fff;
  color: #000;
  border-color: #fff;
}
#mobile-menu-btn.is-open .mm-lines i:nth-child(1) { top: 6px; transform: rotate(45deg); }
#mobile-menu-btn.is-open .mm-lines i:nth-child(2) { opacity: 0; transform: scaleX(0); }
#mobile-menu-btn.is-open .mm-lines i:nth-child(3) { top: 6px; transform: rotate(-45deg); }

/* ---------- 全螢幕覆蓋 ---------- */
.mm {
  position: fixed;
  inset: 0;
  z-index: 45; /* header 是 z-50，按鈕留在上層 */
  background: var(--mm-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0s linear 0.4s;
  overflow: hidden;
  font-family: 'Inter', 'Noto Sans TC', -apple-system, sans-serif;
}
.mm.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.4s ease, visibility 0s;
}
.mm::before {
  /* 背景微光 */
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 80% 0%, rgba(200, 16, 21, 0.18), transparent 70%),
    radial-gradient(50% 40% at 0% 100%, rgba(212, 175, 55, 0.12), transparent 70%);
}

/* ---------- 紙張面板（微斜 + 撕邊） ---------- */
.mm-sheet {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 92px;
  bottom: 18px;
  background: var(--mm-sheet);
  border: 1px solid var(--mm-line);
  box-shadow:
    0 30px 60px -20px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  clip-path: polygon(
    0 7px, 8% 2px, 17% 8px, 29% 3px, 41% 9px, 52% 2px, 63% 7px, 75% 1px, 87% 8px, 100% 3px,
    100% calc(100% - 5px), 90% 100%, 78% calc(100% - 7px), 64% 100%, 50% calc(100% - 3px),
    36% calc(100% - 8px), 22% calc(100% - 2px), 10% calc(100% - 7px), 0 100%
  );
  transform: translateY(40px) rotate(-4deg) scale(0.97);
  transform-origin: 50% 100%;
  opacity: 0;
  transition: transform 0.7s var(--mm-ease), opacity 0.4s ease;
  overflow: hidden;
}
.mm.is-open .mm-sheet {
  transform: translateY(0) rotate(-1.6deg) scale(1);
  opacity: 1;
}
.mm-scroll {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 34px 26px 40px;
  transform: rotate(1.6deg); /* 內容轉回正，只有紙張斜 */
  transform-origin: 50% 50%;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* ---------- 區塊 ---------- */
.mm-section {
  padding: 22px 4px 24px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease, transform 0.6s var(--mm-ease);
}
.mm.is-open .mm-section {
  opacity: 1;
  transform: none;
  transition-delay: calc(0.18s + var(--i, 0) * 0.09s);
}
.mm-section + .mm-section {
  /* 手繪波浪虛線 */
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='12' viewBox='0 0 160 12'><path d='M0 6 Q20 0 40 6 T80 6 T120 6 T160 6' fill='none' stroke='%23555560' stroke-width='1.2' stroke-dasharray='3 3' stroke-linecap='round'/></svg>");
  background-repeat: repeat-x;
  background-position: 0 0;
  background-size: 160px 12px;
}
.mm-title {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--mm-red);
}
.mm-sub {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #fff;
}
.mm-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 0;
  margin-top: 16px;
  padding: 0;
  list-style: none;
}
.mm-links li { display: inline-flex; align-items: center; }
.mm-links a {
  color: #D8D8DE;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.04em;
  padding: 2px 0;
  transition: color 0.25s ease;
}
.mm-links a:hover, .mm-links a:active { color: #fff; }
.mm-links a.is-current {
  color: var(--mm-gold);
  font-weight: 700;
}
.mm-links a.is-current::before {
  content: '';
  display: inline-block;
  width: 5px; height: 5px;
  margin-right: 7px;
  vertical-align: middle;
  background: var(--mm-red);
}
.mm-links li::after {
  content: '/';
  color: #4A4A55;
  font-weight: 300;
  margin: 0 14px;
}
.mm-links li:last-child::after { content: none; }
.mm-links a.is-hot { color: #67E8F9; }

/* ---------- 底部：社群 + CTA + 切換 ---------- */
.mm-foot {
  padding: 26px 4px 8px;
  border-top: 1px solid var(--mm-line);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.5s ease 0.75s, transform 0.6s var(--mm-ease) 0.75s;
}
.mm.is-open .mm-foot { opacity: 1; transform: none; }
.mm-social {
  display: flex;
  gap: 22px;
  align-items: center;
  margin-bottom: 22px;
}
.mm-social a {
  color: #fff;
  display: inline-flex;
  width: 24px; height: 24px;
  transition: color 0.25s ease, transform 0.3s var(--mm-ease);
}
.mm-social a:hover { color: var(--mm-gold); transform: translateY(-2px); }
.mm-social svg { width: 100%; height: 100%; }
.mm-cta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--mm-red);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 15px 26px 15px 22px;
  transition: background 0.3s ease, transform 0.3s var(--mm-ease);
}
.mm-cta::before {
  content: '';
  width: 6px; height: 6px;
  background: #fff;
}
.mm-cta:hover { background: #A50D11; transform: translateX(3px); }
.mm-tools {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}
.mm-tools button {
  appearance: none;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  padding: 8px 14px;
  border-radius: 9999px;
  border: 1px solid var(--mm-line);
  background: rgba(255, 255, 255, 0.04);
  color: #C9C9D2;
  cursor: pointer;
}
.mm-tools button.opacity-50 { opacity: 0.5; }

.mm-brand { display: flex; align-items: center; justify-content: space-between; margin: -8px 0 8px; }
.mm-brand img { height: 30px; width: auto; }
.mm-spectrum { margin: 0 0 14px; }
.mm-spectrum .brand-spectrum { padding-right: 12px; }
/* 小字標籤 */
.mm-tag {
  display: block;
  text-align: right;
  font-family: 'JetBrains Mono', 'Inter', monospace;
  font-size: 9px;
  letter-spacing: 0.3em;
  color: #55555F;
}

/* 選單開啟時，收掉各頁底部固定 CTA（about.html 那顆是 z-50 會蓋到選單） */
body.mm-open .fixed.bottom-4,
body.mm-open .fixed.bottom-8 { visibility: hidden; }

/* 桌機：面板置中、內容兩欄 */
@media (min-width: 1024px) {
  .mm-sheet {
    left: 50%;
    right: auto;
    width: min(860px, 92vw);
    transform: translate(-50%, 40px) rotate(-4deg) scale(0.97);
    transform-origin: 50% 100%;
  }
  .mm.is-open .mm-sheet { transform: translate(-50%, 0) rotate(-1.2deg) scale(1); }
  .mm-scroll { transform: rotate(1.2deg); padding: 40px 56px 48px; }
  .mm-sections { display: grid; grid-template-columns: 1fr 1fr; column-gap: 48px; }
  .mm-section + .mm-section { background-image: none; }
  .mm-section { border-top: 1px dashed rgba(255,255,255,0.12); }
  .mm-section:nth-child(-n+2) { border-top: 0; }
  .mm-title { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  .mm, .mm-sheet, .mm-section, .mm-foot, #mobile-menu-btn .mm-lines i { transition-duration: 0.01s !important; transition-delay: 0s !important; }
}
