/* ========================================
   9×9 — 九九归一 | Main Stylesheet v2
   ======================================== */

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-dark: #080816;
  --bg-mid: #0c0c22;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --accent: #7c6cf0;
  --accent2: #5a4ad8;
  --accent-light: #a89bff;
  --accent-glow: rgba(124, 108, 240, 0.25);
  --text-primary: #f0eeff;
  --text-secondary: rgba(240, 238, 255, 0.6);
  --text-muted: rgba(240, 238, 255, 0.3);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-card: rgba(255, 255, 255, 0.07);
  --font-cn: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --max-width: 960px;
  --radius: 20px;
  --radius-sm: 12px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-cn);
  background: var(--bg-dark);
  color: var(--text-primary);
  overflow-x: hidden;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ========================================
   Animated Background
   ======================================== */

#bgCanvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ========================================
   Navigation
   ======================================== */

.navbar {
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(8, 8, 22, 0.7);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border-bottom: 1px solid var(--border-subtle);
  transition: transform 0.35s ease;
}

.navbar.hidden { transform: translateY(-100%); }

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-en);
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 0%, var(--accent-light) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Hamburger Menu Button ─── */

.nav-menu-btn {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: background 0.2s;
  position: relative;
  z-index: 1002;
}

.nav-menu-btn:hover { background: rgba(255, 255, 255, 0.1); }

.nav-menu-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all 0.3s;
}

.nav-menu-btn.active span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}

.nav-menu-btn.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}

.nav-menu-btn.active span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* ─── Drawer Overlay ─── */

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.nav-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Navigation Drawer ─── */

.nav-drawer {
  position: fixed;
  top: 0; right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: linear-gradient(180deg, #0c0c22 0%, #080816 100%);
  border-left: 1px solid var(--border-card);
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow-y: auto;
  padding: 24px;
}

.nav-drawer.open { transform: translateX(0); }

.nav-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.1em;
}

.nav-drawer-close {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.nav-drawer-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.nav-drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.drawer-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  text-align: center;
  transition: all 0.25s ease;
  cursor: pointer;
  gap: 4px;
}

.drawer-cell:hover {
  background: var(--bg-card-hover);
  border-color: rgba(124, 108, 240, 0.2);
  transform: translateY(-1px);
}

.drawer-cell .drawer-fact {
  font-family: var(--font-cn);
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent-light);
  opacity: 0.8;
}

.drawer-cell .drawer-name {
  font-size: 0.65rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.drawer-cell .drawer-empty {
  font-family: var(--font-en);
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.5;
}

/* ========================================
   Hero Section
   ======================================== */

.hero {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 120px 24px 80px;
}

.hero-content { max-width: 800px; }

.hero-badge {
  display: inline-block;
  padding: 6px 18px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--accent-light);
  border: 1px solid rgba(124, 108, 240, 0.2);
  border-radius: 100px;
  background: rgba(124, 108, 240, 0.06);
  margin-bottom: 32px;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeSlideUp 0.8s ease 0.2s forwards;
}

.hero-title {
  font-family: var(--font-en);
  font-weight: 900;
  line-height: 1;
  margin-bottom: 24px;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeSlideUp 0.8s ease 0.4s forwards;
}

.hero-9 {
  font-size: clamp(5rem, 20vw, 14rem);
  background: linear-gradient(135deg, #fff 0%, var(--accent-light) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-x {
  font-size: clamp(3rem, 12vw, 8rem);
  color: var(--accent);
  margin: 0 0.05em;
  display: inline-block;
  animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.6; filter: brightness(1); }
  50% { opacity: 1; filter: brightness(1.3); }
}

.hero-subtitle {
  font-size: clamp(1.15rem, 2.8vw, 1.8rem);
  font-weight: 300;
  letter-spacing: 0.3em;
  color: var(--text-secondary);
  margin-bottom: 14px;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeSlideUp 0.8s ease 0.6s forwards;
}

.hero-desc {
  font-size: clamp(0.85rem, 1.4vw, 1.05rem);
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 36px;
  line-height: 1.8;
  opacity: 0;
  transform: translateY(20px);
  animation: fadeSlideUp 0.8s ease 0.8s forwards;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  border-radius: 100px;
  font-size: 1rem;
  font-weight: 600;
  transition: transform 0.25s, box-shadow 0.3s;
  box-shadow: 0 4px 24px var(--accent-glow);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeSlideUp 0.8s ease 1s forwards;
}

.hero-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 36px rgba(124, 108, 240, 0.45);
}

.hero-cta svg { transition: transform 0.3s; }
.hero-cta:hover svg { transform: translateY(2px); }

@keyframes fadeSlideUp {
  to { opacity: 1; transform: translateY(0); }
}

.hero-scroll-indicator {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  opacity: 0;
  animation: fadeSlideUp 1s ease 1.4s forwards;
}

.scroll-line {
  width: 1px;
  height: 36px;
  background: linear-gradient(to bottom, var(--text-muted), transparent);
  animation: scrollPulse 2s ease-in-out infinite;
}

