/* Home: Featured Work — full-width "cards opening" slider. Heading reuses the Services heading styles. */
.kok-featured-work {
  padding: 110px 0 0;
  color: #fff;
  font-family: var(--site-font-family, "Gilroy", Helvetica, Arial, sans-serif);
}

/* Services already has generous top padding; tighten it after this section */
.kok-featured-work + .kok-home-services {
  padding-top: 120px;
}

.kfw {
  position: relative;
  height: clamp(560px, 82vh, 820px);
  overflow: hidden;
  background: #0b0b0b;
  isolation: isolate;
}

.kfw__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.kfw__layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.kfw__layer img,
.kfw__layer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kfw__layer--opening {
  inset: auto;
  z-index: 2;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transition: left 0.9s cubic-bezier(0.7, 0, 0.2, 1), top 0.9s cubic-bezier(0.7, 0, 0.2, 1),
    width 0.9s cubic-bezier(0.7, 0, 0.2, 1), height 0.9s cubic-bezier(0.7, 0, 0.2, 1),
    border-radius 0.9s ease, opacity 0.9s ease;
}

.kfw__shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.45) 38%, rgba(0, 0, 0, 0.1) 70%),
    linear-gradient(0deg, rgba(0, 0, 0, 0.55) 0%, rgba(0, 0, 0, 0) 35%);
}

.kfw__inner {
  position: relative;
  z-index: 3;
  height: 100%;
  width: min(100%, 1320px);
  margin: 0 auto;
  padding: 0 15px;
}

.kfw__content {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: min(44%, 560px);
  transition: opacity 0.35s ease, transform 0.5s ease;
}

.kfw__content.is-leaving {
  opacity: 0;
  transform: translateY(calc(-50% + 18px));
}

.kfw__rule {
  display: block;
  width: 28px;
  height: 2px;
  margin-bottom: 18px;
  background: #fff;
}

.kfw__meta {
  margin: 0 0 14px;
  font-size: 15px;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.85);
}

.kfw__title {
  margin: 0 0 18px;
  color: #fff;
  font-size: clamp(34px, 3.8vw, 64px);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kfw__desc {
  margin: 0 0 26px;
  max-width: 440px;
  font-size: 15px;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.78);
}

.kfw__btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 6px 22px 6px 6px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.kfw__btn:hover,
.kfw__btn:focus-visible {
  background: rgba(255, 255, 255, 0.12);
  border-color: #fff;
  color: #fff;
}

.kfw__btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #fff;
}

.kfw__btn-icon img {
  width: 14px;
  height: 14px;
}

/* Cards row: bleeds off the right edge like the reference */
.kfw__cards {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 18px;
  width: max-content;
  transition: opacity 0.3s ease;
}

.kfw__cards.is-leaving .kfw__card:not([style*="hidden"]) {
  opacity: 0.35;
}

.kfw__card {
  position: relative;
  width: clamp(150px, 13vw, 210px);
  aspect-ratio: 2 / 3;
  padding: 0;
  border: 0;
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  cursor: pointer;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  animation: kfw-card-in 0.6s cubic-bezier(0.22, 0.7, 0.2, 1) both;
  animation-delay: var(--d, 0ms);
  transition: transform 0.35s ease, opacity 0.3s ease;
}

.kfw__card:hover,
.kfw__card:focus-visible {
  transform: translateY(-6px);
  outline: none;
}

.kfw__card:focus-visible {
  box-shadow: 0 0 0 2px #fff, 0 18px 40px rgba(0, 0, 0, 0.45);
}

.kfw__card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.kfw__card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0) 55%);
}

.kfw__card-label {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  color: #fff;
}

.kfw__card-meta {
  font-size: 10px;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kfw__card-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.05;
  text-transform: uppercase;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@keyframes kfw-card-in {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: none; }
}

