/* Gallery page */
.page-gallery {
  background-color: var(--bg);
  background-image: url("../assets/bg-texture-large.jpg");
  background-size: cover;
  background-attachment: scroll;
}

.page-gallery .footer-grid::before {
  background-image: url("../assets/contact/footer-bg.jpg");
}

/* Hero — match faq-hero sizing & background */
.gallery-hero {
  position: relative;
  padding: 0.5rem 0 40px;
  text-align: center;
  overflow: visible;
}

.gallery-hero-inner {
  position: relative;
  z-index: 1;
}

.gallery-hero-tree {
  position: absolute;
  inset: -1.5rem 0 -2rem;
  z-index: 0;
  background: url("../assets/services/waist-tree.jpg") calc(50% + 5rem) calc(50% + 3rem) / min(792px, 101.2%) auto no-repeat;
  opacity: 0.42;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(
    ellipse 70% 72% at calc(50% + 5rem) calc(48% + 3rem),
    #000 20%,
    transparent 78%
  );
  mask-image: radial-gradient(
    ellipse 70% 72% at calc(50% + 5rem) calc(48% + 3rem),
    #000 20%,
    transparent 78%
  );
}

.gallery-hero-inner > *:not(.gallery-hero-tree) {
  position: relative;
  z-index: 1;
}

.gallery-hero h1 {
  font-family: var(--font-brand);
  font-size: clamp(2.35rem, 5.5vw, 3.35rem);
  font-weight: 500;
  margin: 50px 0 0.5rem;
}

.gallery-hero .deco-line {
  width: 200px;
  margin: 0 auto 0.85rem;
}

.gallery-hero-sub {
  margin: 0 auto;
  max-width: 640px;
  color: #4b4b4b;
  font-size: 15px;
  line-height: 1.55;
}

/* Main layout — waist background band (matches FAQ) */
.gallery-main {
  position: relative;
  overflow: hidden;
  padding: 2rem 0 4rem;
  background-color: var(--paper);
}

.gallery-main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/home/bg-waist.png") center top / 100% auto repeat-y;
  pointer-events: none;
  z-index: 0;
}

.gallery-main > .wrap {
  position: relative;
  z-index: 1;
}

.gallery-layout {
  display: grid;
  grid-template-columns: minmax(0, 240px) minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

/* Sidebar */
.gallery-sidebar {
  align-self: start;
  padding-right: 2rem;
  border-right: 1px solid rgba(176, 164, 149, 0.45);
}

.gallery-filter-block + .gallery-filter-block {
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(87, 64, 40, 0.18);
}

.gallery-filter-heading {
  margin: 0 0 0.85rem;
  font-family: var(--font-brand);
  font-size: 0.95rem;
  font-weight: 700;
  color: #574028;
}

.gallery-brand-list,
.gallery-area-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.gallery-brand-list label,
.gallery-area-list label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-brand);
  font-size: 0.88rem;
  color: #574028;
  cursor: pointer;
  line-height: 1.35;
}

.gallery-brand-list input,
.gallery-area-list input {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
  cursor: pointer;
}

.gallery-brand-count,
.gallery-area-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: #8a7a68;
}

.gallery-area-list label img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}

.gallery-area-list label span.area-label {
  flex: 1;
}

/* Help CTA */
.gallery-help {
  margin-top: 1.75rem;
  padding: 1.25rem 1rem;
  border: 1px solid rgba(176, 164, 149, 0.55);
  border-radius: 4px;
  background: #f1ebe3;
  text-align: center;
}

.gallery-help-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.65rem;
}

.gallery-help-icon img {
  display: block;
  width: 36px;
  height: 36px;
}

.gallery-help h2 {
  margin: 0 0 0.5rem;
  font-family: var(--font-brand);
  font-size: 0.95rem;
  font-weight: 700;
  color: #574028;
  line-height: 1.35;
}

.gallery-help p {
  margin: 0 0 0.85rem;
  font-family: var(--font-brand);
  font-size: 0.82rem;
  line-height: 1.5;
  color: #574028;
}