@keyframes scrollPulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 0.8; }
}

/* ========================================
   九宫格 Section
   ======================================== */

.grid-section {
  position: relative;
  z-index: 1;
  padding: 60px 24px 100px;
}

.grid-header {
  text-align: center;
  margin-bottom: 48px;
}

.grid-title {
  font-family: var(--font-cn);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
}

.grid-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ─── 3×3 Grid ─── */

.nine-grid {
  max-width: 780px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0;
}

@media (max-width: 640px) {
  .nine-grid {
    gap: 8px;
  }
}

/* ─── Grid Cell ─── */

.grid-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 12px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  gap: 8px;
}

.grid-cell.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.grid-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
              rgba(124, 108, 240, 0.06), transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.grid-cell:hover::before {
  opacity: 1;
}

.grid-cell:hover {
  background: var(--bg-card-hover);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(124, 108, 240, 0.15);
}

.grid-cell:active {
  transform: translateY(-1px) scale(0.98);
}

/* Diagonal cells with assigned content get extra glow */
.grid-cell.assigned {
  border-color: rgba(124, 108, 240, 0.12);
}

.grid-cell.assigned::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  border: 1px solid transparent;
  background: linear-gradient(135deg, rgba(124, 108, 240, 0.15), transparent 50%, rgba(168, 155, 255, 0.08)) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

/* ─── Cell Content ─── */

.cell-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cell-fact-row {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-fact {
  font-family: var(--font-cn);
  font-size: clamp(1.15rem, 2.8vw, 1.9rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  letter-spacing: 0.05em;
  transition: transform 0.3s;
}

.grid-cell:hover .cell-fact {
  transform: scale(1.06);
}

.cell-divider {
  width: 24px;
  height: 1px;
  background: rgba(124, 108, 240, 0.15);
  margin: 4px 0;
}

.cell-name {
  font-size: clamp(0.75rem, 1.3vw, 0.9rem);
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.4;
}

.cell-empty-hint {
  font-family: var(--font-en);
  font-size: 0.6rem;
  color: var(--text-muted);
  opacity: 0.4;
  letter-spacing: 0.05em;
}

.cell-arrow {
  position: absolute;
  bottom: 12px;
  right: 14px;
  font-size: 0.75rem;
  color: var(--accent-light);
  opacity: 0;
  transform: translateX(-4px);
  transition: all 0.3s ease;
}

.grid-cell.assigned:hover .cell-arrow {
  opacity: 0.8;
  transform: translateX(0);
}

/* Assigned cells get subtle color accent based on position */
.grid-cell.assigned[data-idx="0"] { /* 一一得一 */
  --cell-accent: #7c6cf0;
}
.grid-cell.assigned[data-idx="1"] { /* 二二得四 */
  --cell-accent: #6cb8f0;
}
.grid-cell.assigned[data-idx="2"] { /* 三三得九 */
  --cell-accent: #f0a86c;
}

.grid-cell.assigned[data-idx="0"] .cell-fact { color: var(--cell-accent); }
.grid-cell.assigned[data-idx="1"] .cell-fact { color: var(--cell-accent); }
.grid-cell.assigned[data-idx="2"] .cell-fact { color: var(--cell-accent); }

/* ========================================
   Philosophy Section
   ======================================== */

.philosophy {
  position: relative;
  z-index: 1;
  padding: 60px 24px 80px;
  text-align: center;
}

.philosophy-inner {
  max-width: 600px;
  margin: 0 auto;
}

.philosophy-grid-9 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 150px;
  margin: 0 auto 36px;
}

.philosophy-grid-9 span {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-cn);
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
}

.philosophy-grid-9 span.highlight {
  color: var(--accent-light);
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 1.4rem;
  border-color: rgba(124, 108, 240, 0.25);
  background: rgba(124, 108, 240, 0.06);
}

.philosophy-quote {
  border: none;
  padding: 0;
}

.philosophy-quote p {
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  line-height: 1.8;
}

.philosophy-quote cite {
  display: block;
  margin-top: 12px;
  font-size: 0.85rem;
  font-style: normal;
  color: var(--text-muted);
}

/* ========================================
   Footer
   ======================================== */

.footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--border-subtle);
  padding: 40px 24px;
  background: rgba(0, 0, 0, 0.2);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-logo {
  font-family: var(--font-en);
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-brand p {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--accent-light); }

.footer-copy {
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
  .hero { padding: 100px 16px 60px; }
  .grid-section { padding: 40px 16px 60px; }
  
  .grid-cell { padding: 14px 8px; border-radius: var(--radius-sm); gap: 4px; }
  
  .cell-divider { width: 18px; }
  .cell-arrow { bottom: 8px; right: 10px; }

  .philosophy { padding: 40px 16px 60px; }
  .nav-drawer { padding: 16px; }
  .nav-drawer-grid { gap: 6px; }
}

@media (max-width: 400px) {
  .cell-multiplier { font-size: 1.2rem; }
  .cell-name { font-size: 0.65rem; }
}
