.has-open-modal {
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.carousel-group + .carousel-group {
  margin-top: 2.2rem;
}

.carousel-group-title {
  margin: 0 0 0.2rem;
  color: #17202a;
  font-family: 'Google Sans', sans-serif;
  font-size: 1.25rem;
  text-align: center;
}

.result-carousel {
  display: grid;
  grid-template-columns: 2.8rem minmax(0, 1fr) 2.8rem;
  align-items: center;
  gap: 0.4rem;
  max-width: 880px;
  margin: 0.6rem auto 0;
}

.result-carousel[aria-label="Deformation fields carousel"] { max-width: 760px; }

.carousel-viewport {
  display: grid;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  overflow: hidden;
  padding: 0.3rem 0 1rem;
}

 .carousel-slide {
  grid-area: 1 / 1;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  visibility: hidden;
  pointer-events: none;
}

.result-carousel .carousel-slide.is-active {
  visibility: visible;
  pointer-events: auto;
}

.carousel-image-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 240px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #ffffff;
  cursor: zoom-in;
}

.carousel-image-button:focus-visible,
.carousel-nav:focus-visible {
  outline: 3px solid rgba(15, 111, 106, 0.45);
  outline-offset: 3px;
}

.carousel-slide img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 500px;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  object-fit: contain;
}

.deformation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  align-items: end;
  justify-content: center;
  justify-items: center;
  column-gap: 0.85rem;
  row-gap: 0.4rem;
  width: 100%;
  min-width: 0;
  max-width: 660px;
  margin: 0 auto;
}

.deformation-row .carousel-image-button {
  width: 100%;
  min-width: 0;
  min-height: 0;
  flex: 0 1 auto;
  background: transparent;
}

.deformation-row img {
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
}

.deformation-key {
  align-self: center;
}

.deformation-key img {
  max-height: 140px;
  max-width: 120px;
}

.deformation-source img {
  max-height: 240px;
  max-width: min(100%, 240px);
}

.deformation-gif {
  width: 100%;
}

.deformation-gif img {
  width: 100%;
  height: auto;
  max-height: none;
  max-width: 100%;
}

.deformation-label,
.deformation-gif-labels {
  color: #17202a;
  font-family: 'Google Sans', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.deformation-gif-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 100%;
}

 .field-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  max-width: 560px;
  margin: 1.2rem auto 0;
  padding: 0.8rem 1rem;
  border: 1px solid #e1e7e5;
  border-radius: 10px;
  background: #f8fbfa;
}
.field-legend img { width: 74px; height: auto; flex-shrink: 0; }
.field-legend h4 { margin: 0 0 0.2rem; color: #17202a; font-weight: 700; }
.field-legend p { margin: 0; color: #516070; font-size: 0.9rem; line-height: 1.5; }

.deformation-note,
.carousel-note {
  max-width: 820px;
  margin: 0.45rem auto 0;
  color: #3d4856;
  font-size: 1.02rem;
  line-height: 1.65;
  text-align: center;
}

.carousel-slide figcaption {
  margin-top: 0.6rem;
  color: #5d6977;
  font-size: 0.92rem;
  line-height: 1.5;
  text-align: center;
}

.carousel-nav {
  display: inline-flex;
  grid-row: 1;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid #d8e2df;
  border-radius: 50%;
  color: #0f4f4b;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(24, 33, 43, 0.12);
  cursor: pointer;
  font-size: 1rem;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.carousel-nav:hover {
  color: #ffffff;
  background: #0f6f6a;
  transform: translateY(-1px);
}

.carousel-nav-prev {
  grid-column: 1;
  justify-self: end;
}

.carousel-nav-next {
  grid-column: 3;
  justify-self: start;
}

.carousel-dots {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 2;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.45rem;
  width: 100%;
  margin: 0.15rem auto 0;
  padding: 0.2rem 0.1rem;
}

.carousel-dot {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #c5d0d4;
  cursor: pointer;
}

.carousel-dot.is-active {
  background: #0f6f6a;
  transform: scale(1.2);
}

.image-modal[hidden] {
  display: none;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: rgba(10, 18, 26, 0.88);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: #17202a;
  background: #ffffff;
  cursor: pointer;
}

.modal-figure {
  max-width: min(96vw, 1800px);
  max-height: 92vh;
  margin: 0;
}

.modal-figure img {
  display: block;
  max-width: 100%;
  max-height: 84vh;
  margin: 0 auto;
  border-radius: 8px;
  background: #ffffff;
  object-fit: contain;
}

.modal-figure figcaption {
  max-width: 900px;
  margin: 0.75rem auto 0;
  color: #ffffff;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .carousel-slide,
  .carousel-nav {
    transition: none;
  }
}

@media (max-width: 520px) {
  .result-carousel {
    grid-template-columns: 2rem minmax(0, 1fr) 2rem;
    gap: 0.2rem;
  }

  .carousel-nav {
    width: 2rem;
    height: 2rem;
    font-size: 1rem;
  }

  .deformation-row { column-gap: 0.35rem; }

  .deformation-label,
  .deformation-gif-labels { font-size: 0.7rem; }

  .image-modal {
    padding: 0.9rem;
  }

  .modal-close {
    top: 0.6rem;
    right: 0.6rem;
  }
}
