/* ==========================================================================
   style.css — “史无前例”的完整增强版
   目的：在保持你原始 HTML 结构与类/ID 的前提下，提供完备的视觉系统、
   动效基类、降级逻辑与调试钩子，并修复布局问题。
   ========================================================================== */

/* -------------------------
   ROOT THEME VARIABLES
   ------------------------- */
:root{
  /* Colors */
  --color-dark: #000000;
  --color-light: #f5f5f7;
  --color-text-dark: #1d1d1f;
  --color-text-light: #f5f5f7; /* Added for dark sections */
  --color-text-muted: #6e6e73;
  --color-accent: #0071e3;
  --color-accent-2: #00aaff;
  --glass: rgba(255,255,255,0.06);

  /* Candle / light custom variables */
  --candle-shadow-x: 0px;
  --candle-shadow-y: 0px;
  --candle-shadow-blur: 18px;
  --candle-shadow-alpha: 0.25;
  --light-cast-scale: 1;
  --spotlight-x: 50%; /* for spotlight hover effect */
  --spotlight-y: 50%;
  --spotlight-size: 200px;

  /* Layout & typography */
  --font-sans: 'Noto Sans SC', 'SF Pro Display', -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --radius-l: 32px;
  --radius-m: 20px;
  --transition: 0.5s cubic-bezier(0.2,0.8,0.2,1);
  --glass-blur: 14px;

  /* Accessibility */
  --reduced-motion: 0;
}

/* -------------------------
   GLOBAL & RESET
   ------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background-color: var(--color-light);
  color: var(--color-text-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* [修复问题2] 初始隐藏主内容，防止闪烁，等待JS加载 */
#main-content {
  visibility: hidden;
  opacity: 0;
  transition: opacity 1s cubic-bezier(0.2, 0.8, 0.2, 1);
}
#main-content.is-visible {
  visibility: visible;
  opacity: 1;
}

* { -webkit-tap-highlight-color: transparent; }

/* -------------------------
   TERMINAL: Custom Cursor
   ------------------------- */
.cursor {
  pointer-events: none;
  position: fixed;
  z-index: 99999;
  top: 0;
  left: 0;
  transform: translate3d(0,0,0);
  will-change: transform;
}
.cursor-inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-accent);
  transform: translate(-50%, -50%);
  transition: width 0.35s var(--transition), height 0.35s var(--transition), background 0.35s;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}
.cursor.hover-link .cursor-inner {
  width: 62px;
  height: 62px;
  background: rgba(0,113,227,0.12);
}
.cursor.hover-text .cursor-inner {
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, rgba(0,113,227,0.12) 0%, rgba(0,113,227,0.02) 60%);
}

/* -------------------------
   INTRO OVERLAY (FULLSCREEN)
   ------------------------- */
#intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-dark);
  overflow: hidden;
}
#starfield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  will-change: opacity;
}
#light-cast {
  position: absolute;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(var(--light-cast-scale));
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  will-change: left, top, transform, opacity;
  background: radial-gradient(circle, rgba(255,240,180,0.95) 0%, rgba(255,160,70,0.5) 30%, rgba(255,90,20,0.12) 60%, transparent 70%);
  mix-blend-mode: color-dodge; /* 优化光照混合模式 */
  filter: blur(8px);
}
#spark {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 20px 6px rgba(255,255,255,0.95);
  opacity: 0;
  transform-origin: center;
  pointer-events: none;
  z-index: 8;
  will-change: transform, opacity;
}
#camera-zoom-container {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
  z-index: 5;
  will-change: transform;
  transform-origin: center center;
}
#candle-svg {
  position: absolute;
  width: auto;
  height: auto;
  opacity: 1; /* SVG 保持可见，由内部元素控制动画 */
  z-index: 9;
  pointer-events: none;
  will-change: transform, opacity;
}
#camera-zoom-container canvas.flame-local-canvas {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}
#candle-body {
  stroke: var(--color-text-light);
  stroke-width: 2;
  fill: #111;
  transition: filter 0.12s linear, stroke-dashoffset 2s var(--transition);
  filter: drop-shadow(var(--candle-shadow-x) var(--candle-shadow-y) var(--candle-shadow-blur) rgba(0,0,0,var(--candle-shadow-alpha)));
  will-change: filter, stroke-dashoffset;
}
#flame-outer { fill: #ff453a; opacity: 0.35; }
#flame-main  { fill: #ff6a00; opacity: 0.5; }
#flame-core  { fill: #ffee00; opacity: 0.85; }

