/* ============================================
   Services Index — Industrial Precision (1:1 port)
   ============================================ */

/* --ip-header-h is the live sticky-header height. The section-scroll JS measures
   the real header (it varies by viewport width) and publishes it onto :root, so the
   slide sizing below always matches reality. This value is the pre-JS fallback. */
:root { --ip-header-h: 72px; }
.ip-services { background: var(--ip-paper); }

/* The footer is the last section-scroll target; offset its landing under the
   sticky header too. */
.ip-services + .ip-footer { scroll-margin-top: var(--ip-header-h); }

/* ===== Fold: hero image + intro heading occupy exactly one screen ===== */
/* svh (not vh) so mobile browser chrome can't push the heading off-screen.
   The cards section sits OUTSIDE this wrapper, so it falls below the fold. */
.ip-fold {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100svh - var(--ip-header-h));
}

/* ===== Hero ===== */
.ip-hero { padding: 28px 40px 0; background: #FFFFFF; display: flex; flex: 1 1 auto; min-height: 0; }
.ip-hero__panel {
  position: relative;
  overflow: hidden;
  flex: 1 1 auto;       /* absorb whatever vertical space is left in the fold */
  min-height: 220px;    /* never let the image collapse */
  border-radius: var(--ip-r-hero);
  /* Subtle dark scrim over the circuit-board photo keeps the white title legible. */
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.30) 100%),
    url('../img/services-hero.png') center / cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
}
.ip-hero__content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ip-hero__title {
  font-family: var(--ip-font-display);
  font-size: 80px;
  font-weight: 700;
  letter-spacing: -1px;
  color: rgba(255, 255, 255, 0.82);
  margin: 0;
}
.ip-hero__crumb {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--ip-font-body);
  font-size: 15px;
}
.ip-hero__crumb a { color: rgba(255, 255, 255, 0.72); text-decoration: none; font-weight: 500; }
.ip-hero__sep { color: rgba(255, 255, 255, 0.60); }
.ip-hero__current { color: #FFFFFF; font-weight: 600; }

/* ===== Intro ===== */
.ip-intro {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 56px 28px;
  background: var(--ip-paper);
  text-align: center;
}
.ip-intro__eyebrow {
  font-family: var(--ip-font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 1.6px;
  color: var(--ip-accent-2);
}
.ip-intro__heading {
  font-family: var(--ip-font-display);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.15;
  color: var(--ip-ink);
  margin: 0;
  max-width: 760px;
}
.ip-intro__hl {
  display: inline-block;
  background: var(--ip-accent);
  color: #FFFFFF;
  border-radius: 10px;
  padding: 2px 14px;
  line-height: 1.1;
}

@media (max-width: 768px) {
  .ip-hero { padding: 16px 16px 0; }
  .ip-hero__panel { min-height: 180px; border-radius: 24px; }
  .ip-hero__title { font-size: 44px; }
  .ip-intro { padding: 24px 20px 20px; }
  .ip-intro__heading { font-size: 30px; }
}

/* ===== Service slides ===== */
/* Each service = one full-screen slide. Image and text alternate sides via
   the .ip-slide--mirror class (set on even forloop.counter), flipping the row direction. */
.ip-slide {
  display: flex;
  align-items: center;
  /* Each slide is a <section>; the site-wide shell sets `section { padding: 80px 0 }`
     (style.css). That inherited 160px of vertical padding made every slide 160px
     TALLER than the visible region — the 80px top padding read as "white space above
     the section" and pushed the content/ghost-title off the bottom of the screen.
     Zero it so the slide is exactly its min-height (the visible region) and the
     centered content actually sits in the middle of the screen. */
  padding: 0;
  /* Fit the VISIBLE region exactly (dynamic viewport minus the sticky header) so a
     slide is precisely one screen and the section-scroll lands it edge-to-edge with
     no previous-section "peek" at the top. dvh tracks the real current viewport
     (unlike svh, which can resolve taller than the window and cause overflow). */
  min-height: calc(100dvh - var(--ip-header-h));
  /* Section-scroll lands slides via scrollIntoView({block:'start'}); this margin
     offsets the landing so the slide top sits flush UNDER the sticky header. */
  scroll-margin-top: var(--ip-header-h);
  background: var(--ip-paper);
}
.ip-slide__inner {
  display: flex;
  align-items: center;
  gap: 72px;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 56px 56px;
}
.ip-slide--mirror .ip-slide__inner { flex-direction: row-reverse; }

/* Media half */
.ip-slide__media {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ip-slide__render {
  width: 100%;
  max-height: 72svh;          /* flex down on short screens so nothing overflows */
  object-fit: contain;
  border-radius: var(--ip-r-hero);
  display: block;
}
.ip-slide__render.is-placeholder {
  width: 100%;
  height: auto;
  border: 1px solid var(--ip-line);
}

/* Text half */
.ip-slide__text {
  flex: 1 1 50%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}
.ip-slide__index {
  font-family: var(--ip-font-mono);
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--ip-accent-2);
}
.ip-slide__title {
  font-family: var(--ip-font-display);
  font-size: 52px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -1px;
  color: var(--ip-ink);
  margin: 0;
}
.ip-slide__desc {
  font-family: var(--ip-font-body);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ip-muted);
  margin: 0;
  max-width: 46ch;
}
.ip-slide__link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-family: var(--ip-font-card);
  font-size: 16px;
  font-weight: 600;
  color: var(--ip-accent);
  text-decoration: none;
}
.ip-slide__arrow { transition: transform 0.22s ease; }
.ip-slide__link:hover .ip-slide__arrow { transform: translateX(5px); }

