.puuhukat-flow {
  width: 100%;
  color: var(--text);
  font-family: var(--bde-body-font-family);
}

.puuhukat-flow *,
.puuhukat-flow *::before,
.puuhukat-flow *::after {
  box-sizing: border-box;
}

.puuhukat-flow [hidden],
.puuhukat-flow-target[hidden] {
  display: none !important;
}


/* =====================================================
   BREAKDANCE FORM
===================================================== */

.puuhukat-flow-target:not(.is-visible) {
  display: none !important;
}


/* =====================================================
   HEADER
===================================================== */

.puuhukat-flow__header {
  margin-bottom: clamp(24px, 4vw, 42px);
}

.puuhukat-flow__title,
.puuhukat-flow__question-title,
.puuhukat-flow__summary-title {
  margin: 0;
  font-family: var(--bde-heading-font-family);
  color: var(--text);
}

.puuhukat-flow__title.h2-heading.bde-heading {
    width: fit-content;
    margin: auto;
}

.puuhukat-flow__intro,
.puuhukat-flow__help {
  color: var(--grey);
}

.puuhukat-flow__intro {
  max-width: 80ch;
  margin: 12px auto 0;
}


/* =====================================================
   PROGRESS
===================================================== */

.puuhukat-flow__progress {
  display: grid;
  gap: 8px;
  margin-bottom: clamp(24px, 4vw, 40px);
}

.puuhukat-flow__progress-text {
  font-size: 14px;
  color: var(--grey);
}

.puuhukat-flow__progress-track {
  width: 100%;
  height: 4px;
  overflow: hidden;
  background: var(--background-light);
  border-radius: var(--s);
}

.puuhukat-flow__progress-bar {
  width: 12%;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 220ms ease;
}


/* =====================================================
   QUESTION
===================================================== */

.puuhukat-flow__question {
  animation: puuhukat-question-in 220ms ease both;
}

.puuhukat-flow__question-title,
.puuhukat-flow__summary-title {
}


.puuhukat-flow__help {
  margin: 8px 0 12px;
  min-height: 1.5em;
  color: var(--grey);
}

.puuhukat-flow__help.is-empty {
  visibility: hidden;
}


/* =====================================================
   CARDS
===================================================== */

/*.puuhukat-flow__cards{
  --columns: 5;
  --gap: 24px;

  display: grid;
  gap: var(--gap);
  margin-top: clamp(12px, 1vw, 22px);
  grid-template-columns: repeat(
    auto-fit,
    calc(
      (100% - (var(--columns) - 1) * var(--gap))
      / var(--columns)
    )
  );

  justify-content: center;
}

@media (max-width: 991px) {
  .your-grid {
    --columns: 3;
  }
}

@media (max-width: 767px) {
  .your-grid {
    --columns: 2;
  }
}
*/
.puuhukat-flow__cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(10px, 1.4vw, 18px);
}

.puuhukat-flow__cards-wrap {
  position: relative;
  width: 100%;
}

.puuhukat-flow__cards-arrow {
  display: none;
}

/* =====================================================
   KARUSELLI MOBILE
===================================================== */

