/* Paint family: the drawn room and its wall-colour picker. The checked chip sets --wall through :has(), so it works without script. */

:root {
  --paint-white: #ebe5d8;
  --paint-sage: #a3ad94;
  --paint-blue: #9cb1c2;
  --paint-clay: #bf8c76;
  --paint-charcoal: #45484c;
  --room-trim: #fbfbf9;
  --room-trim-2: #ebeae5;
  --room-primer: #f3f2ee;
  --room-floor: #e6dac6;
  --room-metal: #8a9095;
  --room-grip: #2f3337;
  --room-pole: #cdb38d;
  --room-tray: #dadddf;
  --room-tray-edge: #b9bec2;
  --paint-ring: #23272b;
  --paint-gap: #fff;
}

[data-paint-scene] {
  --wall: var(--brand);
}

[data-paint-scene]:has(.paint-input[value="white"]:checked) {
  --wall: var(--paint-white);
}

[data-paint-scene]:has(.paint-input[value="sage"]:checked) {
  --wall: var(--paint-sage);
}

[data-paint-scene]:has(.paint-input[value="blue"]:checked) {
  --wall: var(--paint-blue);
}

[data-paint-scene]:has(.paint-input[value="clay"]:checked) {
  --wall: var(--paint-clay);
}

[data-paint-scene]:has(.paint-input[value="charcoal"]:checked) {
  --wall: var(--paint-charcoal);
}

.room {
  display: block;
  width: 100%;
  height: auto;
}

.room-paint {
  fill: var(--wall);
  transition: fill 0.7s cubic-bezier(0.3, 0, 0.2, 1);
}

.room-trim {
  fill: var(--room-trim);
}

.room-trim-2 {
  fill: var(--room-trim-2);
}

.room-primer {
  fill: var(--room-primer);
}

.room-floor {
  fill: var(--room-floor);
}

.room-seam {
  fill: none;
  stroke: rgb(60 45 25 / 0.08);
  stroke-width: 1.5;
}

.room-shadow {
  fill: rgb(20 24 28 / 0.08);
}

.room-tray {
  fill: var(--room-tray);
  stroke: var(--room-tray-edge);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.room-frame {
  fill: none;
  stroke: var(--room-metal);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.room-grip {
  fill: none;
  stroke: var(--room-grip);
  stroke-width: 13;
  stroke-linecap: round;
}

.room-pole {
  fill: none;
  stroke: var(--room-pole);
  stroke-width: 8;
  stroke-linecap: round;
}

.room-cap {
  fill: var(--room-metal);
}

.room-edge {
  fill: none;
  stroke: rgb(20 24 28 / 0.22);
  stroke-width: 1;
}

/* Load moment: the roller rolls up the wall and leaves its stroke behind. */
@media screen and (prefers-reduced-motion: no-preference) {
  .room-stroke {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: room-stroke 1.5s cubic-bezier(0.45, 0, 0.2, 1) 0.35s both;
  }

  .room-roller {
    animation: room-roll 1.5s cubic-bezier(0.45, 0, 0.2, 1) 0.35s both;
  }
}

@keyframes room-stroke {
  from {
    transform: scaleY(0.04);
  }

  to {
    transform: scaleY(1);
  }
}

@keyframes room-roll {
  from {
    transform: translateY(190px);
  }

  to {
    transform: translateY(0);
  }
}

.paint-chips {
  display: flex;
  gap: 6px;
}

.paint-chip {
  position: relative;
  display: block;
  flex: 1 1 0;
  min-width: 44px;
  cursor: pointer;
}

.paint-input {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 56px;
  margin: 0;
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgb(20 24 28 / 0.45);
  cursor: pointer;
  transition: box-shadow 0.2s ease;
}

.paint-input:checked {
  box-shadow: inset 0 0 0 1px rgb(20 24 28 / 0.45), 0 0 0 3px var(--paint-gap), 0 0 0 5px var(--paint-ring);
}

@media (forced-colors: active) {
  .paint-input {
    forced-color-adjust: none;
    border: 1px solid CanvasText;
  }

  .paint-input:checked {
    outline: 3px solid Highlight;
  }
}

.paint-input:focus-visible {
  outline: 2px solid var(--paint-ring);
  outline-offset: 8px;
}

.paint-input[value="brand"] {
  background-color: var(--brand);
}

.paint-input[value="white"] {
  background-color: var(--paint-white);
}

.paint-input[value="sage"] {
  background-color: var(--paint-sage);
}

.paint-input[value="blue"] {
  background-color: var(--paint-blue);
}

.paint-input[value="clay"] {
  background-color: var(--paint-clay);
}

.paint-input[value="charcoal"] {
  background-color: var(--paint-charcoal);
}

.paint-tick {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.paint-tick circle {
  fill: #fff;
}

.paint-tick path {
  fill: none;
  stroke: var(--paint-ring);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paint-input:checked + .paint-tick {
  opacity: 1;
}

.paint-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.paint-now-name {
  display: none;
}

[data-paint-scene]:has(.paint-input[value="brand"]:checked) [data-paint-name="brand"],
[data-paint-scene]:has(.paint-input[value="white"]:checked) [data-paint-name="white"],
[data-paint-scene]:has(.paint-input[value="sage"]:checked) [data-paint-name="sage"],
[data-paint-scene]:has(.paint-input[value="blue"]:checked) [data-paint-name="blue"],
[data-paint-scene]:has(.paint-input[value="clay"]:checked) [data-paint-name="clay"],
[data-paint-scene]:has(.paint-input[value="charcoal"]:checked) [data-paint-name="charcoal"] {
  display: inline;
}

/* Six 44px chips fit a 280px column only with tighter gaps and a thinner ring. */
@media (max-width: 359.98px) {
  .paint-chips {
    gap: 3px;
  }

  .paint-input:checked {
    box-shadow: inset 0 0 0 1px rgb(20 24 28 / 0.45), 0 0 0 1px var(--paint-gap), 0 0 0 3px var(--paint-ring);
  }
}

@media (prefers-reduced-motion: reduce) {
  .room-paint,
  .paint-input,
  .paint-tick {
    transition: none;
  }
}
