/* =========================================================
   Home page - motion & finish polish
   Loaded only by index.php, after main.css. Every rule is scoped to
   body.page-home, so no other page is affected.

   Approach: longer, gentler ease-out curves; shorter travel distances;
   no rotation on hover; reveals play once (see data-reveal-once in main.js).
   Reveal motion uses the individual `translate` / `scale` properties so it
   never fights the `transform` used by hover states.
   ========================================================= */

.page-home {
  --ease-soft: cubic-bezier(0.22, 1, 0.36, 1);        /* calm ease-out */
  --ease-in-out-soft: cubic-bezier(0.65, 0, 0.35, 1); /* for slides that travel */
  --dur-quick: 180ms;
  --dur-base: 420ms;
  --dur-slow: 950ms;

  --home-shadow-rest: 0 1px 2px rgba(23, 16, 46, 0.04), 0 6px 16px -10px rgba(23, 16, 46, 0.12);
  --home-shadow-hover: 0 22px 44px -22px rgba(37, 99, 235, 0.30), 0 8px 18px -10px rgba(23, 16, 46, 0.10);
  --home-shadow-dark-hover: 0 24px 48px -26px rgba(0, 0, 0, 0.7);
}

/* ---------- Scroll reveal ---------- */
.js .page-home [data-reveal] {
  opacity: 0;
  transform: none;               /* main.css offsets with transform; we use translate */
  translate: 0 18px;
  transition-property: opacity, translate, scale, transform, box-shadow, border-color, background-color;
  transition-duration: var(--dur-slow), var(--dur-slow), var(--dur-slow), var(--dur-base), var(--dur-base), var(--dur-base), var(--dur-base);
  transition-timing-function: var(--ease-soft);
  /* Stagger only the entrance; hover properties respond immediately */
  transition-delay: var(--reveal-delay, 0ms), var(--reveal-delay, 0ms), var(--reveal-delay, 0ms), 0ms, 0ms, 0ms, 0ms;
}
.js .page-home [data-reveal].is-visible { opacity: 1; translate: none; scale: none; }

.page-home .grid > [data-reveal]:nth-child(2) { --reveal-delay: 90ms; }
.page-home .grid > [data-reveal]:nth-child(3) { --reveal-delay: 180ms; }
.page-home .grid > [data-reveal]:nth-child(n+4) { --reveal-delay: 240ms; }

/* Module logos: a softer rise + settle, rippling across each row */
.js .page-home .showcase-grid [data-reveal] { translate: 0 14px; scale: 0.97; }
.js .page-home .showcase-grid [data-reveal].is-visible { translate: none; scale: none; }
.page-home .showcase-item:nth-child(6n+2) { --reveal-delay: 60ms; }
.page-home .showcase-item:nth-child(6n+3) { --reveal-delay: 120ms; }
.page-home .showcase-item:nth-child(6n+4) { --reveal-delay: 180ms; }
.page-home .showcase-item:nth-child(6n+5) { --reveal-delay: 240ms; }
.page-home .showcase-item:nth-child(6n+6) { --reveal-delay: 300ms; }

/* Testimonial slides 2+ fade in with the slide itself, not on scroll */
.js .page-home .testimonial-slide:not(:first-child) [data-reveal] { opacity: 1; translate: none; }

/* ---------- Hero entrance ----------
   CSS-only and starting on first paint (as in main.css), but staggered line
   by line. Starts at 0.01 opacity so the H1 still counts as painted for LCP. */
.js .page-home .hero [data-reveal] { animation: none; opacity: 1; translate: none; }
.js .page-home .hero-grid > :first-child > * { animation: homeHeroRise 1000ms var(--ease-soft) both; }
.js .page-home .hero-grid > :first-child > :nth-child(2) { animation-delay: 70ms; }
.js .page-home .hero-grid > :first-child > :nth-child(3) { animation-delay: 140ms; }
.js .page-home .hero-grid > :first-child > :nth-child(4) { animation-delay: 210ms; }
.js .page-home .hero-grid > :first-child > :nth-child(5) { animation-delay: 280ms; }
.js .page-home .hero .hero-visual { animation: homeHeroVisual 1100ms var(--ease-soft) 180ms both; }

