.farmi-gallery-block .gallery-area {
  position: relative;
  z-index: inherit;
  padding: 120px 0;
}

/* 装饰背景 */
.farmi-gallery-block .gallery-area .fixed-shape {
  position: absolute;
  top: 0;
  right: 0;
  opacity: 0.03;
}

/* ==================================================
   画廊布局
   桌面端：4列 × 2行，共8张
   ================================================== */

.farmi-gallery-block .gallery-area .gallery-items {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
  width: 100%;
  height: auto !important;
}

/* 清除旧版卡片的尺寸、偏移和内边距 */
.farmi-gallery-block .gallery-area .gallery-items > .pf-item {
  position: relative;
  top: auto !important;
  width: auto;
  min-width: 0;
  padding: 0;
  margin: 0;
}

/* 所有卡片统一为4:3 */
.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item {
  position: relative;
  display: block;
  width: 100%;
  height: auto !important;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: #f3f3f3;
}

/* 卡片黑色遮罩 */
.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item::after {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  content: "";
  background-color: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease-in-out;
}

/* ==================================================
   图片区域
   ================================================== */

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* 图片统一铺满卡片 */
.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .thumb
  > img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
  transition: transform 0.35s ease-in-out;
}

/* ==================================================
   图片放大按钮
   ================================================== */

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .thumb
  > a.popup-gallery {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;

  display: flex;
  align-items: center;
  justify-content: center;

  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;

  color: #000;
  background-color: var(--color-primary);
  text-align: center;
  line-height: 60px;
  text-decoration: none;

  opacity: 0;
  transform: translate(-50%, -30%);
  transition:
    opacity 0.35s ease-in-out,
    transform 0.35s ease-in-out,
    background-color 0.35s ease-in-out;
}

/* 防止链接上的item类生成额外遮罩 */
.farmi-gallery-block
  .gallery-area
  .gallery-items
  .thumb
  > a.popup-gallery::after {
  display: none;
  content: none;
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  .thumb
  > a.popup-gallery
  .iconfont {
  color: #000;
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  .thumb
  > a.popup-gallery:hover {
  background-color: var(--btn-hover);
}

/* ==================================================
   标题区域
   ================================================== */

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .info {
  position: absolute;
  right: 0;
  bottom: -25px;
  left: 0;
  z-index: 2;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 20px;
  text-align: center;
  opacity: 0;
  transition:
    bottom 0.35s ease-in-out,
    opacity 0.35s ease-in-out;
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .info
  h4 {
  margin: 0;
  padding: 0;
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .info
  h4
  a {
  display: block;
  color: #fff;
  text-decoration: none;
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .info
  .a-text {
  display: block;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
}

/* 隐藏标题下面原有的固定装饰图片 */
.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item
  > .info
  .image {
  display: none;
}

/* ==================================================
   鼠标悬停效果
   ================================================== */

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item:hover::after {
  opacity: 0.6;
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item:hover
  > .thumb
  > img {
  transform: scale(1.08);
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item:hover
  > .thumb
  > a.popup-gallery {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.farmi-gallery-block
  .gallery-area
  .gallery-items
  > .pf-item
  > .item:hover
  > .info {
  bottom: 0;
  opacity: 1;
}

/* ==================================================
   标题区域（组件原有样式）
   ================================================== */

.farmi-gallery-block .gallery-area .site-heading {
  margin-top: -5px;
  margin-bottom: 60px;
}

.farmi-gallery-block .gallery-area .site-heading h2 {
  position: relative;
  display: block;
  margin-bottom: 0;
  padding-bottom: 20px;
  font-size: 40px;
  font-weight: 600;
  line-height: 1.4;
}

.farmi-gallery-block .gallery-area .site-heading h2::before {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 40px;
  height: 2px;
  margin-left: -25px;
  content: "";
  background: var(--color-primary);
}

.farmi-gallery-block .gallery-area .site-heading h2::after {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 5px;
  height: 2px;
  margin-left: 20px;
  content: "";
  background: var(--color-primary);
}

.farmi-gallery-block .gallery-area .site-heading h4 {
  position: relative;
  display: inline-block;
  overflow: visible;
  color: var(--text-color);
  font-size: 20px;
  font-weight: 600;
  text-transform: uppercase;
}

/* ==================================================
   平板：2列
   ================================================== */

@media (max-width: 991px) {
  .farmi-gallery-block .gallery-area {
    padding: 60px 0;
  }

  .farmi-gallery-block .gallery-area .gallery-items {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
  }
}

/* ==================================================
   手机：1列
   ================================================== */

@media (max-width: 575px) {
  .farmi-gallery-block .gallery-area {
    padding: 30px 0;
  }

  .farmi-gallery-block .gallery-area .gallery-items {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .farmi-gallery-block
    .gallery-area
    .gallery-items
    > .pf-item
    > .item
    > .info
    .a-text {
    font-size: 18px;
  }

  .farmi-gallery-block
    .gallery-area
    .gallery-items
    > .pf-item
    > .item
    > .thumb
    > a.popup-gallery {
    width: 50px;
    height: 50px;
    line-height: 50px;
  }

  .farmi-gallery-block .gallery-area .site-heading {
    margin-bottom: 35px;
  }

  .farmi-gallery-block .gallery-area .site-heading h2 {
    font-size: 30px;
  }
}