/* Company story timeline. */

.gyla-story {
  --story-accent: var(--gyla-color-teal-strong);
  --story-line: var(--gyla-color-border-strong);
  --story-bg: #ffffff;
  padding-block: 88px;
  background: var(--story-bg);
  color: var(--gyla-color-ink);
  scroll-margin-top: 110px;
}

.gyla-story,
.gyla-story * {
  box-sizing: border-box;
}

.gyla-story__inner {
  width: min(100% - 48px, var(--gyla-container));
  margin-inline: auto;
}

.gyla-story__header {
  max-width: 720px;
  margin-bottom: 80px;
}

.gyla-story__header h2 {
  margin: 0 0 20px;
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-h2);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.gyla-story__header p {
  margin: 0;
  color: var(--gyla-color-text);
  font-size: var(--gyla-text-lead);
  line-height: 1.7;
}

.gyla-story__timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.gyla-story__step {
  position: relative;
  display: grid;
  grid-template-columns: repeat(100, minmax(0, 1fr));
  align-items: start;
  margin: 0;
  padding: 0 0 40px;
  isolation: isolate;
}

/* Text and photo columns on a 100-column grid */

.gyla-story__photo {
  grid-column: 1 / 17;
  grid-row: 1;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  border-radius: var(--gyla-radius-media);
  background: var(--gyla-color-surface-soft);
}

.gyla-story__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gyla-story__body {
  grid-column: 25 / 50;
  grid-row: 1;
  min-width: 0;
}

.gyla-story__step:nth-child(even) .gyla-story__body {
  grid-column: 57 / 82;
}

.gyla-story__step:nth-child(even) .gyla-story__photo {
  grid-column: 85 / 101;
}

.gyla-story__body .gyla-story__year {
  margin: 0 0 4px;
  color: var(--gyla-color-teal-strong);
  font-size: var(--gyla-text-caption);
  font-weight: 600;
  line-height: 1.5;
}

.gyla-story__body h3 {
  margin: 0 0 16px;
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-title-lg);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.gyla-story__body > p:not(.gyla-story__year) {
  margin: 0;
  color: var(--gyla-color-text);
  font-size: var(--gyla-text-body);
  line-height: 1.75;
}

/* Step markers */

.gyla-story__marker {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 20%;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  transform: translateX(-50%);
  border: 4px solid var(--story-bg);
  border-radius: 50%;
  background: var(--story-accent);
  color: #ffffff;
  font-size: var(--gyla-text-caption);
  font-weight: 700;
  line-height: 1;
}

.gyla-story__step:nth-child(even) .gyla-story__marker {
  left: 52%;
}

/* Connector line: up from the marker, over the text and down */

.gyla-story__step:not(:last-child)::before,
.gyla-story__step:not(:last-child)::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}

.gyla-story__step:nth-child(odd):not(:last-child)::before {
  top: -30px;
  bottom: -18px;
  left: calc(20% + 24px);
  width: calc(32% - 24px);
  border-top: 2px solid var(--story-line);
  border-right: 2px solid var(--story-line);
  border-top-right-radius: 24px;
}

.gyla-story__step:nth-child(odd):not(:last-child)::after {
  top: -30px;
  left: 20%;
  width: 24px;
  height: 48px;
  border-top: 2px solid var(--story-line);
  border-left: 2px solid var(--story-line);
  border-top-left-radius: 24px;
}

/* Line back from the right step to the left one */

.gyla-story__step:nth-child(even):not(:last-child)::before {
  top: 18px;
  bottom: 32px;
  left: calc(20% + 24px);
  width: calc(32% - 24px);
  border-right: 2px solid var(--story-line);
  border-bottom: 2px solid var(--story-line);
  border-bottom-right-radius: 24px;
}

.gyla-story__step:nth-child(even):not(:last-child)::after {
  bottom: -18px;
  left: 20%;
  width: 24px;
  height: 52px;
  border-top: 2px solid var(--story-line);
  border-left: 2px solid var(--story-line);
  border-top-left-radius: 24px;
}

/* Break between the third and fourth steps */

@media (min-width: 1025px) {
  .gyla-story__step:nth-child(3):not(:last-child)::before {
    top: 50%;
    bottom: -18px;
    left: calc(52% - 48px);
    width: 48px;
    border-top: 2px solid var(--story-line);
    border-right: 2px solid var(--story-line);
    border-top-right-radius: 24px;
  }

  .gyla-story__step:nth-child(3):not(:last-child)::after {
    display: none;
  }
}

/* Closing block with the leaf motif */

.gyla-story__closing {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  align-items: center;
  gap: 36px;
  margin-top: 64px;
  padding: 36px 120px 36px 36px;
  border-radius: 10px;
  background: var(--gyla-color-surface-mist);
}

.gyla-story__closing::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: 18px;
  bottom: -6px;
  width: 80px;
  height: 160px;
  background:
    url("../../img/lapai-apie-mus.svg")
    center bottom / contain no-repeat;
  opacity: 0.45;
  pointer-events: none;
}

.gyla-story__closing h2 {
  margin: 0;
  padding-left: 20px;
  border-left: 2px solid var(--story-accent);
  color: var(--gyla-color-ink);
  font-size: var(--gyla-text-title-lg);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.gyla-story__closing p {
  margin: 0;
  padding-left: 28px;
  border-left: 1px solid var(--gyla-color-border-strong);
  color: var(--gyla-color-text);
  font-size: var(--gyla-text-body);
  line-height: 1.75;
}

/* Tablet: straight vertical line */

@media (max-width: 1024px) {
  .gyla-story__step {
    grid-template-columns: 36px minmax(0, 1fr) 180px;
    column-gap: 24px;
    padding-bottom: 56px;
  }

  .gyla-story__step:nth-child(n):not(:last-child)::before {
    top: 18px;
    bottom: -18px;
    left: 17px;
    width: 0;
    border: 0;
    border-left: 2px solid var(--story-line);
    border-radius: 0;
  }

  .gyla-story__step:nth-child(n)::after {
    display: none;
  }

  .gyla-story__step:nth-child(n) .gyla-story__marker {
    left: 18px;
  }

  .gyla-story__step:nth-child(n) .gyla-story__body {
    grid-column: 2;
  }

  .gyla-story__step:nth-child(n) .gyla-story__photo {
    grid-column: 3;
  }

  .gyla-story__closing {
    gap: 24px;
    padding-left: 28px;
  }
}

/* Phone: text and photo next to the line */

@media (max-width: 767px) {
  .gyla-story {
    padding-block: 56px;
  }

  .gyla-story__inner {
    width: min(100% - 40px, 560px);
  }

  .gyla-story__header {
    margin-bottom: 40px;
  }

  .gyla-story__step {
    grid-template-columns: 36px minmax(0, 1fr);
    column-gap: 16px;
    row-gap: 22px;
    padding-bottom: 48px;
  }

  .gyla-story__step:nth-child(n) .gyla-story__body {
    grid-column: 2;
    grid-row: 1;
  }

  .gyla-story__step:nth-child(n) .gyla-story__photo {
    grid-column: 2;
    grid-row: 2;
    width: min(100%, 240px);
  }

  .gyla-story__body h3 {
    margin-bottom: 14px;
  }

  .gyla-story__closing {
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 40px;
    padding: 28px 24px 100px;
  }

  .gyla-story__closing p {
    padding-left: 0;
    border-left: 0;
  }

  .gyla-story__closing::after {
    right: 18px;
    width: 52px;
    height: 104px;
    opacity: 0.35;
  }
}