@keyframes homeHeroRise {
  from { opacity: 0.01; translate: 0 16px; }
  to   { opacity: 1; translate: none; }
}
@keyframes homeHeroVisual {
  from { opacity: 0.01; translate: 0 22px; scale: 0.985; }
  to   { opacity: 1; translate: none; scale: none; }
}

/* Slower background drift on the mesh sections */
.page-home .section-mesh::before { animation-duration: 32s; }

/* ==========================================================
   Hero product panel - glass card, segmented tabs, linked tiles
   (markup + switching script in index.php)
   ========================================================== */
.page-home .hero-card {
  position: relative;
  padding: clamp(1.15rem, 2.4vw, 1.9rem);
  border-radius: 24px;
  border-color: rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.065) 0%, rgba(255, 255, 255, 0.022) 100%);
  box-shadow: 0 40px 80px -40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
/* Thin brand-coloured highlight along the top edge */
.page-home .hero-card::before {
  content: ""; position: absolute; top: -1px; left: 12%; right: 12%; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.55), rgba(167, 139, 250, 0.65), transparent);
}

/* ---------- Segmented tabs with a sliding highlight ---------- */
.page-home .hero-tabs {
  position: relative; display: inline-flex; gap: 2px; padding: 4px; max-width: 100%;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.page-home .hero-tabs-thumb {
  position: absolute; top: 4px; bottom: 4px; left: 0; width: 0;
  border-radius: var(--radius-pill); background: var(--grad-primary);
  box-shadow: 0 8px 20px -8px rgba(124, 58, 237, 0.7), 0 2px 8px -2px rgba(249, 115, 22, 0.45);
  opacity: 0; pointer-events: none;
}
.page-home .hero-tabs.has-thumb .hero-tabs-thumb { opacity: 1; }
.page-home .hero-tabs.is-animated .hero-tabs-thumb {
  transition: transform 480ms var(--ease-soft), width 480ms var(--ease-soft);
}
.page-home .hero-tab {
  position: relative; z-index: 1; appearance: none; -webkit-appearance: none;
  border: 0; background: transparent; cursor: pointer; white-space: nowrap;
  padding: 0.5rem 1.05rem; border-radius: var(--radius-pill);
  font-size: 0.875rem; font-weight: 600; line-height: 1.2;
  color: rgba(247, 245, 255, 0.66);
  transition: color var(--dur-base) var(--ease-soft);
}
.page-home .hero-tab:hover, .page-home .hero-tab.is-active { color: #fff; }
.page-home .hero-tab:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* Without JS (no sliding thumb) the selected tab carries the gradient itself */
.page-home .hero-tabs:not(.has-thumb) .hero-tab.is-active { background: var(--grad-primary); }

/* ---------- Panel stage ----------
   Brief fade-out, then the height eases to fit the next panel
   (the script drives is-leaving / is-resizing / has-switched). */
.page-home .hero-panels {
  --tile-base: 380ms; /* first load: wait for the card's entrance */
  transition: opacity var(--dur-quick) ease, translate var(--dur-quick) ease, height 520ms var(--ease-soft);
}
.page-home .hero-panels.has-switched { --tile-base: 0ms; }
.page-home .hero-panels.is-leaving { opacity: 0; translate: 0 -4px; }
.page-home .hero-panels.is-resizing { overflow: hidden; }

.page-home .hero-panel-caption {
  margin: 1rem 0 1.1rem; font-size: 0.875rem; line-height: 1.5;
  color: var(--color-text-inverse-muted);
}
.page-home .hero-tiles {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 0.75rem;
}

/* ---------- Tiles ---------- */
.page-home .hero-tile {
  --tile-rgb: 249 115 22; --tile-fg: #fdba74; --tile-grad: var(--grad-primary);
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr;
  grid-template-areas: "icon arrow" "body body";
  row-gap: 1rem; min-height: 128px; padding: 1rem;
  border-radius: 16px; border: 1px solid rgba(255, 255, 255, 0.08);
  background-color: rgba(255, 255, 255, 0);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.055) 0%, rgba(255, 255, 255, 0.018) 100%);
  color: var(--color-text-inverse); text-decoration: none;
  transition-property: transform, background-color, border-color, box-shadow;
  transition-duration: var(--dur-base);
  transition-timing-function: var(--ease-soft);
}
/* Accent per column: orange, blue, violet */
.page-home .hero-tile:nth-child(3n+2) { --tile-rgb: 96 165 250; --tile-fg: #93c5fd; --tile-grad: var(--grad-cool); }
.page-home .hero-tile:nth-child(3n+3) { --tile-rgb: 167 139 250; --tile-fg: #c4b5fd; --tile-grad: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%); }

/* Pointer-following glow (position set by the script) */
.page-home .hero-tile::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), rgb(var(--tile-rgb) / 0.17), transparent 65%);
  opacity: 0; transition: opacity var(--dur-base) var(--ease-soft);
}
/* Gradient hairline border that fades in on hover */
.page-home .hero-tile::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgb(var(--tile-rgb) / 0.75), rgba(124, 58, 237, 0.45) 55%, rgba(255, 255, 255, 0.08));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity var(--dur-base) var(--ease-soft);
}

