/* ============================================================
   DG Elemento Addons · Stage Rail

   The --dgsr-* defaults below are declared on .dgsr itself, so any
   Elementor control that overrides one has to target
   "{{WRAPPER}} .dgsr". Targeting "{{WRAPPER}}" alone sets it on an
   ancestor, and the local declaration here wins over it.

   Ported from irrigation-water-management-v13.html (.stages)
   Prefix .dgsr kept from v1.0.0 so existing pages keep working.
   Values sit on custom properties so the Elementor style controls
   override them without a specificity fight.
   ============================================================ */

.dgsr {
  --dgsr-deep: #0B3A19;
  --dgsr-gold: #BC864D;
  --dgsr-gold-mute: #D2B764;
  --dgsr-body: #4B504D;

  --dgsr-serif: 'Cormorant Garamond', Georgia, serif;
  --dgsr-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --dgsr-mark: 52px;
  --dgsr-mark-bg: var(--dgsr-deep);
  --dgsr-mark-ico: var(--dgsr-gold-mute);
  --dgsr-mark-radius: 0px;
  --dgsr-ico: 24px;
  --dgsr-line: var(--dgsr-gold);
  --dgsr-gap: 24px;

  /* carousel */
  --dgsr-slide: 78%;
  --dgsr-bleed: 22px;
  --dgsr-dot: rgba(11, 58, 25, 0.22);
  --dgsr-dot-on: var(--dgsr-gold);

  font-family: var(--dgsr-sans);
  color: var(--dgsr-body);

  /* Never wider than the parent, and never wider than the screen even when
     the parent has no width of its own to constrain us (a row container, a
     fixed px content width, a float). Without this the text has nothing to
     wrap against and runs straight off the side. */
  max-width: min(100%, 100vw);
  min-width: 0;
}

/* Belt and braces: nothing escapes sideways. Skipped when the carousel is
   bleeding to the screen edge, which needs to overflow on purpose. */
.dgsr:not(.dgsr--bleed) {
  overflow-x: clip;
}

/* Same constraint one level up, scoped to this widget only, in case the
   Elementor wrapper is the thing sizing to content. */
.elementor-widget-dg_stage_rail,
.elementor-widget-dg_stage_rail > .elementor-widget-container {
  min-width: 0;
  max-width: 100%;
}

/* Nothing in here may push the page sideways. */
.dgsr *,
.dgsr *::before,
.dgsr *::after {
  box-sizing: border-box;
}

/* ---------- header ---------- */
.dgsr__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 60px;
  align-items: start;
  margin-bottom: 60px;
}

.dgsr--head-stacked .dgsr__head {
  grid-template-columns: minmax(0, 1fr);
}

.dgsr__head-main,
.dgsr__head-aside {
  min-width: 0;
}

/* Themes and page builders set nowrap in places. Undo it for our text. */
.dgsr__heading,
.dgsr__intro,
.dgsr__title,
.dgsr__text,
.dgsr__eyebrow,
.dgsr__tag {
  white-space: normal;
  overflow-wrap: break-word;
}

.dgsr__eyebrow {
  display: block;
  margin-bottom: 16px;
  font-family: var(--dgsr-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.4;
  color: var(--dgsr-gold);
}

.dgsr__heading {
  margin: 0;
  overflow-wrap: break-word;
  font-family: var(--dgsr-serif);
  font-size: clamp(1.9rem, 3.4vw, 2.8rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--dgsr-deep);
}

.dgsr__intro {
  margin: 0;
  overflow-wrap: break-word;
  max-width: 58ch;
  font-size: 1.125rem;
  line-height: 1.7;
}

.dgsr--head-stacked .dgsr__intro {
  margin-top: 24px;
}

/* ---------- rail ---------- */
.dgsr__rail {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--dgsr-gap);
  max-width: 100%;
  /* The connector on the last item of a row sticks out by one gap.
     Clip it rather than let it widen the page. Carousel mode below
     replaces this with overflow-x: auto. */
  overflow-x: clip;
}

.dgsr__step {
  position: relative;
  min-width: 0;
}

.dgsr__step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: calc(var(--dgsr-mark) / 2);
  left: calc(var(--dgsr-mark) + 10px);
  right: calc(var(--dgsr-gap) * -1);
  height: 1px;
  background: repeating-linear-gradient(
    to right,
    var(--dgsr-line) 0 8px,
    transparent 8px 16px
  );
}

