/* ==========================================================================
   Feature 1 Section: "See Where Your Money Goes"
   Source of truth: design.md Section 2.4, 3.2, 8.4, 8.5, 10
   ========================================================================== */

.feature-section {
  width: 100%;
  background-color: var(--color-background);
  padding: 96px 0 128px;
}

.feature-section--alt {
  padding-top: 0;
}

.feature-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 567px;
  gap: 64px;
  align-items: center;
}

.feature-container--alt {
  grid-template-columns: 567px minmax(0, 1fr);
}

/* ==========================================================================
   Left Column: Heading + Accordion List
   ========================================================================== */

.feature-text-col {
  display: flex;
  flex-direction: column;
}

.feature-heading {
  font-family: var(--font-family-display);
  font-size: clamp(2rem, 1.3rem + 2.8vw, 3rem); /* 32px -> 48px */
  font-weight: var(--font-weight-medium);
  line-height: 1.25; /* 60/48 */
  letter-spacing: var(--tracking-display);
  color: var(--color-text-primary);
  margin-bottom: 48px;
}

.feature-heading .blur-word {
  transition-delay: calc(var(--word-i, 0) * 60ms);
}

.feature-list {
  display: flex;
  flex-direction: column;
}

/* Feature Rows: slide up from bottom when scrolled into view */
.feature-row {
  border-bottom: 1px solid var(--color-border);
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 640ms var(--ease-out),
    transform 640ms var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
  transition-delay: calc(var(--row-i, 0) * 85ms), calc(var(--row-i, 0) * 85ms), 0ms;
}

.feature-list.is-in-view .feature-row {
  opacity: 1;
  transform: translateY(0);
}

.feature-row.is-active {
  border-bottom: 2px solid #7A7CA4;
}

.feature-section--lilac .feature-row.is-active {
  border-bottom-color: #AA8EBB;
}

.feature-section--sky .feature-row.is-active {
  border-bottom-color: #01A5FF;
}

.feature-row-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-family-body);
  font-size: 1.25rem; /* 20px */
  font-weight: var(--font-weight-regular);
  line-height: 1.4;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: color var(--duration-fast) ease;
}

.feature-row-trigger:hover {
  color: var(--color-text-primary);
}

.feature-row-trigger:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.feature-row.is-active .feature-row-trigger {
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  padding-bottom: 10px;
}

.feature-row-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows 280ms var(--ease-out),
    opacity 240ms ease;
}

.feature-row.is-active .feature-row-panel {
  grid-template-rows: 1fr;
  opacity: 1;
}

.feature-row-desc-wrap {
  overflow: hidden;
}

