/* KERO: the suit loads onto the photo, bottom to top, with a blue scan edge */
.kf-stage { perspective: 1400px; position: relative; }

.kf-flip {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* keep the hero name/date label above the suit layers */
.kf-flip > div:last-child { z-index: 30; }

/* dark surface that comes in with the suit, so the figure sits on the site's own dark */
.kf-flip::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 19;
  background: linear-gradient(180deg, rgba(6,8,15,.94) 0%, rgba(6,8,15,.985) 100%);
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1.15s cubic-bezier(.45,.05,.25,1);
  pointer-events: none;
}

/* the suited cut-out */
.kf-flip::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 20;
  background: url("/media/kero-suit.webp") center top / cover no-repeat;
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1.15s cubic-bezier(.45,.05,.25,1);
  pointer-events: none;
}

.kf-flip.kf-on::before,
.kf-flip.kf-on::after { clip-path: inset(0 0 0 0); }

/* the automatic load reads slower and smoother than a hover */
.kf-stage.kf-auto .kf-flip::before,
.kf-stage.kf-auto .kf-flip::after { transition-duration: 1.5s; }

/* the blue scan line riding the reveal edge */
.kf-stage::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  z-index: 40;
  background: linear-gradient(90deg, rgba(56,189,248,0) 0%, rgba(125,211,252,.95) 50%, rgba(56,189,248,0) 100%);
  box-shadow: 0 0 14px 4px rgba(56,189,248,.5), 0 0 44px 16px rgba(56,189,248,.2);
  opacity: 0;
  pointer-events: none;
}

.kf-stage.kf-loading::before {
  animation: kf-scan 1.15s cubic-bezier(.45,.05,.25,1) forwards;
}
.kf-stage.kf-auto.kf-loading::before {
  animation-duration: 1.5s;
}

/* 3D lean while the suit loads */
.kf-flip.kf-on { animation: kf-tilt 1.15s cubic-bezier(.4,0,.2,1); }
.kf-stage.kf-auto .kf-flip.kf-on { animation-duration: 1.5s; }

/* --- spider web that spins itself across the card during the automatic load --- */
.kf-web {
  position: absolute;
  inset: 0;
  z-index: 22;
  pointer-events: none;
  opacity: 0;
  overflow: visible;
}
.kf-web path {
  fill: none;
  stroke: rgba(125,211,252,.5);
  stroke-width: 1.1px;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
}
.kf-web .kf-spoke { stroke: rgba(186,230,253,.8); stroke-width: 1.3px; }
.kf-web .kf-ring-edge { stroke: rgba(248,113,113,.55); }

.kf-web-run { animation: kf-web-fade 1.5s ease-out forwards; }
.kf-web-run path { animation: kf-draw .5s cubic-bezier(.2,.8,.2,1) forwards; }

@keyframes kf-draw { to { stroke-dashoffset: 0; } }
@keyframes kf-web-fade {
  0%   { opacity: 0; }
  8%   { opacity: 1; }
  74%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes kf-scan {
  0%   { bottom: 0; opacity: 0; }
  12%  { opacity: 1; }
  82%  { opacity: 1; }
  100% { bottom: calc(100% - 2px); opacity: 0; }
}

@keyframes kf-tilt {
  0%   { transform: perspective(1000px) rotateY(0deg) translateZ(0); }
  35%  { transform: perspective(1000px) rotateY(-7deg) translateZ(18px); }
  70%  { transform: perspective(1000px) rotateY(3deg) translateZ(8px); }
  100% { transform: perspective(1000px) rotateY(0deg) translateZ(0); }
}

@media (prefers-reduced-motion: reduce) {
  .kf-flip::before, .kf-flip::after { transition: none; }
  .kf-flip.kf-on { animation: none; }
  .kf-stage.kf-loading::before { animation: none; opacity: 0; }
  .kf-web, .kf-web-run { display: none; }
}

/* the name reads as one unit: Arabic first, Latin after it, never colliding */
.kf-name {
  display: inline-flex;
  align-items: baseline;
  gap: .34em;
  direction: rtl;
  unicode-bidi: isolate;
  vertical-align: baseline;
  white-space: nowrap;
}
.kf-name bdi { unicode-bidi: isolate; }

.kf-name .kf-dash { opacity: .55; font-weight: 400; }

/* the facts-row value: plain inline flow, isolated, Arabic then dash then Latin */
.kf-name-row {
  display: inline-block;
  flex: 0 0 auto;
  unicode-bidi: isolate;
  white-space: nowrap;
}
.kf-name-row bdi { unicode-bidi: isolate; }