.page-home .hero-tile-icon {
  grid-area: icon; position: relative; isolation: isolate;
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  color: var(--tile-fg);
  background: rgb(var(--tile-rgb) / 0.13);
  box-shadow: inset 0 0 0 1px rgb(var(--tile-rgb) / 0.28);
  transition: color var(--dur-base) var(--ease-soft), box-shadow var(--dur-base) var(--ease-soft);
}
/* Gradient fill that fades in on hover (gradients can't transition directly) */
.page-home .hero-tile-icon::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit;
  background: var(--tile-grad); opacity: 0;
  transition: opacity var(--dur-base) var(--ease-soft);
}
.page-home .hero-tile-icon svg { width: 20px; height: 20px; }

.page-home .hero-tile-body { grid-area: body; align-self: end; min-width: 0; }
.page-home .hero-tile-label {
  display: block; font-family: var(--font-heading); font-weight: 700;
  font-size: 0.9rem; line-height: 1.3; letter-spacing: -0.005em; color: #fff;
}
.page-home .hero-tile-desc {
  display: block; margin-top: 0.3rem; font-size: 0.84rem; line-height: 1.5;
  color: var(--color-text-inverse-muted);
}
.page-home .hero-tile-arrow {
  grid-area: arrow; width: 16px; height: 16px; justify-self: end;
  color: rgba(255, 255, 255, 0.3);
  transition: transform var(--dur-base) var(--ease-soft), color var(--dur-base) ease;
}

