/* ===== Replaces your stack section ===== */

.stack {
  padding-top: 0;
  padding-bottom: 0;
}

.stack .container {
  padding-bottom: 80px;
}

.stack-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 100px 48px 56px;
  text-align: center;
}

.stack-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 9999px;
  background: #E6F4FE;
  border: 1px solid var(--white);
  color: #0588F0;
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  letter-spacing: -0.07px;
  margin-bottom: 16px;
}

.stack-title {
  font-size: 40px;
  font-weight: 500;
  line-height: 48px;
  letter-spacing: -1.2px;
  color: #0A0A0A;
  margin: 0 auto 16px;
  max-width: 560px;
}

.stack-subtitle {
  font-size: 18px;
  font-weight: 400;
  line-height: 26px;
  letter-spacing: -0.18px;
  color: #5A5A5A;
  max-width: 688px;
  margin: 0 auto;
}

/* Grid of six category cards */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  padding: 0 48px;
}

.stack-card {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 0.5px solid var(--border-color);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(10, 10, 10, 0.03), 0 8px 24px rgba(26, 38, 102, 0.04);
  overflow: hidden;
}

/* Illustration: dots, arcs, curved links, four logo badges and a centre pill */
.stack-illus {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 440 / 200;
  margin: 8px 8px 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #FBFCFE 0%, #FFFFFF 100%);
  overflow: hidden;
}

