/* Widget showcase: a small interactive builder next to a live preview. */

.showcase__layout {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.builder {
  background: var(--nx-white);
  border: 1px solid var(--nx-bone-3);
  border-radius: var(--r-lg);
  padding: clamp(20px, 2.6vw, 28px);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.builder__title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.015em;
}

.builder__group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: none;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.builder__label {
  display: block;
  margin-bottom: 10px;
  padding: 0;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--nx-ink);
}

.builder__hint {
  font-size: 12.5px;
  color: var(--nx-500);
  line-height: 1.5;
}

/* Color swatches: a radio group */

.builder__swatches {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.builder__swatch {
  position: relative;
}

.builder__swatch input {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.builder__swatch-dot {
  display: block;
  width: 38px;
  height: 38px;
  border-radius: var(--r-pill);
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(14, 28, 42, .12) inset;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}

.builder__swatch input:checked+.builder__swatch-dot {
  box-shadow: 0 0 0 2px var(--nx-white), 0 0 0 4px var(--nx-pulse);
}

/* Hover lives on the wrapper: the scaled dot must never cover the input, or hover toggles in a loop. */
.builder__swatch:hover .builder__swatch-dot {
  transform: scale(1.06);
}

.builder__swatch input:focus-visible+.builder__swatch-dot {
  outline: 2px solid var(--nx-pulse);
  outline-offset: 5px;
}

.builder__hex {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--nx-600);
}

/* Segmented controls */

.builder__seg {
  display: flex;
  padding: 3px;
  border-radius: 11px;
  background: var(--nx-bone-3);
  gap: 2px;
}

.builder__seg label {
  position: relative;
  flex: 1;
}

.builder__seg input {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.builder__seg span {
  display: block;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13.5px;
  text-align: center;
  color: var(--nx-600);
  transition: background .2s var(--ease), color .2s var(--ease);
}

.builder__seg input:checked+span {
  background: var(--nx-white);
  color: var(--nx-ink);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(14, 28, 42, .1);
}

.builder__seg input:focus-visible+span {
  outline: 2px solid var(--nx-pulse);
  outline-offset: 2px;
}

.builder__input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--nx-300);
  border-radius: var(--r);
  background: var(--nx-white);
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--nx-ink);
}

.builder__input:focus {
  outline: none;
  border-color: var(--nx-pulse);
  box-shadow: 0 0 0 4px rgba(107, 92, 231, .22);
}

/* Preview stage */

.stage {
  position: relative;
  min-height: 600px;
  border-radius: var(--r-lg);
  border: 1px solid var(--nx-bone-3);
  background-color: var(--nx-white);
  background-image: radial-gradient(var(--nx-300) 1px, transparent 1px);
  background-size: 18px 18px;
  overflow: hidden;
}

.stage__label {
  position: absolute;
  top: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  color: var(--nx-500);
}

.stage__label::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--nx-success);
}

.stage__dock {
  position: absolute;
  bottom: 22px;
  right: 22px;
  width: min(340px, calc(100% - 44px));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}

.stage__dock--left {
  right: auto;
  left: 22px;
  align-items: flex-start;
}

.stage .wg {
  transition: box-shadow .3s var(--ease);
}

@media (max-width: 900px) {
  .showcase__layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .stage {
    min-height: 560px;
  }
}