.feature-row-desc {
  padding-bottom: 20px;
  max-width: 400px;
  font-size: 0.875rem; /* 14px */
  font-weight: var(--font-weight-medium);
  line-height: 1.45;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Right Column: Periwinkle Panel, Phone & Graph SVG Overlay
   ========================================================================== */

.feature-panel {
  position: relative;
  width: 100%;
  max-width: 567px;
  height: 636px;
  border-radius: var(--radius-xl); /* 24px */
  background-color: #D0D2FF;
  overflow: hidden;
  /* Smooth inner shadow around the light purple box */
  box-shadow:
    inset 0 0 38px rgba(92, 96, 175, 0.24),
    inset 0 0 0 1px rgba(122, 124, 164, 0.16);
}

.feature-panel--lilac {
  background-color: #EDCFFF;
  /* Smooth inner shadow around the light pink/lilac box */
  box-shadow:
    inset 0 0 38px rgba(154, 108, 186, 0.24),
    inset 0 0 0 1px rgba(170, 142, 187, 0.18);
}

.feature-panel--sky {
  background-color: #B7E6FF;
  /* Smooth inner shadow around the light blue box */
  box-shadow:
    inset 0 0 38px rgba(0, 135, 208, 0.22),
    inset 0 0 0 1px rgba(1, 165, 255, 0.16);
}

/* Phone Mockup: slowly & smoothly moves in from bottom edge of box */
.feature-phone {
  position: absolute;
  left: 50%;
  top: 98px;
  width: 285px;
  transform: translate(-50%, 130px);
  opacity: 0;
  transition:
    transform 1100ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 800ms var(--ease-out);
  z-index: 1;
  filter: drop-shadow(0 18px 40px rgba(40, 44, 100, 0.14));
}

.feature-panel.is-in-view .feature-phone {
  transform: translate(-50%, 0);
  opacity: 1;
}

.feature-phone-img {
  width: 100%;
  height: auto;
  display: block;
}

/* Graph SVG Overlay Card */
.feature-overlay-card {
  position: absolute;
  left: 50%;
  top: 298px;
  width: 358px;
  transform: translate(-52%, 28px);
  opacity: 0;
  border-radius: var(--radius-lg); /* 14px */
  box-shadow: 0 12px 34px rgba(17, 24, 28, 0.12);
  z-index: 2;
  transition:
    transform 950ms cubic-bezier(0.16, 1, 0.3, 1) 220ms,
    opacity 700ms var(--ease-out) 220ms;
}

.feature-panel.is-in-view .feature-overlay-card {
  transform: translate(-52%, 0);
  opacity: 1;
}

.feature-overlay-float {
  width: 100%;
  border-radius: var(--radius-lg);
  animation: feature-card-float 7.5s cubic-bezier(0.37, 0, 0.63, 1) infinite;
}

.feature-overlay-svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
}

/* Gentle Graph Bar Animation inside Feature 1 */
.feature-panel .f1-graph-bar {
  transform-box: fill-box;
  transform-origin: bottom center;
  transform: scaleY(0.12);
  opacity: 0.3;
}

.feature-panel.is-in-view .f1-graph-bar {
  animation:
    graph-bar-grow 850ms cubic-bezier(0.16, 1, 0.3, 1) both,
    graph-bar-breathe 6.8s ease-in-out infinite;
}

.feature-panel.is-in-view .f1-graph-bar--1 { animation-delay: 420ms, 1.6s; }
.feature-panel.is-in-view .f1-graph-bar--2 { animation-delay: 495ms, 1.95s; }
.feature-panel.is-in-view .f1-graph-bar--3 { animation-delay: 570ms, 2.3s; }
.feature-panel.is-in-view .f1-graph-bar--4 { animation-delay: 645ms, 2.65s; }
.feature-panel.is-in-view .f1-graph-bar--5 { animation-delay: 720ms, 3.0s; }
.feature-panel.is-in-view .f1-graph-bar--6 { animation-delay: 795ms, 3.35s; }
.feature-panel.is-in-view .f1-graph-bar--7 { animation-delay: 870ms, 3.7s; }

@keyframes feature-card-float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Gentle Category Bar & Chip Animations inside Feature 2 */
.feature-panel .f2-cat-seg {
  transform-box: fill-box;
  transform-origin: left center;
  transform: scaleX(0.05);
  opacity: 0;
}

.feature-panel.is-in-view .f2-cat-seg {
  animation:
    cat-seg-grow 820ms cubic-bezier(0.16, 1, 0.3, 1) both,
    cat-seg-pulse 6s ease-in-out infinite;
}

.feature-panel.is-in-view .f2-cat-seg--1 { animation-delay: 380ms, 1.6s; }
.feature-panel.is-in-view .f2-cat-seg--2 { animation-delay: 480ms, 2.1s; }
.feature-panel.is-in-view .f2-cat-seg--3 { animation-delay: 580ms, 2.6s; }
.feature-panel.is-in-view .f2-cat-seg--4 { animation-delay: 680ms, 3.1s; }

