.cw-gallery {
  background: var(--cw-color-surface);
  color: var(--cw-text);
  font-family: var(--font-body);
}

.cw-gallery-hero {
  position: relative;
  min-height: 590px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--cw-color-surface-cinder-soft);
}

.cw-gallery-hero__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cw-gallery-hero__inner {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - 48px));
  text-align: center;
}

.cw-gallery-hero h1 {
  margin: 0;
  color: var(--cw-white);
  font-family: var(--font-heading);
  font-size: 62px;
  font-weight: 400;
  line-height: 1;
}

.cw-gallery-intro {
  padding: 80px 0 54px;
  color: var(--cw-color-text);
  font-size: 18px;
  line-height: 1.55;
}

.cw-gallery-intro p {
  max-width: 1220px;
  margin: 0 0 28px;
}

.cw-gallery-categories {
  display: grid;
  gap: 46px;
  padding-bottom: 94px;
}

.cw-gallery-category {
  display: grid;
  grid-template-columns: minmax(260px, 0.84fr) minmax(0, 1.6fr);
  gap: 54px;
  align-items: center;
  min-height: 520px;
  background: var(--category-bg);
  padding: 44px;
}

.cw-gallery-category.is-reversed {
  grid-template-columns: minmax(0, 1.55fr) minmax(260px, 0.85fr);
}

.cw-gallery-category.is-reversed .cw-gallery-category__text {
  order: 2;
}

.cw-gallery-category.is-reversed .cw-gallery-category__media {
  order: 1;
}

.cw-gallery-category__text h2 {
  margin: 0 0 28px;
  color: var(--cw-green-primary);
  font-family: var(--font-body);
  font-size: 36px;
  font-weight: 400;
  line-height: 1.1;
}

.cw-gallery-category__text {
  padding: 0 8px;
}

.cw-gallery-category__text p {
  margin: 0 0 28px;
  font-size: 16px;
  line-height: 1.45;
}

.cw-gallery-category__text a,
.cw-gallery-detail__back a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 194px;
  min-height: 48px;
  background: var(--cw-color-action);
  color: var(--cw-white);
  text-decoration: none;
  font-size: 16px;
  line-height: 1;
}

.cw-gallery-category__image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10.8;
  object-fit: cover;
}

.cw-gallery-detail {
  padding-top: 63px;
}

.cw-gallery-detail__header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 48px;
  margin-bottom: 56px;
}

.cw-gallery-detail__header h1 {
  margin: 28px 0 0;
  color: var(--cw-green-primary);
  font-family: var(--font-body);
  font-size: 52px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: 0;
}

.cw-gallery-filter {
  position: relative;
  flex: 0 0 240px;
  margin-top: 16px;
  color: #4f4f4f;
  font-size: 16px;
  line-height: 1.2;
}

.cw-gallery-filter__toggle {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 40px;
  border: 1.5px solid #939393;
  border-radius: 21px;
  padding: 5px 18px 5px 28px;
  background: var(--cw-color-surface);
  color: inherit;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.cw-gallery-filter__toggle:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--cw-green-primary) 45%, transparent);
  outline-offset: 3px;
}

.cw-gallery-filter__chevron {
  width: 12px;
  height: 12px;
  border-right: 1.5px solid var(--cw-green-primary);
  border-bottom: 1.5px solid var(--cw-green-primary);
  transform: translateY(-3px) rotate(45deg);
  transition: transform 180ms ease;
}

.cw-gallery-filter.is-open .cw-gallery-filter__chevron {
  transform: translateY(3px) rotate(225deg);
}

.cw-gallery-filter__options {
  position: absolute;
  top: 20px;
  left: 0;
  width: 100%;
  border-radius: 0 0 21px 21px;
  padding: 32px 16px 14px;
  background: #f1f1f1;
  box-shadow: 0 10px 22px rgb(0 0 0 / 8%);
}

.cw-gallery-filter__options[hidden] {
  display: none;
}

.cw-gallery-filter__options fieldset {
  display: grid;
  gap: 4px;
  border: 0;
  margin: 0;
  padding: 0;
}

