/*
 * Shingle color visualizer. One real photo + one roof-shape alpha mask
 * (both generated from a real completed Joe's Roofing job, not stock or
 * manufacturer imagery). mix-blend-mode:color swaps the roof's hue/
 * saturation on click while keeping the photo's real shading and shingle
 * texture -- mask-repeat must be no-repeat and the mask needs a real
 * alpha channel (not just grayscale luminance): -webkit-mask-image (the
 * engine Chromium/Safari actually use) reads alpha only, so a
 * luminance-only PNG renders as if unmasked -- the whole photo tints
 * instead of just the roof.
 */
.jr-shingle-view {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--lib-space-8, 2rem);
  align-items: start;
  width: 100%;
  max-width: 72rem;
  margin-inline: auto;
}

.jr-shingle-view__stage {
  position: relative;
  border-radius: var(--lib-radius-lg, 12px);
  overflow: hidden;
  box-shadow: var(--jr-shadow-card, 0 16px 40px rgba(22, 22, 22, 0.1));
}

.jr-shingle-view__photo {
  display: block;
  width: 100%;
  height: auto;
}

.jr-shingle-view__tint {
  position: absolute;
  inset: 0;
  mix-blend-mode: color;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  transition: background-color 0.2s ease;
  pointer-events: none;
}

.jr-shingle-view__panel {
  display: flex;
  flex-direction: column;
  gap: var(--lib-space-4, 1rem);
}

.jr-shingle-view__title {
  margin: 0;
  font-family: var(--lib-font-heading, inherit);
  font-size: 1.1rem;
  color: var(--jr-color-heading, #161616);
}

.jr-shingle-view__title strong {
  color: var(--lib-color-primary, #D12731);
}

.jr-shingle-view__desc {
  margin: 0;
  min-height: 2.6em;
  color: var(--jr-color-text, #4F4A4A);
  font-size: 0.95rem;
  line-height: 1.5;
}

.jr-shingle-view__swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--lib-space-2, 0.5rem);
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Swatches show real shingle-granule texture (cropped from the same roof
   photo above), tinted per color with the same mix-blend-mode:color
   technique as the main stage -- a flat color square reads as a paint
   chip, not a roofing material sample. The tint lives on ::after so the
   texture background-image stays untouched underneath it. */
.jr-shingle-view__swatch {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: var(--lib-radius-md, 8px);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  background-size: cover;
  background-position: center;
}

.jr-shingle-view__swatch::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--swatch-color);
  mix-blend-mode: color;
}

.jr-shingle-view__swatch:hover {
  transform: scale(1.05);
}

.jr-shingle-view__swatch[aria-pressed="true"] {
  border-color: var(--lib-color-primary, #D12731);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--lib-color-primary, #D12731);
}

.jr-shingle-view__swatch:focus-visible {
  outline: 2px solid var(--jr-color-focus, #D89C42);
  outline-offset: 2px;
}

@media (max-width: 767px) {
  .jr-shingle-view {
    grid-template-columns: 1fr;
  }

  /* Grid items default to min-width:auto, which lets their content force
     the track wider than the viewport instead of wrapping/shrinking --
     the swatches grid below only reflows correctly once this is 0. */
  .jr-shingle-view__panel {
    min-width: 0;
  }

  /* The base 5-column grid needs more width than a phone screen has;
     without a mobile override here it forced the whole panel (and the
     paragraph next to it) wider than the viewport instead of wrapping.
     3 (not 4) so the selected swatch's focus ring -- box-shadow spreads
     6px past its own box on every side -- has room to render without
     visually crowding into the next column at narrow widths. */
  .jr-shingle-view__swatches {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .jr-shingle-view__tint {
    transition: none;
  }
  .jr-shingle-view__swatch:hover {
    transform: none;
  }
}
