/* Homepage product controls. Loaded last; category cards and selected-pair framing stay native. */
#showroom[data-home-showroom] #rr-ultimate-builder[data-home-showroom-controls] {
  --rr-home-opening-stage-height:clamp(320px,34vw,480px);
  /* Keep native inputs and installer hooks in the DOM without exposing manual room controls. */
  & :is(.rr-show-controls,.rr-shop-view .rr-world-picks,
    .rr-floor-led-panel,.rr-led-pair-head,[data-floor-lights],[data-floor-room-settings],
    [data-led-summary],[data-return-packed],[data-wall-sound]) {
    display:none!important;
  }
  /* The native directory remains a fallback if the category controller cannot initialize. */
  &[data-category-carousel] .rr-wall-sill .rr-world-browse,
  & .rr-shop-view .rr-world-picks[hidden] { display:none!important; }
  & .rr-wall-sill {
    height:auto!important;
    min-height:0!important;
    margin:0!important;
    padding:0!important;
  }
  &:not([data-holding-board],[data-world-pack],[data-floor-playing],[data-comparing]) .rr-shop-view {
    padding-top:0;
  }
  &:not([data-browsing-sets],[data-holding-board],[data-world-pack],[data-packing-open],[data-floor-playing],[data-comparing]) .rr-shop-display {
    margin-block-start:0!important;
  }
  &:not([data-holding-board],[data-world-pack],[data-packing-open],[data-floor-playing],[data-comparing],[data-browsing-sets]) .rr-hanging-wall::before {
    bottom:calc(0px - max(var(--shop-stage-full-height),var(--rr-home-opening-stage-height),var(--rr-home-floor-reach,0px)));
  }

  & .rr-home-product-toolbar {
    box-sizing:border-box;
    position:relative;
    z-index:4;
    display:grid;
    grid-template-columns:minmax(0,1fr);
    align-items:start;
    gap:0;
    width:100%;
    min-width:0;
    margin:0;
    padding:0 clamp(8px,2vw,24px);
    pointer-events:auto;
  }
  & .rr-home-sound-tools {
    position:absolute;
    top:0;
    right:clamp(8px,2vw,24px);
    z-index:1;
    display:flex;
    justify-content:flex-end;
    align-items:center;
    width:56px;
    height:56px;
    min-height:0;
    min-width:0;
    pointer-events:none;
  }
  & [data-home-showroom-sound] {
    box-sizing:border-box;
    display:inline-flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;
    gap:4px;
    width:56px;
    height:56px;
    min-width:56px;
    min-height:56px;
    margin:0;
    padding:5px;
    border:1px solid transparent;
    border-radius:6px;
    background:transparent;
    color:#fff;
    font:700 14px/1.2 Barlow,Arial,sans-serif;
    letter-spacing:0;
    text-transform:none;
    white-space:nowrap;
    cursor:pointer;
    touch-action:manipulation;
    pointer-events:auto;
  }
  & [data-home-showroom-sound]::before {
    content:"";
    display:block;
    flex:none;
    box-sizing:border-box;
    width:34px;
    height:19px;
    border:2px dotted;
    border-color:#ff5267 #6af3ff #6af3ff #ff5267;
    border-radius:50%;
    background:none;
    box-shadow:-2px 0 5px #ff294d85,2px 0 5px #30dfff85,inset 0 0 4px #30dfff55;
  }
  & [data-home-showroom-sound][aria-pressed=true]::before {
    border-color:#ff8191 #abfaff #abfaff #ff8191;
    box-shadow:-2px 0 7px #ff294d,2px 0 7px #30dfff,inset 0 0 5px #30dfff88;
  }
  & .rr-home-led-caption {
    display:inline-flex;
    align-items:center;
    justify-content:center;
    gap:4px;
    color:#fff;
    font:700 11px/1 Barlow,Arial,sans-serif;
    letter-spacing:.025em;
    text-shadow:0 1px 3px #000;
  }
  & .rr-home-led-caption svg { display:block; width:16px; height:16px; }
  & [data-home-showroom-sound][aria-pressed=true] .rr-home-led-caption { color:#abfaff; }
  & [data-home-showroom-sound][aria-pressed=true] .rr-home-music-muted { display:none; }
  & [data-home-showroom-sound][aria-busy=true] { opacity:.7; }

  /* Both destinations use the same native button rules and the same selected-set fill. */
  &[data-set-chosen] .rr-vibes-selection nav[data-room-art] :is([data-world-build],[data-world-play]) {
    background:#50e4ed;
    color:#07252a;
    border-color:#83f7fd;
    text-shadow:none;
  }

  /* Keep the action's price with its button, outside the text replaced by the room controller. */
  & .rr-vibes-selection nav[data-room-art] { align-items:flex-start; }
  & .rr-vibes-selection nav[data-room-art] .rr-home-build-action {
    display:grid;
    justify-items:center;
    gap:4px;
    flex:0 1 248px;
    width:min(100%,248px);
    min-width:0;
  }
  & .rr-vibes-selection nav[data-room-art] .rr-home-build-action [data-world-build] { width:100%; }
  & [data-home-starting-price] {
    display:block;
    max-width:100%;
    color:#fff;
    font:400 14px/1.3 Barlow,Arial,sans-serif;
    text-align:center;
    overflow-wrap:break-word;
  }
  & [data-home-starting-price][hidden] { display:none; }

  /* Original names stay complete for assistive technology and in set details. */
  & .rr-showroom-wall [data-featured] button[data-art][data-compact-label]::after { content:none; display:none; }
  & .rr-browse-label {
    display:block;
    width:100%;
    min-width:0;
    color:#fff;
    font:700 clamp(15px,1.32vw,21px)/1.15 Barlow,Arial,sans-serif;
    text-align:center;
    text-transform:none;
    letter-spacing:0;
    text-shadow:0 1px 3px #000;
    white-space:normal;
  }
  & .rr-browse-label > span, & .rr-browse-label > small { display:block; }
  & .rr-browse-label > small { margin-top:2px; font-size:.78em; font-weight:400; line-height:1.2; }
  & [data-art][aria-pressed=true] .rr-browse-label { color:var(--vibes-cyan,#81DBFF); }
  @media (max-width:700px) {
    & .rr-vibes-selection nav[data-room-art] .rr-home-build-action { flex-basis:calc(50% - 4px); width:calc(50% - 4px); }
  }
  @media (max-width:749px) {
    & .rr-hanging-row [data-featured] .rr-browse-label { min-height:2.4em; font-size:13px; line-height:1.2; }
  }

  /* These are the original native Mix and 3D controls, moved together above the selected pair. */
  & .rr-home-product-actions:not([hidden]) {
    box-sizing:border-box;
    grid-area:1/1;
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    justify-content:center;
    gap:0 5px;
    width:100%;
    min-width:0;
    min-height:44px;
    margin:0;
    padding:0 58px;
  }
  & .rr-home-product-actions :is([data-match="no"],[data-pickup-cue]) {
    box-sizing:border-box;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    min-width:44px;
    min-height:44px;
    margin:0;
    padding:6px 3px;
    border:0;
    border-radius:4px;
    background:transparent;
    box-shadow:none;
    color:#fff;
    font:700 clamp(16px,4.4vw,20px)/1.2 Barlow,Arial,sans-serif;
    letter-spacing:0;
    text-transform:none;
    text-shadow:0 1px 3px #0008;
    cursor:pointer;
    touch-action:manipulation;
  }
  & .rr-home-product-actions :is([data-match="no"],[data-pickup-cue])::before,
  & .rr-home-product-actions :is([data-match="no"],[data-pickup-cue])::after { content:none; }
  & .rr-home-action-separator { color:#fff; font:700 20px/1 Barlow,Arial,sans-serif; }
  & .rr-home-mix-confirm { display:none; }
  &[data-editing-mix] .rr-home-mix-confirm {
    box-sizing:border-box;
    grid-area:1/1;
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    min-width:0;
    min-height:56px;
    padding:4px 58px;
  }
  & .rr-home-set-price {
    display:flex;
    flex-wrap:wrap;
    align-items:baseline;
    justify-content:center;
    gap:4px 10px;
    max-width:100%;
    margin:8px 0 2px;
    color:#fff;
  }
  & .rr-home-set-price > span { font:600 14px/1.3 Barlow,Arial,sans-serif; }
  & .rr-home-set-price > strong { font:700 clamp(20px,5.6vw,26px)/1.2 Barlow,Arial,sans-serif; }
  & .rr-home-product-toolbar [data-pickup-sides]:not([hidden]) {
    grid-area:2/1;
    justify-self:center;
    display:grid;
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:6px;
    width:min(100%,440px);
    max-width:440px;
    margin:16px 0 6px;
  }
  & .rr-home-product-toolbar [data-pick-side] {
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
    color:#fff;
    background:#132126;
    border:1px solid #607f86;
    border-radius:6px;
    cursor:pointer;
    min-width:0;
    min-height:52px;
    padding:5px 6px;
    font:700 14px/1.2 Barlow,Arial,sans-serif;
    white-space:normal;
  }
  & .rr-home-product-toolbar [data-pick-side] img { flex:none; }
  & .rr-home-product-toolbar [data-pick-side] span { min-width:0; overflow-wrap:anywhere; }
  & .rr-home-product-toolbar [data-pickup-sides][hidden] { display:none!important; }
  & .rr-home-product-actions[hidden],
  & .rr-home-product-actions [hidden],
  &:not([data-set-chosen]) .rr-home-product-actions,
  &:is([data-editing-mix],[data-holding-board],[data-world-pack],[data-packing-open],
    [data-floor-playing],[data-comparing],[data-browsing-sets]) .rr-home-product-actions,
  &:has([data-showroom-floor][data-board-held]) .rr-home-product-actions {
    display:none!important;
  }
  &:is([data-world-pack],[data-packing-open],[data-floor-playing],[data-comparing],[data-browsing-sets]) .rr-home-product-toolbar {
    display:none;
  }
  &:is([data-holding-board],[data-editing-mix]) .rr-home-product-toolbar {
    min-height:56px;
  }

  /* The larger opening stage changes neither the selected-pair camera nor the inspection camera. */
  &:not([data-holding-board],[data-world-pack],[data-floor-playing]) .rr-shop-view [data-showroom-floor]:has(> rr-showroom-turntable) {
    height:var(--rr-home-opening-stage-height)!important;
    min-height:0!important;
    max-height:none;
  }
  & rr-showroom-turntable :is(img,canvas) {
    inset:0;
    width:100%;
    height:100%;
    max-width:100%;
    max-height:100%;
    transform:none;
    object-fit:contain;
  }
  & rr-showroom-turntable::before { top:auto; bottom:2%; width:32%; height:5%; }
  & rr-showroom-turntable button:not(.rr-spin-browse) { z-index:2; }

  /* Keep each native details link and its mixed-pair modal; let long names wrap in full. */
  & .rr-shop-view .rr-vibes-selection { gap:8px; padding-top:5px; }
  & .rr-pair-details .rr-floor-details:not(:empty) {
    align-items:flex-start;
    gap:8px;
    margin:0;
    padding:0;
  }
  & .rr-pair-details .rr-floor-details .rr-set-details-link {
    display:grid;
    grid-template-columns:minmax(0,auto) auto;
    grid-template-areas:"name name" "label arrow";
    justify-items:center;
    justify-content:center;
    align-content:start;
    gap:2px 6px;
    min-width:0;
    max-width:100%;
    min-height:44px;
    margin:0;
    padding:3px 4px;
    color:#fff;
    text-decoration:none;
    text-align:center;
  }
  & .rr-pair-details .rr-floor-details .rr-set-details-link[hidden] { display:none; }
  & .rr-pair-details .rr-set-details-link strong {
    display:block;
    grid-area:name;
    min-width:0;
    max-width:100%;
    color:#fff;
    font:700 clamp(18px,4.8vw,23px)/1.22 Barlow,Arial,sans-serif;
    white-space:normal;
    overflow-wrap:anywhere;
    text-wrap:balance;
  }
  & .rr-pair-details .rr-set-details-link > span:not([aria-hidden]) {
    display:inline-flex;
    grid-area:label;
    align-items:center;
    justify-content:center;
    min-height:44px;
    color:#fff;
    font:700 clamp(17px,4.6vw,20px)/1.2 Barlow,Arial,sans-serif;
    text-decoration:underline;
    text-decoration-thickness:1px;
    text-underline-offset:4px;
    white-space:normal;
  }
  & .rr-pair-details .rr-floor-details .rr-set-details-link > span[aria-hidden] {
    display:inline-flex;
    grid-area:arrow;
    align-self:stretch;
    align-items:center;
    color:#fff;
    font:700 clamp(17px,4.6vw,20px)/1.2 Barlow,Arial,sans-serif;
  }
  & .rr-pair-details .rr-floor-details:has(a:nth-child(2)) > a { flex:1 1 0; }
  & .rr-pair-details .rr-floor-details:has(a:nth-child(2)) strong { font-size:clamp(16px,4.3vw,21px); }
  & .rr-mix-names [data-side] { min-width:0; }
  & .rr-mix-names [data-side] b { overflow-wrap:anywhere; text-wrap:balance; }

  & :is([data-home-showroom-sound],.rr-home-product-toolbar button,.rr-set-details-link):focus-visible {
    outline:2px solid #fff;
    outline-offset:3px;
  }
  & .rr-home-product-toolbar button:disabled { opacity:.5; cursor:default; }
}

@media (max-width:700px) {
  #showroom[data-home-showroom] #rr-ultimate-builder[data-home-showroom-controls] {
    --rr-home-opening-stage-height:clamp(260px,78vw,320px);
  }
}
@media (orientation:landscape) and (max-height:540px) {
  #showroom[data-home-showroom] #rr-ultimate-builder[data-home-showroom-controls] {
    --rr-home-opening-stage-height:clamp(190px,62svh,290px);
  }
}
@media (hover:hover) {
  #showroom[data-home-showroom] #rr-ultimate-builder[data-home-showroom-controls] {
    & [data-home-showroom-sound]:hover { border-color:#ffffff60; background:#ffffff08; }
    & .rr-home-product-actions button:not(:disabled):hover,
    & .rr-set-details-link:hover { color:#fff; text-decoration:underline; text-underline-offset:4px; }
  }
}
@media (prefers-reduced-motion:reduce) {
  #showroom[data-home-showroom] #rr-ultimate-builder[data-home-showroom-controls] :is(.rr-home-product-toolbar,.rr-home-product-toolbar *,.rr-pair-details *) {
    animation:none!important;
    transition:none!important;
  }
}
