/* ===== Mobile-First · 东方书卷气 ===== */
/* 零外部依赖，系统字体 */

:root {
  --bg: #FAF8F5;
  --surface: #FFFFFF;
  --surface-alt: #F3EDE6;
  --surface-hover: #F0EAE0;
  --surface-dark: #2C2C2C;
  --border: #E8E0D8;
  --border-hover: #C4B8AA;
  --border-strong: #2C2C2C;
  --text: #2C2C2C;
  --text-secondary: #5C5C5C;
  --text-tertiary: #8C8C8C;
  --text-inverse: #FAF8F5;
  --accent: #C45C3C;
  --accent-hover: #A8462C;
  --accent-light: #E8A08C;
  --secondary: #2C5F6E;
  --gold: #B8860B;
  --bg-rgb: 250,248,245;
  --accent-rgb: 196,92,60;
  --text-rgb: 44,44,44;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-ink: cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.8;
  letter-spacing: 0.02em;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Base Typography ===== */
h1, h2, h3 {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-weight: 700;
  line-height: 1.3;
}
h1 { font-size: 2.5rem; font-weight: 900; letter-spacing: 0.08em; }
h2 { font-size: 1.75rem; letter-spacing: 0.04em; margin-bottom: 16px; }
h3 { font-size: 1.25rem; margin-bottom: 12px; }

.eyebrow {
  font-family: 'Kaiti SC', 'STKaiti', cursive;
  font-size: 0.8125rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin-bottom: 8px;
  display: block;
}

/* ===== Layout ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; margin: 0 auto; }
.section { padding: 60px 0; }

/* ===== Navigation ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 12px 0;
  transition: all 0.4s var(--ease-ink);
}
.nav.scrolled {
  background: rgba(var(--bg-rgb), 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  display: flex; align-items: center; justify-content: space-between;
}
.nav-logo {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-size: 1.125rem; font-weight: 700;
  color: var(--text); text-decoration: none; letter-spacing: 0.06em;
}

/* Hamburger toggle */
.nav-toggle {
  display: flex; width: 48px; height: 48px;
  align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative; z-index: 110;
}
.nav-toggle span {
  display: block; width: 20px; height: 2px;
  background: var(--text); border-radius: 1px;
  transition: all 0.3s var(--ease-ink);
  position: relative;
}
.nav-toggle span::before,
.nav-toggle span::after {
  content: ''; position: absolute; left: 0;
  width: 20px; height: 2px; background: var(--text); border-radius: 1px;
  transition: all 0.3s var(--ease-ink);
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }

.nav-toggle.active span { background: transparent; }
.nav-toggle.active span::before { top: 0; transform: rotate(45deg); }
.nav-toggle.active span::after { top: 0; transform: rotate(-45deg); }

/* Mobile menu overlay */
.nav-menu {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 280px; max-width: 80vw;
  background: var(--bg);
  border-left: 1px solid var(--border);
  padding: 80px 24px 40px;
  transform: translateX(100%);
  transition: transform 0.3s var(--ease-out);
  z-index: 105;
  list-style: none;
  display: flex; flex-direction: column; gap: 0;
}
.nav-menu.open { transform: translateX(0); }

.nav-overlay {
  position: fixed; inset: 0;
  background: rgba(var(--text-rgb), 0.3);
  opacity: 0; visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 104;
}
.nav-overlay.open { opacity: 1; visibility: visible; }

.nav-menu a {
  font-size: 1.125rem; color: var(--text); text-decoration: none;
  padding: 16px 0; display: block;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.04em;
  -webkit-tap-highlight-color: transparent;
}
.nav-menu a:active { color: var(--accent); }

/* ===== Hero ===== */
.hero {
  min-height: 100svh; display: flex; align-items: center; justify-content: center;
  text-align: center; position: relative; overflow: hidden;
  background: radial-gradient(ellipse at 30% 40%, rgba(196,92,60,0.06) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 60%, rgba(44,92,110,0.05) 0%, transparent 50%),
              var(--bg);
  padding: 80px 16px 40px;
}
.hero-content { position: relative; z-index: 2; }
.hero h1 { margin-bottom: 16px; color: var(--text); }
.hero-subtitle {
  font-family: 'Kaiti SC', 'STKaiti', cursive;
  font-size: 1.125rem; color: var(--text-secondary);
  margin-bottom: 24px; letter-spacing: 0.04em;
}
.hero-tagline {
  font-size: 0.9375rem; color: var(--text-tertiary);
  max-width: 500px; margin: 0 auto 32px;
  line-height: 1.7;
}

/* Hero entry animation */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}
.hero-content > * {
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out) forwards;
}
.hero-content > *:nth-child(1) { animation-delay: 0.1s; }
.hero-content > *:nth-child(2) { animation-delay: 0.2s; }
.hero-content > *:nth-child(3) { animation-delay: 0.3s; }
.hero-content > *:nth-child(4) { animation-delay: 0.4s; }
.hero-content > *:nth-child(5) { animation-delay: 0.5s; }

