/* ============================================
   Custom Styles — Gokou Portfolio
   Light Minimal Theme + Creative Effects
   ============================================ */

/* ----- Smooth Scrolling ----- */
html { scroll-behavior: smooth; }

/* ----- Custom Scrollbar ----- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #f9fafb; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================
   1. Scroll Reveal
   ============================================ */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   2. Hero Particles
   ============================================ */
#hero-particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ============================================
   3. Card Hover Micro-movement
   ============================================ */
.portfolio-card {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.portfolio-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
}
.portfolio-card:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.featured-card {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.featured-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  border-color: rgba(99, 102, 241, 0.25);
}
.featured-card:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* ============================================
   5. Volume Knob Button Ripple
   ============================================ */
@keyframes btnRipple {
  0%   { transform: scale(0); opacity: 0.4; }
  100% { transform: scale(4); opacity: 0; }
}
.btn-ripple {
  position: relative;
  overflow: hidden;
}
/* Knob decoration inside primary buttons */
.btn-knob {
  position: relative;
}
.btn-knob::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  border: 1.5px solid rgba(255,255,255,0.35);
  margin-right: 6px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.btn-knob:hover::before {
  transform: rotate(30deg);
}

/* ============================================
   6. Music Note Decorations
   ============================================ */
.note-decor {
  position: absolute;
  font-size: 32px;
  color: #c7d2fe;
  opacity: 0.28;
  pointer-events: none;
  user-select: none;
}
.note-decor.float {
  animation: noteFloat 4s ease-in-out infinite;
}
@keyframes noteFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* ============================================
   7. Video Thumbnail Hover Preview
   ============================================ */
.video-thumb-hover {
  position: relative;
  overflow: hidden;
}
.video-thumb-hover img {
  transition: transform 0.4s ease, filter 0.4s ease;
}
@media (hover: hover) {
  .video-thumb-hover:hover img {
    transform: scale(1.03);
    filter: brightness(1.1);
  }
  .video-thumb-hover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 1;
  }
  .video-thumb-hover:hover::after {
    opacity: 1;
  }
  /* Play button */
  .video-thumb-hover .play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
  }
  .video-thumb-hover .play-overlay::before {
    content: '';
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(79,70,229,0.85);
    transform: scale(0.6);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1),
                opacity 0.3s ease;
  }
  .video-thumb-hover:hover .play-overlay::before {
    transform: scale(1);
    opacity: 1;
  }
  /* Play triangle */
  .video-thumb-hover .play-overlay::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 16px solid #fff;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    margin-left: 4px;
    transform: scale(0.6);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1),
                opacity 0.3s ease;
  }
  .video-thumb-hover:hover .play-overlay::after {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   8. Expand Ripple
   ============================================ */
.expand-ripple {
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(165,180,252,0.35);
  transform: translate(-50%, -50%) scale(0);
  animation: expandRipple 0.7s ease-out forwards;
  pointer-events: none;
  z-index: 0;
}
@keyframes expandRipple {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0.5; }
  100% { transform: translate(-50%, -50%) scale(120); opacity: 0; }
}

/* ============================================
   9. Project Theme Accent Colors
   ============================================ */
.portfolio-detail-inner {
  position: relative;
  overflow: hidden;
}
/* Module 1 — 深海蓝 */
.portfolio-item[data-theme="battle"] .portfolio-detail-inner {
  border-left: 3px solid #1e40af !important;
}
.portfolio-item[data-theme="battle"] .portfolio-detail.expanded ~ *,
.portfolio-item[data-theme="battle"] .portfolio-detail-inner h4 {
  /* accent handled via parent */
}
/* Module 2 — 雪白灰 */
.portfolio-item[data-theme="snow"] .portfolio-detail-inner {
  border-left: 3px solid #d1d5db !important;
}
.portfolio-item[data-theme="snow"] .portfolio-detail-inner h4 {
  color: #6b7280 !important;
}
/* Module 3 — 科技紫 */
.portfolio-item[data-theme="tech"] .portfolio-detail-inner {
  border-left: 3px solid #7c3aed !important;
}
.portfolio-item[data-theme="tech"] .portfolio-detail-inner h4 {
  color: #7c3aed !important;
}
/* Module 4 — 星空银 */
.portfolio-item[data-theme="star"] .portfolio-detail-inner {
  border-left: 3px solid #94a3b8 !important;
}
.portfolio-item[data-theme="star"] .portfolio-detail-inner h4 {
  color: #64748b !important;
}

/* ============================================
   12. Glitch Photo Swap
   ============================================ */
.glitch-photo-frame {
  --glitch-dur: 0.38s;
}
.glitch-img {
  transition: opacity 0.2s ease;
}

/* Scanlines overlay */
.glitch-scanlines {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.04) 2px,
    rgba(0,0,0,0.04) 4px
  );
  opacity: 0;
}

