/* =========================================================
   Landing Animation Component
   ---------------------------------------------------------
   A reusable full-screen intro: a minimalist SVG character
   walks in from the left, then the headline fades in.

   QUICK EDIT MAP (variables below):
     --landing-walk-duration : how long the walk takes
     --landing-step-duration : length of one arm/leg swing
     --landing-step-count    : number of swings (walk/step)
     --landing-char-size     : character width
     --landing-char-color    : silhouette color
     --landing-bg-1 / --bg-2 : gradient background colors

   Matches walk/step math: walk = step × count.
   Default: 3s = 0.6s × 5  (character ends in neutral pose)
   ========================================================= */

.landing {
  /* ---- Timing & sizing (edit freely) ---- */
  --landing-walk-duration: 3s;
  --landing-step-duration: 0.6s;
  --landing-step-count: 5;
  --landing-char-size: clamp(120px, 18vw, 180px);
  --landing-char-color: var(--color-primary, #4f46e5);
  --landing-leave-duration: 0.6s;

  /* ---- Layout ---- */
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  overflow: hidden;

  /* Soft two-tone gradient that respects the site's theme.
     Swap to a plain color if preferred. */
  background:
    radial-gradient(ellipse at 18% 30%,
      color-mix(in srgb, var(--color-primary, #4f46e5) 14%, transparent) 0%,
      transparent 55%),
    radial-gradient(ellipse at 82% 72%,
      color-mix(in srgb, var(--color-secondary, #f59e0b) 10%, transparent) 0%,
      transparent 55%),
    var(--color-bg, #fafaf7);

  transition:
    opacity var(--landing-leave-duration) ease-out,
    visibility var(--landing-leave-duration) ease-out;
}

/* State applied just before the overlay is removed */
.landing--leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}


/* ---------------------------------------------------------
   SKIP BUTTON
   --------------------------------------------------------- */
.landing__skip {
  position: absolute;
  top: clamp(1rem, 3vh, 2rem);
  right: clamp(1rem, 3vh, 2rem);
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  background: color-mix(in srgb, var(--color-bg, #fff) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 999px;
  color: var(--color-text, #18181b);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  z-index: 2;
  transition: all 0.2s ease;
  animation: landing-skip-in 0.35s ease-out both;
}
.landing__skip:hover,
.landing__skip:focus-visible {
  background: var(--color-primary, #4f46e5);
  color: #fff;
  border-color: var(--color-primary, #4f46e5);
  transform: translateY(-1px);
}
.landing__skip kbd {
  font: inherit;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: color-mix(in srgb, currentColor 14%, transparent);
  line-height: 1;
}

@keyframes landing-skip-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ---------------------------------------------------------
   STAGE  (walker + copy, flex-laid-out)
   --------------------------------------------------------- */
.landing__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 5vw, 3rem);
  max-width: 900px;
  width: 100%;
}

.landing__character { flex-shrink: 0; }
.landing__copy      { flex-shrink: 1; min-width: 0; max-width: 28rem; }

@media (max-width: 640px) {
  .landing__stage {
    flex-direction: column;
    text-align: center;
    gap: 1.25rem;
  }
}


/* ---------------------------------------------------------
   WALKING CHARACTER (SVG)
   Each limb is a <g> rotated around its joint (shoulder/hip).
   The whole figure translates horizontally.
   The body group bobs vertically. Shadow pulses.
   --------------------------------------------------------- */
.walker {
  width: var(--landing-char-size);
  height: auto;
  display: block;
  color: var(--landing-char-color);
  /* Horizontal walk-in: from off-screen left to natural flex position */
  animation: walker-walk-in var(--landing-walk-duration)
             cubic-bezier(0.4, 0, 0.2, 1) forwards;
  will-change: transform;
}

@keyframes walker-walk-in {
  from { transform: translateX(-60vw); }
  to   { transform: translateX(0); }
}

/* Figure pieces inherit color */
.walker__head                 { fill: currentColor; }
.walker__torso,
.walker__limb line            { stroke: currentColor; stroke-linecap: round; fill: none; }
.walker__torso                { stroke-width: 7; }
.walker__limb line            { stroke-width: 6; }
.walker__limb ellipse         { fill: currentColor; }
.walker__shadow               { fill: rgba(0, 0, 0, 0.14); }
html[data-theme="dark"] .walker__shadow { fill: rgba(0, 0, 0, 0.45); }

/* Body bob: double frequency of the leg swing (2 bounces per step) */
.walker__body {
  animation: walker-bob
             calc(var(--landing-step-duration) / 2)
             ease-in-out
             calc(var(--landing-step-count) * 2)
             forwards;
}
@keyframes walker-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* Shadow pulses opposite the bob (flatter when figure lifts) */
.walker__shadow {
  transform-box: fill-box;
  transform-origin: center;
  animation: walker-shadow
             calc(var(--landing-step-duration) / 2)
             ease-in-out
             calc(var(--landing-step-count) * 2)
             forwards;
}
@keyframes walker-shadow {
  0%, 100% { transform: scaleX(1);    opacity: 0.32; }
  50%      { transform: scaleX(0.88); opacity: 0.22; }
}

/* Limb swing — phase A (forward at 25%, back at 75%) */
.walker__limb--a {
  animation: walker-swing-a var(--landing-step-duration)
             ease-in-out var(--landing-step-count) forwards;
}
/* Phase B is the mirror (back at 25%, forward at 75%) */
.walker__limb--b {
  animation: walker-swing-b var(--landing-step-duration)
             ease-in-out var(--landing-step-count) forwards;
}
@keyframes walker-swing-a {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(24deg); }
  75%      { transform: rotate(-24deg); }
}
@keyframes walker-swing-b {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-24deg); }
  75%      { transform: rotate(24deg); }
}


/* ---------------------------------------------------------
   COPY (name + tagline) — fades in mid-walk
   --------------------------------------------------------- */
.landing__copy {
  opacity: 0;
  transform: translateY(14px);
  animation: landing-copy-in 0.9s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  /* Start fading in ~55% through the walk, so content
     "meets" the character as it arrives at center. */
  animation-delay: calc(var(--landing-walk-duration) * 0.55);
}

@keyframes landing-copy-in {
  to { opacity: 1; transform: translateY(0); }
}

.landing__eyebrow {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-primary, #4f46e5);
  margin: 0 0 0.6rem;
}

.landing__title {
  font-family: var(--font-heading, inherit);
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 0.65rem;
  color: var(--color-text, #18181b);
}
.landing__title .landing__name {
  color: var(--color-primary, #4f46e5);
}

.landing__sub {
  font-size: clamp(0.98rem, 1.5vw, 1.1rem);
  color: var(--color-text-muted, #52525b);
  margin: 0;
  max-width: 26rem;
}


/* ---------------------------------------------------------
   ACCESSIBILITY — prefers-reduced-motion
   Replace the whole walk with a calm fade-in.
   --------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .walker,
  .walker__body,
  .walker__shadow,
  .walker__limb--a,
  .walker__limb--b {
    animation: none !important;
    transform: none !important;
  }

  .landing__copy,
  .landing__skip {
    animation: landing-simple-fade 0.5s ease-out both;
  }

  .walker {
    animation: landing-simple-fade 0.6s ease-out both;
  }

  @keyframes landing-simple-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

/* JS also adds this class as a belt-and-braces fallback */
.landing--reduced .walker,
.landing--reduced .landing__copy {
  animation: landing-simple-fade 0.5s ease-out both;
}