@media (max-width: 767px) {

  .puuhukat-flow__cards-wrap {
    position: relative;

    /* Slider hieman muun sisällön leveyttä leveämmäksi */
    width: 100%;
  }


  .puuhukat-flow__cards {
    --mobile-card-width: 60%;
    --mobile-card-gap: 12px;

    display: flex;
    grid-template-columns: none;

    gap: var(--mobile-card-gap);

    width: 100%;

    margin-top: 22px;

    padding-top: 4px;

    padding-left:
      calc(
        (100% - var(--mobile-card-width)) / 2
      );

    padding-right:
      calc(
        (100% - var(--mobile-card-width)) / 2
      );

    overflow-x: auto;
    overflow-y: visible;

    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;

    overscroll-behavior-x: contain;

    -webkit-overflow-scrolling: touch;

    /* Scrollbar pois näkyvistä. */
    scrollbar-width: none;
  }


  .puuhukat-flow__cards::-webkit-scrollbar {
    display: none;
  }


  .puuhukat-flow__card {
    flex:
      0 0
      var(--mobile-card-width);

    width:
      var(--mobile-card-width);

    scroll-snap-align: center;
    scroll-snap-stop: always;
  }


  .puuhukat-flow__card-inner {
    width: 100%;
    aspect-ratio: 1 / 1;
  }


  /* Keskimmäinen kortti hieman korostettuna. */
  .puuhukat-flow__card.is-centered
  .puuhukat-flow__card-inner {
    transform: translateY(-3px);
  }


  /* Nuolinäppäimet sliderin sivuilla */

  .puuhukat-flow__cards-arrow {
    position: absolute;

    top: 50%;

    z-index: 5;

    display: grid;
    place-items: center;

    width: 38px;
    height: 38px;

    padding: 0;

    color: var(--text);
    background: var(--background-light);

    border:
      1px solid
      color-mix(
        in srgb,
        var(--grey) 40%,
        transparent
      );

    border-radius: 50%;

    font: inherit;
    font-size: 28px;
    line-height: 1;

    cursor: pointer;

    transform: translateY(-20%);
  }


  .puuhukat-flow__cards-arrow--prev {
    left: 4px;
  }


  .puuhukat-flow__cards-arrow--next {
    right: 4px;
  }


  .puuhukat-flow__cards-arrow:disabled {
    opacity: .25;
    pointer-events: none;
  }


  .puuhukat-flow__cards-arrow:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }

}

@media (max-width: 560px) {
  .puuhukat-flow__cards {
    --mobile-card-width: 70%;
  }
}


.puuhukat-flow__card {
  position: relative;
  min-width: 0;
  cursor: pointer;

  animation: puuhukat-card-in 220ms ease both;
  animation-delay: calc(var(--card-index, 0) * 35ms);
}


/* Accessible visually hidden input */

.puuhukat-flow__input {
  position: absolute;

  width: 1px;
  height: 1px;

  margin: -1px;
  padding: 0;

  overflow: hidden;

  clip: rect(0 0 0 0);

  white-space: nowrap;

  border: 0;
}


.puuhukat-flow__card-inner {
  position: relative;

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  gap: 14px;

  width: 100%;
  aspect-ratio: 1 / 1;

  padding: clamp(14px, 2vw, 22px);

  text-align: center;

  background: var(--background-light);

  border: 1px solid
    color-mix(in srgb, var(--grey) 35%, transparent);

  border-radius: var(--s);

  transition:
    transform 200ms ease,
    border-color 200ms ease,
    box-shadow 200ms ease,
    background-color 200ms ease;
}


/* Hover */

.puuhukat-flow__card:hover
.puuhukat-flow__card-inner {
  transform: translateY(-3px);
  border-color: var(--grey);
}


/* Keyboard focus */

.puuhukat-flow__input:focus-visible
+ .puuhukat-flow__card-inner {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}


/* Selected */

.puuhukat-flow__card.selected
.puuhukat-flow__card-inner {
  border-color: var(--accent);

  background:
    color-mix(
      in srgb,
      var(--accent) 9%,
      var(--background-light)
    );

  box-shadow:
    0 10px 28px
    color-mix(
      in srgb,
      var(--background) 45%,
      transparent
    );
}


/* =====================================================
   ICON
===================================================== */

.puuhukat-flow__card-icon {
  display: grid;
  place-items: center;

  width: clamp(80px, 7vw, 100px);

  color: var(--accent);
}

.puuhukat-flow__card-icon svg {
  display: block;
  width: 100%;
  height: auto;
}


/* =====================================================
   CARD TEXT
===================================================== */

.puuhukat-flow__card-label {
  font-size: clamp(13px, 1.15vw, 15px);
  line-height: 1.3;
  font-weight: 600;
}


/* =====================================================
   CHECK ICON
===================================================== */