.gallery-help-cta {
  font-size: 0.85rem;
  padding: 0.45rem 1.1rem;
}

.gallery-disclaimer {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 1.5rem 0 0;
  text-align: center;
}

.gallery-disclaimer-icon {
  display: block;
  width: 40px;
  height: 45px;
  margin: 0 auto 0.65rem;
  opacity: 0.85;
}

.gallery-disclaimer p {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 0.72rem;
  line-height: 1.5;
  color: #574028;
}

/* Main content */
.gallery-content {
  min-width: 0;
  align-self: start;
  padding-left: 2rem;
  margin-top: 0;
}

.gallery-damage-bar {
  margin-bottom: 1.25rem;
}

.gallery-damage-heading {
  margin: 0 0 0.65rem;
  font-family: var(--font-brand);
  font-size: 0.95rem;
  font-weight: 700;
  color: #574028;
}

.gallery-damage-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.gallery-damage-pill {
  border: 1px solid rgba(176, 164, 149, 0.45);
  background: #e8dfd0;
  color: #574028;
  padding: 0.42rem 0.9rem;
  border-radius: 4px;
  font-family: var(--font-brand);
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.gallery-damage-pill:hover {
  background: #ddd2c0;
  border-color: rgba(176, 164, 149, 0.55);
}

.gallery-damage-pill.is-active {
  background: #574028;
  color: #fff;
  border-color: #574028;
}

/* Results grid — 6 cols: vertical span 2, horizontal span 3 */
.gallery-results-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1rem;
  align-items: start;
}

.gallery-card {
  border: 2px solid rgba(87, 64, 40, 0.4);
  border-radius: 8px;
  background: #fff;
  padding: 0.35rem;
  overflow: hidden;
  height: 420px;
}

.gallery-card.layout-vertical {
  grid-column: span 2;
}

.gallery-card.layout-horizontal {
  grid-column: span 3;
}

.gallery-card-images {
  display: grid;
  gap: 0.4rem;
  align-items: start;
  cursor: zoom-in;
}

.gallery-card-images:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gallery-card-images.layout-vertical {
  grid-template-columns: 1fr 1fr;
}

.gallery-card-images.layout-horizontal {
  grid-template-columns: 1fr;
}

.gallery-shot {
  display: flex;
  margin: 0;
  min-width: 0;
  background: #f5f2ec;
}

.gallery-card-images.layout-vertical .gallery-shot {
  flex-direction: column;
}

.gallery-card-images.layout-vertical .gallery-shot img {
  width: 100%;
  aspect-ratio: 195 / 445;
  height: auto;
  flex: none;
  object-fit: cover;
  object-position: center;
}

.gallery-card-images.layout-horizontal .gallery-shot {
  flex-direction: row-reverse;
  align-items: stretch;
}

.gallery-shot img {
  display: block;
  width: 100%;
  height: auto;
  flex: 1;
  min-width: 0;
  object-fit: cover;
}

.gallery-shot-label {
  margin: 0;
  font-family: var(--font-brand);
  font-style: italic;
  font-size: clamp(0.72rem, 1.6vw, 0.84rem);
  font-weight: 500;
  line-height: 1.2;
  flex-shrink: 0;
}

/* Side-by-side images — horizontal label bars below */
.gallery-card-images.layout-vertical .gallery-shot-label {
  min-height: 2.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  text-align: center;
}

.gallery-card-images.layout-vertical .gallery-shot-label--before {
  background: #333332;
  color: #fff;
}

.gallery-card-images.layout-vertical .gallery-shot-label--after {
  background: #c8b29a;
  color: #333332;
  clip-path: polygon(
    0 0,
    0 28%,
    0.5rem 50%,
    0 72%,
    0 100%,
    100% 100%,
    100% 0
  );
}

/* Stacked images — vertical label bars on the left */
.gallery-card-images.layout-horizontal .gallery-shot-label {
  width: 2.35rem;
  min-width: 2.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.3rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  text-align: center;
}