.kfw__nav {
  position: absolute;
  left: 50%;
  right: 15px;
  bottom: 40px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.kfw__arrow {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.kfw__arrow:hover,
.kfw__arrow:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: #fff;
  outline: none;
}

.kfw__arrow svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kfw__progress {
  flex: 1 1 auto;
  height: 2px;
  margin: 0 10px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.kfw__progress-fill {
  display: block;
  height: 100%;
  width: 0;
  background: #fff;
}

.kfw__progress-fill.is-running {
  animation: kfw-progress 3s linear forwards;
}

.kfw.is-paused .kfw__progress-fill {
  animation-play-state: paused;
}

@keyframes kfw-progress {
  from { width: 0; }
  to { width: 100%; }
}

.kfw__num {
  font-size: clamp(36px, 3.4vw, 54px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* Without the script: no cards/nav, just the first project */
.kfw:not(.is-ready) .kfw__cards,
.kfw:not(.is-ready) .kfw__nav {
  display: none;
}

@media screen and (max-width: 991px) {
  .kfw__content { width: 52%; }
  .kfw__cards { left: 58%; }
  .kfw__nav { left: 15px; }
}

@media screen and (max-width: 767px) {
  .kok-featured-work { padding-top: 64px; }
  .kok-featured-work + .kok-home-services { padding-top: 72px; }

  /* phones: stack text, cards and controls in one column so nothing can overlap */
  .kfw { height: auto; }

  .kfw__shade {
    background: linear-gradient(0deg, rgba(0, 0, 0, 0.88) 0%, rgba(0, 0, 0, 0.6) 55%, rgba(0, 0, 0, 0.2) 100%);
  }

  .kfw__inner {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 22px;
    height: auto;
    min-height: 660px;
    padding: 110px 16px 24px;
  }

  .kfw__content,
  .kfw__cards,
  .kfw__nav {
    position: static;
    transform: none;
  }

  .kfw__content { width: auto; }
  .kfw__content.is-leaving { transform: translateY(12px); }

  .kfw__rule { margin-bottom: 14px; }
  .kfw__meta { margin-bottom: 10px; font-size: 13px; }

  .kfw__title {
    margin-bottom: 12px;
    font-size: clamp(28px, 8.5vw, 36px);
    line-height: 1.02;
    -webkit-line-clamp: 3;
  }

  .kfw__desc {
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .kfw__desc[hidden] { display: none; }

  /* cards run off the right edge, like the desktop row */
  .kfw__cards {
    width: auto;
    margin-right: -16px;
    gap: 10px;
    overflow: hidden;
  }

  .kfw__card { flex: 0 0 auto; width: 104px; border-radius: 12px; }
  .kfw__card-label { left: 10px; right: 10px; bottom: 10px; }
  .kfw__card-meta { display: none; }
  .kfw__card-title { font-size: 12px; line-height: 1.1; }

  .kfw__nav { gap: 10px; }
  .kfw__arrow { width: 44px; height: 44px; }
  .kfw__progress { margin: 0 6px; }
  .kfw__num { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .kfw__card { animation: none; }
  .kfw__layer--opening,
  .kfw__content,
  .kfw__card { transition: none; }
}

/* ---------- Animation ---------- */
/* First scroll into view: the section opens from a rounded inset and the picture settles */
.kfw.is-ready {
  clip-path: inset(6% 4% round 28px);
  transition: clip-path 1.2s cubic-bezier(0.65, 0, 0.2, 1);
}

.kfw.is-ready.is-in { clip-path: inset(0 round 0); }

.kfw.is-ready:not(.is-in) .kfw__nav { opacity: 0; transform: translateY(20px); }
.kfw__nav { transition: opacity 0.6s ease 0.7s, transform 0.6s ease 0.7s; }

/* cards wait off to the side until the section is in view, then slide in one after another */
.kfw:not(.is-in) .kfw__card { animation-play-state: paused; }
.kfw.is-in .kfw__card { animation-delay: calc(var(--d, 0ms) + 0.35s); }

/* slow zoom on the current background */
.kfw__layer img,
.kfw__layer video {
  animation: kfw-zoom 9s ease-out both;
}

@keyframes kfw-zoom {
  from { transform: scale(1.14); }
  to { transform: scale(1); }
}

/* title words rise out of a mask, one after another */
.kfw__w {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.06em;
}

.kfw__w > span { display: inline-block; }

.kfw:not(.is-in) .kfw__w > span,
.kfw:not(.is-in) .kfw__rule,
.kfw:not(.is-in) .kfw__meta,
.kfw:not(.is-in) .kfw__desc,
.kfw:not(.is-in) .kfw__btn { opacity: 0; }

.kfw.is-in .kfw__content.is-entering .kfw__w > span {
  animation: kfw-word 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: calc(0.15s + var(--w, 0) * 0.06s);
}

@keyframes kfw-word {
  from { transform: translateY(105%); }
  to { transform: none; }
}

.kfw.is-in .kfw__content.is-entering .kfw__rule {
  transform-origin: left;
  animation: kfw-rule 0.7s cubic-bezier(0.65, 0, 0.2, 1) both;
}

@keyframes kfw-rule {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.kfw.is-in .kfw__content.is-entering .kfw__meta { animation: kfw-up 0.6s ease both 0.05s; }
.kfw.is-in .kfw__content.is-entering .kfw__desc { animation: kfw-up 0.7s ease both 0.45s; }
.kfw.is-in .kfw__content.is-entering .kfw__btn { animation: kfw-up 0.7s ease both 0.6s; }

@keyframes kfw-up {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

/* number rolls up */
.kfw__num { display: inline-block; overflow: hidden; }
.kfw.is-in .kfw__num.is-entering { animation: kfw-num 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both; }

@keyframes kfw-num {
  from { opacity: 0; transform: translateY(60%); }
  to { opacity: 1; transform: none; }
}

/* button arrow nudges on hover */
.kfw__btn-icon { transition: transform 0.3s ease; }
.kfw__btn:hover .kfw__btn-icon { transform: rotate(45deg); }

@media (prefers-reduced-motion: reduce) {
  .kfw.is-ready { clip-path: none; transition: none; }
  .kfw__layer img,
  .kfw__layer video,
  .kfw .kfw__w > span,
  .kfw .kfw__rule,
  .kfw .kfw__meta,
  .kfw .kfw__desc,
  .kfw .kfw__btn,
  .kfw .kfw__num { animation: none !important; opacity: 1 !important; }
  .kfw__nav { transition: none; }
}

/* "contain" slides (e.g. packaging): whole image visible, blurred copy fills the sides */
.kfw__fit {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.kfw__layer .kfw__fit img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.kfw__layer .kfw__fit-fill {
  object-fit: cover;
  filter: blur(28px) brightness(0.75);
  transform: scale(1.15);
  animation: none;
}

.kfw__layer .kfw__fit-main {
  object-fit: contain;
  animation: none;
}