/* 罗盘背景装饰 */
.luopan {
  position: absolute; width: 360px; height: 360px;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 1; pointer-events: none;
  opacity: 0.22;
  -webkit-mask-image: radial-gradient(circle at center, #000 55%, transparent 88%);
          mask-image: radial-gradient(circle at center, #000 55%, transparent 88%);
}
.luopan-svg { width: 100%; height: 100%; display: block; }
.luopan-svg text {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-weight: 500; user-select: none;
}
.lp-ring {
  transform-box: view-box;
  transform-origin: 50% 50%;
  will-change: transform;
}
.lp-spin-cw-slow  { animation: lpSpin 240s linear infinite; }
.lp-spin-cw-med   { animation: lpSpin 150s linear infinite; }
.lp-spin-cw-fast  { animation: lpSpin 90s  linear infinite; }
.lp-spin-ccw-slow { animation: lpSpin 200s linear infinite reverse; }
.lp-spin-ccw-med  { animation: lpSpin 120s linear infinite reverse; }
@keyframes lpSpin { to { transform: rotate(360deg); } }

/* ===== Buttons ===== */
.btn {
  font-family: 'PingFang SC', sans-serif;
  font-size: 1rem; font-weight: 500;
  padding: 14px 32px;
  min-height: 48px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: transparent; color: var(--text);
  cursor: pointer;
  transition: all 0.3s var(--ease-ink);
  letter-spacing: 0.04em;
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--text); color: var(--text-inverse); border-color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn-primary { background: var(--accent); color: var(--text-inverse); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* ===== Marquee ===== */
.marquee-section {
  padding: 32px 0; overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.marquee-track {
  display: flex; gap: 40px; white-space: nowrap;
  animation: marqueeScroll 25s linear infinite;
}
.marquee-track span {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-size: 2rem; font-weight: 700;
  color: var(--text); opacity: 0.1; letter-spacing: 0.08em; flex-shrink: 0;
}
@keyframes marqueeScroll { to { transform: translateX(-50%); } }

/* ===== Bento Grid (Features) ===== */
.bento-grid {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.bento-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 24px 20px; position: relative; overflow: hidden;
  transition: all 0.4s var(--ease-ink);
}
.bento-item:hover {
  border-color: var(--border-hover); transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(var(--text-rgb), 0.08);
}
.bento-item .bento-icon {
  font-size: 1.75rem; margin-bottom: 12px; display: block;
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif; color: var(--accent);
}
.bento-item h3 { font-size: 1.125rem; margin-bottom: 6px; }
.bento-item p { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.7; }

/* ===== Divination Tool ===== */
.tool-section { background: var(--surface-alt); }
.tool-layout { display: flex; flex-direction: column; gap: 24px; }

.form-group { margin-bottom: 20px; }
.form-label {
  font-family: 'Kaiti SC', 'STKaiti', cursive;
  font-size: 0.875rem; color: var(--text-secondary);
  margin-bottom: 8px; display: block; letter-spacing: 0.04em;
}
.input {
  font-family: 'PingFang SC', sans-serif;
  font-size: 16px; /* iOS 防缩放 */
  padding: 12px 16px; min-height: 48px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--surface); color: var(--text); width: 100%;
  transition: border-color 0.3s; line-height: 1.6;
  -webkit-appearance: none; appearance: none;
}
.input:hover { border-color: var(--border-hover); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1); }
.input::placeholder { color: var(--text-tertiary); }
textarea.input { min-height: 80px; resize: vertical; }

.quick-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.tag {
  font-family: 'Kaiti SC', 'STKaiti', cursive;
  font-size: 0.8125rem;
  padding: 8px 14px; min-height: 40px;
  border: 1px solid var(--border); border-radius: 2px;
  color: var(--text-secondary); letter-spacing: 0.04em;
  cursor: pointer; transition: all 0.3s; background: transparent;
  -webkit-tap-highlight-color: transparent;
  display: inline-flex; align-items: center;
}
.tag:hover, .tag.active {
  background: var(--accent); color: var(--text-inverse); border-color: var(--accent);
}

.method-toggle { display: flex; gap: 0; }
.method-btn {
  flex: 1; padding: 12px 8px; text-align: center;
  border: 1px solid var(--border);
  background: var(--surface); cursor: pointer;
  font-size: 0.875rem; font-family: 'PingFang SC', sans-serif;
  transition: all 0.3s; color: var(--text-secondary);
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}
.method-btn:first-child { border-radius: 4px 0 0 4px; }
.method-btn:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.method-btn.active { background: var(--text); color: var(--text-inverse); border-color: var(--text); }

.datetime-inputs { display: grid; grid-template-columns: 1fr; gap: 12px; }

/* ===== Qimen Board ===== */
.qimen-board {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 1px; background: var(--border-strong); border: 2px solid var(--text);
  border-radius: 4px; overflow: hidden;
}
.qimen-cell {
  background: var(--surface); padding: 8px 4px; text-align: center;
  min-height: 80px; display: flex; flex-direction: column;
  justify-content: space-between; font-size: 0.6875rem; line-height: 1.3;
  position: relative; transition: background 0.3s;
}
.qimen-cell.highlight { background: rgba(var(--accent-rgb), 0.06); }
.qimen-cell.kong {
  background: repeating-linear-gradient(
    45deg, transparent, transparent 4px,
    rgba(var(--text-rgb), 0.02) 4px,
    rgba(var(--text-rgb), 0.02) 8px
  );
}
.cell-god { font-family: 'Kaiti SC'; color: var(--secondary); font-size: 0.6rem; }
.cell-star { color: var(--gold); font-weight: 700; font-size: 0.65rem; }
.cell-gate { color: var(--accent); font-weight: 700; font-size: 0.65rem; }
.cell-stems { font-size: 0.75rem; font-weight: 500; }
.cell-stems .sky { color: var(--text); }
.cell-stems .earth { color: var(--text-tertiary); }
.cell-palace {
  font-family: 'Kaiti SC'; color: var(--text-tertiary);
  font-size: 0.55rem; position: absolute; bottom: 2px; right: 4px;
}
.cell-mark {
  position: absolute; top: 2px; right: 4px;
  font-size: 0.5rem; color: var(--accent); font-weight: 700;
}

/* ===== Result Panel ===== */
.result-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 4px; padding: 20px 16px; min-height: 300px;
}
.result-panel h3 {
  font-size: 1.125rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px; margin-bottom: 16px;
}
.result-info { margin-bottom: 20px; }
.result-info .info-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
  font-size: 0.8125rem;
}
.info-label { color: var(--text-tertiary); font-family: 'Kaiti SC'; min-width: 48px; }
.info-value { color: var(--text); font-weight: 500; }

