// 导入SASS模块
@use 'sass:map';

// 核心变量
$transitions: (
  base: all 0.3s ease,
  hover: all 0.4s ease,
);

$radii: (
  sm: 8px,
  md: 12px,
  lg: 16px,
  xl: 20px,
  2xl: 24px,
);

$shadows: (
  light: (
    base: 0 4px 6px -1px rgb(0 0 0 / 0.08),
    hover: 0 20px 25px -5px rgb(0 0 0 / 0.15),
  ),
  dark: (
    base: 0 4px 6px -1px rgba(0, 0, 0, 0.3),
    hover: 0 20px 25px -5px rgba(0, 0, 0, 0.4),
  ),
);

// 核心混入
@mixin hover-lift($y: -6px, $scale: 1.02) {
  transition: map.get($transitions, hover);
  &:hover {
    transform: translateY($y) scale($scale);
  }
}

@mixin glass($opacity: 0.1) {
  background: rgba(255, 255, 255, $opacity);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, $opacity + 0.05);
}

@mixin theme-colors($dark, $light) {
  .dark-theme & {
    color: $dark;
  }
  .project-homepage:not(.dark-theme) & {
    color: $light;
  }
}

@mixin theme-background($dark, $light) {
  .dark-theme & {
    background: $dark !important;
  }
  .project-homepage:not(.dark-theme) & {
    background: $light !important;
  }
}

@mixin responsive-grid(
  $mobile: 1fr,
  $tablet: repeat(2, 1fr),
  $desktop: repeat(3, 1fr)
) {
  display: grid;
  grid-template-columns: $desktop;
  gap: 1.5rem;

  @media (max-width: 768px) {
    & {
      grid-template-columns: $tablet;
    }
  }
  @media (max-width: 480px) {
    & {
      grid-template-columns: $mobile;
    }
  }
}

// 基础卡片样式
%card-base {
  border-radius: map.get($radii, xl) !important;
  @include hover-lift;

  .dark-theme & {
    box-shadow:
      map.get($shadows, dark, base),
      0 2px 4px -2px rgba(0, 0, 0, 0.2) !important;
    &:hover {
      box-shadow:
        map.get($shadows, dark, hover),
        0 8px 10px -6px rgba(0, 0, 0, 0.3) !important;
    }
  }

  .project-homepage:not(.dark-theme) & {
    box-shadow:
      map.get($shadows, light, base),
      0 2px 4px -2px rgb(0 0 0 / 0.06) !important;
    border: 1px solid #e5e7eb !important;
    &:hover {
      box-shadow:
        map.get($shadows, light, hover),
        0 8px 10px -6px rgb(0 0 0 / 0.1) !important;
    }
  }
}

// 基础样式
.project-homepage {
  min-height: 100vh;
  background: var(--n-body-color);
  color: var(--n-text-color);
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
  transition: map.get($transitions, base);
}

// 顶部横幅
.hero-banner {
  background: linear-gradient(
    135deg,
    var(--n-primary-color) 0%,
    var(--n-primary-color-hover) 100%
  );
  padding: 3.6rem 1.8rem; // 4rem * 0.9, 2rem * 0.9
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 100%;
    height: 200%;
    background: radial-gradient(
      circle,
      rgba(255, 255, 255, 0.1) 0%,
      transparent 70%
    );
    animation: float 20s linear infinite;
  }

  .hero-content {
    max-width: 1260px; // 1400 * 0.9
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.8rem; // 2rem * 0.9
    align-items: start;
    position: relative;
    z-index: 2;

    @media (max-width: 1200px) {
      grid-template-columns: 1fr;
      gap: 1.8rem;
    }
  }
}