.cw-gallery-filter__options label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

.cw-gallery-filter__options input {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--cw-green-primary);
}

.cw-gallery-filter-status {
  min-height: 28px;
  margin-top: -34px;
  margin-bottom: 6px;
  color: var(--cw-dark-moss);
  font-size: 15px;
}

@media (min-width: 1601px) {
  .cw-gallery-filter,
  .cw-gallery-filter__toggle {
    font-size: 18px;
  }
}

.cw-gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 62px 64px;
  transition: opacity 160ms ease;
}

.cw-gallery-grid.is-loading {
  opacity: 0.42;
  pointer-events: none;
}

.cw-gallery-grid__empty {
  grid-column: 1 / -1;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--cw-dark-moss);
  font-size: 20px;
}

.cw-gallery-card__button {
  display: block;
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.cw-gallery-card__button:focus {
  outline: 3px solid var(--cw-dark-evergreen);
  outline-offset: 5px;
}

.cw-gallery-card__image {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.cw-gallery-card__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  border: 0;
  padding-top: 24px;
  padding-right: 0;
  padding-bottom: 0;
  padding-left: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.cw-gallery-card__meta:focus-visible {
  outline: 3px solid var(--cw-dark-evergreen);
  outline-offset: 5px;
}

.cw-gallery-card__title {
  display: block;
  width: 100%;
  margin: 0;
  color: var(--cw-dark-moss);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.cw-gallery-card__species {
  display: block;
  width: 100%;
  color: var(--cw-green-primary);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
}

.cw-gallery-detail__back {
  display: flex;
  justify-content: center;
  padding: 86px 0 118px;
}

.cw-gallery-detail__back a {
  min-width: 300px;
  min-height: 70px;
  font-size: 24px;
}

.cw-gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  background: var(--cw-color-surface);
}

.cw-gallery-modal.is-open {
  display: block;
}

.cw-gallery-modal__inner {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 100vh;
  padding: 88px 92px 72px;
}

.cw-gallery-modal__count {
  position: absolute;
  top: 16px;
  left: 28px;
  color: var(--cw-dark-moss);
  font-size: 18px;
  font-weight: 700;
}

.cw-gallery-modal__close {
  position: absolute;
  top: 30px;
  right: 38px;
  width: 51px;
  height: 51px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.cw-gallery-modal__close::before,
.cw-gallery-modal__close::after {
  content: "";
  position: absolute;
  top: 25px;
  left: 5px;
  width: 45px;
  height: 2px;
  background: var(--cw-dark-moss);
}

.cw-gallery-modal__close::before {
  transform: rotate(45deg);
}

.cw-gallery-modal__close::after {
  transform: rotate(-45deg);
}

.cw-gallery-modal__content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 58px;
  align-items: center;
  width: min(1660px, calc(100vw - 260px));
  margin: 0 auto;
}

.cw-gallery-modal__media {
  display: flex;
  align-items: center;
  justify-content: center;
  height: min(74vh, 780px);
  min-height: 420px;
}

.cw-gallery-modal__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.cw-gallery-modal__species {
  margin-bottom: 18px;
  color: var(--cw-green-primary);
  font-size: 18px;
  font-weight: 700;
}

.cw-gallery-modal__text h2 {
  margin: 0 0 40px;
  color: var(--cw-color-text);
  font-size: 26px;
  line-height: 1.2;
}

.cw-gallery-modal__text {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding-right: 8px;
}

.cw-gallery-modal__text p {
  margin: 0;
  color: var(--cw-text);
  font-size: 22px;
  line-height: 1.22;
}

.cw-gallery-modal__facts {
  display: grid;
  gap: 9px;
  margin: 0 0 28px;
}

.cw-gallery-modal__facts > div {
  display: grid;
  grid-template-columns: 142px minmax(0, 1fr);
  gap: 12px;
}

.cw-gallery-modal__facts > div[hidden] {
  display: none;
}

.cw-gallery-modal__facts dt,
.cw-gallery-modal__facts dd {
  margin: 0;
  color: var(--cw-color-text);
  font-size: 16px;
  line-height: 1.35;
}

.cw-gallery-modal__facts dt {
  font-weight: 700;
}

.cw-gallery-modal__description p {
  font-size: 17px;
  line-height: 1.4;
  white-space: pre-line;
}

.cw-gallery-modal__arrow {
  position: absolute;
  top: 52%;
  width: 42px;
  height: 66px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translateY(-50%);
}

.cw-gallery-modal__arrow::before,
.cw-gallery-modal__arrow::after {
  content: "";
  position: absolute;
  top: 16px;
  width: 34px;
  height: 34px;
  border-top: 2px solid var(--cw-dark-moss);
  border-right: 2px solid var(--cw-dark-moss);
}

.cw-gallery-modal__arrow--prev {
  left: 34px;
}

.cw-gallery-modal__arrow--prev::before {
  left: 12px;
  transform: rotate(-135deg);
}

.cw-gallery-modal__arrow--prev::after {
  display: none;
}

.cw-gallery-modal__arrow--next {
  right: 34px;
}

.cw-gallery-modal__arrow--next::before {
  right: 12px;
  transform: rotate(45deg);
}

.cw-gallery-modal__arrow--next::after {
  display: none;
}

body.cw-gallery-modal-open {
  overflow: hidden;
}

@media (max-width: 1180px) {
  .cw-gallery-grid {
    gap: 42px 34px;
  }

  .cw-gallery-modal__inner {
    padding: 96px 72px 72px;
  }

  .cw-gallery-modal__content {
    width: min(100%, calc(100vw - 180px));
    gap: 36px;
  }

  .cw-gallery-modal__media {
    height: min(66vh, 680px);
  }
}

@media (max-width: 900px) {
  .cw-gallery-modal__inner {
    padding-right: 32px;
    padding-left: 32px;
  }

  .cw-gallery-modal__content {
    width: 100%;
  }

  .cw-gallery-hero {
    min-height: 360px;
  }

  .cw-gallery-category,
  .cw-gallery-category.is-reversed {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .cw-gallery-category.is-reversed .cw-gallery-category__text,
  .cw-gallery-category.is-reversed .cw-gallery-category__media {
    order: initial;
  }

  .cw-gallery-detail {
    padding-top: 36px;
  }

  .cw-gallery-detail__header {
    align-items: stretch;
    flex-direction: column;
    gap: 26px;
    margin-bottom: 38px;
  }

  .cw-gallery-filter {
    flex-basis: auto;
    width: min(240px, 100%);
    margin-top: 0;
  }

  .cw-gallery-filter-status {
    margin-top: -20px;
  }

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

  .cw-gallery-modal__content {
    grid-template-columns: 1fr;
    gap: 24px;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
  }

  .cw-gallery-modal__media {
    height: min(54vh, 520px);
    min-height: 300px;
  }

  .cw-gallery-modal__text p {
    font-size: 20px;
  }

  .cw-gallery-modal__text {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }
}

@media (max-width: 560px) {
  .cw-gallery-hero {
    min-height: 280px;
  }

  .cw-gallery-hero h1 {
    font-size: 40px;
  }

  .cw-gallery-intro {
    padding: 42px 0 28px;
  }

  .cw-gallery-category {
    padding: 24px;
  }

  .cw-gallery-grid {
    grid-template-columns: 1fr;
  }

  .cw-gallery-filter {
    width: 100%;
  }

  .cw-gallery-filter__toggle {
    min-height: 40px;
    padding-left: 24px;
    font-size: 16px;
  }

  .cw-gallery-card__meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .cw-gallery-modal__inner {
    padding: 86px 20px 64px;
  }

  .cw-gallery-modal__close {
    top: 24px;
    right: 22px;
  }

  .cw-gallery-modal__arrow {
    top: auto;
    bottom: 18px;
  }

  .cw-gallery-modal__arrow--prev {
    left: 24px;
  }

  .cw-gallery-modal__arrow--next {
    right: 24px;
  }
}
