/* Shared platform-managed Hub backgrounds */

body {
  background-color: var(--hub-page-bg, #f4f6f8) !important;
}

:root[style*="--hub-shared-background-image"],
html:has(#tenant-shared-background) {
  min-height: 100%;
}

html:has(#tenant-shared-background) body {
  min-height: 100vh;
  background-image:
    linear-gradient(
      color-mix(in srgb, var(--hub-page-bg, #f4f6f8) var(--hub-background-overlay, 68%), transparent),
      color-mix(in srgb, var(--hub-page-bg, #f4f6f8) var(--hub-background-overlay, 68%), transparent)
    ),
    var(--hub-shared-background-image) !important;
  background-size: cover !important;
  background-position: center center !important;
  background-repeat: no-repeat !important;
  background-attachment: fixed !important;
}

html.dark-mode:has(#tenant-shared-background) body {
  background-image:
    linear-gradient(
      rgba(24, 29, 28, var(--hub-background-dark-overlay, .68)),
      rgba(24, 29, 28, var(--hub-background-dark-overlay, .68))
    ),
    var(--hub-shared-background-image) !important;
}

.hub-background-section {
  min-width: 0;
  overflow: hidden;
}

.background-choice-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(190px, 225px);
  gap: 12px;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 3px 12px;
  overscroll-behavior-inline: contain;
  scroll-snap-type: inline proximity;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.background-choice {
  position: relative;
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 9px;
  cursor: pointer;
  scroll-snap-align: start;
  background: color-mix(in srgb, var(--hub-surface, #fff) 96%, transparent);
  border: 1px solid var(--hub-border, #e2e6ea);
  border-radius: max(14px, calc(var(--hub-radius, 18px) * .72));
  box-shadow: 0 4px 14px rgba(18, 32, 44, .05);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.background-choice:hover,
.background-choice:focus-within {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--green, #0f766e) 36%, var(--hub-border, #e2e6ea));
  box-shadow: 0 8px 20px rgba(18, 32, 44, .08);
}

.background-choice.is-selected,
.background-choice:has(input:checked) {
  border: 2px solid var(--green, #0f766e);
  padding: 8px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--green, #0f766e) 11%, transparent);
}

.background-choice.is-archived {
  opacity: .72;
}

.background-choice > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.background-choice-preview {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 16 / 10;
  border-radius: max(10px, calc(var(--hub-radius, 18px) * .55));
  background: #e8ebee;
}

.background-choice-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.background-choice-theme {
  background:
    radial-gradient(circle at 74% 26%, color-mix(in srgb, var(--orange, #2563eb) 72%, white) 0 14%, transparent 15%),
    linear-gradient(135deg, var(--hub-page-bg, #f4f6f8), color-mix(in srgb, var(--green, #0f766e) 16%, var(--hub-page-bg, #f4f6f8)));
  border: 1px solid color-mix(in srgb, var(--hub-border, #e2e6ea) 78%, transparent);
}

.background-choice-theme::before,
.background-choice-theme::after,
.background-choice-theme i {
  content: "";
  position: absolute;
  display: block;
  background: color-mix(in srgb, var(--hub-surface, #fff) 94%, transparent);
  border: 1px solid var(--hub-border, #e2e6ea);
  border-radius: 8px;
}

.background-choice-theme::before {
  left: 10%;
  right: 10%;
  top: 14%;
  height: 18%;
}

.background-choice-theme::after {
  left: 10%;
  width: 35%;
  bottom: 14%;
  height: 35%;
}

.background-choice-theme i {
  right: 10%;
  width: 35%;
  bottom: 14%;
  height: 35%;
}

.background-choice-copy {
  display: block;
  min-width: 0;
}

.background-choice-copy strong,
.background-choice-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.background-choice-copy strong {
  font-size: .94rem;
}

.background-choice-copy small {
  margin-top: 2px;
  color: var(--muted, #667085);
  font-size: .78rem;
}

.background-transparency-control {
  margin-top: 14px;
  padding: 16px 18px;
  background: color-mix(in srgb, var(--hub-surface, #fff) 96%, transparent);
  border: 1px solid var(--hub-border, #e2e6ea);
  border-radius: max(14px, calc(var(--hub-radius, 18px) * .72));
}

.background-transparency-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.background-transparency-heading strong,
.background-transparency-heading span {
  display: block;
}

.background-transparency-heading span {
  margin-top: 3px;
  color: var(--muted, #667085);
  font-size: .86rem;
  line-height: 1.35;
}

.background-transparency-heading output {
  flex: 0 0 auto;
  min-width: 56px;
  padding: 5px 9px;
  text-align: center;
  font-weight: 700;
  color: var(--green, #0f766e);
  background: color-mix(in srgb, var(--green, #0f766e) 10%, var(--hub-surface, #fff));
  border-radius: 999px;
}

.background-transparency-control input[type="range"] {
  width: 100%;
  accent-color: var(--green, #0f766e);
}

.background-transparency-scale {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 3px;
  color: var(--muted, #667085);
  font-size: .76rem;
}

.background-transparency-control .field-help {
  margin: 9px 0 0;
}

@media (max-width: 700px) {
  html:has(#tenant-shared-background) body {
    background-attachment: scroll !important;
  }

  .hub-background-section {
    overflow: visible;
  }

  .background-choice-strip {
    grid-auto-columns: 172px;
    width: calc(100% + 28px);
    margin-inline: -14px;
    padding-inline: 14px;
    padding-bottom: 10px;
    scrollbar-width: none;
  }

  .background-choice-strip::-webkit-scrollbar {
    display: none;
  }

  .background-transparency-control {
    padding: 14px;
  }

  .background-transparency-heading {
    gap: 10px;
  }
}
