/* ==========================================================================
   Responsive adaptation of the 1920px Figma desktop layout.
   ≥ 1920px  exact Figma geometry (centred 1920 frame)
   1280–1919 exact Figma geometry, scaled to the window width (scripts/scale.js)
   < 1280px  wide blocks become fluid; components switch to flow layout
   < 1100px  stacked two-part rows, two-column grids
   < 1100px  navigation collapses into a menu
   < 768px   single-column mobile layout
   ========================================================================== */

/* ---------- Wider than the design frame ---------- */
@media (min-width: 1921px) {
  /* The hero artwork scales with the viewport instead of leaving flat bands at the sides */
  .hero__bg {
    background-size: calc(100% * 1.016406) auto, auto;
    background-position: 0 calc(80.05px * 100vw / 1920px), 0 0;
  }
  /* Keep frame-bound decorations inside the 1920 frame, as in Figma */
  .clients,
  .process__stage { left: calc(50% - 960px); right: auto; width: var(--frame); overflow: hidden; }
  .clients__track { left: 31px; }
}

/* ---------- Process stage: animated composition scales as one piece below the frame width ---------- */
@media (max-width: 1279px) and (min-width: 1024px) {
  .process { container-type: inline-size; }
  .process__stage {
    --k: tan(atan2(100cqw, 1920px));
    left: 0;
    top: calc((710px - 710px * var(--k)) / 2);
    width: 1920px;
    zoom: var(--k);
  }
}

