/* ============================================================
   Riparazioni-Elettrodomestici-Hogas — shared background gallery
   A small picker that swaps the hero photo without touching
   the rest of the demo. Used by the last four concepts.
   ============================================================ */

.gallery-host {
  position: relative;
  isolation: isolate;
}

.gallery-bg {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  filter: saturate(0.88) contrast(1.03);
  transition: opacity 0.8s ease, filter 0.5s ease;
  pointer-events: none;
}

.gallery-bg.is-active {
  z-index: -1;
  opacity: 0.82;
}

[data-gallery-auto] .gallery-bg {
  transition: opacity 1.1s ease, filter 0.6s ease;
}

[data-gallery-auto] .gallery-bg.is-active {
  opacity: 0.9;
  filter: saturate(0.96) contrast(1.02) brightness(1.08);
}

.gallery-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    var(--gallery-tint, rgba(10, 10, 12, 0.5)),
    var(--gallery-tint-strong, rgba(10, 10, 12, 0.9))
  );
}

.gallery-bg[data-empty="true"] {
  opacity: 0;
}

.gallery-toggle {
  position: fixed;
  left: 20px;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 86;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  border: 1px solid var(--gallery-line, rgba(255, 255, 255, 0.28));
  border-radius: 2px;
  background: var(--gallery-button-bg, rgba(10, 10, 12, 0.78));
  color: var(--gallery-button-ink, #f4efe6);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  backdrop-filter: blur(12px);
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.gallery-toggle:hover,
.gallery-toggle[aria-expanded="true"] {
  border-color: var(--gallery-accent, #f2a33c);
  color: var(--gallery-accent, #f2a33c);
}

.gallery-toggle svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}

.gallery-panel {
  position: fixed;
  left: 20px;
  bottom: calc(136px + env(safe-area-inset-bottom));
  z-index: 87;
  width: min(330px, calc(100vw - 40px));
  max-height: min(62vh, 470px);
  overflow: auto;
  border: 1px solid var(--gallery-line, rgba(255, 255, 255, 0.24));
  border-radius: 3px;
  background: var(--gallery-panel-bg, rgba(12, 12, 14, 0.94));
  color: var(--gallery-button-ink, #f4efe6);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(18px);
}

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

.gallery-panel__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--gallery-line, rgba(255, 255, 255, 0.16));
}

.gallery-panel__head strong {
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.gallery-panel__head span {
  color: var(--gallery-muted, rgba(255, 255, 255, 0.5));
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px;
  letter-spacing: 0.1em;
}

.gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
}

.gallery-item {
  display: grid;
  gap: 7px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.gallery-item img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  filter: saturate(0.9);
  transition: filter 0.2s ease;
}

.gallery-item span {
  display: block;
  padding: 0 2px 6px;
  color: var(--gallery-muted, rgba(255, 255, 255, 0.56));
}

.gallery-item:hover {
  border-color: var(--gallery-accent, #f2a33c);
}

.gallery-item:hover img {
  filter: saturate(1.1);
}

.gallery-item.is-active {
  border-color: var(--gallery-accent, #f2a33c);
}

.gallery-item.is-active span {
  color: var(--gallery-accent, #f2a33c);
}

.gallery-reset {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(100% - 24px);
  margin: 0 12px 12px;
  padding: 10px 12px;
  border: 1px solid var(--gallery-line, rgba(255, 255, 255, 0.18));
  border-radius: 2px;
  background: transparent;
  color: var(--gallery-muted, rgba(255, 255, 255, 0.6));
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.gallery-reset:hover {
  border-color: var(--gallery-accent, #f2a33c);
  color: var(--gallery-accent, #f2a33c);
}

.gallery-panel__note {
  margin: 0;
  padding: 0 16px 14px;
  color: var(--gallery-muted, rgba(255, 255, 255, 0.42));
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 8px;
  line-height: 1.6;
  letter-spacing: 0.04em;
}

.channel__media img.channel__img--next {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.9s ease, transform 0.7s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.4s ease;
}

.channel__media img.channel__img--next.is-visible {
  opacity: 1;
}

@media (max-width: 520px) {
  .gallery-toggle span {
    display: none;
  }

  .gallery-toggle {
    width: 46px;
    height: 46px;
    justify-content: center;
    padding: 0;
  }

  .gallery-panel {
    left: 12px;
    bottom: calc(132px + env(safe-area-inset-bottom));
    width: calc(100vw - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-bg,
  .gallery-toggle,
  .gallery-item,
  .gallery-item img,
  .channel__media img.channel__img--next {
    transition: none;
  }
}