/* RGB tint overlay */
.glitch-rgb-tint {
  background:
    linear-gradient(rgba(255,60,90,0.06) 0%,   transparent 30%, rgba(50,180,255,0.05) 70%,  transparent 100%),
    linear-gradient(90deg, rgba(255,80,100,0.04) 0%, transparent 50%, rgba(60,200,240,0.04) 100%);
  transition: opacity 0.1s ease;
}

/* === Glitch animation (enter) === */
.glitch-photo-frame.glitching {
  overflow: visible;
}
.glitch-photo-frame.glitching .glitch-img {
  animation: glitchRgb var(--glitch-dur) steps(8) forwards;
}
.glitch-photo-frame.glitching .glitch-scanlines {
  animation: scanFlash var(--glitch-dur) steps(6) forwards;
}
.glitch-photo-frame.glitching .glitch-rgb-tint {
  opacity: 1;
}

/* === Glitch animation (exit — shorter) === */
.glitch-photo-frame.unglitching {
  overflow: visible;
}
.glitch-photo-frame.unglitching .glitch-img {
  animation: glitchRgbShort 0.18s steps(5) forwards;
}
.glitch-photo-frame.unglitching .glitch-scanlines {
  animation: scanFlashShort 0.18s steps(4) forwards;
}

/* Keyframes: main glitch */
@keyframes glitchRgb {
  0%   { filter: brightness(1) contrast(1) drop-shadow(0 0 0 transparent); transform: translateX(0); }
  12%  { filter: brightness(1.15) contrast(1.08) drop-shadow(3px 0 0 rgba(255,50,80,0.45)) drop-shadow(-3px 0 0 rgba(50,180,255,0.45)); transform: translateX(-2px); }
  25%  { filter: brightness(0.9) contrast(1.25) drop-shadow(-2px 0 0 rgba(255,40,70,0.4)) drop-shadow(2px 0 0 rgba(40,200,240,0.4)); transform: translateX(2px) skewX(-0.5deg); }
  37%  { filter: brightness(1.2) contrast(0.95) drop-shadow(1px -1px 0 rgba(255,60,90,0.35)) drop-shadow(-1px 1px 0 rgba(60,220,250,0.35)); transform: translateX(-1px) skewX(0.3deg); }
  50%  { filter: brightness(0.85) contrast(1.3) drop-shadow(-3px 0 0 rgba(255,30,60,0.4)) drop-shadow(3px 0 0 rgba(30,190,240,0.4)); transform: translateX(3px); }
  62%  { filter: brightness(1.1) contrast(1) drop-shadow(2px 0 0 rgba(255,50,80,0.3)) drop-shadow(-2px 0 0 rgba(50,200,250,0.3)); transform: translateX(-1px) skewX(0); }
  75%  { filter: brightness(1.05) contrast(1.05) drop-shadow(-1px 0 0 rgba(255,50,80,0.2)) drop-shadow(1px 0 0 rgba(50,200,250,0.2)); transform: translateX(0.5px); }
  100% { filter: brightness(1) contrast(1) drop-shadow(0 0 0 transparent); transform: translateX(0); }
}

/* Keyframes: short unglitch */
@keyframes glitchRgbShort {
  0%   { filter: brightness(1) contrast(1) drop-shadow(0 0 0 transparent); transform: translateX(0); }
  25%  { filter: brightness(1.12) contrast(1.1) drop-shadow(2px 0 0 rgba(255,50,80,0.35)) drop-shadow(-2px 0 0 rgba(50,180,255,0.35)); transform: translateX(-1.5px); }
  60%  { filter: brightness(0.92) contrast(1.2) drop-shadow(-1.5px 0 0 rgba(255,40,70,0.3)) drop-shadow(1.5px 0 0 rgba(40,200,240,0.3)); transform: translateX(1.5px); }
  100% { filter: brightness(1) contrast(1) drop-shadow(0 0 0 transparent); transform: translateX(0); }
}

/* Scanline flashes */
@keyframes scanFlash {
  0%, 100% { opacity: 0; }
  15% { opacity: 0.7; }
  30% { opacity: 0.05; }
  45% { opacity: 0.5; }
  60% { opacity: 0.02; }
  75% { opacity: 0.35; }
  90% { opacity: 0.1; }
}

@keyframes scanFlashShort {
  0%, 100% { opacity: 0; }
  25% { opacity: 0.5; }
  55% { opacity: 0.05; }
  80% { opacity: 0.2; }
}