/* -------------------------
   INTRO: Typing text & cursor
   ------------------------- */
.intro-text-container {
  position: relative;
  z-index: 7;
  display: inline-block;
  pointer-events: none;
  padding: 8px 14px;
}
.text-intro {
  margin: 0;
  color: rgba(245,245,247,0.98);
  font-weight: 500;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.01em;
}
.text-intro-cursor {
  position: absolute;
  display: inline-block;
  width: 1.2em;
  height: 0.18em;
  background: rgba(245,245,247,0.95);
  border-radius: 2px;
  transform-origin: center;
  opacity: 0;
  will-change: left, top;
}
.text-intro-cursor.blinking {
  opacity: 1;
  animation: introCursorBlink 1s steps(2, start) infinite;
}
@keyframes introCursorBlink {
  from { opacity: 1; }
  to { opacity: 0; }
}
.intro-text-container .typing-char { display: inline-block; white-space: pre; }

/* -------------------------
   MAIN HEADER & NAVIGATION
   ------------------------- */
#main-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 1.25rem 2rem;
  z-index: 1000;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transform: translateY(-120%);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.8s var(--transition), opacity 0.8s var(--transition), visibility 0.8s, background-color 0.5s ease, border-color 0.5s ease;
  border-bottom: 1px solid transparent;
  background: transparent;
  will-change: transform, background-color, opacity;
}
#main-header.visible {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
  background-color: rgba(245,245,247,0.7);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom-color: rgba(0,0,0,0.08);
}
.logo {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text-dark);
  text-decoration: none;
}
nav a {
  color: #444;
  text-decoration: none;
  margin-left: 2rem;
  font-weight: 500;
  transition: color 0.3s ease;
}
nav a:hover { color: var(--color-accent); }
.magnetic-button {
  display: inline-block;
  position: relative;
  z-index: 1;
  transition: transform .55s cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}

/* -------------------------
   HERO, TEXT & SECTION STYLES
   ------------------------- */
.content-section {
  padding: 8rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
}
.hero-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8rem 3rem; /* Add padding for smaller screens */
}
.hero-title {
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 700;
  line-height: 1.08;
  margin: 0;
  letter-spacing: -0.02em;
}
/* [修复问题2] 确保动画容器隐藏其子元素 */
.anim-title-reveal .char-wrapper,
.anim-text-reveal .line-wrapper {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}
.anim-title-reveal .char,
.anim-text-reveal .line-inner {
  display: block;
  transform: translateY(110%);
  will-change: transform;
}
.about-text p {
  font-size: 1.18rem;
  line-height: 1.8;
  color: var(--color-text-muted);
}
.about-image-wrapper {
  border-radius: var(--radius-l);
  overflow: hidden;
  perspective: 1000px;
}
.about-image-wrapper img.parallax-img {
  width: 100%;
  display: block;
}
.philosophy-item,
.expertise-item {
  padding: 2.5rem;
  border-radius: var(--radius-m);
  position: relative;
  overflow: hidden;
  background: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-light);
  transition: transform 0.4s var(--transition), box-shadow 0.4s var(--transition);
}
.philosophy-item:hover,
.expertise-item:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
}
.philosophy-item::before,
.expertise-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle var(--spotlight-size, 200px) at var(--spotlight-x, 50%) var(--spotlight-y, 50%), rgba(255,255,255,0.08), transparent 80%);
  opacity: 0;
  transition: opacity 0.6s var(--transition);
  will-change: opacity;
}
.philosophy-item:hover::before,
.expertise-item:hover::before { opacity: 1; }

/* -------------------------
   HORIZONTAL WORKS
   ------------------------- */