.gallery-card-images.layout-horizontal .gallery-shot-label--before {
  background: #333332;
  color: #fff;
}

.gallery-card-images.layout-horizontal .gallery-shot-label--after {
  background: #c8b29a;
  color: #333332;
  clip-path: polygon(
    0 0,
    28% 0,
    50% 0.5rem,
    72% 0,
    100% 0,
    100% 100%,
    0 100%
  );
}

.gallery-card-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 12px;
  margin-left: 10px;
  height: 55px;
  padding: 0.1rem 0 0;
}

.gallery-card-logo {
  width: 45px;
  height: 45px;
  object-fit: contain;
  flex-shrink: 0;
}

.gallery-card-text {
  min-width: 0;
  line-height: 1.35;
}

.gallery-card-vehicle {
  display: block;
  margin-left: 5px;
  font-family: var(--font-brand);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

.gallery-card-title {
  display: block;
  margin-left: 5px;
  font-family: var(--font-brand);
  font-size: 0.82rem;
  font-style: italic;
  color: var(--ink);
  white-space: pre-line;
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: 2.5rem 1rem;
  text-align: center;
  font-family: var(--font-brand);
  color: #574028;
}

/* Pagination */
.gallery-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 1.75rem;
}

.gallery-page-btn {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  font-family: var(--font-brand);
  font-size: 0.82rem;
  color: #574028;
  cursor: pointer;
}

.gallery-page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.gallery-page-btn.is-active {
  background: #e8e0d4;
  border-color: #b8a898;
  font-weight: 700;
}

.gallery-page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.gallery-page-ellipsis {
  padding: 0 0.25rem;
  font-family: var(--font-brand);
  font-size: 0.82rem;
  color: #8a7a68;
}

/* Responsive */
@media (max-width: 960px) {
  .gallery-layout {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .gallery-sidebar {
    padding-right: 0;
    border-right: none;
  }

  .gallery-content {
    padding-left: 0;
  }

  /* 品牌筛选：三列 */
  .gallery-brand-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem 0.5rem;
  }

  .gallery-brand-list label {
    font-size: clamp(0.72rem, 2.4vw, 0.84rem);
    gap: 0.3rem;
  }

  /* 内饰部位：两列 */
  .gallery-area-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem 0.65rem;
  }

  .gallery-area-list label {
    font-size: clamp(0.75rem, 2.5vw, 0.88rem);
  }

  /* 结果区：瀑布流（多列不等高） */
  .gallery-results-grid {
    display: block;
    column-count: 2;
    column-gap: 0.75rem;
  }

  .gallery-card {
    display: inline-block;
    width: 100%;
    margin: 0 0 0.75rem;
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    page-break-inside: avoid;
    height: auto;
    min-height: 0;
    grid-column: auto;
  }

  .gallery-card.layout-vertical,
  .gallery-card.layout-horizontal {
    grid-column: auto;
  }

  /* 横图案例：独占一整行 */
  .gallery-card.layout-horizontal {
    column-span: all;
    display: block;
    width: 100%;
  }

  /* 卡片内：每个案例的修复前/后图片同一排 */
  .gallery-card-images.layout-vertical,
  .gallery-card-images.layout-horizontal {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.3rem;
  }

  .gallery-card-images.layout-vertical .gallery-shot,
  .gallery-card-images.layout-horizontal .gallery-shot {
    flex-direction: column;
  }

  .gallery-card-images.layout-vertical .gallery-shot img {
    width: 100%;
    aspect-ratio: 3 / 4;
    height: auto;
    max-height: 220px;
    object-fit: cover;
  }

  /* 横图案例：更宽的横向比例 */
  .gallery-card-images.layout-horizontal .gallery-shot img {
    width: 100%;
    aspect-ratio: 445 / 220;
    height: auto;
    max-height: none;
    object-fit: cover;
  }

  .gallery-card-images.layout-horizontal .gallery-shot-label {
    width: auto;
    min-width: 0;
    writing-mode: horizontal-tb;
    text-orientation: mixed;
    min-height: 1.6rem;
    padding: 0.25rem 0.35rem;
  }

  .gallery-card-images.layout-horizontal .gallery-shot-label--after {
    clip-path: none;
  }

  .gallery-card-images.layout-vertical .gallery-shot-label--after {
    clip-path: none;
  }
}

