/**
 * HCF VISUAL LAB - Brand FX
 * 把 logo 的彩虹語言帶進全站：色票 token、光譜色帶、可換色的強調色，
 * 以及互動程式的樣式（logo 顯現/傾斜、磁吸按鈕、漣漪、彩虹游標光暈）。
 */

:root {
  /* 取自 logo 的七色 */
  --lg-blue: #2F5BFF;
  --lg-violet: #8A5CFF;
  --lg-pink: #FF3DB0;
  --lg-orange: #FF6B35;
  --lg-yellow: #FFD23F;
  --lg-green: #12A35B;
  --lg-red: #FF3B47;
  --hcf-grad: linear-gradient(90deg, var(--lg-blue), var(--lg-violet), var(--lg-pink), var(--lg-orange), var(--lg-yellow), var(--lg-green), var(--lg-red));
  /* 可由選色器覆寫的強調色（預設維持 HCF 紅） */
  --hcf-accent: #C81015;
  --hcf-accent-soft: rgba(200, 16, 21, 0.18);
}

/* ---------- 強調色接管 Tailwind 任意值 class（選色器換色時全站跟著變） ---------- */
html.brand-tinted .text-\[\#C81015\] { color: var(--hcf-accent) !important; }
html.brand-tinted .bg-\[\#C81015\] { background-color: var(--hcf-accent) !important; }
html.brand-tinted .border-\[\#C81015\] { border-color: var(--hcf-accent) !important; }
html.brand-tinted .hover\:bg-\[\#C81015\]:hover { background-color: var(--hcf-accent) !important; }
html.brand-tinted .hover\:text-\[\#C81015\]:hover { color: var(--hcf-accent) !important; }
html.brand-tinted .bg-\[\#C81015\]\/20, html.brand-tinted .bg-\[\#C81015\]\/15, html.brand-tinted .bg-\[\#C81015\]\/10 { background-color: var(--hcf-accent-soft) !important; }
html.brand-tinted .mm-title { color: var(--hcf-accent); }
html.brand-tinted .mm-cta { background: var(--hcf-accent); }
html.brand-tinted .mm-links a.is-current::before { background: var(--hcf-accent); }
html.brand-tinted #mobile-menu-btn.is-open { background: var(--hcf-accent); border-color: var(--hcf-accent); color: #fff; }
html.brand-tinted .glass-input:focus { border-color: var(--hcf-accent); box-shadow: 0 0 16px -2px var(--hcf-accent-soft); }

/* ---------- 彩虹漸層字 ---------- */
.text-gradient-brand {
  background: var(--hcf-grad);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: brandShift 9s linear infinite;
}
@keyframes brandShift { to { background-position: 200% 0; } }

/* ---------- 光譜色帶（可互動） ---------- */
.brand-spectrum {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.brand-spectrum-bar { display: flex; gap: 3px; }
.brand-spectrum button {
  appearance: none;
  border: 0;
  width: 26px;
  height: 10px;
  border-radius: 3px;
  cursor: pointer;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, height 0.25s ease;
}
.brand-spectrum button:hover { transform: translateY(-3px); height: 14px; box-shadow: 0 6px 16px -4px currentColor; }
.brand-spectrum button.active { height: 16px; transform: translateY(-2px); box-shadow: 0 0 0 2px #fff inset; }
.brand-spectrum button[data-color="reset"] { background: linear-gradient(135deg, #C81015, #D4AF37); }
.brand-spectrum-label {
  font-family: 'JetBrains Mono', 'Inter', monospace;
  font-size: 10px;
  letter-spacing: 0.25em;
  color: #9A9AA5;
  white-space: nowrap;
}
.brand-spectrum-label b { color: #fff; font-weight: 600; }

/* 色帶掃光（logo 下方那條的動態版） */
.brand-bar {
  height: 4px; border-radius: 2px;
  background: var(--hcf-grad); background-size: 200% 100%;
  animation: brandShift 6s linear infinite;
}

/* ---------- Logo 互動 ---------- */
.brand-logo { position: relative; display: inline-block; will-change: transform; transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), filter 0.35s ease; }
.brand-logo img { display: block; }
.brand-logo.is-reveal img { animation: logoReveal 1.1s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes logoReveal {
  0% { clip-path: inset(0 100% 0 0); filter: brightness(2) saturate(0); }
  60% { filter: brightness(1.3) saturate(1.4); }
  100% { clip-path: inset(0 0 0 0); filter: brightness(1) saturate(1); }
}
.brand-logo:hover { filter: drop-shadow(0 0 10px rgba(138, 92, 255, 0.55)) drop-shadow(0 0 22px rgba(255, 61, 176, 0.35)); }
.brand-logo::after {
  /* hover 掃過的光 */
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.55) 50%, transparent 70%);
  background-size: 250% 100%;
  mix-blend-mode: overlay;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.brand-logo:hover::after { opacity: 1; animation: logoSheen 0.9s ease forwards; }
@keyframes logoSheen { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---------- 磁吸按鈕 / 漣漪 ---------- */
.magnetic { position: relative; overflow: hidden; will-change: transform; transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1); }
.magnetic .ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 70%);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 0.65s ease-out forwards;
}
@keyframes ripple { to { transform: translate(-50%, -50%) scale(1); opacity: 0; } }

/* ---------- 彩虹游標光暈（桌機） ---------- */
#brand-glow {
  position: fixed; left: 0; top: 0; z-index: 1;
  width: 420px; height: 420px; border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, rgba(138, 92, 255, 0.22) 0%, rgba(255, 61, 176, 0.12) 35%, rgba(0, 0, 0, 0) 70%);
  transform: translate(-50%, -50%);
  filter: blur(18px);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.6s ease;
  animation: glowHue 12s linear infinite;
}
#brand-glow.is-on { opacity: 1; }
@keyframes glowHue { to { filter: blur(18px) hue-rotate(360deg); } }
@media (pointer: coarse), (max-width: 1023px) { #brand-glow { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .text-gradient-brand, .brand-bar, #brand-glow, .brand-logo.is-reveal img { animation: none !important; }
  .magnetic { transition: none; }
}

/* ---------- 日夜切換鈕 ---------- */
.theme-toggle {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; min-width: 36px; padding: 0 10px;
  border-radius: 9999px; border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04); color: #fff;
  font: inherit; font-size: 10px; font-weight: 700; letter-spacing: 0.18em;
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.theme-toggle:hover { border-color: rgba(255, 255, 255, 0.4); transform: rotate(-12deg); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; }
html.theme-light .theme-toggle { color: #111; border-color: rgba(0, 0, 0, 0.15); background: rgba(0, 0, 0, 0.03); }
html.theme-light .theme-toggle:hover { border-color: rgba(0, 0, 0, 0.5); }
html.theme-light .theme-toggle .ico-sun { display: block; }
html.theme-light .theme-toggle .ico-moon { display: none; }
.theme-toggle-label { display: none; }
@media (min-width: 1280px) { .theme-toggle-label { display: inline; } }
.mm-tools .theme-toggle { height: auto; padding: 8px 14px; }
.mm-tools .theme-toggle-label { display: inline; }
@media (max-width: 640px) {
  .brand-spectrum { flex-wrap: wrap; row-gap: 6px; }
  .brand-spectrum-label { display: none; }
  .mm-spectrum .brand-spectrum-label { display: inline; }
}