.stack-illus::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(5, 136, 240, 0.22) 1px, transparent 1.4px);
  background-size: 14px 14px;
  -webkit-mask-image: radial-gradient(ellipse 75% 85% at 50% 30%, #000 0%, transparent 78%);
  mask-image: radial-gradient(ellipse 75% 85% at 50% 30%, #000 0%, transparent 78%);
  pointer-events: none;
}

.stack-illus-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.stack-arc {
  fill: none;
  stroke: rgba(5, 136, 240, 0.14);
  stroke-width: 1;
}

.stack-link {
  fill: none;
  stroke: rgba(5, 136, 240, 0.4);
  stroke-width: 1;
  stroke-linecap: round;
}

.stack-badge-circle {
  position: absolute;
  width: 13.4%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 0 0 1px rgba(5, 136, 240, 0.08), 0 0 0 6px rgba(255, 255, 255, 0.75), 0 8px 20px rgba(26, 38, 102, 0.1);
  color: #0588F0;
}

.stack-badge-circle img {
  width: 50%;
  height: 50%;
  object-fit: contain;
  display: block;
}

.stack-badge-circle svg {
  width: 46%;
  height: 46%;
  stroke-width: 2px;
}

.stack-badge-tl { left: 30%; top: 31%; }
.stack-badge-tr { left: 70%; top: 31%; }
.stack-badge-bl { left: 19%; top: 74%; }
.stack-badge-br { left: 81%; top: 74%; }

.stack-illus-pill {
  position: absolute;
  left: 50%;
  top: 75%;
  transform: translate(-50%, -50%);
  padding: 0.55em 1.5em;
  border-radius: 9999px;
  background: linear-gradient(180deg, #5DB7FF 0%, #1E8BF0 100%);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45), 0 8px 20px rgba(5, 136, 240, 0.3);
  color: #FFFFFF;
  font-size: 14px;
  font-size: max(10.5px, 3.7cqw);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.stack-card-copy {
  flex: 1;
  padding: 16px 32px 24px;
}

.stack-card-lead {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 22px;
  letter-spacing: -0.01em;
  color: #0A0A0A;
}

.stack-card-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 32px;
  padding: 18px 0 26px;
  border-top: 1px dashed var(--border-color);
}

.stack-replace {
  display: inline-grid;
  justify-items: start;
  min-height: 40px;
  padding: 0 14px;
  border: 0.5px solid var(--border-color);
  border-radius: 8px;
  background: #FAFAFA;
  box-shadow: inset 2px 2px 2px rgba(255, 255, 255, 0.72);
  font: inherit;
  font-size: 15px;
  line-height: 20px;
  letter-spacing: -0.08px;
  color: #0A0A0A;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.stack-replace:focus-visible {
  outline: 2px solid #0588F0;
  outline-offset: 2px;
}

.stack-replace[aria-disabled="true"] {
  cursor: default;
}

/* Both labels share one grid cell, so the button never changes size between states */
.stack-replace > span {
  grid-area: 1 / 1;
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.stack-replace-icon {
  flex: none;
}

.stack-replace-done {
  opacity: 0;
  visibility: hidden;
}

.stack-card.is-done .stack-replace-idle {
  opacity: 0;
  visibility: hidden;
}

.stack-card.is-done .stack-replace-done {
  opacity: 1;
  visibility: visible;
}

.stack-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Tulvo logo that takes the centre of the illustration once the tools are replaced */
.stack-illus-tulvo {
  position: absolute;
  left: 50%;
  top: 75%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.4cqw 4.6cqw;
  border-radius: 9999px;
  background: var(--white);
  box-shadow: 0 0 0 1px rgba(5, 136, 240, 0.2), 0 0 0 6px rgba(255, 255, 255, 0.85), 0 12px 28px rgba(5, 136, 240, 0.22);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  pointer-events: none;
}

.stack-illus-tulvo img {
  display: block;
  width: auto;
  height: max(18px, 5.4cqw);
}

/* Replaced state: the tools collapse into the centre, the links fade, Tulvo appears */
.stack-card.is-replaced .stack-badge-circle {
  opacity: 0;
  pointer-events: none;
}

.stack-card.is-replaced .stack-badge-circle.stack-badge-tl { transform: translate(-50%, -50%) translate(20cqw, 20cqw) scale(0.4); }
.stack-card.is-replaced .stack-badge-circle.stack-badge-tr { transform: translate(-50%, -50%) translate(-20cqw, 20cqw) scale(0.4); }
.stack-card.is-replaced .stack-badge-circle.stack-badge-bl { transform: translate(-50%, -50%) translate(31cqw, 0.5cqw) scale(0.4); }
.stack-card.is-replaced .stack-badge-circle.stack-badge-br { transform: translate(-50%, -50%) translate(-31cqw, 0.5cqw) scale(0.4); }

.stack-card.is-replaced .stack-link {
  opacity: 0;
  animation: none;
}

.stack-card.is-replaced .stack-illus-pill {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.9);
}

.stack-card.is-replaced .stack-illus-tulvo {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Motion is only added when the visitor has not asked for less; otherwise the state simply switches */
@media (prefers-reduced-motion: no-preference) {
  .stack-card .stack-badge-circle {
    transition: transform 0.56s cubic-bezier(0.55, 0, 0.3, 1), opacity 0.4s ease, box-shadow 0.45s ease;
  }

  .stack-card .stack-link { transition: stroke 0.4s ease, opacity 0.35s ease; }
  .stack-card .stack-illus-pill { transition: transform 0.4s ease, opacity 0.3s ease, box-shadow 0.45s ease; }
  .stack-card .stack-illus-tulvo { transition: transform 0.3s ease, opacity 0.2s ease; }
  .stack-card .stack-replace-idle,
  .stack-card .stack-replace-done { transition: opacity 0.3s ease, visibility 0.3s; }
  .stack-card .stack-replace-icon { transition: transform 0.2s ease; }

  .stack-card.is-replaced .stack-badge-tr { transition-delay: 0.05s; }
  .stack-card.is-replaced .stack-badge-bl { transition-delay: 0.1s; }
  .stack-card.is-replaced .stack-badge-br { transition-delay: 0.15s; }
  .stack-card.is-replaced .stack-illus-pill { transition-delay: 0.15s; }

  .stack-card.is-replaced .stack-illus-tulvo {
    transition: transform 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.2) 0.3s, opacity 0.4s ease 0.3s;
  }

}

@media (hover: hover) {
  .stack-replace:not([aria-disabled="true"]):hover {
    border-color: rgba(5, 136, 240, 0.4);
    background: #F4FAFF;
  }

  .stack-replace-idle .stack-replace-icon { transform: none; }
  .stack-replace:not([aria-disabled="true"]):hover .stack-replace-idle .stack-replace-icon { transform: translateX(3px); }
  .stack-replace:not([aria-disabled="true"]):hover .stack-replace-done .stack-replace-icon { transform: translateX(-2px); }
}

.stack-card-title {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 500;
  line-height: 28px;
  letter-spacing: -0.02em;
  color: #0A0A0A;
}

.stack-card-text {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
  letter-spacing: -0.01em;
  color: #657080;
}

.stack-banner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 80px;
  width: 100%;
  margin-top: 12px;
  padding: 0 120px;
  background: var(--white);
  border-bottom: 0.5px solid var(--border-color);
  box-sizing: border-box;
}

.stack-banner-inner {
  position: relative;
  display: flex;
  flex: 1 0 0;
  min-height: 1px;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-left: 0.5px solid var(--border-color);
  border-right: 0.5px solid var(--border-color);
  box-shadow: inset 2px 2px 2px var(--white);
}

.stack-banner p {
  font-size: 16px;
  font-weight: 500;
  line-height: 24px;
  letter-spacing: -0.16px;
  color: #0A0A0A;
  text-align: center;
}

.stack-banner p span {
  font-weight: 400;
  color: #737373;
}

/* Laptops (1024px and up) keep three columns; the gap and padding tighten so they fit without overflow */
@media (min-width: 1024px) and (max-width: 1279px) {
  .stack-grid {
    gap: 20px;
    padding: 0 32px;
  }

  .stack-card-copy {
    padding: 16px 24px 20px;
  }

  .stack-card-foot {
    margin: 0 24px;
    padding: 16px 0 22px;
  }
}

/* Tablets: two columns */
@media (min-width: 641px) and (max-width: 1023px) {
  .stack-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    padding: 0 32px;
  }
}


