/*
 * Hands holding a phone in landscape, with an Orbis IO screen on the phone.
 * A tall rounded card, the hands anchored to its bottom edge, the screen placed BEHIND the hands image,
 * whose phone screen is transparent. hands-phone.js adds the fluid, the scroll zoom and the pointer tilt; without it the card is
 * static.
 *
 * Breakpoints: phone < 480 px, tablet 480-991 px, desktop >= 992 px.
 */

.hp {
  /* Theme. "violet" by default; data-theme="orbis" switches to the orbisio.co.uk navy and orange. */
  --hp-base: linear-gradient(259deg, #886ff8, #8340d4 51.44%, #180047);
  --hp-glow-1: rgba(167, 139, 255, 0.55);
  --hp-glow-2: rgba(106, 7, 228, 0.55);
  --hp-text: #ceced7;
  --hp-radius: 60px;
  /* Desktop: 1820 x 960 (720 px tall at a 1440 px window). Tablet and phone: fixed heights. */
  --hp-height: auto;
  --hp-aspect: 1820 / 960;
  position: relative;
}
.hp[data-theme="orbis"] {
  --hp-base: linear-gradient(259deg, #0a0848, #06043a 51%, #02002a);
  --hp-glow-1: rgba(232, 99, 10, 0.42);
  --hp-glow-2: rgba(120, 110, 255, 0.35);
  --hp-text: #f0eefa;
}
/* data-theme="v3": the v3 site's ink (#0f1319, as the footer) with a hint of its deep green, and Perx
   lime and sky ink (orbisio-site /platform, 2 Nov 2026). */
.hp[data-theme="v3"] {
  --hp-base: linear-gradient(259deg, #1b2a19, #131b16 51%, #0f1319);
  --hp-glow-1: rgba(156, 229, 69, 0.32);
  --hp-glow-2: rgba(185, 226, 255, 0.3);
  --hp-text: #ffffff;
}

/* The card. --hp-radius and the translate are driven by the script on scroll (desktop). */
.hp-card {
  position: relative;
  width: 100%;
  height: var(--hp-height);
  aspect-ratio: var(--hp-aspect);
  border-radius: var(--hp-radius);
  overflow: hidden;
  isolation: isolate;
  background: var(--hp-base);
  perspective: 1500px;
  /* A sideways finger drag stirs the ink; an up-and-down one still scrolls the page. */
  touch-action: pan-y;
  transform: translate3d(0, var(--hp-shift, 0%), 0);
  will-change: transform;
}

/* Fallback background: two slow drifting glows plus one that follows the pointer. */
.hp-glow,
.hp-glow::before,
.hp-glow::after {
  position: absolute;
  inset: -20%;
  pointer-events: none;
}
.hp-glow {
  z-index: 0;
  background: radial-gradient(28% 34% at var(--hp-mx, 50%) var(--hp-my, 35%), var(--hp-glow-1), transparent 70%);
  transition: opacity 0.8s ease;
}
/* The fluid (fluid.js) draws on a transparent canvas over the card's gradient; the CSS glows are only the
   fallback for phones, reduced motion and browsers without WebGL. */
.hp-fluid {
  position: absolute;
  inset: 0;
  z-index: 0;
}
.hp--fluid .hp-glow { opacity: 0; }
.hp-glow::before,
.hp-glow::after {
  content: "";
  inset: 0;
  filter: blur(40px);
  animation: hp-drift 18s ease-in-out infinite alternate;
}
.hp-glow::before { background: radial-gradient(30% 40% at 25% 70%, var(--hp-glow-2), transparent 70%); }
.hp-glow::after { background: radial-gradient(26% 30% at 78% 22%, var(--hp-glow-1), transparent 70%); animation-duration: 23s; animation-direction: alternate-reverse; }
@keyframes hp-drift {
  from { transform: translate3d(-6%, -4%, 0) scale(1); }
  to { transform: translate3d(6%, 5%, 0) scale(1.12); }
}

/* Optional line of copy, shown on tablet and phone only. */
.hp-caption {
  position: absolute;
  z-index: 2;
  top: 40px;
  left: 26px;
  width: 257px;
  margin: 0;
  color: var(--hp-text);
  font-size: 20px;
  line-height: 1.25;
  pointer-events: none;
}

/* Zoom layer (scroll) and tilt layer (pointer). Both are set by the script. */
.hp-scale {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform-style: preserve-3d;
  transform: scale(var(--hp-scale, 1.05));
  will-change: transform;
}
.hp-tilt {
  width: 100%;
  height: 100%;
  transform: translate3d(var(--hp-tx, 0px), var(--hp-ty, 0px), 0) rotateX(var(--hp-rx, 0deg)) rotateY(var(--hp-ry, 0deg));
  will-change: transform;
}

/* The stage measures the card so the frame can fill it: as wide as possible while staying inside it,
   anchored to the bottom edge, nudged down a little when the card is wider than the picture. */
.hp-stage {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  container-type: size;
}
.hp-frame {
  position: relative;
  flex-shrink: 0;
  isolation: isolate;
  width: min(100cqw, calc(100cqh * 2.4694));
  aspect-ratio: 3640 / 1474;
  translate: 0 max(0px, calc((100cqw - 100cqh * 2.4694) * 0.04));
}

/* The picture of the hands: transparent around them and inside the phone's screen. */
.hp-hands {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  user-select: none;
}

/* The screen sits behind the hands, centred on the phone's screen opening (measured on the picture). */
.hp-screen {
  position: absolute;
  z-index: 0;
  top: 37.18%;
  left: 49.45%;
  width: 45.33%;
  aspect-ratio: 825 / 382;
  transform: translate(-50%, -50%);
  border-radius: 8px;
  object-fit: cover;
  object-position: var(--hp-screen-pos, 50% 0%);
  background: #0b0d12;
}

/* A small honest label: the screenshot is demo data. It sits in the screen's top-right corner: the screen
   spans 11.26%-63.10% of the frame's height and 26.79%-72.12% of its width. */
.hp-label {
  position: absolute;
  z-index: 2;
  top: 13.6%;
  right: 29.2%;
  padding: 0.28em 0.7em;
  border-radius: 999px;
  background: rgba(10, 10, 11, 0.72);
  color: #f0eefa;
  font-size: clamp(9px, 0.75cqw, 13px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.02em;
  pointer-events: none;
}

/* Tablet */
@media (max-width: 991px) {
  .hp { --hp-radius: 40px; --hp-height: 885px; --hp-aspect: auto; }
  .hp-caption { top: 50px; left: 50px; width: 475px; font-size: 38px; line-height: 44px; }
  .hp-stage { align-items: center; }
  .hp-frame { scale: 1.55; translate: 0 26%; }
}
/* Phone */
@media (max-width: 479px) {
  .hp { --hp-radius: 30px; --hp-height: 420px; --hp-aspect: auto; }
  .hp-caption { top: 40px; left: 26px; width: 257px; font-size: 20px; line-height: 1.25; }
  .hp-stage { align-items: flex-end; }
  .hp-frame { scale: 1.5; translate: 0 -40%; }
  .hp-label { font-size: 7px; padding: 0.25em 0.6em; } /* the frame is scaled 1.5x here, so this reads as about 10.5 px */
}
@media (min-width: 992px) {
  .hp-caption { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .hp-glow::before, .hp-glow::after { animation: none; }
}