/* ===== Featured slide (first) — floating render + oversized ghost title ===== */
/* Inspired by the FUTURESKYLINES reference: a giant low-contrast title bleeds off
   the edge behind a free-floating render (no card); the text block layers over a corner. */
.ip-slide--featured { position: relative; overflow: hidden; display: block; }
.ip-slide--featured .ip-slide__inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  min-height: calc(100dvh - var(--ip-header-h));
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  gap: 0;
  padding: 48px 56px;
}

/* The oversized ghosted service title sitting behind everything, right-aligned and
   fully on-screen (no letter clipping against the slide's overflow:hidden edge). */
.ip-slide--featured .ip-slide__ghost {
  position: absolute;
  top: 50%;
  right: 24px;
  transform: translateY(-50%);
  z-index: 0;
  margin: 0;
  max-width: 78%;
  text-align: right;
  font-family: var(--ip-font-display);
  font-weight: 700;
  font-size: clamp(56px, 11.5vw, 176px);
  line-height: 0.94;
  letter-spacing: -1px;
  text-transform: uppercase;
  color: rgba(20, 23, 28, 0.16);   /* bolder partial-contrast ghost; render still wins */
  pointer-events: none;
  white-space: normal;
  overflow-wrap: break-word;
}

/* Render floats free — no card, no border, just a soft contact shadow */
.ip-slide--featured .ip-slide__media {
  grid-column: 2;
  align-self: center;
  justify-self: center;
}
.ip-slide--featured .ip-slide__render {
  width: 100%;
  max-width: 620px;
  /* Stay within the visible region (minus the header + slide padding + the soft
     drop-shadow) so the render can't make the slide overflow below the fold. */
  max-height: calc(100dvh - var(--ip-header-h) - 150px);
  border-radius: 0;
  filter: drop-shadow(0 40px 60px rgba(20, 23, 28, 0.28));
}

/* Text block centered in the visible region, layered above the ghost type */
.ip-slide--featured .ip-slide__text {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  max-width: 460px;
}
.ip-slide--featured .ip-slide__title { font-size: 40px; }

