/* ==========================================================================
   Home page (index.html)
   Depends on: variables.css, base.css, header.css, footer.css
   ========================================================================== */

.page-main {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
  padding-bottom: var(--section-gap);
  overflow-x: clip;   /* cards swinging in from the side must not widen the page (phones zoom out) */
}

/* Narrower content column used by "Recent works" (205px side padding at 1440) */
.container--narrow {
  max-width: calc(1030px + 2 * var(--gutter));
}

/* Faint 6×4 grid behind the header + hero (Figma "bg", 40% opacity) */
.page-grid {
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 1024px;
  max-width: var(--container-max);
  margin-inline: auto;
  opacity: 0.4;
  pointer-events: none;
  background:
    linear-gradient(to right, var(--color-grid-line) 1px, transparent 1px) 0 0 / calc((100% - 1px) / 6) 100%,
    linear-gradient(to bottom, var(--color-grid-line) 1px, transparent 1px) 0 0 / 100% calc((100% - 1px) / 4);
}

/* ==========================================================================
   Hero
   ========================================================================== */

.hero {
  position: relative;
  padding-top: 60px;
}

.hero__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
  max-width: 1240px;   /* the 70px title is ~1060px wide; the lead text stays at 1040px */
  margin-inline: auto;
  text-align: center;
}

.hero__text {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero__title {
  font-family: var(--font-heading);
  font-size: var(--fs-display);
  line-height: var(--lh-display);
  font-weight: var(--fw-bold);
  color: var(--color-zinc-900);
}

.hero__title-light {
  display: block;
  font-weight: var(--fw-regular);
}

.hero__lead {
  max-width: 1040px;
  margin-inline: auto;
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  color: var(--color-zinc-500);
}

.hero__buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 24px;
}

/* ---- Decorations (desktop only) ---- */

.hero__deco {
  position: absolute;
  pointer-events: none;
}

.hero__arrow {
  top: 96px;
  right: 220px;
  width: 180px;
  height: 75px;
}

.hero__sparkle {
  top: 32px;
  right: 435px;
  width: 48px;
  height: 48px;
}

.hero__cursor {
  top: 109px;
  left: 214px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 48px;
}

.hero__cursor-label {
  align-self: flex-start;
  padding: 10px 13px;
  border-radius: var(--radius-pill);
  background: var(--color-secondary);
  filter: drop-shadow(3px 3px 0 var(--color-secondary-shadow));
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: var(--fw-medium);
  color: var(--color-zinc-50);
  white-space: nowrap;
}

.hero__cursor-icon {
  width: 24px;
  height: 24px;
  transform: rotate(180deg);
}

/* ==========================================================================
   "Load more" under a card grid (Case studies, Blog) — js/load-more.js
   The button swaps with Figma's spinning loader while the next row arrives.
   ========================================================================== */

.load-more__button[hidden],
.load-more__loader[hidden] {
  display: none;
}

.load-more__loader {
  width: 64px;
  height: 64px;
  animation: load-more-spin 2.4s steps(8) infinite;
}

@keyframes load-more-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .load-more__loader {
    animation: none;
  }
}

@media (max-width: 768px) {
  .load-more__loader {
    width: 40px;
    height: 40px;
  }
}

/* ==========================================================================
   Services
   ========================================================================== */

.services {
  display: flex;
  justify-content: center;   /* 5 cards are wider than the viewport: overflow both sides like the design */
  align-items: flex-end;
  gap: 24px;
  overflow: hidden;
  padding-block: 8px 20px;   /* room for the card shadow… */
  margin-block: -8px -20px;  /* …without adding to the layout height */
}

.service-card {
  flex: 0 0 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px;
  border: 1px solid var(--color-zinc-400);
  border-radius: var(--radius-md);
  background: var(--color-white);
  box-shadow: var(--shadow-card);
  text-align: center;
}

.service-card--accent {
  background: var(--color-main-lighter);
}

.service-card--short { height: 312px; }
.service-card--tall  { height: 372px; }

.service-card__icon {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
}

.service-card__title {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-zinc-900);
}

.service-card__text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--color-zinc-700);
}

.service-card--short .service-card__text { -webkit-line-clamp: 4; line-clamp: 4; }
.service-card--tall  .service-card__text { -webkit-line-clamp: 7; line-clamp: 7; }

/* ---- Carousel (enabled by js/main.js adding .is-carousel) ----
   Cards are placed by their distance from the centre (data-dist):
   0 = centre (tallest, green) · 1 = neighbours (white) · 2+ = outer (short, green)
   — the same rhythm as the Figma frame. */

.services.is-carousel {
  --card-w: 340px;
  --step: 364px;          /* card width + 24px gap */
  --h0: 432px;
  --h1: 372px;
  --h2: 312px;
  position: relative;
  display: block;
  height: calc(var(--h0) + 28px);
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  outline: none;
}