@keyframes f2-chip-in {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes f2-chip-gentle {
  0%, 100% {
    transform: translateY(0px) scale(1);
  }
  50% {
    transform: translateY(-2.5px) scale(1.015);
  }
}

.feature-panel .f2-chip {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
}

.feature-panel.is-in-view .f2-chip {
  animation:
    f2-chip-in 700ms cubic-bezier(0.16, 1, 0.3, 1) both,
    f2-chip-gentle 5.4s ease-in-out infinite;
}

.feature-panel.is-in-view .f2-chip--1 { animation-delay: 460ms, 1.7s; }
.feature-panel.is-in-view .f2-chip--2 { animation-delay: 560ms, 2.15s; }
.feature-panel.is-in-view .f2-chip--3 { animation-delay: 660ms, 2.6s; }
.feature-panel.is-in-view .f2-chip--4 { animation-delay: 760ms, 3.05s; }

/* Feature 3: Popup Category Sheet & Gentle Chip Animations */
.feature-popup-card {
  position: absolute;
  left: 50%;
  bottom: -44px;
  width: 471px;
  transform: translate(-50%, 42px);
  opacity: 0;
  z-index: 2;
  transition:
    transform 950ms cubic-bezier(0.16, 1, 0.3, 1) 200ms,
    opacity 700ms var(--ease-out) 200ms;
}

.feature-panel.is-in-view .feature-popup-card {
  transform: translate(-50%, 0);
  opacity: 1;
}

.feature-popup-svg {
  width: 100%;
  height: auto;
  display: block;
}

@keyframes f3-chip-stack-up {
  0% {
    opacity: 0;
    transform: translateY(46px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.feature-panel .f3-chip {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
  transform: translateY(46px);
}

.feature-panel.is-in-view .f3-chip {
  animation:
    f3-chip-stack-up 820ms cubic-bezier(0.16, 1, 0.3, 1) both,
    f2-chip-gentle 5.6s ease-in-out infinite;
  animation-delay:
    calc(340ms + var(--chip-i, 0) * 55ms),
    calc(1.9s + var(--chip-i, 0) * 200ms);
}

/* ==========================================================================
   Responsive Breakpoints (per design.md Section 12)
   ========================================================================== */

@media (max-width: 1199px) {
  .feature-container {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 48px;
  }

  .feature-container--alt {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .feature-panel {
    height: 580px;
  }

  .feature-phone {
    width: 255px;
    top: 86px;
  }

  .feature-overlay-card {
    width: 318px;
    top: 268px;
  }

  .feature-popup-card {
    width: 430px;
    bottom: -40px;
  }
}

@media (max-width: 860px) {
  .feature-section {
    padding: 64px 0 88px;
  }

  .feature-container,
  .feature-container--alt {
    grid-template-columns: 1fr;
    gap: 44px;
  }

  .feature-container--alt .feature-text-col {
    order: -1;
  }

  .feature-heading {
    margin-bottom: 32px;
  }

  .feature-panel {
    margin: 0 auto;
    height: 560px;
  }
}

@media (max-width: 599px) {
  .feature-section {
    padding: 48px 0 72px;
  }

  .feature-panel {
    height: 470px;
    border-radius: 20px;
  }

  .feature-phone {
    width: 215px;
    top: 64px;
  }

  .feature-overlay-card {
    width: 270px;
    top: 215px;
    transform: translate(-50%, 28px);
  }

  .feature-panel.is-in-view .feature-overlay-card {
    transform: translate(-50%, 0);
  }

  .feature-popup-card {
    width: 350px;
    bottom: -36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .feature-row,
  .feature-phone,
  .feature-overlay-card,
  .feature-popup-card,
  .feature-panel .f1-graph-bar,
  .feature-panel .f2-cat-seg,
  .feature-panel .f2-chip,
  .feature-panel .f3-chip {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
  }

  .feature-phone,
  .feature-popup-card {
    transform: translate(-50%, 0) !important;
  }

  .feature-overlay-card {
    transform: translate(-52%, 0) !important;
  }

  .feature-overlay-float {
    animation: none !important;
  }
}