// 项目介绍区域
.project-intro {
  .project-badge {
    margin-bottom: 2rem;
    @include glass(0.15);

    .badge-dot {
      width: 8px;
      height: 8px;
      background: #00ff88;
      border-radius: 50%;
      animation: pulse 2s infinite;
      box-shadow: 0 0 10px #00ff88;
    }
  }

  .project-title {
    margin-bottom: 2rem;

    .title-main {
      display: block;
      font-size: 3.5rem;
      font-weight: 800;
      line-height: 1.1;
      margin-bottom: 0.5rem;
      cursor: pointer;
      background: linear-gradient(
        45deg,
        #ff6b6b,
        #4ecdc4,
        #45b7d1,
        #96ceb4,
        #ffeaa7
      );
      background-clip: text;
      -webkit-text-fill-color: transparent;
      background-size: 300% 300%;
      animation: gentleColorFlow 6s ease-in-out infinite;

      @media (max-width: 768px) {
        font-size: 2.5rem;
      }

      .title-char {
        display: inline-block;
        transition: map.get($transitions, base);
        transform-origin: center;

        &.animate {
          animation: charBounceRainbow 0.6s ease-in-out;
          background: linear-gradient(
            45deg,
            #ff6b6b,
            #4ecdc4,
            #45b7d1,
            #96ceb4,
            #ffeaa7,
            #fd79a8,
            #fdcb6e,
            #6c5ce7,
            #a29bfe,
            #fd79a8
          ) !important;
          background-size: 400% 400% !important;
          background-clip: text !important;
          -webkit-text-fill-color: transparent !important;
          animation:
            charBounceRainbow 0.6s ease-in-out,
            rainbowShift 1.5s ease-in-out infinite;
        }
      }
    }

    .title-desc {
      display: block;
      font-size: 1.25rem;
      opacity: 0.9;
      font-weight: 400;
    }
  }

  .project-description {
    font-size: 1.125rem;
    line-height: 1.7;
    opacity: 0.9;
    margin-bottom: 2.5rem;
    max-width: 800px;
  }

  .project-stats {
    margin-bottom: 2.5rem;
    @include responsive-grid(repeat(2, 1fr), repeat(2, 1fr), repeat(4, 1fr));

    .stat-item {
      @include glass(0.1);
      border-radius: map.get($radii, lg);
      padding: 1.5rem;
      text-align: center;
      transition: map.get($transitions, hover);
      cursor: pointer;

      &:hover {
        transform: translateY(-6px) scale(1.05);
        background: rgba(255, 255, 255, 0.15);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
      }

      .stat-number {
        font-size: 2rem;
        font-weight: 700;
        margin-bottom: 0.25rem;
      }

      .stat-label {
        font-size: 0.875rem;
        opacity: 0.8;
      }
    }
  }

  .project-actions .btn-icon {
    font-size: 1.125rem;
  }
}