.puuhukat-flow__check {
  position: absolute;

  top: 10px;
  right: 10px;

  display: grid;
  place-items: center;

  width: 24px;
  height: 24px;

  opacity: 0;

  color: var(--background);
  background: var(--accent);

  border-radius: 50%;

  font-size: 13px;
  font-weight: 700;

  transform: scale(.8);

  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.puuhukat-flow__card.selected
.puuhukat-flow__check {
  opacity: 1;
  transform: scale(1);
}


/* =====================================================
   NAVIGATION
===================================================== */

.puuhukat-flow__nav,
.puuhukat-flow__summary-actions {
  display: flex;
  align-items: center;

  gap: 12px;

  margin-top: clamp(24px, 4vw, 40px);
}


.puuhukat-flow__back,
.puuhukat-flow__next,
.puuhukat-flow__summary-back {
  min-height: 44px;

  padding: 10px 18px;

  font: inherit;
  font-weight: 600;

  border: 1px solid var(--grey);
  border-radius: var(--s);

  cursor: pointer;

  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease;
}


.puuhukat-flow__back,
.puuhukat-flow__summary-back {
  color: var(--text);
  background: transparent;
}


.puuhukat-flow__next {
  margin-left: auto;

  color: var(--text);
  background: var(--accent);

  border-color: var(--accent);
}


.puuhukat-flow__back:hover,
.puuhukat-flow__next:hover,
.puuhukat-flow__summary-back:hover {
  transform: translateY(-2px);
}


.puuhukat-flow__back:focus-visible,
.puuhukat-flow__next:focus-visible,
.puuhukat-flow__summary-back:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}


/* =====================================================
   SUMMARY
===================================================== */

.puuhukat-flow__summary {
  animation: puuhukat-question-in 220ms ease both;
}

.puuhukat-flow__summary-content {
  margin: 12px auto 0 auto;
  max-width: fit-content;
}

.puuhukat-flow__summary-content dl {
  display: grid;
  gap: 0;

  margin: 0;
}


.puuhukat-flow__summary-row {
  display: grid;

  grid-template-columns:
    minmax(180px, 1fr)
    1fr;

  gap: 18px;

  padding: 8px 0;

  border-bottom:
    1px solid
    color-mix(
      in srgb,
      var(--grey) 28%,
      transparent
    );
}


.puuhukat-flow__summary-row dt {
  color: var(--grey);
  font-weight: 500;
  text-align: left;
}

.puuhukat-flow__summary-row dd {
  margin: 0;
  font-weight: 600;
  text-align: left;
}


/* =====================================================
   ANIMATIONS
===================================================== */

@keyframes puuhukat-question-in {

  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }

}


@keyframes puuhukat-card-in {

  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }

}


/* =====================================================
   RESPONSIVE
===================================================== */

@media (max-width: 1100px) {

  .puuhukat-flow__cards {
    grid-template-columns:
      repeat(5, minmax(0, 1fr));
  }

}


@media (max-width: 800px) {

  .puuhukat-flow__cards {
    grid-template-columns:
      repeat(4, minmax(0, 1fr));
  }

}


/*@media (max-width: 560px) {

  .puuhukat-flow__cards {
    grid-template-columns:
      repeat(2, minmax(0, 1fr));
  }


  .puuhukat-flow__summary-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }


  .puuhukat-flow__nav,
  .puuhukat-flow__summary-actions {
    align-items: stretch;
  }


  .puuhukat-flow__back,
  .puuhukat-flow__next,
  .puuhukat-flow__summary-back {
    flex: 1;
  }

}
*/

/* =====================================================
   REDUCED MOTION
===================================================== */

@media (prefers-reduced-motion: reduce) {

  .puuhukat-flow__question,
  .puuhukat-flow__card,
  .puuhukat-flow__summary {
    animation: none;
  }


  .puuhukat-flow__progress-bar,
  .puuhukat-flow__card-inner,
  .puuhukat-flow__check,
  .puuhukat-flow__back,
  .puuhukat-flow__next,
  .puuhukat-flow__summary-back {
    transition: none;
  }

}