.ai-reading {
  margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border);
}
.ai-reading h4 {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-size: 1rem; margin-bottom: 12px; color: var(--accent);
}
.ai-content {
  font-size: 0.875rem; line-height: 1.9; color: var(--text-secondary);
  white-space: pre-wrap; word-break: break-word;
}
.ai-content h3 {
  font-size: 0.9375rem; color: var(--text);
  margin-top: 16px; margin-bottom: 6px; border: none; padding: 0;
}
.ai-loading {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-tertiary); font-size: 0.8125rem;
}
.ai-loading .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
.ai-loading .dot:nth-child(2) { animation-delay: 0.3s; }
.ai-loading .dot:nth-child(3) { animation-delay: 0.6s; }
@keyframes pulse { 0%,100% { opacity: 0.3; } 50% { opacity: 1; } }

/* ===== Knowledge Section ===== */
.knowledge-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.knowledge-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  padding: 24px 20px; transition: all 0.4s var(--ease-ink);
}
.knowledge-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(var(--text-rgb), 0.06);
}
.knowledge-card .card-icon {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-size: 2rem; color: var(--accent); margin-bottom: 12px; display: block;
}
.knowledge-card h3 { margin-bottom: 6px; }
.knowledge-card p { font-size: 0.875rem; color: var(--text-secondary); }
.knowledge-card .card-items {
  margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px;
}
.knowledge-card .card-items span {
  font-family: 'Kaiti SC'; font-size: 0.75rem;
  padding: 2px 8px; border: 1px solid var(--border); border-radius: 2px;
  color: var(--text-secondary);
}

