/* Custom hero: background, two characters, and a mouse-following spotlight for the
   hero -> Codecyon AI transition. Scroll/mouse values are set by hero-characters.js. */

/* keep the page content (title box, menu, lines) above our layer */
.main-wrapper { position: relative; z-index: 6; }

.hc-layer {
  --hc-w: min(36vw, 640px);
  --hc-gap: 180px;             /* half the title box width: fingers point at its edges */
  --hc-meet-y: 46vh;           /* height of the pointing fingers */
  --hc-p: 0;                   /* characters leaving 0..1 */
  --hc-l: 0;                   /* spotlight strength 0..1 */
  --hc-q: 0;                   /* whole layer fading out (Codecyon AI takes over) 0..1 */
  --hc-d: 0;                   /* desk image sliding in 0..1 */
  --hc-do: 0;                  /* desk image sliding out 0..1 */
  --hc-mx: 0;                  /* mouse -1..1 (parallax) */
  --hc-my: 0;
  --hc-lx: 50%;                /* spotlight centre inside the background box */
  --hc-ly: 50%;
  --hc-lr: 300px;              /* spotlight radius */
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
  opacity: calc(1 - var(--hc-q));
}

/* background scene: plain + lit copies share one transform so they stay aligned */
.hc-scene {
  position: absolute;
  inset: -3%;
  translate: calc(var(--hc-mx) * 8px) calc(var(--hc-my) * 6px);
  animation: hc-drift 30s ease-in-out infinite alternate;
}
.hc-bg, .hc-lit {
  position: absolute;
  inset: 0;
  background: #0b1a2e url("/assets/custom/hero-bg.webp?v=2") center / cover no-repeat;
}
.hc-bg::after { /* hero darkening + vignette so the title box text stays readable */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 42% 55% at 50% 50%, rgba(0, 0, 0, .3), transparent 70%),
    linear-gradient(to bottom, rgba(0, 0, 0, .4), transparent 18%, transparent 80%, rgba(0, 0, 0, .5)),
    rgba(0, 0, 0, .5); /* overall darkening */
}
/* extra darkness outside the spotlight while it is on */
.hc-shade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: calc(var(--hc-l) * .45);
}
/* the lit copy: full brightness, visible only inside the spotlight */
.hc-lit {
  filter: brightness(1.12) saturate(1.1);
  opacity: var(--hc-l);
  -webkit-mask-image: radial-gradient(circle var(--hc-lr) at var(--hc-lx) var(--hc-ly), #000 0%, #000 45%, rgba(0, 0, 0, .55) 70%, transparent 100%);
          mask-image: radial-gradient(circle var(--hc-lr) at var(--hc-lx) var(--hc-ly), #000 0%, #000 45%, rgba(0, 0, 0, .55) 70%, transparent 100%);
}
/* soft white glow at the centre of the light */
.hc-glow {
  position: absolute;
  inset: 0;
  opacity: var(--hc-l);
  mix-blend-mode: screen;
  background: radial-gradient(circle calc(var(--hc-lr) * .9) at var(--hc-lx) var(--hc-ly),
    rgba(255, 255, 255, .22) 0%, rgba(255, 244, 225, .1) 35%, transparent 75%);
}
@keyframes hc-drift { from { scale: 1; } to { scale: 1.06; } }

/* right-side desk scene in the spotlight section: slides in from the right, then away */
.hc-desk { /* --hc-d (in) and --hc-do (out) come from .hc-layer */
  position: absolute;
  right: 0;
  bottom: 0;
  width: min(54vw, 1000px);
  max-height: 86vh;
  object-fit: contain;
  object-position: right bottom;
  opacity: calc(var(--hc-d) * (1 - var(--hc-do)));
  translate:
    calc((1 - var(--hc-d)) * 18vw + var(--hc-do) * 22vw + var(--hc-mx) * -6px)
    calc(var(--hc-my) * -4px);
  filter: drop-shadow(0 20px 50px rgba(0, 0, 0, .5));
}

/* characters: fade and fly apart as you scroll out of the hero */
.hc-chars { position: absolute; inset: 0; opacity: calc(1 - var(--hc-p) * 1.15); }
.hc-char {
  position: absolute;
  left: 50%;
  top: var(--hc-meet-y);
  width: var(--hc-w);
  height: auto;
  will-change: transform;
  filter: drop-shadow(0 24px 40px rgba(0, 0, 0, .35));
  opacity: 0;
}
.hc-layer.is-in .hc-char { opacity: 1; }

/* left figure: fingertip sits at its right edge, ~47% down */
.hc-left {
  translate:
    calc(-100% - var(--hc-gap) - var(--hc-p) * 30vw + var(--hc-mx) * -10px)
    calc(-47% + var(--hc-p) * 10vh + var(--hc-my) * -8px);
  animation: hc-float-a 7s ease-in-out infinite;
}
/* right figure: fingertip sits at its left edge, ~31% down */
.hc-right {
  translate:
    calc(var(--hc-gap) + var(--hc-p) * 30vw + var(--hc-mx) * 10px)
    calc(-31% + var(--hc-p) * 10vh + var(--hc-my) * 8px);
  animation: hc-float-b 8s ease-in-out infinite;
}
.hc-layer:not(.is-in) .hc-left  { translate: calc(-100% - var(--hc-gap) - 8vw) -47%; }
.hc-layer:not(.is-in) .hc-right { translate: calc(var(--hc-gap) + 8vw) -31%; }
.hc-layer .hc-char { transition: opacity 1.2s ease-out, translate 1.4s cubic-bezier(.2, .8, .2, 1); }
.hc-layer.is-live .hc-char { transition: opacity 1.2s ease-out; }

@keyframes hc-float-a { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-14px) rotate(-1deg); } }
@keyframes hc-float-b { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(12px) rotate(1deg); } }

