/* ======================================================
   COMPANIES SECTION — "TRUSTED BY"
   AAA / cyberpunk HUD treatment of the clients section.
====================================================== */

.trustedby {
  position: relative;
  isolation: isolate;
  width: 100%;
  padding: clamp(2.4rem, 4vw, 3.75rem) clamp(1rem, 3vw, 2.5rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
}

@media (min-width: 769px) {
  .trustedby {
    height: 100svh;
    min-height: 0;
    padding: clamp(0.65rem, 1.5vw, 1.15rem) clamp(1rem, 3vw, 2.5rem);
  }
}

.trustedby::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(rgb(var(--theme-bg-deep-rgb) / 0.28), rgb(var(--theme-bg-deep-rgb) / 0.4)),
    url("/Assets/Companies-Projects-logos/trustedby-background.webp") center /
      cover no-repeat;
  opacity: 0;
  transform: scale(1.035);
  filter: brightness(0.55) saturate(0.7);
  transition:
    opacity 0.85s cubic-bezier(0.2, 0, 0.2, 1),
    transform 1.15s cubic-bezier(0.2, 0, 0.2, 1),
    filter 1.15s cubic-bezier(0.2, 0, 0.2, 1);
}

.trustedby.reveal::before {
  opacity: 1;
  transform: scale(1);
  filter: brightness(1) saturate(1);
}

/* ======================================================
   DECORATIVE BACKGROUND LAYERS
====================================================== */
.trustedby__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* Halftone dot fields (top corners) — removed (flat dark bg). */
.trustedby__halftone {
  display: none;
}

/* Diagonal paint-slash light streaks — removed (flat dark bg). */
.trustedby__slash {
  display: none;
}

/* Faint scanline overlay across the whole section */
.trustedby__scanlines {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgb(var(--theme-text-rgb) / 0.018) 0px,
    rgb(var(--theme-text-rgb) / 0.018) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.6;
}

/* ======================================================
   HUD BARS (top + bottom)
====================================================== */
.trustedby__hud {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-formular-mono);
  font-size: clamp(0.5rem, 0.78vw, 0.66rem);
  letter-spacing: 0.18em;
  color: rgb(var(--theme-text-rgb) / 0.62);
  text-transform: uppercase;
}

.trustedby__hud--top {
  display: none;
  margin-bottom: clamp(1rem, 3vh, 2.25rem);
}

.trustedby__hud-cluster {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
}

.trustedby__hud-cluster--right {
  text-align: right;
  flex-direction: column;
  align-items: flex-end;
}

.trustedby__hud-stack {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.trustedby__hud-title {
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.24em;
}

.trustedby__hud-sub {
  line-height: 1.5;
  letter-spacing: 0.2em;
}

.trustedby__hud-sub--right {
  color: rgb(var(--theme-text-rgb) / 0.82);
}

.trustedby__sigil {
  color: var(--purple-light);
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  line-height: 1;
  filter: drop-shadow(0 0 8px rgb(var(--theme-primary-rgb) / 0.6));
}

.trustedby__plus-row {
  letter-spacing: 0.3em;
  color: rgb(var(--theme-text-rgb) / 0.5);
}

/* Barcode strip */
.trustedby__barcode {
  display: block;
  width: clamp(6rem, 10vw, 9rem);
  height: 0.85rem;
  margin-top: 0.15rem;
  background: repeating-linear-gradient(
    90deg,
    var(--text) 0 1px,
    transparent 1px 3px,
    var(--text) 3px 5px,
    transparent 5px 8px,
    var(--text) 8px 9px,
    transparent 9px 13px
  );
  opacity: 0.78;
}

/* Slant ticks (top-right) */
.trustedby__slant {
  display: block;
  width: clamp(2.5rem, 5vw, 4rem);
  height: 0.7rem;
  background: repeating-linear-gradient(
    115deg,
    var(--purple-light) 0 2px,
    transparent 2px 6px
  );
  margin-top: 0.35rem;
}

/* ======================================================
   HEADING BLOCK
====================================================== */
.trustedby__content-container {
  width: 100%;
}

.trustedby__content-container--clients {
  display: flex;
  flex-direction: column;
}

.trustedby__rail-container {
  width: 100%;
  min-width: 0;
}

.trustedby__head {
  text-align: center;
  margin-bottom: clamp(0.65rem, 1.8vh, 1.15rem);
}

.trustedby__title {
  position: relative;
  display: inline-block;
  font-family: var(--font-bebas-neue);
  font-weight: 400;
  font-style: italic;
  font-size: clamp(3.35rem, 8.2vw, 6.8rem);
  line-height: 0.74;
  letter-spacing: 0;
  text-transform: uppercase;
  color: rgb(var(--theme-text-rgb));
  -webkit-text-stroke: 1px rgb(var(--theme-text-rgb) / 0.18);
  text-shadow: 0 2px 0 rgb(var(--theme-shadow-rgb) / 0.45);
  transform: skewX(-5deg);
}

.trustedby__rule {
  display: block;
  width: clamp(12rem, 29vw, 23rem);
  height: 2px;
  margin: clamp(0.45rem, 1vh, 0.7rem) auto 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--purple-light) 20%,
    var(--purple-light) 80%,
    transparent
  );
  box-shadow: 0 0 14px rgb(var(--theme-primary-rgb) / 0.5);
}