@media (max-width: 640px) {
  .stack-intro {
    padding: 64px 24px 40px;
  }

  .stack-grid {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 16px;
  }

  .stack-card-copy {
    padding: 14px 24px 20px;
  }

  .stack-card-foot {
    margin: 0 24px;
    padding: 16px 0 22px;
  }

  .stack-title {
    font-size: var(--section-title-phone);
    line-height: var(--section-title-phone-lh);
    letter-spacing: -0.02em;
  }

  .stack-subtitle {
    font-size: 16px;
  }
}

/* Banner: let the text wrap on narrower screens instead of being squeezed into a thin column */
@media (max-width: 860px) {
  .stack-banner {
    height: auto;
    min-height: 80px;
    padding: 0 24px;
  }

  .stack-banner-inner {
    flex: 1 0 auto;
    height: auto;
    padding: 20px 16px;
  }
}

@media (max-width: 480px) {
  .stack-banner {
    padding: 0 20px;
  }
}

/* Hover: the card lifts, the logo badges drift apart, the links flow towards the pill */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .stack-card {
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease, border-color 0.35s ease;
  }

  .stack-card:hover {
    transform: translateY(-4px);
    border-color: rgba(5, 136, 240, 0.28);
    box-shadow: 0 2px 4px rgba(10, 10, 10, 0.04), 0 18px 40px rgba(5, 136, 240, 0.12);
  }

  .stack-badge-circle {
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.45s ease;
  }

  .stack-card:hover .stack-badge-circle {
    box-shadow: 0 0 0 1px rgba(5, 136, 240, 0.18), 0 0 0 6px rgba(255, 255, 255, 0.85), 0 12px 26px rgba(5, 136, 240, 0.18);
  }

  .stack-card:hover .stack-badge-tl { transform: translate(-50%, -50%) translate(-4px, -5px) scale(1.07); }
  .stack-card:hover .stack-badge-tr { transform: translate(-50%, -50%) translate(4px, -5px) scale(1.07); }
  .stack-card:hover .stack-badge-bl { transform: translate(-50%, -50%) translate(-5px, 2px) scale(1.07); }
  .stack-card:hover .stack-badge-br { transform: translate(-50%, -50%) translate(5px, 2px) scale(1.07); }

  .stack-illus-pill {
    transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.45s ease;
  }

  .stack-card:hover .stack-illus-pill {
    transform: translate(-50%, -50%) scale(1.06);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.45), 0 10px 26px rgba(5, 136, 240, 0.42);
  }

  .stack-arc,
  .stack-link {
    transition: stroke 0.4s ease;
  }

  .stack-card:hover .stack-arc {
    stroke: rgba(5, 136, 240, 0.26);
  }

  .stack-card:hover .stack-link {
    stroke: rgba(5, 136, 240, 0.75);
    stroke-dasharray: 3 5;
    animation: stackFlow 0.9s linear infinite;
  }
}

@keyframes stackFlow {
  to { stroke-dashoffset: -16; }
}