.content-section-work {
  padding: 8rem 0; /* [修复问题3] 调整padding，上下留白 */
  position: relative;
  overflow: visible; /* overflow is managed by pin-spacer */
}
.work-container-horizontal {
  display: flex;
  flex-wrap: nowrap;
  width: max-content;
  padding: 0 3rem;
  gap: 2.5rem;
  will-change: transform;
}
.work-card-horizontal {
  width: 60vw;
  max-width: 800px;
  height: 70vh;
  border-radius: var(--radius-l);
  display: flex;
  flex-direction: column; /* 内容垂直居中 */
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  color: var(--color-text-dark);
  background: linear-gradient(180deg, #ffffff, #e8e8ed);
  position: relative;
  overflow: hidden;
  transition: transform 0.5s var(--transition), box-shadow 0.5s var(--transition);
  box-shadow: 0 10px 30px rgba(11,12,14,0.06);
}
.work-card-horizontal:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 30px 60px rgba(11,12,14,0.1);
}
.work-card-horizontal::after {
  content: '';
  position: absolute;
  top: 0;
  left: -150%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.work-card-horizontal:hover::after {
  transform: translateX(250%);
}

/* [修复问题3] 进度条改为 fixed 定位，由 JS 控制显隐 */
.work-progress-bar-wrapper {
  position: fixed;
  bottom: 3rem; /* 调整位置更合理 */
  left: 3rem;
  right: 3rem;
  height: 2px;
  background: rgba(0,0,0,0.1);
  z-index: 1001;
  pointer-events: none;
  opacity: 0; /* 初始隐藏 */
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s;
  will-change: opacity;
}
.work-progress-bar-wrapper.is-visible {
    opacity: 1;
    visibility: visible;
}
.work-progress-bar {
  width: 100%;
  height: 100%;
  background: var(--color-text-dark);
  transform-origin: left;
  transform: scaleX(0); /* JS will animate this */
  will-change: transform;
}

/* -------------------------
   CTA / Liquid metal button
   ------------------------- */
.cta-button {
  padding: 1.2rem 3rem;
  border-radius: 50px;
  text-decoration: none;
  font-weight: 700;
  position: relative;
  overflow: hidden;
  display: inline-block;
  color: white;
  z-index: 1;
  background: var(--color-accent);
  transition: transform 0.3s var(--transition);
}
.cta-button:hover {
    transform: scale(1.05);
}
.cta-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: transform 0.8s ease;
  z-index: 2;
}
.cta-button:hover::before {
  transform: translateX(200%);
}
.cta-button span { position: relative; z-index: 1; }

/* -------------------------
   ANIMATIONS / MOTION REDUCTION
   ------------------------- */
@media (prefers-reduced-motion: reduce) {
  :root { --reduced-motion: 1; }
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* -------------------------
   FOOTER / MISC
   ------------------------- */
#main-footer {
  padding: 4rem 3rem;
  text-align: center;
  color: var(--color-text-muted);
  background: var(--color-light);
}

/* -------------------------
   DARK SECTIONS & POLISH
   ------------------------- */
.dark-section {
  background-color: #111;
  color: var(--color-text-light);
  position: relative;
}
.dark-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="4" stitchTiles="stitch"/></filter><rect width="100%" height="100%" filter="url(%23n)" opacity="0.04"/></svg>');
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* -------------------------
   ENSURE MAIN CONTENT VISIBILITY WHEN NO-JS
   ------------------------- */
.no-js #intro-overlay { display: none !important; }
.no-js #main-content { visibility: visible !important; opacity: 1 !important; }

/* -------------------------
   RESPONSIVE TUNING
   ------------------------- */
@media (max-width: 900px) {
  .content-section, .hero-section { padding: 6rem 1.5rem; }
  .work-container-horizontal { padding: 0 1.5rem; gap: 1.5rem; }
  .work-card-horizontal { width: 85vw; height: 60vh; font-size: 2.2rem; }
  .hero-title { font-size: clamp(2.4rem, 11vw, 4rem); }
  nav a { margin-left: 1.5rem; }
  #main-header { padding: 1rem 1.5rem; }
}

#camera-zoom-container { opacity: var(--candle-initial-opacity, 1); }