/* ======================================================
   CARD CAROUSEL
====================================================== */
.trustedby__carousel {
  position: relative;
  display: flex;
  align-items: center;
  gap: clamp(0.5rem, 1.5vw, 1.25rem);
  width: 100%;
}

.trustedby__viewport {
  position: relative;
  flex: 1;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent,
    rgb(var(--theme-shadow-rgb)) 6%,
    rgb(var(--theme-shadow-rgb)) 94%,
    transparent
  );
  mask-image: linear-gradient(
    90deg,
    transparent,
    rgb(var(--theme-shadow-rgb)) 6%,
    rgb(var(--theme-shadow-rgb)) 94%,
    transparent
  );
}

.trustedby__track {
  display: flex;
  gap: clamp(0.85rem, 1.65vw, 1.35rem);
  width: max-content;
  padding: clamp(0.55rem, 1.4vh, 0.95rem) 0.45rem;
  animation: trustedby-scroll 48s linear infinite;
  animation-delay: -0.68s;
  animation-play-state: running;
  will-change: transform;
}

@keyframes trustedby-scroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    /* -50% lands one seam-gap too far; back off half a gap so the
       duplicated set lines up exactly (see syncLoopOffset in JS). */
    transform: translate3d(calc(-50% - (var(--loop-gap, 0px) / 2)), 0, 0);
  }
}

/* ---- Card ----
   Base layer = the master SVG chrome (body, brackets, badge box, tick,
   divider). The logo and category TEXT are HTML overlays styled here —
   NOT baked into the SVG — so they stay data-driven via CSS.
   Overlay positions are % of the card box, tracking the SVG geometry
   (viewBox 292.37 x 372.11). The card carries the HUD slant, so text
   overlays are skewed to match. Edit the chrome in trustedby-card.svg. */
.trustedby__card {
  position: relative;
  flex: 0 0 auto;
  width: clamp(10.75rem, 14.4vw, 14rem);
  /* viewBox aspect ratio 292.37 : 372.11 keeps overlays aligned at any size */
  aspect-ratio: 292.37 / 372.11;
  display: block;
  /* Cards rest at full brightness; hover pops the active one forward. */
  opacity: 1;
  filter: none;
  transform: translateY(0) scale(1);
  transition:
    opacity 360ms ease,
    filter 360ms ease,
    transform 360ms cubic-bezier(0.2, 0, 0.2, 1);
}

/* SVG chrome fills the card as the base layer */
.trustedby__card-chrome {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Logo — overlaid in the well */
.trustedby__card-logo {
  position: absolute;
  top: 46%;
  left: 50%;
  transform: translate(-50%, -50%) skewX(-4deg);
  width: 62%;
  height: 30%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.trustedby__card-logo img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 1;
  transition: opacity 320ms ease;
}

/* Category — overlaid on the divider row, aligned after the tick */
.trustedby__card-cat {
  position: absolute;
  bottom: 11%;
  left: 16%;
  transform: skewX(-4deg);
  font-family: var(--font-rajdhani);
  font-size: clamp(0.5rem, 0.64vw, 0.6rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgb(var(--theme-text-rgb));
  white-space: nowrap;
  pointer-events: none;
}

.trustedby__carousel:has(.trustedby__card:hover) .trustedby__card:not(:hover) {
  opacity: 0.36;
  filter: saturate(0.24) brightness(0.58);
  transform: translateY(0) scale(0.92);
}

.trustedby__card:hover {
  z-index: 3;
  opacity: 1;
  filter: saturate(1.08) brightness(1.08);
  transform: translateY(-14px) scale(1.08);
}

/* ======================================================
   PROMOTED PROJECTS
====================================================== */
.trustedby__promoted {
  width: 100%;
  margin-top: clamp(3rem, 8vh, 5.5rem);
}

.trustedby__subhead {
  text-align: center;
  margin-bottom: clamp(1.45rem, 3vh, 2.25rem);
}

.trustedby__subtitle {
  display: inline-block;
  font-family: var(--font-bebas-neue);
  font-size: clamp(2.35rem, 5.6vw, 4.9rem);
  font-style: italic;
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: 0;
  text-transform: uppercase;
  color: rgb(var(--theme-text-rgb));
  -webkit-text-stroke: 1px rgb(var(--theme-text-rgb) / 0.14);
  text-shadow: 0 2px 0 rgb(var(--theme-shadow-rgb) / 0.45);
  transform: skewX(-5deg);
}

.trustedby__subrule {
  display: block;
  width: clamp(11rem, 24vw, 19rem);
  height: 2px;
  margin: clamp(0.35rem, 0.8vh, 0.55rem) auto 0;
  background: linear-gradient(
    90deg,
    transparent,
    var(--purple-light) 20%,
    var(--purple-light) 80%,
    transparent
  );
  box-shadow: 0 0 14px rgb(var(--theme-primary-rgb) / 0.5);
}

.trustedby__project-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent,
    rgb(var(--theme-shadow-rgb)) 5%,
    rgb(var(--theme-shadow-rgb)) 95%,
    transparent
  );
  mask-image: linear-gradient(
    90deg,
    transparent,
    rgb(var(--theme-shadow-rgb)) 5%,
    rgb(var(--theme-shadow-rgb)) 95%,
    transparent
  );
}