.page-home .hero-tile:hover,
.page-home .hero-tile:focus-visible { background-color: rgba(255, 255, 255, 0.04); border-color: transparent; }
.page-home .hero-tile:hover::after,
.page-home .hero-tile:focus-visible::after { opacity: 1; }
.page-home .hero-tile:hover .hero-tile-icon,
.page-home .hero-tile:focus-visible .hero-tile-icon { color: #fff; box-shadow: 0 8px 20px -8px rgb(var(--tile-rgb) / 0.75); }
.page-home .hero-tile:hover .hero-tile-icon::before,
.page-home .hero-tile:focus-visible .hero-tile-icon::before { opacity: 1; }
.page-home .hero-tile:hover .hero-tile-arrow,
.page-home .hero-tile:focus-visible .hero-tile-arrow { color: #fff; transform: translate(2px, -2px); }
.page-home .hero-tile:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
@media (hover: hover) {
  .page-home .hero-tile:hover { transform: translate3d(0, -2px, 0); box-shadow: 0 18px 36px -20px rgba(0, 0, 0, 0.7); }
  .page-home .hero-tile:hover::before { opacity: 1; }
}

/* Single-product tab: one wide tile with a description */
.page-home .hero-tile.is-feature {
  grid-column: 1 / -1; min-height: 0; padding: 1.25rem;
  grid-template-columns: auto minmax(0, 1fr) auto; grid-template-rows: auto;
  grid-template-areas: "icon body arrow"; align-items: center; column-gap: 1rem;
}
.page-home .hero-tile.is-feature .hero-tile-icon { width: 48px; height: 48px; border-radius: 14px; }
.page-home .hero-tile.is-feature .hero-tile-icon svg { width: 22px; height: 22px; }
.page-home .hero-tile.is-feature .hero-tile-body { align-self: center; }
.page-home .hero-tile.is-feature .hero-tile-label { font-size: 1rem; }

/* Entrance: caption, then tiles cascade - after the card on first load,
   immediately when switching tabs (a panel restarts its animations when shown) */
.page-home .hero-panel-caption,
.page-home .hero-tile { animation: homeTileIn 640ms var(--ease-soft) both; animation-delay: var(--tile-base); }
.page-home .hero-tile:nth-child(1) { animation-delay: calc(var(--tile-base) + 40ms); }
.page-home .hero-tile:nth-child(2) { animation-delay: calc(var(--tile-base) + 85ms); }
.page-home .hero-tile:nth-child(3) { animation-delay: calc(var(--tile-base) + 130ms); }
.page-home .hero-tile:nth-child(4) { animation-delay: calc(var(--tile-base) + 175ms); }
.page-home .hero-tile:nth-child(5) { animation-delay: calc(var(--tile-base) + 220ms); }
.page-home .hero-tile:nth-child(n+6) { animation-delay: calc(var(--tile-base) + 265ms); }
@keyframes homeTileIn {
  from { opacity: 0; translate: 0 8px; }
  to   { opacity: 1; translate: none; }
}

@media (max-width: 560px) {
  .page-home .hero-tabs { display: flex; width: 100%; }
  .page-home .hero-tab { flex: 1 1 0; padding-inline: 0.5rem; }
  .page-home .hero-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .page-home .hero-tile { min-height: 116px; padding: 0.9rem; }
  /* The wide tile stacks like the others on phones */
  .page-home .hero-tile.is-feature {
    grid-template-columns: 1fr auto; grid-template-rows: auto 1fr;
    grid-template-areas: "icon arrow" "body body"; align-items: stretch; row-gap: 1rem;
  }
  .page-home .hero-tile.is-feature .hero-tile-arrow { align-self: start; }
}

/* ---------- Cards ---------- */
.page-home .card {
  transition-property: transform, box-shadow, border-color, background-color;
  transition-duration: var(--dur-base);
  transition-timing-function: var(--ease-soft);
}
.page-home .card::before { transition: transform 700ms var(--ease-soft); }
.page-home .icon-tile { transition: transform var(--dur-base) var(--ease-soft); }

/* Hover lift only where hover is real, so taps on touch screens don't leave cards raised */
@media (hover: hover) {
  /* The second selector outweighs main.css's `.js [data-reveal].is-visible`
     transform, which otherwise cancels the lift on revealed cards. */
  .page-home .card:hover,
  .js .page-home .card[data-reveal].is-visible:hover { transform: translate3d(0, -4px, 0); }
  .page-home .card:hover { box-shadow: var(--home-shadow-hover); }
  .page-home .card-dark:hover { box-shadow: var(--home-shadow-dark-hover); background-color: rgba(255, 255, 255, 0.06); border-color: rgba(167, 139, 250, 0.35); }
  .page-home .card:hover .icon-tile { transform: translateY(-2px) scale(1.04); }
}

/* ---------- Buttons ---------- */
.page-home .btn {
  transition-property: transform, box-shadow, background-color, color, border-color;
  transition-duration: var(--dur-base);
  transition-timing-function: var(--ease-soft);
}
.page-home .btn:active { transform: translateY(0) scale(0.98); transition-duration: 120ms; }
.page-home .btn-primary::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transition: transform 1100ms var(--ease-soft);
}
/* On dark sections the default blue hover text is hard to read; brighten instead */
.page-home .section-dark .btn-outline:hover { border-color: rgba(255, 255, 255, 0.6); color: #fff; background-color: rgba(255, 255, 255, 0.06); }

/* ---------- Module showcase ---------- */
.page-home .showcase-icon {
  box-shadow: var(--home-shadow-rest);
  transition-duration: 600ms;
  transition-timing-function: var(--ease-soft);
}
.page-home .showcase-icon img { transition: transform 600ms var(--ease-soft); }
.page-home .showcase-icon::after {
  background: linear-gradient(115deg, transparent 40%, rgba(255, 255, 255, 0.4) 50%, transparent 60%);
  transition: transform 1000ms var(--ease-soft);
}
.page-home .showcase-item:hover .showcase-icon,
.page-home .showcase-item:focus-visible .showcase-icon {
  transform: translate3d(0, -6px, 0) scale(1.04);
  box-shadow: 0 18px 32px -16px rgba(37, 99, 235, 0.38), 0 4px 10px -4px rgba(23, 16, 46, 0.10);
}
.page-home .showcase-item:hover .showcase-icon img,
.page-home .showcase-item:focus-visible .showcase-icon img { transform: scale(1.03); }
.page-home .showcase-item span { transition: color var(--dur-base) ease, transform var(--dur-base) var(--ease-soft); }

/* ---------- Testimonials carousel ---------- */
/* Slide + cross-fade: only the current slide is visible, so wrapping from the
   last slide back to the first doesn't sweep through the middle one */
.page-home .testimonial-slides { transition: transform 900ms var(--ease-in-out-soft); }
.page-home .testimonial-slide { transition: opacity 700ms var(--ease-in-out-soft); }
.page-home .testimonial-slide:not(.is-active) { opacity: 0; }

.page-home .testimonial-card .quote-mark {
  display: inline-block;
  background: var(--grad-primary); -webkit-background-clip: text; background-clip: text; color: transparent;
  opacity: 0.85;
}

/* Active dot stretches into a pill instead of scaling */
.page-home .carousel-dots button {
  border-radius: var(--radius-pill);
  transition: width var(--dur-base) var(--ease-soft), background-color var(--dur-base) ease;
}
.page-home .section-dark .carousel-dots button { background-color: rgba(255, 255, 255, 0.22); }
.page-home .section-dark .carousel-dots button:hover { background-color: rgba(255, 255, 255, 0.4); }
.page-home .carousel-dots button.active { width: 26px; transform: none; background: var(--grad-primary); }

.page-home .carousel-arrow { transition: background-color var(--dur-base) ease, border-color var(--dur-base) ease, transform var(--dur-base) var(--ease-soft); }
.page-home .carousel-arrow:hover { border-color: rgba(255, 255, 255, 0.35); transform: translateY(-1px); }

/* ---------- Reduced motion ----------
   main.css already zeroes durations; also drop delays and offsets so
   nothing waits or shifts before appearing. */
@media (prefers-reduced-motion: reduce) {
  .page-home *, .page-home *::before, .page-home *::after { animation-delay: 0ms !important; transition-delay: 0ms !important; }
  .js .page-home [data-reveal] { opacity: 1 !important; translate: none !important; scale: none !important; }
}