// 作者卡片
.author-card {
  border-radius: map.get($radii, 2xl) !important;
  @include hover-lift;

  @include theme-background(
    rgba(255, 255, 255, 0.1),
    linear-gradient(135deg, #dbeafe 0%, #eff6ff 100%)
  );

  .dark-theme & {
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
  }

  .project-homepage:not(.dark-theme) & {
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.1);
  }

  .author-content {
    text-align: center;
    padding: 1rem;
  }

  .author-avatar {
    position: relative;
    margin-bottom: 1.5rem;

    .avatar-glow {
      position: absolute;
      inset: -10px;
      border-radius: 50%;
      animation: pulse-glow 3s ease-in-out infinite;

      background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.3) 0%,
        transparent 70%
      );
      .project-homepage:not(.dark-theme) & {
        background: radial-gradient(
          circle,
          rgba(59, 130, 246, 0.3) 0%,
          transparent 70%
        );
      }
    }

    .avatar-main {
      position: relative;
      margin: 0 auto 1rem;
      font-size: 2rem;
      transition: map.get($transitions, base);
      animation: gentleFloat 4s ease-in-out infinite;
      cursor: pointer;

      &:hover {
        transform: scale(1.1) rotate(10deg);
        animation: none;
      }

      @include theme-background(
        rgba(255, 255, 255, 0.2),
        rgba(59, 130, 246, 0.1)
      );
    }

    .author-status {
      @include theme-background(
        rgba(79, 172, 254, 0.2),
        rgba(59, 130, 246, 0.15)
      );

      .dark-theme & {
        border: 1px solid rgba(79, 172, 254, 0.4) !important;
        color: #4facfe !important;
      }

      .project-homepage:not(.dark-theme) & {
        border: 1px solid rgba(59, 130, 246, 0.3) !important;
        color: #3b82f6 !important;
      }

      .status-dot {
        width: 6px;
        height: 6px;
        background: #00ff88;
        border-radius: 50%;
        animation: pulse 2s infinite;
        box-shadow: 0 0 6px #00ff88;

        .project-homepage:not(.dark-theme) & {
          background: #3b82f6;
          box-shadow: 0 0 6px #3b82f6;
        }
      }
    }
  }

  .author-info {
    .author-name {
      font-size: 1.25rem;
      font-weight: 600;
      margin-bottom: 0.75rem;
      @include theme-colors(#f8fafc, #1e40af);
    }

    .author-bio {
      font-size: 0.875rem;
      opacity: 0.9;
      line-height: 1.6;
      margin-bottom: 1.5rem;
      @include theme-colors(#e2e8f0, #374151);
    }

    .author-stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 1rem;

      .author-stat {
        text-align: center;

        .stat-number {
          font-size: 1.5rem;
          font-weight: 700;
          margin-bottom: 0.25rem;
          @include theme-colors(#f8fafc, #1e40af);
        }

        .stat-label {
          font-size: 0.75rem;
          opacity: 0.8;
          @include theme-colors(#cbd5e1, #6b7280);
        }
      }
    }
  }
}

// 主要内容区域 - 整体缩小90%
.main-container {
  max-width: 1260px; // 1400 * 0.9
  margin: 0 auto;
  padding: 3.6rem 1.8rem; // 4rem * 0.9, 2rem * 0.9
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.8rem; // 2rem * 0.9
  align-items: start;

  @media (max-width: 1200px) {
    grid-template-columns: 1fr;
    gap: 1.8rem;
    padding: 2.7rem 0.9rem; // 3rem * 0.9, 1rem * 0.9
  }
}

.content-left,
.content-right {
  display: flex;
  flex-direction: column;
  gap: 1.8rem; // 2rem * 0.9
}

// 卡片样式
.n-card {
  @extend %card-base;
}

// 功能模块
.feature-modules {
  .modules-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.9rem; // 1rem * 0.9
    
    @media (max-width: 968px) {
      grid-template-columns: repeat(2, 1fr);
    }
    
    @media (max-width: 640px) {
      grid-template-columns: 1fr;
    }
  }

  .module-card {
    @extend %card-base;
    border-radius: map.get($radii, lg) !important;

    .module-content {
      text-align: center;
      padding: 0.9rem; // 1rem * 0.9

      .module-icon {
        font-size: 1.8rem; // 2rem * 0.9
        margin-bottom: 0.675rem; // 0.75rem * 0.9
      }

      h3 {
        font-size: 0.855rem; // 0.95rem * 0.9
        font-weight: 600;
        color: var(--n-text-color);
        margin-bottom: 0.45rem; // 0.5rem * 0.9
      }

      p {
        font-size: 0.72rem; // 0.8rem * 0.9
        color: var(--n-text-color-depth-2);
        line-height: 1.5;
        margin-bottom: 0.675rem; // 0.75rem * 0.9
      }

      .module-tech {
        font-size: 0.63rem; // 0.7rem * 0.9
      }
    }
  }
}

// 技术架构
.tech-architecture {
  .architecture-flow {
    display: flex;
    flex-direction: column;
    gap: 0.9rem; // 1rem * 0.9

    .arch-layer-wrapper {
      display: flex;
      flex-direction: column;
      align-items: center;
    }

    .arch-layer {
      width: 100%;
      border-radius: map.get($radii, lg);
      padding: 1.35rem; // 1.5rem * 0.9
      transition: map.get($transitions, base);
      background: var(--n-card-color);
      border: 1px solid var(--n-border-color);

      &.layer-frontend {
        border-left: 4px solid #6366f1;
      }
      &.layer-build {
        border-left: 4px solid #10b981;
      }
      &.layer-state {
        border-left: 4px solid #f59e0b;
      }
      &.layer-tools {
        border-left: 4px solid #ef4444;
      }
      &.layer-dx {
        border-left: 4px solid #8b5cf6;
      }

      .layer-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.9rem; // 1rem * 0.9

        .layer-title {
          font-weight: 600;
          color: var(--n-text-color);
          margin: 0;
          font-size: 0.9rem; // 1rem * 0.9
        }

        .layer-icon {
          font-size: 1.35rem; // 1.5rem * 0.9
          opacity: 0.7;
        }
      }

      .layer-techs {
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem; // 0.5rem * 0.9
        justify-content: center;
      }
    }

    .arch-arrow {
      color: var(--n-text-color-depth-3);
      font-size: 1.35rem; // 1.5rem * 0.9
      margin: 0 auto;
    }
  }
}

// 项目结构
.project-structure {
  .file-tree-container {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 12px;
    margin-right: -4px;

    &::-webkit-scrollbar {
      width: 8px;
      &-track {
        background: var(--n-scrollbar-track-color);
        border-radius: 4px;
        margin: 4px 0;
      }
      &-thumb {
        background: var(--n-scrollbar-color);
        border-radius: 4px;
        border: 1px solid var(--n-scrollbar-track-color);
        &:hover {
          background: var(--n-scrollbar-color-hover);
        }
      }
    }
  }

  :deep(.file-tree) {
    font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;

    .tree-item {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      padding: 0.25rem 0;
      color: var(--n-text-color);

      &.folder {
        font-weight: 500;
      }

      .tree-icon {
        font-size: 1rem;
        flex-shrink: 0;
      }

      .tree-name {
        flex: 1;
        min-width: 0;
      }

      .tree-desc {
        font-size: 0.75rem;
        color: var(--n-text-color-depth-3);
        font-style: italic;
        flex-shrink: 0;
        margin-left: 0.5rem;
      }
    }

    .tree-children {
      margin-left: 1.5rem;
      border-left: 1px solid var(--n-border-color);
      padding-left: 1rem;
    }
  }
}