.trustedby__project-rail {
  display: flex;
  gap: clamp(0.8rem, 1.55vw, 1.2rem);
  width: max-content;
  padding: clamp(0.55rem, 1.2vh, 0.85rem) clamp(0.25rem, 1.5vw, 0.8rem);
  animation: trustedby-project-scroll 38s linear infinite reverse;
  animation-delay: -1.28s;
  animation-play-state: running;
  will-change: transform;
}

@keyframes trustedby-project-scroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    /* Same seam-gap correction as the clients rail. */
    transform: translate3d(calc(-50% - (var(--loop-gap, 0px) / 2)), 0, 0);
  }
}

.trustedby__project-card {
  position: relative;
  flex: 0 0 clamp(10.6rem, 15.2vw, 14rem);
  aspect-ratio: 4 / 3;
  min-height: clamp(7.95rem, 11.4vw, 10.5rem);
  padding: clamp(0.85rem, 1.4vw, 1.1rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-image: url("/Assets/Companies-Projects-logos/promoted-projects/promoted-project-card.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  overflow: hidden;
  filter: saturate(0.88);
  transform: translateY(0) scale(1);
  transition:
    filter 320ms ease,
    opacity 320ms ease,
    transform 320ms cubic-bezier(0.2, 0, 0.2, 1);
  will-change: transform, filter;
}

.trustedby__project-rail:has(.trustedby__project-card:hover)
  .trustedby__project-card:not(:hover) {
  opacity: 0.42;
  filter: saturate(0.22) brightness(0.56);
  transform: translateY(0) scale(0.94);
}

.trustedby__project-card:hover {
  z-index: 3;
  opacity: 1;
  filter: saturate(1.08) brightness(1.08);
  transform: translateY(-10px) scale(1.08);
}

.trustedby__project-media {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: clamp(0.45rem, 1vw, 0.8rem) 0 clamp(0.3rem, 0.8vw, 0.55rem);
}

.trustedby__project-img {
  width: var(--project-logo-width, 78%);
  max-width: var(--project-logo-max-width, 100%);
  max-height: var(--project-logo-max-height, clamp(3.15rem, 5.25vw, 4.6rem));
  height: auto;
  object-fit: contain;
  display: block;
}

.trustedby__project-img[src$=".svg"] {
  filter: drop-shadow(0 0 10px rgb(var(--theme-primary-rgb) / 0.22));
}

.trustedby__project-img--mk11 {
  --project-logo-width: 88%;
  --project-logo-max-height: clamp(2.35rem, 3.7vw, 3.25rem);
}

.trustedby__project-img--mortalkombatmovie {
  --project-logo-width: 86%;
  --project-logo-max-height: clamp(2.35rem, 3.85vw, 3.35rem);
  filter: brightness(1.35) contrast(1.08)
    drop-shadow(0 0 12px rgb(var(--theme-primary-rgb) / 0.18));
}

.trustedby__project-img--ac-mirage {
  --project-logo-width: 86%;
  --project-logo-max-height: clamp(3.25rem, 5.25vw, 4.7rem);
}

.trustedby__project-img--dyinglight2 {
  --project-logo-width: 84%;
  --project-logo-max-height: clamp(2.5rem, 4.05vw, 3.6rem);
}

.trustedby__project-img--genesis {
  --project-logo-width: 52%;
  --project-logo-max-height: clamp(3.45rem, 5.35vw, 4.7rem);
}

.trustedby__project-img--zeekr,
.trustedby__project-img--omada {
  --project-logo-width: 74%;
  --project-logo-max-height: clamp(1.85rem, 3vw, 2.6rem);
}

.trustedby__project-img--jaecoo {
  --project-logo-width: 86%;
  --project-logo-max-height: clamp(2.05rem, 3.35vw, 2.85rem);
}

.trustedby__project-meta {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
  transform: translateY(-0.28rem);
}

.trustedby__project-name,
.trustedby__project-cat {
  font-family: var(--font-rajdhani);
  text-transform: uppercase;
}

.trustedby__project-name {
  font-size: clamp(0.78rem, 0.98vw, 0.95rem);
  font-weight: 700;
  line-height: 1;
  color: rgb(var(--theme-text-rgb));
}

.trustedby__project-cat {
  font-size: clamp(0.5rem, 0.64vw, 0.6rem);
  font-weight: 600;
  letter-spacing: 0.18em;
  color: rgb(var(--theme-text-rgb) / 0.58);
}

/* ======================================================
   REVEAL-ON-LOAD
====================================================== */
.trustedby__head,
.trustedby__subhead {
  opacity: 0;
  transform: translateY(22px);
  transition:
    opacity 0.72s cubic-bezier(0.2, 0, 0.2, 1),
    transform 0.72s cubic-bezier(0.2, 0, 0.2, 1);
}

.trustedby__rail-container--clients,
.trustedby__rail-container--promoted {
  opacity: 0;
  transform: none;
  transition: opacity 0.72s cubic-bezier(0.2, 0, 0.2, 1);
}

.trustedby.reveal .trustedby__head {
  transition-delay: 0.38s;
}
.trustedby.reveal .trustedby__rail-container--clients {
  transition-delay: 0.68s;
}
.trustedby.reveal .trustedby__subhead {
  transition-delay: 0.98s;
}
.trustedby.reveal .trustedby__rail-container--promoted {
  transition-delay: 1.28s;
}

.trustedby.reveal .trustedby__head,
.trustedby.reveal .trustedby__rail-container--clients,
.trustedby.reveal .trustedby__subhead,
.trustedby.reveal .trustedby__rail-container--promoted {
  opacity: 1;
  transform: translateY(0);
}

/* Failure / no-JS fallback: scoped to :not(.js-reveal), so it only runs
   when the script never executed (no JS, or a hard error before it adds
   the .js-reveal marker). When the script IS running, the reveal is gated
   on scroll and this timer must not pre-empt it — the marker disables it. */
@keyframes trustedby-reveal-fallback {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.trustedby:not(.js-reveal):not(.reveal) .trustedby__head,
.trustedby:not(.js-reveal):not(.reveal) .trustedby__rail-container--clients,
.trustedby:not(.js-reveal):not(.reveal) .trustedby__subhead,
.trustedby:not(.js-reveal):not(.reveal) .trustedby__rail-container--promoted {
  animation: trustedby-reveal-fallback 0.6s ease 3s forwards;
}

/* ======================================================
   RESPONSIVE
====================================================== */
@media (max-width: 768px) {
  .trustedby__head {
    max-width: 100%;
    overflow: hidden;
  }

  .trustedby__title {
    max-width: 100%;
    font-size: clamp(2.7rem, 12.9vw, 4.2rem);
    line-height: 0.78;
  }

  .trustedby__rule {
    width: min(78vw, 18rem);
  }

  .trustedby__hud-sub,
  .trustedby__barcode,
  .trustedby__slant,
  .trustedby__plus-row {
    display: none;
  }

  .trustedby__hud--top {
    justify-content: space-between;
  }

  .trustedby__viewport {
    -webkit-mask-image: linear-gradient(
      90deg,
      transparent,
      rgb(var(--theme-shadow-rgb)) 10%,
      rgb(var(--theme-shadow-rgb)) 90%,
      transparent
    );
    mask-image: linear-gradient(
      90deg,
      transparent,
      rgb(var(--theme-shadow-rgb)) 10%,
      rgb(var(--theme-shadow-rgb)) 90%,
      transparent
    );
  }
}

@media (prefers-reduced-motion: reduce) {
  .trustedby__track,
  .trustedby__project-rail {
    animation: none;
  }

  .trustedby::before,
  .trustedby__head,
  .trustedby__rail-container--clients,
  .trustedby__subhead,
  .trustedby__rail-container--promoted {
    opacity: 1;
    transform: none;
    filter: none;
    animation: none;
  }
}