@media (max-width: 560px) {
  .gallery-brand-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.3rem 0.35rem;
  }

  .gallery-brand-list label {
    font-size: 0.7rem;
  }

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

  /* 小屏仍保持两列瀑布流 */
  .gallery-results-grid {
    column-count: 2;
    column-gap: 0.55rem;
  }

  .gallery-card {
    margin-bottom: 0.55rem;
    padding: 0.28rem;
  }

  .gallery-card.layout-horizontal {
    column-span: all;
    width: 100%;
  }

  .gallery-card-images.layout-vertical,
  .gallery-card-images.layout-horizontal {
    grid-template-columns: 1fr 1fr !important;
  }

  .gallery-card-images.layout-vertical .gallery-shot img {
    max-height: 180px;
    aspect-ratio: 3 / 4;
  }

  .gallery-card-images.layout-horizontal .gallery-shot img {
    max-height: none;
    aspect-ratio: 445 / 220;
  }
}

/* Lightbox */
body.gallery-lightbox-open {
  overflow: hidden;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

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

.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 16, 12, 0.82);
}

.gallery-lightbox-dialog {
  position: relative;
  z-index: 1;
  width: min(1100px, 96vw);
  max-height: 92vh;
  overflow: auto;
  background: #fff;
  padding: 1.25rem 1.25rem 1.5rem;
  border: 1px solid rgba(180, 170, 155, 0.55);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.gallery-lightbox-close {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #574028;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
}

.gallery-lightbox-close:hover {
  color: var(--accent);
}

.gallery-lightbox-head {
  margin: 0 2rem 0.85rem 0;
  line-height: 1.35;
}

.gallery-lightbox-vehicle {
  display: block;
  font-family: var(--font-brand);
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.gallery-lightbox-service {
  display: block;
  font-family: var(--font-brand);
  font-size: 0.92rem;
  font-style: italic;
  color: var(--ink);
  white-space: pre-line;
}

.gallery-lightbox-hint {
  margin: 0.45rem 0 0;
  font-family: var(--font-brand);
  font-size: 0.75rem;
  color: #8a7a68;
}

.gallery-lightbox-images {
  display: grid;
  gap: 0.65rem;
  align-items: start;
}

.gallery-lightbox-images.layout-vertical {
  grid-template-columns: 1fr 1fr;
}

.gallery-lightbox-images.layout-horizontal {
  grid-template-columns: 1fr;
}

.gallery-lightbox-shot {
  position: relative;
  margin: 0;
  line-height: 0;
  background: #f5f2ec;
}

.gallery-lightbox-zoom {
  overflow: auto;
  max-height: min(72vh, 900px);
  cursor: zoom-in;
  -webkit-overflow-scrolling: touch;
}

.gallery-lightbox-zoom.is-zoomed {
  cursor: zoom-out;
}

.gallery-lightbox-zoom img {
  display: block;
  width: 100%;
  height: auto;
  max-width: none;
  margin: 0;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-lightbox-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.45rem 0.6rem;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
  font-family: var(--font-brand);
  font-size: 0.78rem;
  text-align: center;
  line-height: 1.2;
}

@media (max-width: 640px) {
  .gallery-lightbox {
    padding: 0.75rem;
  }

  .gallery-lightbox-dialog {
    padding: 1rem 0.85rem 1.15rem;
  }

  .gallery-lightbox-images.layout-vertical {
    grid-template-columns: 1fr;
  }

  .gallery-lightbox-zoom {
    max-height: 42vh;
  }
}
