/* 
 * Jerry's Portfolio — GSAP Animation Styles v2
 * 配合 animations.js 的特效样式
 */

/* ==================== 基础动画状态 ==================== */

.eyebrow,
#hero-title,
.hero-summary-line,
.hero-actions .button,
.profile-panel,
.portrait-visual,
.meta-item {
  will-change: transform, opacity;
}

/* ==================== Glitch Flash Effect ==================== */

@keyframes glitch-flash {
  0%   { clip-path: inset(40% 0 61% 0); transform: translate(-2px, 2px); }
  20%  { clip-path: inset(92% 0 1% 0);  transform: translate(2px, -1px); }
  40%  { clip-path: inset(43% 0 1% 0);  transform: translate(-1px, 3px); }
  60%  { clip-path: inset(25% 0 58% 0); transform: translate(3px, -2px); }
  80%  { clip-path: inset(54% 0 7% 0);  transform: translate(-3px, 1px); }
  100% { clip-path: inset(0 0 0 0);     transform: translate(0); }
}

.glitch-flash {
  animation: glitch-flash 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
  text-shadow: 
    2px 0 rgba(95, 184, 201, 0.4),
    -2px 0 rgba(134, 211, 223, 0.3);
}

/* ==================== Accent Line Draw ==================== */

.accent-line-draw {
  position: relative;
  padding-left: 16px;
}

.accent-line-draw::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-3));
  border-radius: 2px;
  transform: scaleY(var(--line-scale, 0));
  transform-origin: top center;
}

/* ==================== Quote Highlight Bar ==================== */

.quote-highlight-bar {
  position: relative;
}

.quote-highlight-bar::after {
  content: '';
  position: absolute;
  left: -8px;
  top: 0;
  width: calc(100% + 16px);
  height: 100%;
  background: linear-gradient(90deg, rgba(95, 184, 201, 0.08), transparent);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  transform: scaleX(var(--bar-scale, 0));
  transform-origin: left center;
  z-index: -1;
}

/* ==================== Timeline & Glow（相对定位） ==================== */

.timeline-line-draw {
  position: relative;
}

.timeline-line-draw::before {
  content: '';
  position: absolute;
  left: clamp(10px, 2.5vw, 20px);
  top: 0;
  width: 2px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  transform: scaleY(var(--tl-line, 0));
  transform-origin: top center;
  border-radius: 1px;
}

.timeline-glow {
  --glow-opacity: 0;
  position: relative;
}

.timeline-glow::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  opacity: var(--glow-opacity, 0);
  box-shadow: 0 0 clamp(6px, 1.5vw, 12px) rgba(95, 184, 201, 0.6);
  transition: opacity 0.3s ease;
}

/* ==================== Terminal Line（相对单位） ==================== */

.terminal-line {
  position: relative;
  padding-left: clamp(8px, 2vw, 12px);
}

.terminal-line::before {
  content: '›';
  position: absolute;
  left: -4px;
  top: 50%;
  transform: translateY(-50%) scaleX(var(--dash-scale, 0));
  color: var(--accent);
  font-weight: 700;
  font-size: clamp(14px, 2vw, 16px);
  transform-origin: left center;
}

/* ==================== Scanline（视口相对密度） ==================== */

.contact-section {
  position: relative;
}

.contact-section::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 0.25em,
    rgba(95, 184, 201, 0.015) 0.25em,
    rgba(95, 184, 201, 0.015) 0.5em
  );
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

.contact-section > * {
  position: relative;
  z-index: 1;
}

/* ==================== 导航栏滚动效果 ==================== */

.site-header {
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.site-header.scrolled {
  background: rgba(15, 44, 56, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
}

.site-header.scrolled .nav-links {
  background: rgba(18, 23, 28, 0.9);
  border-color: rgba(95, 184, 201, 0.2);
}

/* ==================== 交互反馈增强 ==================== */

.button:active,
.icon-link:active {
  transform: scale(0.97) translateY(0);
  transition: transform 0.1s ease;
}

.stat-card:focus-visible,
.timeline-item:focus-visible,
.work-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* 复制成功提示 */
.copy-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: rgba(95, 184, 201, 0.95);
  color: #0f2c38;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  z-index: 1000;
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.copy-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== 作品集轮播增强 ==================== */

.work-card {
  transition: 
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    filter 0.4s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  transform-style: preserve-3d;
}

.work-card:hover {
  border-color: rgba(95, 184, 201, 0.5);
  box-shadow: 
    0 25px 60px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(95, 184, 201, 0.2) inset;
}

/* 轮播控制按钮 */
.work-control {
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  overflow: hidden;
}

.work-control::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(95, 184, 201, 0.3), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.work-control:hover::after {
  opacity: 1;
}

/* ==================== 按钮光晕 ==================== */

.button.primary {
  position: relative;
  overflow: hidden;
}

.button.primary::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.button.primary:hover::before {
  opacity: 1;
}

/* ==================== 卡片光泽 ==================== */

.stat-card,
.timeline-item {
  position: relative;
  overflow: hidden;
}

.stat-card::before,
.timeline-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent);
  transition: left 0.5s ease;
}

.stat-card:hover::before,
.timeline-item:hover::before {
  left: 100%;
}

/* ==================== 平滑滚动 ==================== */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

/* ==================== 选择高亮 ==================== */

::selection {
  background: rgba(95, 184, 201, 0.3);
  color: var(--ink);
}

::-moz-selection {
  background: rgba(95, 184, 201, 0.3);
  color: var(--ink);
}

/* ==================== 加载状态 ==================== */

body:not(.loaded) {
  overflow: hidden;
}

body:not(.loaded) main {
  opacity: 0;
}

body.loaded main {
  opacity: 1;
  transition: opacity 0.5s ease;
}

/* ==================== 响应式优化 ==================== */

@media (max-width: 768px) {
  .work-card {
    transition-duration: 0.4s;
  }

  .site-header.scrolled {
    backdrop-filter: blur(15px);
  }
}

/* ==================== 减少动画偏好 ==================== */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .work-card,
  .copy-toast {
    transition: none;
  }

  .glitch-flash {
    animation: none;
  }

  .accent-line-draw::before,
  .timeline-line-draw::before,
  .timeline-glow::after,
  .terminal-line::before,
  .quote-highlight-bar::after {
    display: none;
  }
}
