/* Hero K (template-parts/home/hero-k.php): a changing line above
   "Egy KAPOCS." and the KAPOCS Órarend data flow, drawn as fine threads on a
   canvas (assets/js/home/hero-k.js). Light-teal brand, no glow, no glass. */
.khk {
  overflow: hidden;
  background: linear-gradient(180deg, #fff 0%, #f1f8f8 100%);
}

.khk__inner {
  display: grid;
  grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr);
  gap: clamp(32px, 4vw, 64px);
  align-items: center;
  width: min(1200px, calc(100% - 48px));
  margin-inline: auto;
  padding: clamp(56px, 6vw, 88px) 0 clamp(20px, 2.4vw, 32px);
}

/* Headline: one changing line, then "Egy KAPOCS." */
.khk__title {
  margin: 0;
  color: var(--ks-ink);
  font: 700 clamp(42px, 4.3vw, 64px)/1.02 var(--ks-display);
  letter-spacing: -.045em;
}

.khk__roll {
  display: inline-grid;
  max-width: 100%;
  margin: -.14em 0;
  padding: .14em 0;
  overflow: hidden;
  vertical-align: top;
  white-space: nowrap;
}

.khk__word {
  grid-area: 1 / 1;
}

.khk__ch {
  display: inline-block;
  white-space: pre;
}

.khk-js .khk__word.is-in .khk__ch {
  animation: khk-in .6s cubic-bezier(.16, 1, .3, 1) both;
  animation-delay: calc(260ms + var(--i) * 22ms);
}

.khk-js .khk__word.is-out .khk__ch {
  animation: khk-out .26s cubic-bezier(.55, 0, .8, .2) both;
  animation-delay: calc(var(--i) * 8ms);
}

@keyframes khk-in {
  from {
    opacity: 0;
    transform: translateY(.62em);
  }
}

@keyframes khk-out {
  to {
    opacity: 0;
    transform: translateY(-.5em);
  }
}

.khk__accent {
  display: block;
  color: var(--ks-teal);
  white-space: nowrap;
}

.khk__lead {
  max-width: 520px;
  margin: 26px 0 0;
  color: var(--ks-copy);
  font-size: 18px;
  line-height: 1.65;
}

.khk__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

/* The data flow, on a 680×460 plan; text scales with the box. */
.khk__flow {
  position: relative;
  aspect-ratio: 680 / 460;
  container-type: inline-size;
}