.dgsr__mark {
  position: relative;
  z-index: 2;
  width: var(--dgsr-mark);
  height: var(--dgsr-mark);
  border-radius: var(--dgsr-mark-radius);
  background: var(--dgsr-mark-bg);
  color: var(--dgsr-mark-ico);
  display: grid;
  place-items: center;
  margin-bottom: 24px;
}

.dgsr__mark:empty {
  display: none;
}

.dgsr__ico {
  width: var(--dgsr-ico);
  height: var(--dgsr-ico);
  stroke: currentColor;
  fill: none;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* Elementor icon-picker output (font icon or uploaded SVG) */
.dgsr__mark i {
  font-size: var(--dgsr-ico);
  line-height: 1;
}

.dgsr__mark svg:not(.dgsr__ico) {
  width: var(--dgsr-ico);
  height: var(--dgsr-ico);
  fill: currentColor;
  display: block;
}

.dgsr__tag {
  display: block;
  margin-bottom: 6px;
  font-family: var(--dgsr-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  line-height: 1.4;
  color: var(--dgsr-gold);
}

.dgsr__title {
  margin: 0 0 6px;
  overflow-wrap: break-word;
  font-family: var(--dgsr-serif);
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--dgsr-deep);
}

.dgsr__title a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.dgsr__title a:hover,
.dgsr__title a:focus-visible {
  border-bottom-color: var(--dgsr-gold);
}

.dgsr__text {
  margin: 0;
  overflow-wrap: break-word;
  font-size: 0.9375rem;
  line-height: 1.58;
}

.dgsr :focus-visible {
  outline: 2px solid var(--dgsr-gold);
  outline-offset: 3px;
}

/* ---------- dots ---------- */
.dgsr__dots {
  display: none;
  gap: 8px;
  align-items: center;
  margin-top: 28px;
}

.dgsr__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--dgsr-dot);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.dgsr__dot.is-active {
  background: var(--dgsr-dot-on);
  transform: scale(1.35);
}

/* ---------- carousel ----------
   Native scroll-snap, no slider library. The two blocks below are the
   same rules at two breakpoints, switched by the wrapper class. */
@media (max-width: 767px) {
  .dgsr--carousel-mobile .dgsr__rail {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .dgsr--carousel-mobile .dgsr__rail::-webkit-scrollbar {
    display: none;
  }
  .dgsr--carousel-mobile .dgsr__step {
    flex: 0 0 var(--dgsr-slide);
    scroll-snap-align: start;
  }
  .dgsr--carousel-mobile.dgsr--bleed .dgsr__rail {
    margin-left: calc(var(--dgsr-bleed) * -1);
    margin-right: calc(var(--dgsr-bleed) * -1);
    padding-left: var(--dgsr-bleed);
    padding-right: var(--dgsr-bleed);
    scroll-padding-left: var(--dgsr-bleed);
  }
  .dgsr--carousel-mobile .dgsr__dots {
    display: flex;
  }
}

@media (max-width: 1024px) {
  .dgsr--carousel-tablet .dgsr__rail {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .dgsr--carousel-tablet .dgsr__rail::-webkit-scrollbar {
    display: none;
  }
  .dgsr--carousel-tablet .dgsr__step {
    flex: 0 0 var(--dgsr-slide);
    scroll-snap-align: start;
  }
  .dgsr--carousel-tablet.dgsr--bleed .dgsr__rail {
    margin-left: calc(var(--dgsr-bleed) * -1);
    margin-right: calc(var(--dgsr-bleed) * -1);
    padding-left: var(--dgsr-bleed);
    padding-right: var(--dgsr-bleed);
    scroll-padding-left: var(--dgsr-bleed);
  }
  .dgsr--carousel-tablet .dgsr__dots {
    display: flex;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dgsr__rail {
    scroll-behavior: auto;
  }
  .dgsr__dot {
    transition: none;
  }
}

/* ---------- fallbacks for themes without Elementor breakpoints set ---------- */
@media (max-width: 1024px) {
  .dgsr__head {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }
}

@media (max-width: 767px) {
  .dgsr__mark {
    margin-bottom: 16px;
  }
}