/* Mobile: simplified — only opacity crossfade */
@media (max-width: 768px) {
  .glitch-photo-frame.glitching .glitch-img,
  .glitch-photo-frame.unglitching .glitch-img {
    animation: none;
    filter: none;
    transform: none;
  }
  .glitch-photo-frame.glitching .glitch-scanlines,
  .glitch-photo-frame.unglitching .glitch-scanlines {
    animation: none;
    opacity: 0;
  }
  .glitch-photo-frame.glitching .glitch-rgb-tint,
  .glitch-photo-frame.unglitching .glitch-rgb-tint {
    opacity: 0;
  }
  .glitch-photo-frame.glitching,
  .glitch-photo-frame.unglitching {
    overflow: hidden;
  }
}

/* ============================================
   10. Quote Decoration
   ============================================ */
.quote-bar {
  border-left: 3px solid #c7d2fe;
  padding-left: 1.25rem;
}

/* ============================================
   11. Footer Falling Notes
   ============================================ */
.footer-notes {
  position: relative;
  overflow: hidden;
}
.falling-note {
  position: absolute;
  top: -30px;
  font-size: 18px;
  color: #d1d5db;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  animation: noteFall var(--dur, 10s) var(--delay, 0s) ease-in infinite;
  left: var(--x, 10%);
}
.falling-note:nth-child(1) { --x: 10%; --dur: 10s; --delay: 0s; }
.falling-note:nth-child(2) { --x: 35%; --dur: 12s; --delay: 4s; }
.falling-note:nth-child(3) { --x: 65%; --dur: 9s;  --delay: 7s; }
.falling-note:nth-child(4) { --x: 85%; --dur: 11s; --delay: 2s; }

@keyframes noteFall {
  0%   { transform: translateY(0) translateX(0);    opacity: 0; }
  10%  { opacity: 0.25; }
  90%  { opacity: 0.15; }
  100% { transform: translateY(380px) translateX(var(--sway, 20px)); opacity: 0; }
}
.falling-note:nth-child(odd)  { --sway: -20px; }
.falling-note:nth-child(even) { --sway: 20px; }

/* ============================================
   Shared: Expand/Collapse
   ============================================ */
.portfolio-detail {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.55s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.35s ease,
              margin-top 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  margin-top: 0;
}
.portfolio-detail.expanded {
  max-height: 2800px;
  opacity: 1;
  margin-top: 1.5rem;
}
.expand-icon {
  transition: transform 0.35s ease;
}
.portfolio-card.expanded .expand-icon {
  transform: rotate(180deg);
}
.portfolio-detail-inner {
  padding: 0 1px;
  border-radius: 12px;
}

/* Filter Tags */
.filter-tag {
  transition: all 0.25s ease;
  cursor: pointer;
  user-select: none;
}
.filter-tag:hover {
  border-color: rgba(99, 102, 241, 0.4);
  color: #4f46e5;
}
.filter-tag.active {
  background: #111827 !important;
  border-color: #111827 !important;
  color: #fff !important;
}
.portfolio-item {
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.portfolio-item.filter-hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  position: absolute;
}