/* ===== Footer ===== */
.footer {
  padding: 40px 0; text-align: center;
  border-top: 1px solid var(--border);
}
.footer-quote {
  font-family: 'Songti SC', 'Noto Serif SC', 'SimSun', serif;
  font-size: 1.125rem; color: var(--text-secondary);
  margin-bottom: 12px; letter-spacing: 0.06em;
}
.footer-copy { font-size: 0.75rem; color: var(--text-tertiary); }

/* ===== Scroll Reveal ===== */
.reveal {
  opacity: 0; transform: translateY(24px);
  transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.reveal.visible {
  opacity: 1; transform: translateY(0);
}

/* ============================
   Tablet (768px+)
   ============================ */
@media (min-width: 768px) {
  h1 { font-size: 3.25rem; }
  h2 { font-size: 2rem; margin-bottom: 20px; }
  h3 { font-size: 1.375rem; }
  .container { padding: 0 24px; }
  .section { padding: 80px 0; }

  .luopan { width: 520px; height: 520px; opacity: 0.2; }
  .hero { padding: 100px 24px 60px; }
  .hero-subtitle { font-size: 1.25rem; margin-bottom: 32px; }
  .hero-tagline { margin-bottom: 40px; }

  .marquee-track span { font-size: 2.5rem; }
  .marquee-track { gap: 60px; }
  .marquee-section { padding: 40px 0; }

  .bento-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; }
  .bento-item.span-2 { grid-column: span 2; }
  .bento-item { padding: 28px 24px; }

  .datetime-inputs { grid-template-columns: 1fr 1fr; }

  .qimen-cell { min-height: 100px; padding: 10px 6px; font-size: 0.75rem; }
  .cell-god { font-size: 0.65rem; }
  .cell-star, .cell-gate { font-size: 0.7rem; }
  .cell-stems { font-size: 0.8rem; }
  .cell-palace { font-size: 0.6rem; }
  .cell-mark { font-size: 0.55rem; }

  .result-panel { padding: 28px 24px; }
  .result-info .info-row { font-size: 0.875rem; gap: 16px; }

  .knowledge-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .knowledge-card { padding: 32px; }

  .footer { padding: 60px 0; }
  .footer-quote { font-size: 1.25rem; }
}

/* ============================
   Desktop (1024px+)
   ============================ */
@media (min-width: 1024px) {
  h1 { font-size: 4rem; }
  h2 { font-size: 2.25rem; margin-bottom: 24px; }
  h3 { font-size: 1.5rem; margin-bottom: 16px; }
  .section { padding: 100px 0; }

  .nav { padding: 20px 0; }
  .nav.scrolled { padding: 12px 0; }
  .nav-logo { font-size: 1.25rem; }

  /* Desktop: hide hamburger, show inline links */
  .nav-toggle { display: none; }
  .nav-menu {
    position: static; transform: none;
    width: auto; max-width: none;
    background: none; border: none;
    padding: 0;
    flex-direction: row; gap: 4px;
  }
  .nav-menu a {
    font-size: 0.875rem; color: var(--text-secondary);
    padding: 8px 16px; border-bottom: none;
    transition: color 0.3s;
  }
  .nav-menu a:hover { color: var(--accent); }
  .nav-overlay { display: none; }

  .hero { padding: 0; }
  .luopan { width: 680px; height: 680px; opacity: 0.18; }

  .marquee-track span { font-size: 3rem; }
  .marquee-track { gap: 80px; }
  .marquee-section { padding: 48px 0; }

  .bento-grid { grid-template-columns: repeat(4, 1fr); }
  .bento-item { padding: 32px 24px; }

  .tool-layout {
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 48px; align-items: start;
  }
  .tool-form { position: sticky; top: 100px; }

  .qimen-cell { min-height: 110px; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.2s !important;
  }
  .reveal { opacity: 1; transform: none; }
  .hero-content > * { opacity: 1; animation: none; }
  .lp-ring { animation: none; }
  .marquee-track { animation: none; }
}