.khk__lines,
.khk__threads {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.khk__lines {
  overflow: visible;
}

.khk__line {
  fill: none;
  stroke: var(--ks-teal);
  stroke-opacity: .34;
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

/* The canvas takes over from the plain drawing once it runs. */
.khk__threads {
  pointer-events: none;
}

.khk__flow.is-live .khk__lines {
  visibility: hidden;
}

.khk__nodes {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 29.41%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.khk__nodes--in {
  left: 0;
}

.khk__nodes--out {
  right: 0;
}

.khk__node {
  position: absolute;
  top: var(--y);
  right: 0;
  left: 0;
  transform: translateY(-50%);
}

.khk__node-btn {
  display: flex;
  align-items: center;
  gap: 1.8cqi;
  width: 100%;
  margin: 0;
  padding: 1.7cqi 2cqi;
  border: 1px solid rgba(13, 43, 56, .1);
  border-radius: 2.2cqi;
  color: inherit;
  background: #fff;
  box-shadow: 0 1px 2px rgba(13, 43, 56, .05), 0 10px 24px -16px rgba(13, 43, 56, .3);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .35s ease, box-shadow .35s ease, transform .45s cubic-bezier(.16, 1, .3, 1);
}

.khk__node-btn:hover {
  border-color: rgba(23, 142, 139, .35);
}

.khk__node-btn:focus-visible {
  outline: 3px solid rgba(23, 142, 139, .35);
  outline-offset: 2px;
}

.khk__node.is-active .khk__node-btn {
  border-color: rgba(23, 142, 139, .55);
  box-shadow: 0 1px 2px rgba(13, 43, 56, .05), 0 14px 30px -16px rgba(23, 142, 139, .55);
  transform: translateY(-2px);
}

.khk__icon {
  display: grid;
  flex: 0 0 5cqi;
  place-items: center;
  width: 5cqi;
  height: 5cqi;
  border-radius: 1.5cqi;
  color: var(--ks-teal-dark);
  background: var(--ks-mint);
  transition: color .35s ease, background-color .35s ease;
}

.khk__node.is-active .khk__icon {
  color: #fff;
  background: var(--ks-teal);
}

.khk__icon svg {
  width: 2.7cqi;
  height: 2.7cqi;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.khk__node-copy {
  display: grid;
  min-width: 0;
  gap: .3cqi;
}

.khk__node-copy b {
  color: var(--ks-ink);
  font-size: 2.1cqi;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.khk__node-copy small {
  overflow: hidden;
  color: var(--ks-copy);
  font-size: 1.8cqi;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.khk__node.is-active .khk__node-copy small {
  color: var(--ks-teal-dark);
  font-weight: 600;
}

.khk__core {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 14.12cqi;
  aspect-ratio: 1;
  border: 1px solid rgba(23, 142, 139, .2);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 12px 30px -14px rgba(13, 43, 56, .3);
  transform: translate(-50%, -50%);
}

/* The mark is its two halves: on a "click" they open a hair and snap shut. */
.khk__mark {
  position: relative;
  width: 58%;
  aspect-ratio: 846 / 832;
}

.khk__core .khk__half {
  position: absolute;
  top: 0;
  width: auto;
  max-width: none;
  height: 100%;
}

.khk__half--l {
  left: 0;
}

.khk__half--r {
  right: 0;
}

/* The mark "clicks" when the threads arrive. */
.khk__core::after {
  position: absolute;
  inset: -1px;
  border: 1.5px solid var(--ks-teal);
  border-radius: 50%;
  opacity: 0;
  content: "";
}

.khk__core.is-click .khk__half--l {
  animation: khk-snap-l .58s cubic-bezier(.3, 1.5, .5, 1);
}

.khk__core.is-click .khk__half--r {
  animation: khk-snap-r .58s cubic-bezier(.3, 1.5, .5, 1);
}

.khk__core.is-click::after {
  animation: khk-ring .9s cubic-bezier(.16, 1, .3, 1);
}

@keyframes khk-snap-l {
  35% {
    transform: translateX(-9%);
  }
}

@keyframes khk-snap-r {
  35% {
    transform: translateX(9%);
  }
}

@keyframes khk-ring {
  from {
    opacity: .55;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(1.38);
  }
}

/* Tablet: text above, the flow below. */
@media (max-width: 1080px) {
  .khk__inner {
    grid-template-columns: minmax(0, 1fr);
  }

  .khk__copy {
    max-width: 640px;
  }

  .khk__flow {
    width: min(100%, 720px);
    margin-inline: auto;
  }
}

/* Phones: the same flow, top to bottom. */
@media (max-width: 620px) {
  .khk__inner {
    width: calc(100% - 32px);
    padding: 44px 0 56px;
  }

  .khk__title {
    font-size: clamp(38px, 11vw, 50px);
  }

  .khk__lead {
    font-size: 16.5px;
  }

  .khk__flow {
    display: grid;
    gap: 36px;
    aspect-ratio: auto;
    container-type: normal;
  }

  .khk__lines {
    display: none;
  }

  .khk__nodes {
    position: relative;
    display: grid;
    gap: 8px;
    width: auto;
  }

  .khk__nodes--in {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .khk__nodes--out {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .khk__node {
    position: static;
    transform: none;
  }

  .khk__node-btn {
    flex-direction: column;
    gap: 8px;
    height: 100%;
    padding: 12px 8px;
    border-radius: 12px;
    text-align: center;
  }

  .khk__icon {
    flex-basis: auto;
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .khk__icon svg {
    width: 18px;
    height: 18px;
  }

  .khk__node-copy {
    gap: 2px;
  }

  .khk__node-copy b {
    font-size: 13px;
    white-space: normal;
  }

  .khk__node-copy small {
    font-size: 11.5px;
    white-space: normal;
  }

  .khk__core {
    position: relative;
    top: auto;
    left: auto;
    justify-self: center;
    width: 76px;
    transform: none;
  }
}

/* The seam: a hairline fading at both ends, ruler ticks around the middle,
   the KAPOCS clasp on it, and a thread down to the next chapter's label. */
.khk-seam {
  position: relative;
  z-index: 2;
  height: 0;
}

.khk-seam__line {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(23, 142, 139, .3) 22%, rgba(23, 142, 139, .3) 78%, transparent);
}

.khk-seam__ticks {
  position: absolute;
  top: -4px;
  left: 50%;
  width: 560px;
  max-width: 76vw;
  height: 9px;
  background:
    repeating-linear-gradient(90deg, rgba(23, 142, 139, .5) 0 1px, transparent 1px 70px) center / 100% 9px no-repeat,
    repeating-linear-gradient(90deg, rgba(23, 142, 139, .3) 0 1px, transparent 1px 14px) center / 100% 5px no-repeat;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 32%, #000 68%, transparent);
  transform: translateX(-50%);
}

.khk-seam__node {
  position: absolute;
  top: 0;
  left: 50%;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(23, 142, 139, .3);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 6px #fff, 0 8px 22px -10px rgba(13, 43, 56, .35);
  transform: translate(-50%, -50%);
}

.khk-seam__mark {
  position: relative;
  width: 20px;
  aspect-ratio: 846 / 832;
}

.khk-seam .khk-seam__half {
  position: absolute;
  top: 0;
  width: auto;
  max-width: none;
  height: 100%;
}

.khk-seam__half--l {
  left: 0;
}

.khk-seam__half--r {
  right: 0;
}

.khk-seam__thread {
  position: absolute;
  top: 24px;
  left: 50%;
  width: 1px;
  height: clamp(20px, 2.6vw, 34px);
  background: linear-gradient(rgba(23, 142, 139, .45), rgba(23, 142, 139, 0));
  transform: translateX(-50%);
}

/* Once, as it scrolls in: the line draws out from the middle, the clasp
   closes, the thread runs down (hero-k.js adds .is-armed and .is-in). */
.khk-seam.is-armed .khk-seam__line {
  transform: scaleX(0);
}

.khk-seam.is-armed .khk-seam__ticks,
.khk-seam.is-armed .khk-seam__node {
  opacity: 0;
}

.khk-seam.is-armed .khk-seam__node {
  transform: translate(-50%, -50%) scale(.7);
}

.khk-seam.is-armed .khk-seam__thread {
  transform: translateX(-50%) scaleY(0);
  transform-origin: 50% 0;
}

.khk-seam.is-in .khk-seam__line {
  transform: none;
  transition: transform 1.1s cubic-bezier(.65, 0, .35, 1);
}

.khk-seam.is-in .khk-seam__ticks {
  opacity: 1;
  transition: opacity .9s ease .5s;
}

.khk-seam.is-in .khk-seam__node {
  opacity: 1;
  transform: translate(-50%, -50%);
  transition: opacity .5s ease .35s, transform .7s cubic-bezier(.16, 1, .3, 1) .35s;
}

.khk-seam.is-in .khk-seam__half--l {
  animation: khk-snap-l .6s cubic-bezier(.3, 1.5, .5, 1) .9s;
}

.khk-seam.is-in .khk-seam__half--r {
  animation: khk-snap-r .6s cubic-bezier(.3, 1.5, .5, 1) .9s;
}

.khk-seam.is-in .khk-seam__thread {
  transform: translateX(-50%);
  transition: transform .7s cubic-bezier(.16, 1, .3, 1) 1.1s;
}

@media (prefers-reduced-motion: reduce) {
  .khk__node-btn,
  .khk__icon {
    transition: none;
  }

  .khk__core.is-click .khk__half,
  .khk__core.is-click::after {
    animation: none;
  }
}
