/* ==========================================
   AI Model Pipeline – Layout Container
========================================== */
#ai-flow {
  padding: 80px 0;
  position: relative;
}

.ai-flow-wrapper {
  display: flex;
  align-items: flex-start;
  max-width: 1600px;
  margin: 0 auto;
  gap: 150px; /* 左右距離縮短 */
  padding-left: 60px;
}


/* ==========================================
   左側標題
========================================== */
.ai-flow-left {
  position: relative;  
  width: 340px;
}

.flow-title {
  font-size: 45px;
  font-weight: 900;
  line-height: 1.25;
  color: #1b2340;
}

.flow-sub {
  font-size: 22px;
  color: #3a7d34;
  margin-top: 20px;
}

.flow-desc {
  margin-top: 15px;
  color: #444;
  font-size: 14px;
  line-height: 1.7;
}


/* ==========================================
   三階段垂直文字
========================================== */
.flow-phases-left {
  position: absolute;
  top: 90;
  left: 1200px;   /* ★ Phase 整體與菱形距離（可調） */
  z-index: 30;
  width: 260px;
}

.phase-1 { top: 70px; }
.phase-2 { top: 300px; }
.phase-3 { top: 520px; }

.phase {
  position: absolute;
  writing-mode: horizontal-tb;
  font-size: 16px;
  letter-spacing: 2px;
  color: #555;
  opacity: 0.95;
  white-space: nowrap;
}

/* ==========================================
   右側菱形矩陣（縮短間距）
========================================== */
.ai-flow-right {
  position: relative;
}

.diamond-grid {
  display: grid;
  grid-template-columns: repeat(3, 150px); /* 整體縮窄 */
  grid-row-gap: 60px;   /* ★ 上下更緊 */
  grid-column-gap: 80px;/* ★ 左右更緊 */
  justify-content: center;
  margin-top: 30px;
   position: relative;   /* ★ 讓線條定位基準正確 */
}

/* ==========================================
   Diamond Style
========================================== */
.diamond-wrap {
  position: relative;
  width: 150px;
  height: 150px;
  perspective: 900px;
}

.diamond {
  width: 120px;
  height: 120px;
  background: #fff;
  border-radius: 28px;
  transform: rotate(45deg);
  box-shadow: 0 12px 24px rgba(0,0,0,0.08);
  position: relative;
  margin: 0 auto;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.diamond:hover {
  transform: rotate(45deg) scale(1.06);
  box-shadow: 0 20px 32px rgba(0,0,0,0.18);
}

.diamond img {
  width: 110px;
  height: 110px;
  position: absolute;
  top: 48%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* 滑鼠移入：微 3D 傾斜 + 飄浮 */
.diamond.hover-3d {
  transform: rotate(45deg) scale(1.1) translateY(-6px) rotateX(10deg) rotateY(-10deg);
  box-shadow: 0 18px 40px rgba(0,0,0,0.18);
}

/* 手機自動浮動效果 */
@keyframes autoFloat {
  0%   { transform: rotate(45deg) translateY(0px); }
  50%  { transform: rotate(45deg) translateY(-8px); }
  100% { transform: rotate(45deg) translateY(0px); }
}

@media (max-width: 768px) {
  .diamond {
    animation: autoFloat 3s ease-in-out infinite;
  }
}

/* ==========================================
   文字移入菱形底部（深色字）
========================================== */
.diamond-label {
  position: absolute;
  bottom: -8px; /* 貼在菱形底部內 */
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  color: #1a1a1a;  /* 深色字 */
  font-weight: 600;
  width: 130px;
  text-align: center;
  pointer-events: none;
}

/* Active 狀態 */
.diamond.active {
  border: 0;
  background: linear-gradient(135deg, #6c78e2c2, #949de98c);
  border: 15px solid #b5c3fcdc;
  box-shadow: 0 22px 50px rgba(80, 100, 255, 0.575);
  transform: rotate(45deg) scale(1.15);
  backdrop-filter: blur(4px);
}

/* ==========================================
   Flow Lines 動態線條容器
========================================== */
.flow-lines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(82,113,255,0.0);
  opacity: 0;
  border-radius: 999px;
  transform-origin: left center;
  pointer-events: none;
  z-index: 20;
}

/* ==========================================
   單條線條
========================================== */
.flow-line {
  position: absolute;
  height: 3px;
  background: rgba(82,113,255,0.0); /* 初始透明 */
  border-radius: 999px;
  opacity: 0;
  transform-origin: left center;
}

/* 線條上的流動光點 Pulse */
.flow-line::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  background: #ffffffdd;
  border-radius: 50%;
  top: -9px;
  left: -20px;
  opacity: 0;  
}
/* 線條亮起動畫：滑入 + 亮色 */
@keyframes line-reveal {
  0% { opacity: 0; transform: scaleX(0); }
  100% { opacity: 1; transform: scaleX(1); background: rgba(82,113,255,0.9); }
}

/* Pulse 移動動畫 */
@keyframes pulse-move {
  0%   { left: -20px; opacity: 0; transform: scale(.4); }
  20%  { opacity: 1; transform: scale(1); }
  100% { left: 100%; opacity: 0; transform: scale(.4); }
}

/* 啟動 pulse（JS 會加上此 class） */
.pulse-active::after {
  animation: pulse-move 1.4s ease-out forwards;
}
/* ==========================================
  SVG 曲線線條樣式
========================================== */
.flow-svg path {
  stroke: rgba(82,113,255,0.0); /* 初始透明 */
  stroke-width: 3;
  fill: none;
  opacity: 0;
}

/* 曲線 reveal 動畫 */
@keyframes path-reveal {
  0%   { opacity: 0; stroke-dashoffset: 200; }
  100% { opacity: 1; stroke-dashoffset: 0; stroke: rgba(82,113,255,0.9); }
}

/* pulse 粒子 */
.flow-pulse {
  fill: white;
  opacity: 0;
}

/* =====================================================
   RWD — Mobile Version（<= 768px）
===================================================== */
@media (max-width: 768px) {

  /* 整體堆疊 */
  .ai-flow-wrapper {
    flex-direction: column;
    gap: 40px;
    padding-left: 0;
    align-items: center;
  }

  /* 左側文字置中 */
  .ai-flow-left {
    width: 100%;
    text-align: center;
  }

  /* Phase 由垂直改成橫排 */
  .flow-phases-left {
    position: absolute;
    top: 260px;             /* ★ 會對齊菱形第二排中心位置 */
    left: 780px;   
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
    z-index: 50;
  }

  .phase {
    writing-mode: horizontal-tb !important;
    position: relative;
    top: 0 !important;
    font-size: 16px;
    letter-spacing: 2px;
    color: #666;
    opacity: 0.95;
  }

  /* 菱形 grid 改成單欄 */
  .diamond-grid {
    grid-template-columns: 1fr !important;
    grid-row-gap: 70px !important;
    grid-column-gap: 0 !important;
    margin-top: 20px;
  }

  /* 包覆器縮窄 */
  .diamond-wrap {
    width: 160px;
    height: 160px;
    margin: 0 auto;
  }

  /* 菱形縮小 */
  .diamond {
    width: 120px;
    height: 120px;
  }

  /* 圖標縮小 */
  .diamond img {
    width: 80px;
    height: 80px;
  }

  /* label 依然在裡面，但縮小不溢位 */
  .diamond-label {
    font-size: 14px;
    bottom: -10px;
    width: 120px;
  }

  /* Active 效果縮小，不會爆版 */
  .diamond.active {
    border-width: 24px;
  }
}


