@import url("https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap");

/* ============================================================
   TOOLS section — calculator 卡片橫向 sticky 輪播
   來源：阿翰提供 deconstructed-card demo（calculatequick.com）
   scope 化到 .tools-section 避免污染主題
   ============================================================ */

.tools-section {
  --card-width: 300px;
  --card-height: 400px;
  --black: #080808;
  --white: #fafafa;
  --accent: #ff2d55;
  --grid-color: rgba(0, 0, 0, 0.08);
  --frame-color: rgba(8, 8, 8, 0.8);
  --transition-slow: 0.8s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  position: relative;
  width: 100%;
  height: calc(200vh + 1500px); /* sticky 範圍 = vh + 1500：1×vh 給 Phase 6 淡出 + 1500px 停留 */
  background: #000;
  color: var(--black);
  font-feature-settings: "salt" 1, "ss01" 1, "ss02" 1;
}

.tools-pin {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tools-section .carousel {
  position: relative;
  width: max-content;
  padding: 5vh 0;
}

.tools-section .carousel-track {
  display: flex;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 40px 0;
  gap: 40px;
}

.tools-section .deconstructed-card {
  position: relative;
  width: var(--card-width);
  height: var(--card-height);
  cursor: pointer;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transform-style: preserve-3d;
  flex-shrink: 0;
}

.tools-section .deconstructed-card.is-active {
  transform: scale(1.08);
  z-index: 2;
}

.tools-section .card-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.tools-section .card-image {
  overflow: hidden;
  z-index: 1;
}

.tools-section .wave-svg {
  width: 100%;
  height: 100%;
  transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tools-section .card-frame {
  z-index: 3;
  pointer-events: none;
}

.tools-section .frame-path {
  fill: none;
  stroke: var(--frame-color);
  stroke-width: 1;
  stroke-dasharray: 1520;
  stroke-dashoffset: 1520;
  transition: stroke-dashoffset 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.tools-section .card-background {
  z-index: 0;
  background-color: var(--white);
}

.tools-section .bg-grid {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.tools-section .grid-line {
  position: absolute;
  background-color: var(--grid-color);
  transition: transform var(--transition-slow), opacity var(--transition-fast);
}

.tools-section .grid-line.horizontal {
  width: 100%;
  height: 1px;
  transform: scaleX(0.3);
  transform-origin: left;
}

.tools-section .grid-line.vertical {
  height: 100%;
  width: 1px;
  transform: scaleY(0.3);
  transform-origin: top;
}

.tools-section .bg-objects {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tools-section .bg-object {
  position: absolute;
  opacity: 0.3;
  transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.tools-section .bg-object.circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  bottom: 40px;
  left: -30px;
  transform: translateY(20px);
}

.tools-section .bg-object.square {
  width: 60px;
  height: 60px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  top: 40px;
  right: 30px;
  transform: rotate(45deg) translateY(-20px);
}

.tools-section .bg-object.triangle {
  width: 0;
  height: 0;
  border-left: 40px solid transparent;
  border-right: 40px solid transparent;
  border-bottom: 70px solid rgba(0, 0, 0, 0.05);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
}

.tools-section .card-content {
  z-index: 2;
  padding: 30px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
}

.tools-section .content-fragment {
  position: relative;
}

.tools-section .fragment-heading {
  margin-top: auto;
  margin-bottom: 1.5rem;
}

.tools-section .content-text {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--black);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
  transform: translateY(10px);
  opacity: 0.7;
}

.tools-section .content-subtext {
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  margin-top: 1rem;
  color: var(--black);
  opacity: 0.5;
  transform: translateY(10px);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.tools-section .fragment-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2rem;
}

.tools-section .meta-line {
  width: 40px;
  height: 1px;
  background-color: var(--black);
  transform: scaleX(0.5);
  transform-origin: left;
  transition: transform var(--transition-fast);
}

.tools-section .meta-text {
  font-family: "Space Mono", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  opacity: 0.6;
  transform: translateX(-5px);
  transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.tools-section .fragment-body {
  max-width: 85%;
  margin: 1.5rem 0;
}

.tools-section .fragment-body .content-text {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: normal;
  opacity: 0.6;
}

.tools-section .fragment-cta {
  margin-top: auto;
  overflow: visible;
}

.tools-section .cta-link {
  text-decoration: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 8px 0;
}

.tools-section .cta-box {
  position: absolute;
  top: 0;
  left: -10px;
  width: calc(100% + 20px);
  height: 100%;
  background-color: var(--black);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-fast);
}

.tools-section .cta-text {
  position: relative;
  font-family: "Space Mono", monospace;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--black);
  transform: translateX(-5px);
  opacity: 0.7;
  transition: transform var(--transition-fast), opacity var(--transition-fast),
    color var(--transition-fast);
}

.tools-section .align-right {
  text-align: right;
}

.tools-section .text-align-right {
  align-self: flex-end;
  text-align: right;
}

.tools-section .text-align-right .meta-line {
  transform-origin: right;
}

.tools-section .text-align-right .cta-box {
  transform-origin: right;
}

.tools-section .text-align-right .meta-text {
  transform: translateX(5px);
}

.tools-section .text-card .content-text,
.tools-section .text-card .content-subtext {
  color: var(--black);
}

/* Hover 互動 */
.tools-section .deconstructed-card:hover .frame-path {
  stroke-dashoffset: 0;
}

.tools-section .deconstructed-card:hover .content-text,
.tools-section .deconstructed-card:hover .content-subtext {
  transform: translateY(0);
  opacity: 1;
  transition-delay: 0.05s;
}

.tools-section .deconstructed-card:hover .fragment-body .content-text {
  transition-delay: 0.1s;
  opacity: 1;
}

.tools-section .deconstructed-card:hover .meta-text {
  transform: translateX(0);
  opacity: 1;
  transition-delay: 0.15s;
}

.tools-section .deconstructed-card:hover .meta-line {
  transform: scaleX(1);
  transition-delay: 0.05s;
}

.tools-section .deconstructed-card:hover .wave-svg {
  transform: scale(1.05);
}

.tools-section .deconstructed-card:hover .cta-text {
  transform: translateX(0);
  opacity: 1;
  transition-delay: 0.2s;
}

.tools-section .deconstructed-card:hover .cta-link:hover .cta-box {
  transform: scaleX(1);
}

.tools-section .deconstructed-card:hover .cta-link:hover .cta-text {
  color: var(--white);
}

.tools-section .text-card:hover .grid-line.horizontal {
  transform: scaleX(1);
}

.tools-section .text-card:hover .grid-line.vertical {
  transform: scaleY(1);
}

.tools-section .text-card:hover .bg-object {
  opacity: 1;
  transform: translate(0, 0) rotate(0);
}

.tools-section .text-card:hover .bg-object.square {
  transform: rotate(45deg) translate(0, 0);
}

.tools-section .text-card:hover .bg-object.triangle {
  transform: translate(-50%, -50%) scale(1);
}

.tools-section .deconstructed-card:hover .grid-line:nth-child(1) { transition-delay: 0.1s; }
.tools-section .deconstructed-card:hover .grid-line:nth-child(2) { transition-delay: 0.2s; }
.tools-section .deconstructed-card:hover .grid-line:nth-child(3) { transition-delay: 0.3s; }
.tools-section .deconstructed-card:hover .grid-line:nth-child(4) { transition-delay: 0.15s; }
.tools-section .deconstructed-card:hover .grid-line:nth-child(5) { transition-delay: 0.25s; }

/* 各卡片配色 */
.tools-section .pregnancy-content .card-image svg { background: linear-gradient(135deg, #ff6b6b, #ff8e8e); }
.tools-section .baby-content .card-image svg      { background: linear-gradient(135deg, #4ecdc4, #7ee8e1); }
.tools-section .percentage-content                { color: var(--black); }
.tools-section .percentage-content .card-image svg{ background: linear-gradient(135deg, #ffd166, #ffe0a3); }
.tools-section .egg-content                       { color: var(--black); }
.tools-section .egg-content .card-image svg       { background: linear-gradient(135deg, #06d6a0, #62f7d1); }
.tools-section .sleep-content                     { color: var(--white); }
.tools-section .sleep-content .card-image svg     { background: linear-gradient(135deg, #118ab2, #5ac8e3); }
.tools-section .age-content                       { color: var(--white); }
.tools-section .age-content .card-image svg       { background: linear-gradient(135deg, #073b4c, #3c7c8c); }

.tools-section .percentage-content .meta-line,
.tools-section .egg-content .meta-line {
  background-color: var(--black);
}

.tools-section .sleep-content .meta-line,
.tools-section .age-content .meta-line {
  background-color: var(--white);
}

.tools-section .percentage-content .content-text,
.tools-section .percentage-content .meta-text,
.tools-section .percentage-content .cta-text,
.tools-section .egg-content .content-text,
.tools-section .egg-content .meta-text,
.tools-section .egg-content .cta-text {
  color: var(--black);
}

.tools-section .sleep-content .content-text,
.tools-section .sleep-content .meta-text,
.tools-section .sleep-content .cta-text,
.tools-section .age-content .content-text,
.tools-section .age-content .meta-text,
.tools-section .age-content .cta-text {
  color: var(--white);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tools-section .sleep-content .cta-box,
.tools-section .age-content .cta-box {
  background-color: var(--white);
}

.tools-section .sleep-content .cta-link:hover .cta-text,
.tools-section .age-content .cta-link:hover .cta-text {
  color: var(--black) !important;
}

/* Dots 進度指示（可點切換卡片） */
.tools-section .dots-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.tools-section .dot {
  width: 8px;
  height: 8px;
  background-color: var(--white);
  border-radius: 50%;
  opacity: 0.3;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: auto;
  cursor: pointer;
}

.tools-section .dot.active {
  opacity: 1;
  transform: scale(1.3);
}

/* RWD */
@media (max-width: 768px) {
  .tools-section {
    --card-width: 280px;
    --card-height: 380px;
  }

  .tools-section .card-content {
    padding: 20px;
  }

  .tools-section .content-text {
    font-size: 1.8rem;
  }

  /* 手機 carousel 改 native scroll-snap：每張卡 swipe 到中央可看到完整內容（桌機保留 click→scale 邏輯） */
  .tools-section .carousel {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .tools-section .carousel::-webkit-scrollbar { display: none; }
  .tools-section .carousel-track {
    padding-inline: calc(50vw - var(--card-width) / 2);
    gap: 24px;
  }
  .tools-section .deconstructed-card {
    scroll-snap-align: center;
  }
}