.services.is-carousel.is-dragging {
  cursor: grabbing;
}

.services.is-carousel .service-card {
  position: absolute;
  left: 50%;
  bottom: 20px;
  width: var(--card-w);
  height: var(--h2);
  margin-left: calc(var(--card-w) / -2);
  background: var(--color-main-lighter);
  transform: translateX(calc(var(--offset, 0) * var(--step) + var(--drag, 0px)));
  transition:
    transform 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
    height 0.55s cubic-bezier(0.22, 0.61, 0.36, 1),
    background-color 0.4s ease;
  cursor: pointer;
}

.services.is-carousel .service-card img {
  pointer-events: none;
  -webkit-user-drag: none;
}

.services.is-carousel .service-card[data-dist="1"] {
  height: var(--h1);
  background: var(--color-white);
}

.services.is-carousel .service-card[data-dist="0"] {
  height: var(--h0);
  cursor: default;
}

.services.is-carousel.is-dragging .service-card,
.services.is-carousel .service-card.no-anim {
  transition: none;
}

.services.is-carousel:focus-visible .service-card[data-dist="0"] {
  outline: 2px solid var(--color-secondary);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .services.is-carousel .service-card {
    transition: none;
  }
}

/* ==========================================================================
   Counter
   ========================================================================== */

.counter-section {
  padding-inline: calc(var(--gutter) + 40px);
}

.counter {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 64px;
  border-radius: var(--radius-2xl);
  background: var(--color-secondary);
  color: var(--color-white);
  text-align: center;
}

/* 6×3 grid lines, 20% opacity */
.counter::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.2;
  pointer-events: none;
  background:
    linear-gradient(to right, var(--color-grid-line) 1px, transparent 1px) 0 0 / calc((100% - 1px) / 6) 100%,
    linear-gradient(to bottom, var(--color-grid-line) 1px, transparent 1px) 0 0 / 100% calc((100% - 1px) / 3);
}

.counter__head {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 932px;
}

.counter__badge {
  padding: 6px 20px;
  border-radius: var(--radius-pill);
  background: var(--color-main);
  font-family: var(--font-heading);
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: var(--fw-medium);
  color: var(--color-black);
}

.counter__title {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: var(--fw-semibold);
}

.counter__arrow {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 144px;
  height: 61px;
}

.counter__sparkle {
  position: absolute;
  top: 38px;
  right: 64px;
  width: 68px;
  height: 68px;
}

.counter__stats {
  position: relative;
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.counter__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 200px;
}

.counter__value {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  line-height: var(--lh-h2);
  font-weight: var(--fw-semibold);
}

.counter__label {
  font-size: var(--fs-xl);
  line-height: var(--lh-xl);
  color: var(--color-zinc-300);
}

/* ==========================================================================
   Recent works
   ========================================================================== */

.works,
.blog,
.clients {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.works__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

.works__col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.works__col--offset {
  padding-top: 60px;
}

.project-card {
  position: relative;
  display: block;
  height: 600px;
  overflow: hidden;
  border-radius: var(--radius-xl);
  background: var(--color-zinc-900);
}

.project-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.project-card:hover .project-card__image {
  transform: scale(1.03);
}

.project-card__bar {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 16px 24px;
  border: 1px solid var(--color-zinc-700);
  border-radius: var(--radius-pill);
  background: var(--color-white);
  backdrop-filter: blur(25px);
}

.project-card__name {
  flex: 1 1 0;
  min-width: 0;
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-zinc-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-card__cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding-inline: 12px;
  border: 1px solid var(--color-danger-900);
  border-radius: var(--radius-md);
  font-size: var(--fs-xs);
  line-height: var(--lh-xs);
  color: var(--color-black);
  white-space: nowrap;
}

.project-card__cta img {
  width: 20px;
  height: 20px;
}

/* decorative hand cursor on the first card */
.project-card__pointer {
  position: absolute;
  left: calc(50% + 197px);
  top: calc(50% + 162px);
  width: 43px;
  height: 46px;
  pointer-events: none;
}

/* ==========================================================================
   Blog
   ========================================================================== */

.blog__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.blog-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--color-zinc-400);
  border-radius: var(--radius-xl);
  background: var(--color-white);
  transition: background-color 0.35s ease, border-color 0.35s ease, transform 0.35s ease, box-shadow 0.35s ease;
}

/* hover: brand purple card, light text, image zooms inside its frame */
.blog-card:hover {
  border-color: var(--color-secondary);
  background: var(--color-secondary);
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -12px rgba(79, 54, 234, 0.45);
}

.blog-card__media {
  overflow: hidden;
  border-radius: 20px;
}

.blog-card__image {
  width: 100%;
  height: 300px;
  object-fit: cover;
  border-radius: 20px;
  transition: transform 0.5s ease;
}