/* ---------- Fluid wide blocks ---------- */
@media (max-width: 1279px) {
  :root { --gutter: 24px; }

  /* Hero artwork (planet + shading blob) scales as one piece, keeping its composition and drawing the
     2752px photo near its native resolution instead of upscaling a 1951px-wide slice */
  .hero__bg {
    --hero-art: max(0.3, tan(atan2(100vw, 1536px)));
    zoom: var(--hero-art);
    /* the planet's rim sits 155 units below the layer top: keep it 97px down the page (clear of the header) */
    top: calc(97px / var(--hero-art) - 155px);
    bottom: 0;
    height: auto;
  }

  .rating { top: auto; bottom: 43.89px; }

  /* Hero title may take two lines */
  .hero__title { max-width: 100%; margin-top: 36px; line-height: 1.3; white-space: normal; text-wrap: balance; }
  .hero__lead { margin-top: 18px; }

  .showreel,
  .service-grid,
  .why-grid,
  .project,
  .behind__body,
  .faq-list {
    width: min(var(--block-w), 100% - 2 * var(--gutter));
    margin-inline: auto;
  }
  .showreel { --block-w: 1583px; height: auto; aspect-ratio: 1583 / 754; }
  .service-grid { --block-w: 1582px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .why-grid { --block-w: 1582px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .project { --block-w: 1589px; }
  .behind__body { --block-w: 1553.23px; gap: clamp(40px, 6vw, 100.05px); }
  .faq-list { --block-w: 1589px; }

  /* Showreel: title + CTA stay bottom-centred */
  .showreel__title { top: auto; bottom: 105.63px; }
  .cta-slot--showreel { top: auto; bottom: 33.35px; }

  /* Service card: flow layout with the Figma insets (title at 104.9, text at 144.3, sides 31) */
  .service-card { height: auto; min-height: 238px; padding: 104.9px 31px 30px; }
  .service-card__burst,
  .service-card__icon { inset-inline-end: auto; inset-inline-start: 31.16px; }
  .service-card__title,
  .service-card__text { position: relative; inset-inline-start: auto; top: auto; }
  .service-card__title { white-space: normal; }
  .service-card__text { width: auto; max-width: var(--text-w); margin-top: 7.77px; }
  .service-card--app .service-card__text,
  .service-card--system .service-card__text { margin-top: 7.47px; }

  /* Why card */
  .why-card { height: auto; min-height: 198px; padding: 94px 34px 34px; }
  .why-card__title,
  .why-card__text { position: relative; inset-inline-start: auto; top: auto; white-space: normal; }
  .why-card__text { margin-top: 8.98px; }

  /* Projects: media fills the space left by the fixed info card */
  .project { column-gap: 27px; }
  .project__media { flex: 1 1 auto; width: auto; min-width: 0; }

  /* Behind the product */
  .behind__media { flex: 0 1 694px; width: auto; height: auto; aspect-ratio: 694 / 582; }
  .pillars { flex: 1 1 759.19px; width: auto; min-width: 0; }
  .pillar::after { width: calc(100% - 20px); }

  /* FAQ */
  .faq-item__question { inset-inline-start: 12px; width: auto; }
  .faq-item__answer { white-space: normal; inset-inline-end: 24px; text-align: start; }

  /* Footer panel: flow layout */
  .site-footer { height: auto; padding-bottom: 40px; }
  .site-footer__panel {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: start;
    column-gap: 48px;
    height: auto;
    padding: 137px clamp(24px, 6vw, 110px) 60px;
  }
  .site-footer__panel > * { position: relative; }
  .site-footer__top { display: contents; }
  .site-footer__heading { position: relative; inset-inline-start: auto; top: auto; grid-column: 1; }
  .site-footer__intro { position: relative; inset-inline-end: auto; top: auto; grid-column: 2; grid-row: 1; width: min(587px, 42vw); height: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 28px; }
  .site-footer__about { position: relative; width: auto; }
  .site-footer__rule { grid-column: 1 / -1; inset-inline-end: auto; top: auto; width: 100%; margin: 36px 0 55px; }
  .site-footer__cols { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 40px 48px; }
  .footer-col { position: relative; inset-inline-start: auto; top: auto; }
  .footer-col--services, .footer-col--contact { margin-top: 6.26px; }
  .site-footer__vision { position: relative; inset-inline-end: auto; top: auto; }
  .site-footer__logo { position: relative; display: block; inset-inline-end: auto; top: auto; margin: 15px auto 0; }
  .social { position: relative; left: auto; top: auto; justify-content: center; margin: 21px auto 0; }
}

/* ---------- Contact fields row (1212px) becomes fluid ---------- */
@media (max-width: 1279px) {
  .contact-form__fields { width: calc(100% - 2 * var(--gutter)); max-width: 1212.26px; margin-inline: auto; }
  .field { flex: 1 1 0; min-width: 0; }
}

/* ---------- Stacked rows / two-column grids ---------- */
@media (max-width: 1099px) {
  .about__lead, .faq__lead, .contact__lead {
    width: auto;
    max-width: calc(100% - 2 * var(--gutter));
    margin-inline: auto;
  }
  .contact__lead { white-space: normal; text-align: center; }

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

  .project { flex-direction: column; align-items: stretch; row-gap: 24px; }
  .project__media { order: -1; flex: none; width: 100%; }
  .project__info { align-self: center; }

  .behind__body { flex-direction: column; align-items: center; gap: 48px; }
  .behind__media { flex: none; width: min(694px, 100%); }
  .pillars { flex: none; width: 100%; }
}

/* ---------- Navigation menu: below the scaled desktop range the menu collapses behind a button ---------- */
@media (max-width: 1279px) {
  :root { --header-h: 76px; --ctl-h: 41.59px; }
  .site-header__inner { width: calc(100% - 32px); }
  .brand { inset-inline-start: 0; }
  .nav-toggle {
    position: absolute;
    inset-inline-start: 73px;
    top: calc((var(--header-h) - var(--ctl-h)) / 2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: var(--ctl-h);
    height: var(--ctl-h);
    padding: 0 11px;
    border-radius: 80px;
    background: var(--color-white-10);
  }
  .nav-toggle span { display: block; height: 1.5px; border-radius: 1px; background: var(--color-white); }
  .lang-switch { inset-inline-start: calc(73px + var(--ctl-h) + 8px); } /* 8px after the menu button */
  .cta--header { --z: 0.653417; } /* 63.65px button → 41.59px control height */
  .site-nav {
    inset-inline-end: auto;
    inset-inline-start: 0;
    top: calc(var(--header-h) - 8px);
    width: min(393.81px, 100%);
    height: auto;
    padding: 8px 24px;
    border-radius: 20.8px;
    background: rgba(2, 2, 12, 0.92);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s var(--ease-out-cubic), visibility 0s linear 0.3s;
  }
  .site-header.is-menu-open .site-nav { visibility: visible; opacity: 1; transition: opacity 0.3s var(--ease-out-cubic); }
  .site-nav__list { display: block; height: auto; padding: 0; }
  .site-nav__link { font-size: 16px; line-height: 44px; }
}

/* ---------- Tablet and phone: footer and FAQ ---------- */
@media (max-width: 1099px) {
  /* Footer */
  .site-footer__panel { display: flex; flex-direction: column; align-items: center; padding: 48px 20px 40px; text-align: center; }
  .site-footer__panel::before { background-size: max(1000px, 100%) auto; background-position: center bottom; }
  .site-footer__heading { line-height: 1.4; }
  .site-footer__intro { width: 100%; align-items: center; margin-top: 16px; }
  .site-footer__about { text-align: center; line-height: 1.75; text-wrap: balance; }
  .site-footer__rule { margin: 32px 0; }
  .site-footer__cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); justify-items: center; gap: 32px 16px; width: 100%; }
  .footer-col { text-align: center; }
  .footer-col--contact { grid-column: 1 / -1; }
  .site-footer__vision { grid-column: 1 / -1; }

  /* FAQ */
  .faq-item, .faq-item.is-open { height: auto; margin-bottom: 8px; overflow: visible; }
  .faq-item__heading { display: block; }
  .faq-item__question { position: relative; inset-inline: auto; top: auto; display: block; width: 100%; height: auto; padding-block: 18px; padding-inline: 0 56px; }
  .faq-item__q-text { position: relative; inset-inline-start: auto; display: block; line-height: 1.65; white-space: normal; }
  .faq-item__chevron { inset-inline-start: auto; inset-inline-end: 0; top: 50%; margin-top: -11.6px; }
  .faq-item__answer {
    position: relative;
    inset-inline: auto;
    top: auto;
    max-height: 0;
    overflow: hidden;
    line-height: 1.75;
    opacity: 0.9;
    transition: max-height var(--dur-card) var(--ease-out-cubic), padding var(--dur-card) var(--ease-out-cubic);
  }
  .faq-item.is-open .faq-item__answer { max-height: 320px; padding: 12px 0 8px; }
}

/* ---------- Process below the scaled-stage range ---------- */
@media (max-width: 1023px) {
  /* Process: no pinning (the vertical sequence is taller than the viewport); the title sweeps through its
     own lane and each step/arrow rises into place as it scrolls into view */
  .process { height: auto; }
  .process__pin { position: relative; top: auto; height: auto; padding: 120px var(--gutter) 60px; }
  .process__pin::before {
    background-image: url('../images/process-background-mobile.jpg');
    background-size: max(430px, 100%) auto;
    background-position: center top;
  }
  .badge--process { top: 40px; }
  .process__stage { position: relative; left: auto; width: 100%; height: auto; overflow: hidden; }
  .process__title {
    inset-inline-end: 0;
    top: 0;
    font-size: clamp(30px, 9vw, 60px);
    line-height: 1.5;
    --sweep: calc(100vw + 100%);
    translate: calc(-100% * var(--dir)) 0; /* waits just outside the lane's entry edge */
  }
  .process-steps { display: flex; flex-direction: column; align-items: center; gap: 150px; padding-top: calc(var(--lane) + 24px); }
  .process-step { position: relative; inset-inline-end: auto; top: auto; width: min(283px, 100%); --from-y: 60px; opacity: var(--ps); }
  .process-step__text { inset-inline: 0; }
  .process-arrow { --gx: calc(50% - 59.755px); --from-y: 60px; rotate: calc(-90deg * var(--dir)); opacity: var(--ps); }
  .process-arrow--1 { --gy: calc(var(--lane) + 286.8px); }
  .process-arrow--2 { --gy: calc(var(--lane) + 635.6px); }
  .process-arrow--3 { --gy: calc(var(--lane) + 984.4px); }
  .process__stage { --lane: calc(clamp(30px, 9vw, 60px) * 1.5); }
}

/* ---------- Reduced motion: stop the decorative loops (the process section shows its resting state) ---------- */
@media (prefers-reduced-motion: reduce) {
  .clients__track, .clients__card { animation: none; }
}

/* ---------- Mobile ----------
   The same type roles at phone sizes; 64px between sections; 16px page gutter; cards use a 24px inset. */
@media (max-width: 767px) {
  :root {
    --gutter: 16px;
    --fs-display: clamp(25px, 7.2vw, 30px);
    --fs-title: clamp(20px, 5.7vw, 24px);
    --fs-step: 22px;
    --fs-card-title: 18px;
    --fs-lead: clamp(14px, 3.85vw, 16px);
    --fs-body: 15px;
    --fs-small: 14px;
    --fs-badge: 14px;
  }

  .badge { gap: 11px; padding-block: 7px; padding-inline: 18px 22px; }
  .site-footer { padding: 16px 12px 40px; }

  .services, .about, .why, .launch, .work, .behind, .faq, .contact { padding-top: 0; padding-bottom: 64px; }
  .about__lead, .why__title, .launch__title, .work__title, .work__lead, .behind__title,
  .faq__title, .faq__lead, .contact__title, .contact__lead, .hero__title, .hero__lead, .showreel__title {
    width: auto;
    max-width: calc(100% - 2 * var(--gutter));
    white-space: normal;
    text-align: center;
    text-wrap: balance;
  }
  .why__title, .work__title, .behind__title, .faq__title, .contact__title, .showreel__title {
    margin-top: 16px;
    line-height: 1.5;
  }
  .work__lead, .faq__lead, .contact__lead { margin-top: 8px; line-height: 1.7; }

  /* Header */
  .site-header__inner { width: calc(100% - 2 * var(--gutter)); }
  .header-phone { width: var(--ctl-h); }
  .header-phone__number { display: none; }
  .cta--header { inset-inline-end: calc((var(--ctl-h) + 20px) / var(--z)); }

  /* Hero */
  .hero { height: auto; padding-bottom: 48px; }
  .hero__content { width: calc(100% - 2 * var(--gutter)); margin-inline: auto; padding-top: 136px; }
  .hero__tagline { width: 100%; padding-block: 9px; padding-inline: 48px 12px; }
  .hero__tagline-icon { top: 50%; translate: 0 -50%; }
  .hero__tagline-text { flex: 1; font-size: 13px; line-height: 1.6; white-space: normal; text-align: center; text-wrap: balance; }
  .hero__title { margin-top: 20px; line-height: 1.45; }
  .hero__lead { max-width: 100%; margin-top: 12px; line-height: 1.7; }
  .cta--hero { margin-top: 28px; }
  .clients { position: relative; top: auto; height: 216px; margin-top: 40px; zoom: 0.72; }
  .hero__shade { display: none; }

  /* Services: the video carries its own on-screen text, so the title and CTA sit below it */
  .services { padding-top: 8px; }
  .showreel { display: flex; flex-direction: column; align-items: center; height: auto; aspect-ratio: auto; margin-top: 24px; padding-bottom: 24px; background: var(--color-purple-10); }
  .showreel__video { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .showreel__shade { display: none; }
  .showreel__title { position: static; margin-top: 20px; translate: none; }
  .cta-slot--showreel { position: static; margin-top: 16px; translate: none; }
  .service-grid { grid-template-columns: minmax(0, 1fr); row-gap: 12px; margin-top: 12px; }
  .service-card { min-height: 0; padding: 100px 24px 26px; }
  .service-card__burst, .service-card__icon { inset-inline-start: 24px; top: 24px; }
  .service-card__title { line-height: 1.5; }
  .service-card__text { max-width: none; margin-top: 6px; line-height: 1.7; }

  /* About */
  .about__lead { margin-top: 20px; line-height: 1.75; }
  .about-steps { display: grid; grid-template-columns: repeat(2, max-content); justify-content: center; gap: 14px 18px; margin-top: 28px; } /* two steps per row */
  .about-step { gap: 8px; }
  .about-step__arrow { font-size: 20px; }
  .about__motto { max-width: calc(100% - 2 * var(--gutter)); margin-top: 24px; padding: 8px 22px; line-height: 1.6; white-space: normal; text-align: center; }
  .cta--about { margin-top: 28px; }

  /* Why */
  .why-grid { grid-template-columns: minmax(0, 1fr); row-gap: 12px; margin-top: 28px; }
  .why-card { min-height: 0; padding: 94px 24px 26px; }
  .why-card__icon { inset-inline-start: 24px; top: 24px; }
  .why-card__title { line-height: 1.5; }
  .why-card__text { margin-top: 6px; line-height: 1.7; }

  /* Process */
  .process-step__title { line-height: 1.5; }
  .process-step__text { line-height: 1.6; }

  /* Launch */
  .launch { padding-top: 64px; }
  .launch__title { margin-top: 16px; line-height: 1.5; }
  .cta-slot--launch { margin-top: 28px; }

  /* Work */
  .projects { margin-top: 28px; }
  .project { row-gap: 12px; }
  .project + .project { margin-top: 28px; }
  .project__media { border-radius: 16px; }
  .project__info {
    width: 100%;
    padding: 24px;
    border-radius: 16px;
    align-items: center; /* mobile: project content centred */
    text-align: center;
  }
  .project__name { margin-top: 14px; }
  .project__tags { text-wrap: balance; }
  .project__summary, .project__role { margin-top: 8px; line-height: 1.75; text-wrap: balance; }
  .project__role-title { margin-top: 16px; }
  .project__link { margin-top: 16px; }
  .cta--work { margin-top: 32px; }

  /* Behind */
  .behind__body { margin-top: 28px; gap: 20px; }
  .pillar { height: auto; padding-block: 20px; padding-inline: 44px 0; }
  .pillar:last-child { height: auto; }
  .pillar__check { inset-inline-start: 4px; top: 24px; font-size: 22px; line-height: 22px; }
  .pillar__title, .pillar__text { position: relative; inset-inline-start: auto; top: auto; width: auto; text-align: start; white-space: normal; }
  .pillar__title { line-height: 1.2; }
  .pillar__text { margin-top: 8px; line-height: 1.6; }
  .pillar::after { inset-inline-end: 0; top: 0; width: 100%; height: 100%; }

  /* Contact */
  .contact { padding-top: 8px; }
  .contact-form__fields { flex-direction: column; gap: 12px; width: calc(100% - 2 * var(--gutter)); margin-top: 28px; }
  .field, .field--name, .field--channel, .field--type { width: 100%; margin: 0; }
  .field input { height: 54px; padding-inline: 22px 20px; font-size: 16px; } /* 16px keeps iOS from zooming on focus */
  .contact-form__message { width: calc(100% - 2 * var(--gutter)); margin-top: 16px; }
  .contact-form__message textarea { height: auto; min-height: 44.38px; font-size: 16px; line-height: 1.7; text-align: center; white-space: normal; }
  .cta-slot--submit { margin-top: 20px; }

  /* Footer: tighter rhythm */
  .site-footer__panel { padding: 40px 20px 32px; }
  .site-footer__about { font-size: var(--fs-small); }
  .site-footer__rule { margin: 28px 0; }
  .site-footer__cols { gap: 28px 16px; }
  .footer-col { line-height: 2.1; }
  .footer-col__title { margin-bottom: 4px; line-height: 1.6; }
  .footer-col--services, .footer-col--contact { margin-top: 0; }
}

/* ---------- Narrow phones: keep logo, menu, language and CTA; the phone number stays available in the footer ---------- */
@media (max-width: 520px) {
  .header-phone { display: none; }
  .cta--header { --z: 0.56; inset-inline-end: 0; }
}

/* ---------- Small phones: brand and round header controls shrink so everything fits on one row ---------- */
@media (max-width: 400px) {
  :root { --ctl-h: 36px; }
  .brand { --brand-k: 0.84; }
  .nav-toggle { inset-inline-start: 56px; padding: 0 9px; }
  .lang-switch { inset-inline-start: 98px; gap: 6px; padding-inline: 8px 10px; }
}

/* ---------- Smallest phones (320–359px): the language switch shows its flag only (the link keeps its name) ---------- */
@media (max-width: 359px) {
  .cta--header { --z: 0.5; }
  .lang-switch { justify-content: center; width: var(--ctl-h); padding: 0; }
  .lang-switch__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