// 演示页面
.demo-showcase {
  .demo-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;

    .demo-title {
      font-size: 1.125rem;
      font-weight: 600;
    }
  }

  .demo-grid {
    @include responsive-grid();

    .demo-item {
      background: var(--n-card-color);
      border-radius: map.get($radii, md);
      padding: 1rem;
      text-align: center;
      border: 1px solid var(--n-border-color);
      transition: map.get($transitions, hover);
      cursor: pointer;

      &:hover {
        transform: translateY(-4px) scale(1.05);
        box-shadow: var(--n-box-shadow-2);
      }

      .demo-icon {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
      }

      .demo-name {
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--n-text-color);
      }
    }
  }
}

// 核心特性
.core-features .features-list .feature-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--n-action-color);
  border-radius: 50%;
}

// 开发工具
.dev-tools .tools-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

  .tool-category {
    h4 {
      font-size: 1rem;
      font-weight: 600;
      color: var(--n-text-color);
      margin-bottom: 0.75rem;
    }

    .tool-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
    }
  }
}

// 许可证卡片
.license-card .license-content .license-info {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;

  .license-badge,
  .author-info-card {
    padding: 1rem;
    background: var(--n-action-color);
    border-radius: map.get($radii, md);
    border: 1px solid var(--n-border-color);
  }

  .license-badge {
    display: flex;
    align-items: center;
    gap: 1rem;

    .license-icon {
      font-size: 2rem;
    }

    .license-text {
      h4 {
        font-size: 1rem;
        font-weight: 600;
        color: var(--n-text-color);
        margin-bottom: 0.25rem;
      }

      p {
        font-size: 0.875rem;
        color: var(--n-text-color-depth-2);
        margin: 0;
      }
    }
  }

  .author-info-card {
    h4 {
      font-size: 1rem;
      font-weight: 600;
      color: var(--n-text-color);
      margin-bottom: 0.75rem;
    }

    p {
      font-size: 0.875rem;
      color: var(--n-text-color-depth-2);
      margin-bottom: 0.5rem;

      &:last-child {
        margin-bottom: 0;
      }

      a {
        color: var(--n-primary-color);
        text-decoration: none;
        &:hover {
          text-decoration: underline;
        }
      }
    }
  }
}

// 快速开始
.quick-start {
  .start-steps {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
  }

  .step-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;

    .step-number {
      width: 32px;
      height: 32px;
      background: var(--n-primary-color);
      color: white;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-weight: 600;
      font-size: 0.875rem;
      flex-shrink: 0;
    }

    .step-content {
      flex: 1;

      h4 {
        font-size: 1rem;
        font-weight: 600;
        color: var(--n-text-color);
        margin-bottom: 0.75rem;
      }

      :deep(.step-code) {
        margin-top: 0.75rem;
        background: #1e1e1e !important;
        border-radius: map.get($radii, sm) !important;
        font-family: 'JetBrains Mono', 'Monaco', 'Menlo', monospace !important;
        font-size: 0.875rem !important;
        border: 1px solid #333 !important;
        overflow: hidden;

        .n-code,
        code,
        pre {
          background: #1e1e1e !important;
          color: #d4d4d4 !important;
        }

        .hljs,
        code,
        pre {
          padding: 14px 18px !important;
          margin: 0 !important;
          line-height: 1.5;
        }

        code {
          font-family: inherit !important;
          display: block !important;
        }

        pre code {
          background: transparent !important;
          padding: 0 !important;
        }
      }
    }
  }
}

// 动画
@keyframes gentleColorFlow {
  0% {
    background-position: 0% 50%;
  }
  25% {
    background-position: 100% 50%;
  }
  50% {
    background-position: 50% 100%;
  }
  75% {
    background-position: 0% 50%;
  }
  100% {
    background-position: 50% 0%;
  }
}

@keyframes gentleFloat {
  0%,
  100% {
    transform: translateY(0px) rotate(0deg);
  }
  25% {
    transform: translateY(-3px) rotate(1deg);
  }
  50% {
    transform: translateY(-6px) rotate(0deg);
  }
  75% {
    transform: translateY(-3px) rotate(-1deg);
  }
}

@keyframes charBounceRainbow {
  0%,
  20%,
  50%,
  80%,
  100% {
    transform: translateY(0) scale(1) rotateZ(0deg);
  }
  40% {
    transform: translateY(-20px) scale(1.3) rotateZ(10deg);
  }
  60% {
    transform: translateY(-10px) scale(1.15) rotateZ(-5deg);
  }
}

@keyframes rainbowShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes float {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.1);
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.4;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.6;
  }
}

// 响应式
@media (max-width: 768px) {
  .hero-banner {
    padding: 2rem 1rem;
  }
  .project-intro .title-main {
    font-size: 2.5rem !important;
  }
}