/* Alternation: mirrored featured slides — ghost+render to the LEFT, text to the RIGHT */
.ip-slide--featured.ip-slide--mirror .ip-slide__ghost {
  right: auto;
  left: 24px;
  text-align: left;
}
.ip-slide--featured.ip-slide--mirror .ip-slide__media { grid-column: 1; }
.ip-slide--featured.ip-slide--mirror .ip-slide__text {
  grid-column: 2;
  justify-self: end;
  text-align: right;
  align-items: flex-end;
}

/* The "Chat with us" widget (Tidio) is fixed in the bottom-right corner and we
   can't move it. On MIRRORED featured slides the text is right-aligned, so the
   "Explore service" link can fall under the chat bubble. Reserve a clear corner:
   pull the right-aligned text block in from the right edge and lift it off the
   bottom so the link never lands behind the widget. (Only mirrored slides need
   this — on non-mirrored slides the text is on the left, clear of the corner.) */
.ip-slide--featured.ip-slide--mirror .ip-slide__text {
  padding-right: 88px;        /* clear the bubble's width on the right edge */
  align-self: center;
}
/* On shorter viewports the centered text sits lower and can reach the bubble —
   nudge the whole mirrored block up so the link clears the bottom-right corner. */
@media (max-height: 760px) {
  .ip-slide--featured.ip-slide--mirror .ip-slide__text {
    align-self: start;
    margin-top: 8%;
  }
}

@media (max-width: 1024px) {
  .ip-slide--featured .ip-slide__inner { padding: 88px 32px 56px; }
  .ip-slide--featured .ip-slide__render { max-width: 480px; }
}

@media (max-width: 768px) {
  /* Single stacked column for ALL featured slides: render on top, text below,
     left-aligned, alternation disabled. The selectors below intentionally also
     match `.ip-slide--mirror` so the desktop mirror placement (grid-column:2,
     justify-self:end, text-align:right, padding-right:88px) is fully RESET —
     otherwise the mirrored even slides (2/4/6) kept their desktop column
     placement, the media cell collapsed to 0 width, and the render vanished. */
  .ip-slide--featured .ip-slide__inner,
  .ip-slide--featured.ip-slide--mirror .ip-slide__inner {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: calc(100svh - var(--ip-header-h));
    align-content: center;
    gap: 24px;
    padding: 40px 20px;
  }
  .ip-slide--featured .ip-slide__media,
  .ip-slide--featured.ip-slide--mirror .ip-slide__media {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
  }
  .ip-slide--featured .ip-slide__text,
  .ip-slide--featured.ip-slide--mirror .ip-slide__text {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    justify-self: stretch;
    align-items: flex-start;
    text-align: left;
    padding-right: 0;        /* reset the desktop mirror chat-widget guard */
    padding-bottom: 0;
    max-width: 100%;
  }
  .ip-slide--featured .ip-slide__render { max-width: 340px; max-height: 42svh; }
  /* Ghost title is decorative oversized type that overlaps content on narrow
     screens — hide it on mobile so the stacked render + text read cleanly. */
  .ip-slide--featured .ip-slide__ghost,
  .ip-slide--featured.ip-slide--mirror .ip-slide__ghost { display: none; }
  .ip-slide--featured .ip-slide__title { font-size: 32px; }
}

.ip-slides__empty { text-align: center; padding: 96px 24px; color: var(--ip-muted); }

/* Tablet: tighten the gap + type before stacking */
@media (max-width: 1024px) {
  .ip-slide__inner { gap: 48px; padding: 48px 32px; }
  .ip-slide__title { font-size: 42px; }
}

/* Mobile: stack image on top, text below — alternation disabled */
@media (max-width: 768px) {
  .ip-slide { min-height: 100svh; }
  .ip-slide__inner,
  .ip-slide--mirror .ip-slide__inner {
    flex-direction: column;
    gap: 28px;
    padding: 40px 20px;
    justify-content: center;
  }
  .ip-slide__media,
  .ip-slide__text { flex: 0 0 auto; width: 100%; }
  .ip-slide__render { max-height: 42svh; }
  .ip-slide__title { font-size: 34px; }
  .ip-slide__desc { font-size: 16px; }
}