.blog-card:hover .blog-card__image {
  transform: scale(1.05);
}

.blog-card__title,
.blog-card__excerpt {
  transition: color 0.35s ease;
}

.blog-card:hover .blog-card__title {
  color: var(--color-white);
}

.blog-card:hover .blog-card__excerpt {
  color: var(--color-zinc-200);
}

.blog-card__body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
}

.blog-card__title {
  font-size: var(--fs-lg);
  line-height: var(--lh-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-zinc-900);
}

.blog-card__excerpt,
.blog-card__date {
  font-size: var(--fs-sm);
  line-height: var(--lh-sm);
  font-weight: var(--fw-medium);
  color: var(--color-zinc-600);
}

.blog-card__date {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--color-main-light);
}

/* ==========================================================================
   Clients
   ========================================================================== */

.clients__grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 200px));
  justify-content: space-between;
  gap: 24px 60px;
}

.client-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--color-zinc-200);
  border-radius: var(--radius-md);
  background: var(--color-white);
  transition: border-color 0.25s ease;
}

/* 160 × --h box (numbers from Figma); scales down in narrow cards */
.client-logo__box {
  position: relative;
  display: block;
  width: min(160px, 100%);
  aspect-ratio: 160 / var(--h, 49);
  overflow: hidden;
}

.client-logo__box img {
  position: absolute;
  max-width: none;
  transition: opacity 0.25s ease;
}

/* grey export already contains Figma's crop — stretch it to the box like Figma does */
.client-logo__gray {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: var(--fit, fill);
}

/* colour export is the raw image — apply Figma's crop via --l/--t/--w/--hh */
.client-logo__color {
  left: var(--l, 0%);
  top: var(--t, 0%);
  width: var(--w, 100%);
  height: var(--hh, 100%);
  object-fit: var(--fit, fill);
  opacity: 0;
}

.client-logo:hover {
  border-color: var(--color-zinc-400);
}

.client-logo:hover .client-logo__gray { opacity: 0; }
.client-logo:hover .client-logo__color { opacity: 1; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1200px) {
  .hero__deco {
    display: none;
  }

  .counter-section {
    padding-inline: var(--gutter);
  }

  .project-card {
    height: 520px;
  }

  .project-card__pointer {
    display: none;
  }

  .clients__grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 24px;
  }
}

@media (max-width: 992px) {
  /* no-JS fallback: plain swipe row */
  .services:not(.is-carousel) {
    justify-content: flex-start;
    align-items: stretch;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter);
    padding-inline: var(--gutter);
    scrollbar-width: none;
  }

  .services:not(.is-carousel)::-webkit-scrollbar {
    display: none;
  }

  .services:not(.is-carousel) .service-card {
    flex-basis: 300px;
    height: 340px;
    scroll-snap-align: start;
  }

  .services:not(.is-carousel) .service-card__text {
    -webkit-line-clamp: 5;
    line-clamp: 5;
  }

  .counter {
    padding: 48px 32px;
  }

  .counter__arrow,
  .counter__sparkle {
    display: none;
  }

  .blog .section-head {
    flex-wrap: wrap;
  }

  .blog__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .clients__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .hero {
    padding-top: 32px;
  }

  /* Figma mobile keeps the sparkle: 32px, top-right of the title */
  .hero .hero__sparkle {
    display: block;
    top: 20px;
    right: 36px;
    width: 32px;
    height: 32px;
  }

  .hero__content {
    gap: 32px;
  }

  .hero__lead {
    font-size: var(--fs-md);
    line-height: var(--lh-md);
  }

  .hero__buttons {
    gap: 12px;
    width: 100%;
  }

  .hero__buttons .btn {
    flex: 1 1 160px;
  }

  .service-card {
    flex-basis: 280px;
    padding: 24px;
  }

  .services.is-carousel {
    --card-w: 280px;
    --step: 292px;
    --h0: 400px;
    --h1: 352px;
    --h2: 312px;
  }

  .counter {
    padding: 40px 20px;
    border-radius: var(--radius-xl);
  }

  .counter__stats {
    flex-direction: column;
    align-items: center;
    gap: 24px;
  }

  .counter__label {
    font-size: var(--fs-md);
    line-height: var(--lh-md);
  }

  .works__grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .works__col--offset {
    padding-top: 0;
  }

  .project-card {
    height: 440px;
  }

  .project-card__bar {
    height: 56px;
    padding: 12px 16px;
  }

  .project-card__name {
    font-size: var(--fs-md);
    line-height: var(--lh-md);
  }

  .blog__grid {
    grid-template-columns: 1fr;
  }

  .blog-card__image {
    height: 220px;
  }

  .clients__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
  }

  .client-logo {
    padding: 12px;
  }
}