@media (max-width: 1023px) {
  .hc-layer { --hc-w: 40vw; --hc-gap: 150px; }
}
@media (max-width: 767px) {
  /* phones: the title box fills the top, so the pair sits in the space below it */
  .hc-layer { --hc-w: 47vw; --hc-gap: 2px; --hc-meet-y: 84vh; }
  .hc-desk { width: 100vw; max-height: 55vh; }
}
@media (max-width: 767px) and (orientation: portrait) {
  /* the hero box is shorter on phones (lite.css): the pair meets just below it */
  .hc-layer { --hc-meet-y: max(64vh, calc(108px + min(340px, 100vw - 24px) * .941 + 31.5vw)); }
}
@media (prefers-reduced-motion: reduce) {
  .hc-char, .hc-scene { animation: none; }
}


/* ---------- Codecyon AI intro figure (custom/sidekick-figure.js) ---------- */
.sk-layer {
  --sk-in: 0; --sk-out: 0; --sk-y: 0; --sk-scroll: 0px;
  position: fixed;
  inset: 0;
  z-index: 0;                  /* placed just before the 3D canvas container (see sidekick-figure.js),
                                  so the stars and the torn-paper wipe pass over the figure */
  pointer-events: none;
  overflow: hidden;
  opacity: calc(var(--sk-in) * (1 - var(--sk-out)));
}
/* character + laptop: the whole image stays in view, sitting on the bottom-right */
.sk-figure {
  position: absolute;
  right: 4vw;
  bottom: 0;
  height: min(92vh, 1100px);
  width: auto;
  max-width: none;
  translate: 0 calc(3vh - var(--sk-y) * 5vh - var(--sk-scroll));
  filter: drop-shadow(0 0 60px rgba(0, 0, 0, .6));
  /* soften the image's flat bottom edge (laptop base and sleeve) */
  -webkit-mask-image: linear-gradient(to bottom, #000 95%, transparent);
          mask-image: linear-gradient(to bottom, #000 95%, transparent);
}
@media (max-width: 767px) {
  .sk-figure { right: -8vw; height: 70vh; }
}

/* "Want to hire a tech devil?": between the hero and "Who we are", on the left (the desk slides in on the right) */
.hc-pitch {
  position: absolute; left: clamp(20px, 21vw, 340px); top: 36%; max-width: min(44vw, 640px);
  color: #f7f7ee; opacity: var(--hc-t, 0); transform: translateY(calc((1 - var(--hc-t, 0)) * 28px));
  text-shadow: 0 2px 24px rgba(0, 0, 0, .55); pointer-events: none;
}
.hc-pitch h2 {
  margin: 0 0 18px; font-family: NeueMontreal, Helvetica, Arial, sans-serif; font-weight: 700;
  font-size: clamp(36px, 5.2vw, 84px); line-height: .95; letter-spacing: -.04em;
}
.hc-pitch h2 em { font-family: HWCigars, Georgia, "Times New Roman", serif; font-weight: 400; font-style: italic; letter-spacing: -.02em; }
.hc-pitch p { margin: 0; font-family: HWCigars, Georgia, "Times New Roman", serif; font-size: clamp(20px, 2vw, 32px); line-height: 1.15; }
@media (max-width: 767px) {
  .hc-pitch { left: 20px; right: 20px; top: 30%; max-width: none; }
}