/* Audio Player (kept for future use) */
.custom-audio-player {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.3s ease;
}
.custom-audio-player:hover { border-color: #d1d5db; }
.audio-controls { display: flex; align-items: center; gap: 1rem; }
.btn-play {
  width: 40px; height: 40px; border-radius: 50%;
  background: #4f46e5; border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.2s ease, transform 0.15s ease;
  flex-shrink: 0;
}
.btn-play:hover { background: #6366f1; transform: scale(1.05); }
.btn-play:active { transform: scale(0.95); }
.audio-progress-container { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.audio-time-row { display: flex; justify-content: space-between; font-size: 0.7rem; color: #9ca3af; font-variant-numeric: tabular-nums; }
.progress-bar { width: 100%; height: 4px; border-radius: 2px; background: #e5e7eb; cursor: pointer; -webkit-appearance: none; appearance: none; outline: none; }
.progress-bar::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #6366f1; cursor: pointer; box-shadow: 0 0 6px rgba(99,102,241,0.4); }
.progress-bar::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #6366f1; border: none; cursor: pointer; }
.volume-control { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.volume-icon { color: #9ca3af; flex-shrink: 0; }
.volume-slider { width: 80px; height: 3px; border-radius: 2px; background: #e5e7eb; cursor: pointer; -webkit-appearance: none; appearance: none; outline: none; }
.volume-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #6366f1; cursor: pointer; }
.volume-slider::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #6366f1; border: none; cursor: pointer; }

/* Mobile Menu */
.mobile-menu { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.mobile-menu.open { max-height: 300px; }

/* Hero gradient */
.hero-gradient {
  background: radial-gradient(ellipse 80% 60% at 50% 30%, rgba(79,70,229,0.06) 0%, transparent 60%),
              radial-gradient(ellipse 60% 50% at 80% 70%, rgba(139,92,246,0.04) 0%, transparent 60%);
}

/* Expand pulse */
@keyframes expandPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}
.expand-hint { animation: expandPulse 2s ease-in-out infinite; }

/* Video wrapper */
.video-wrapper {
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.video-wrapper iframe { width: 100%; height: 100%; border: 0; }

/* ============================================
   [第二波创意增强] Custom Cursor
   ============================================ */
body.custom-cursor-active,
body.custom-cursor-active * {
  cursor: none !important;
}

.custom-cursor-dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(129, 140, 248, 0.8); /* indigo-400 */
  pointer-events: none;
  z-index: 9999;
  will-change: transform;
  transition: width 0.2s ease, height 0.2s ease, background 0.2s ease;
}
.custom-cursor-ring {
  position: fixed;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(199, 210, 254, 0.4); /* indigo-200 */
  pointer-events: none;
  z-index: 9998;
  will-change: transform;
  transition: width 0.2s ease, height 0.2s ease, border-color 0.2s ease;
}

/* Hover: links/buttons — enlarge */
.custom-cursor-dot.cursor-hover-link {
  width: 32px;
  height: 32px;
  background: rgba(99, 102, 241, 0.9); /* indigo-500 */
}
.custom-cursor-ring.cursor-hover-link {
  width: 54px;
  height: 54px;
  border-color: rgba(165, 180, 252, 0.55);
}

/* Hover: video — play triangle in dot centre */
.custom-cursor-dot.cursor-hover-video::after {
  content: '\25B6';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fff;
  line-height: 1;
}

/* Click pulse */
.custom-cursor-dot.cursor-click {
  width: 16px !important;
  height: 16px !important;
  transition: width 0.075s ease, height 0.075s ease;
}

/* Scroll hide */
body.cursor-scrolling .custom-cursor-dot,
body.cursor-scrolling .custom-cursor-ring {
  opacity: 0;
  transition: opacity 0.08s ease;
}

/* ============================================
   [第二波创意增强] Loading Overlay
   ============================================ */
#loading-overlay {
  transition: opacity 0.5s ease, background-color 0.7s ease;
}
#loading-overlay.fade-out {
  opacity: 0;
  background-color: #fff !important;
  pointer-events: none;
}

.loading-bars {
  gap: 0.625rem;
}

.loading-bar {
  height: 0;
  width: 0.75rem;
  border-radius: 9999px;
  animation: loadingBounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.loading-bar:nth-child(1) { animation-delay: 0s; }
.loading-bar:nth-child(2) { animation-delay: 0.1s; }
.loading-bar:nth-child(3) { animation-delay: 0.2s; }
.loading-bar:nth-child(4) { animation-delay: 0.3s; }
.loading-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes loadingBounce {
  0%   { height: 0; }
  100% { height: var(--bar-h, 100%); }
}

/* Phase 2 — wave oscillation */
.loading-bar.wave {
  animation: loadingWave 0.75s ease-in-out infinite;
}
.loading-bar.wave:nth-child(1) { animation-delay: 0s; }
.loading-bar.wave:nth-child(2) { animation-delay: 0.08s; }
.loading-bar.wave:nth-child(3) { animation-delay: 0.16s; }
.loading-bar.wave:nth-child(4) { animation-delay: 0.24s; }
.loading-bar.wave:nth-child(5) { animation-delay: 0.32s; }

@keyframes loadingWave {
  0%, 100% { height: var(--bar-h, 100%); }
  50%      { height: 25%; }
}

/* ============================================
   [第二波创意增强] Typography
   ============================================ */
/* Utility classes for Google Fonts */
.font-body {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.font-quote {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
}

/* Body text base */
.body-text {
  line-height: 1.8;
}
.heading-text {
  line-height: 1.3;
}

/* ============================================
   prefers-reduced-motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .note-decor.float { animation: none; }
  .falling-note { display: none; }
  .expand-ripple { animation: none; display: none; }
  .glitch-photo-frame.glitching,
  .glitch-photo-frame.unglitching { animation: none; }
  .glitch-scanlines { display: none; }
  /* Second-wave effects */
  .custom-cursor-dot,
  .custom-cursor-ring { display: none !important; }
  body.custom-cursor-active,
  body.custom-cursor-active * { cursor: auto !important; }
  .loading-bar { animation: none !important; height: 60% !important; }
  #loading-overlay.fade-out { opacity: 0; background-color: #fff !important; }
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .audio-controls { flex-wrap: wrap; }
  .volume-control { width: 100%; justify-content: flex-start; padding-top: 0.25rem; }
  .portfolio-detail-inner .grid { grid-template-columns: 1fr; }
  .note-decor { font-size: 20px; }
  .falling-note { display: none; }
  .video-thumb-hover::after,
  .video-thumb-hover .play-overlay { display: none; }
  /* Second-wave: no custom cursor on mobile */
  .custom-cursor-dot,
  .custom-cursor-ring { display: none !important; }
  body.custom-cursor-active,
  body.custom-cursor-active * { cursor: auto !important; }
}
