/* UTILITIES */

.text-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-secondary-hover);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);

  &:hover { color: var(--color-black); }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* button_to renders a wrapping <form>; this keeps it in the text flow. */
.inline-form { display: inline; }

/* Shared column-header link for the DON-backed history tables (order
   history, rug configurations) — see SortableTableHelper#sortable_column_header. */
.sortable-column {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: inherit;
  text-decoration: none;

  &:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
  &:hover, &.active { color: var(--color-black); }
  span { font-size: var(--font-size-3); font-weight: 400; line-height: 1; }
}

/* SHARED ANIMATIONS */

@keyframes account-error-arrive {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

/* GRIDS */

.grid {
  display: grid;

  &.base {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-gap: 1rem;
  }

  &.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-gap: 1rem;
  }

  &.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-gap: 1rem;
  }

  &.six {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-gap: 1rem;
  }

  &.bottom-margin-l {
    margin-bottom: 16px;
  }

  .column {

    &.xs {
      grid-column: span 1;
    }

    &.s {
      grid-column: span 2;
    }

    &.l {
      grid-column: span 10;
    }

    &.xl {
      grid-column: span 11;
    }

    &.full {
      grid-column: span 12;
    }

    &.tray-area {
      grid-column: span 4;
      position: relative;
    }

    &.tray-area.narrow {
      grid-column: span 3;
    }

    &.products-area {
      grid-column: span 8;
    }

    &.products-area.wide {
      grid-column: span 9;
    }

    &.h-span-2 {
      grid-column: span 2;
    }

    &.h-span-3{
      grid-column: span 3;
    }

    &.h-span-4 {
      grid-column: span 4;
    }

    &.h-span-5 {
      grid-column: span 5;
    }

    &.h-span-6 {
      grid-column: span 6;
    }

    &.h-span-7 {
      grid-column: span 7;
    }

    &.h-span-8 {
      grid-column: span 8;
    }

    &.h-span-9 {
      grid-column: span 9;
    }

    &.h-span-10 {
      grid-column: span 10;
    }

    &.h-span-11 {
      grid-column: span 11;
    }

    &.h-span-12 {
      grid-column: span 12;
    }

  }

  &.three .column.span-2 {
    grid-column: span 2;
  }

  &.three .column.span-3 {
    grid-column: span 3;
  }

}

/* ICONS */

.icon-type, .icon-act {
  font-family: 'MaharamNeue';
  font-size: 14px;
  padding: 5px 5px 5px 0;
  display: inline-block;
}

.icon {
  width: 16px;
  height: 16px;
  stroke: var(--color-black);
  fill: none;
  stroke-width: 1.5px;
  stroke-linecap: round;
  stroke-linejoin: round;

  &.small {
    width: 12px;
    height: 12px;
  }

  &.inline {
    display: inline-block;
    margin-right: 4px;
    /* vertical-align: text-top; */
  }

  svg {
    display: block;
    width: 100%;
    height: 100%;
  }

}

/* CARDS */

.card {
  position: relative;
  width: 100%;
  overflow: hidden;
  box-shadow:
    0 0 8px rgba(0, 0, 0, 0.1);
  background-color: var(--color-white);
  transform-origin: center center;
  will-change: transform, box-shadow, filter;
  transition:
    transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    box-shadow 420ms cubic-bezier(0.2, 0.8, 0.2, 1),
    filter 320ms cubic-bezier(0.2, 0.8, 0.2, 1);

  &:hover {
    cursor: pointer;
  }

  a.card-link {
    display: block;
  }

  a.card-link .images-wrapper {
    position: relative;
    aspect-ratio: 1 / 1;
  }

  a.card-link .images-wrapper .detail-image,
  a.card-link .images-wrapper .install-image {
     position: absolute;
     width: 100%;
     aspect-ratio: 1 / 1;
     background-repeat: no-repeat;
     background-size: cover;
     background-position: center center;
  }

  a.card-link .images-wrapper .install-image {
    opacity: 0;
    transition: opacity var(--motion-duration-standard) var(--motion-ease-standard);
  }

  /* Scoped to the card rather than the link so hovering the toolbar — which
     lives outside the link — doesn't drop the install-image swap. */
  &:hover .images-wrapper .install-image {
    opacity: 1;
  }

  span.new-product {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: var(--font-size-2);
    line-height: 1;
    color: var(--color-black);
    background: rgba(255, 255, 255, 0.625);
    z-index: 5;
    padding: 7px 12px 6px 12px;
  }

  .text-wrapper {
    position: relative;
    aspect-ratio: 2.5 / 1;
  }

  &.double .text-wrapper {
    position: relative;
    aspect-ratio: 4 / 1;
  }

  p.product-brand,
  p.product-name,
  p.product-color,
  p.product-price,
  p.number-colors,
  p.decision-driver {
    font-size: 14px;
    line-height: 1.45;
    margin-bottom: 0;
    color: var(--color-black);
  }

  a.card-link .product-caption {
    padding: 0.75rem 1rem 1rem 1rem;
  }

  p.product-name,
  p.product-color,
  p.product-price {
    line-height: 1.35;
  }

  p.product-name,
  p.product-color {
    font-weight: 700;
  }

  /* -- Card Toolbar -- */

  .toolbar {
    position: absolute;
    bottom: 6px;
    right: 12px;
    display: inline-block;
    text-align: left;
    min-width: 24px;
    min-height: 24px;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }

  /* The card's own hover already swaps the install image and fades the tools
     in; a tooltip on top of that is noise. */
  .toolbar .tooltip {
    display: none;
  }

  .toolbar .tool {
    position: relative;
    display: inline-block;
    opacity: 0;
    cursor: pointer;
    margin-left: 8px;
    transition: opacity var(--motion-duration-standard) var(--motion-ease-standard);
  }

  &:hover .toolbar .tool {
    opacity: 1;
  }

  /* A favorited heart or a compared scale stays visible even when the card
     isn't hovered */
  .toolbar .tool.selected,
  .toolbar .tool.favorited,
  .toolbar .tool.compared {
    opacity: 1;
  }

  .toolbar .tool:hover .icon {
    stroke: var(--color-red);
    transition: opacity var(--motion-duration-standard) var(--motion-ease-standard);
  }

  .toolbar .tool.selected .icon,
  .toolbar .tool.compared .icon {
    stroke: var(--color-red);
  }

  .toolbar .tool.favorited .icon {
    stroke: var(--color-red);
    fill: var(--color-red);
  }

  /* button_to wraps the icon in a <button>; strip the UA chrome so it reads
     as the same inline glyph the other tools are. */
  .toolbar .tool button {
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
  }

  /* The glyph inside that button is a <span class="icon">, and .icon's 16px
     box only applies once it stops being inline — without this the SVG
     stretches to the width of the card. */
  .toolbar .tool button .icon {
    display: block;
  }

}

/* CHIPS */

.chip {
  display: inline-block;
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--color-gray-5);
  border-radius: 8px;
  padding: 0 16px 0 8px;
  white-space: nowrap;
  text-align: left;
  font-size: 0;
  margin: 4px;
  cursor: pointer;
  transition: all 0.2s ease;

  &.clear {
    background-color: var(--color-gray-3);
    border-radius: 0;
  }

  .icons-wrapper {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-top: 8px;
    margin-right: 4px;
  }

  .icons-wrapper .icon-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    stroke-width: 1.5px;
    inset: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
  }

  .icons-wrapper .icon-wrapper.default-state {
    opacity: 1;

    .icon {
      stroke: var(--color-green);
    }

  }

  &.clear .icons-wrapper .icon-wrapper.default-state {
    opacity: 1;

    .icon {
      stroke: var(--color-black);
      transition: stroke 0.2s ease;
    }

  }

  .icons-wrapper .icon-wrapper.hover-state {
    opacity: 0;

    .icon {
      stroke: var(--color-red);
    }

  }

  &:hover .icons-wrapper .icon-wrapper.default-state {
    opacity: 0;
  }

  &:hover .icons-wrapper .icon-wrapper.hover-state {
    opacity: 1;
  }

  &.clear:hover .icons-wrapper .icon-wrapper.default-state {
    opacity: 1;

    .icon {
      stroke: var(--color-red);
    }

  }

  &.clear:hover .icons-wrapper .icon-wrapper.hover-state {
    opacity: 0;
  }

  p.label {
    display: inline-block;
    font-size: 0.8125rem;
    line-height: 1;
    vertical-align: top;
    margin-top: 11px;
    margin-right: 2px;
    margin-bottom: 0;
  }

}

/* COUNT BADGES */

/* The tally on the header's bag icon and beside Comparisons in its nav tray.
   Each caller adds only its own placement. */
.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 14px;
  height: 14px;
  /* MaharamNeue sits high in its em box; with no element around the digit to
     nudge, the lopsided padding is what drops it to optical center. */
  padding: 2px 3px 0;
  border-radius: var(--radius-round);
  background-color: var(--color-primary);
  color: var(--color-white);
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
}

/* SORT */

.sorting-wrapper {
  width: 100%;
  height: 42px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;

  .sort-dropdown {
    position: relative;
    user-select: none;
  }

  /* The always-visible trigger row */
  .sort-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .sort-trigger-label {
    padding: 0;
    background: none;
    font-size: 14px;
    line-height: 1;
    color: var(--color-black);
    cursor: pointer;
  }

  .sort-trigger-dir {
    padding: 6px 2px;
    background: none;
    color: var(--color-black);
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    transform: translateY(-2px);
  }

  .sort-trigger-dir svg {
    width: 14px;
    height: 14px;
    stroke: var(--color-black);
    fill: none;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.12s;
  }

  .sort-trigger-dir.flipped svg {
    transform: scaleY(-1);
  }

  .sort-trigger-label:hover {
    color: var(--color-primary);
  }

  .sort-trigger-dir:hover svg {
    stroke: var(--color-primary);
  }

  /* The options panel — only shown when open */
  .sort-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: -20px;
    min-width: 120px;
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: 0 0 16px rgba(0,0,0,0.125);
    overflow: hidden;
    z-index: 10;
  }

  .sort-dropdown.open .sort-panel {
    display: block;
  }

  .sort-panel li {
    list-style: none;
  }

  /* The option is a <button> so it is keyboard operable; the padding lives on
     it rather than the <li> so the whole row stays the hit target. */
  .sort-panel .sort-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 20px;
    font-size: 16px;
    color: #1d1d1f;
    background: none;
    cursor: pointer;
    transition: background 0.12s;
  }

  .sort-panel .sort-option:hover {
    color: var(--color-primary);
  }

  .sort-panel li + li {
    border-top: 1px solid #e0e0e5;
  }

  .sort-panel .sort-option.active {
    color: var(--color-primary);
  }

}

/* TOOLTIPS */

.tooltip {
  position: absolute;
	z-index: var(--z-highest);
  left: 50%;
  bottom: 100%;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
  filter: drop-shadow(0 0 16px rgba(0, 0, 0, 0.16)) drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));

  &::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 0;
    bottom: -2px;
    transform: translateX(-50%);
    background: #ffffff;
    color: var(--color-black);
    padding: 16px 24px 12px 24px;
    border-radius: 8px;
    white-space: nowrap;
    font-size: 14px;
    line-height: 1.2;
  }

  &::before {
    content: "";
    position: absolute;
    left: 0;
    bottom: -8px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    transform: translateX(-50%) rotate(45deg);
  }
}

.thumbnail:hover .tooltip,
.thumbnail:focus-within .tooltip,
.tool:hover .tooltip,
.tool:focus-within .tooltip {
  opacity: 1;
  visibility: visible;
}

/* PAGINATION */

.pagination-wrapper {
  text-align: center;
  padding-bottom: 48px;
}

/* Inline pagination beside the sort dropdown (product index top row) */
.pagination-inline {
  display: inline-flex;
  align-items: center;
}

ul.pagination {
  display: inline-block;
  height: 16px;
  padding: 0 0 0 0;

  li {
    display: inline-block;
    vertical-align: top;

    a.text,
    p.text {
      width: auto;
      height: 14px;
      font-size: 14px;
      line-height: 1;
      color: var(--color-text-primary);
      padding-right: 4px;
      padding-left: 4px;
      margin-bottom: 0;
      vertical-align: top;
      transition: color var(--motion-duration-standard) var(--motion-ease-standard);
    }

    a.text {
      cursor: pointer;

      &.active {
        color: var(--color-text-primary-active);
      }

      &:hover {
        color: var(--color-text-primary-hover);
      }

    }

    p.text {
      cursor: default;

      &.active {
        color: var(--color-text-primary-active);
      }

      &.product-count {
        padding-right: 0;
      }
    }

    a.icon {
      width: 20px;
      height: 20px;
      stroke: var(--color-text-primary);
      padding: 0;
      margin-bottom: 0;
      transform: translateY(-4px);
      transition: color var(--motion-duration-standard) var(--motion-ease-standard);

      &.active {
        stroke: var(--color-text-primary-active);
      }

      &:hover {
        stroke: var(--color-text-primary-hover);
      }

    }

  }

}

a.view-all {
  display: inline-block;
  height: 14px;
  margin-left: 4px;
  padding: 0 4px;
  font-size: 14px;
  line-height: 14px;
  color: var(--color-text-primary);
  vertical-align: top;
  transition: color var(--motion-duration-standard) var(--motion-ease-standard);

  &:hover {
    color: var(--color-text-primary-hover);
  }
}

/* BUTTONS */

.cta-wrapper {
  display: flex;
  /* Wraps because the PDP tray is too narrow to hold Sample + Downloads +
     the tools oval on one row at any viewport. */
  flex-wrap: wrap;
  gap: 8px;
  row-gap: 16px;
  padding-top: 8px;
  transform: translateX(-3px);
}

.cta {
  text-decoration: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  padding-inline: 30px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition:
    background-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);

  &:active { transform: translateY(1px); }

  &:disabled {
    background-color: var(--color-gray-8);
    color: var(--color-gray-20);
    cursor: not-allowed;
  }

  @media (prefers-reduced-motion: reduce) {
    &:active { transform: none; }
  }

  .icon {
    width: 18px;
    height: 18px;
    stroke: var(--color-white);
    stroke-width: 2px;
  }

}

/* Similar to .cta, but at 40px instead of 56px. */
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  height: 40px;
  padding: 0 var(--space-5);
  border: 1px solid var(--color-gray-8);
  border-radius: var(--radius-round);
  background-color: var(--color-white);
  color: var(--color-black);
  font-family: var(--font-stack);
  font-size: var(--font-size-3);
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);

  &:hover { border-color: var(--color-primary); background-color: var(--color-primary); }
  &:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 3px; }
}

/* MaharamNeue sits high in its em box, so every button label is nudged down to
   optical center. Both button sizes wrap their text in a .label to get it —
   .small-button is the 40px sibling of .cta. */
.cta .label,
.small-button .label {
  line-height: 1;
  transform: translateY(2px);
}

.cta-primary {
  color: var(--color-white);
  border-radius: var(--radius-round);
  background-color: var(--color-primary);

  &:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
  }

}

.cta-cancel {
  color: var(--color-white);
  border-radius: var(--radius-round);
  background-color: var(--color-black);

  &:hover {
    background-color: color-mix(in srgb, var(--color-black) 82%, var(--color-white));
  }

}

/* SCROLL AREA */

.scroll-area {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  overflow-x: visible;
  overflow-y: auto;

  /* reserve scrollbar space */
  scrollbar-gutter: stable;

  /* Firefox */
  scrollbar-width: none;

  /* old Edge / IE */
  -ms-overflow-style: none;

  &::-webkit-scrollbar {
    display: none;
  }

  &.padded {
    padding-inline: 36px;
  }
}

.scroll-fade-out {
  position: absolute;
  z-index: 100;
  bottom: 0;
  width: 100%;
  height: 90px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 90%);

}

/* ACCORDION */

.accordion {
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: 0;
  border-bottom: 0.625px solid var(--color-black);

  .accordion-item {
    overflow: hidden;
    border-top: 0.625px solid var(--color-black);

    input {
      display: none;
    }

    .accordion-label {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 0;
      cursor: pointer;
      font-size: 16px;
      transition: background 0.3s ease;
    }

    .accordion-icon {
      position: relative;
      width: 14px;
      height: 14px;
      flex-shrink: 0;

      &::before, &::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 14px;
        height: 1px;
        background: var(--color-black);
        border-radius: 2px;
        transform: translate(-50%, -50%);
        transition: transform 0.3s ease, opacity 0.3s ease;
      }

      &::after {
        transform: translate(-50%, -50%) rotate(90deg);
      }

    }

    .accordion-content {
      display: grid;
      grid-template-rows: 0fr;
      transition: grid-template-rows 0.35s ease;

      & > div {
        overflow: hidden;
        margin-bottom: 24px;
      }

      p {
        max-width: 580px;
        font-size: 16px;
        line-height: 1.5;
        color: var(--color-black);
        padding: 0 22px 16px 0;
      }

      .floating-image {
        float: left;
        margin-right: 6px;
        margin-bottom: 0;
        width: 18px;
        height: 18px;
        transform: translateY(1px);
      }
    }

    input:checked + .accordion-label .accordion-icon::after {
      opacity: 0;
      transform: translate(-50%, -50%) rotate(90deg) scale(0);
    }

    input:checked ~ .accordion-content {
      grid-template-rows: 1fr;
    }

  }

}

/* TABS */

.tabs {
  width: 100%;

  .tab-labels {
    position: relative;
    display: flex;
    gap: 32px;

    .tab-label {
      appearance: none;
      border: 0;
      background: none;
      padding: 8px 0;
      margin: 0;
      font-weight: 700;
      color: var(--color-black);
      cursor: pointer;
      transition: color 220ms ease;

      &:hover, &.is-active {
        color: var(--color-primary);
      }

    }

  }

  .tab-underline {
    position: absolute;
    left: 0;
    bottom: 0;
    display: block;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transform: translateX(0);
    transition:
      width 500ms cubic-bezier(0.4, 0, 0.2, 1),
      transform 500ms cubic-bezier(0.4, 0, 0.2, 1);
  }

}

.tab-panels {
  position: relative;
  padding-top: 28px;

  .tab-panel {
    position: absolute;
    inset: 28px 0 auto 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity 500ms cubic-bezier(0.4, 0, 0.2, 1),
      visibility 0s linear 0ms;

    &.is-active {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
    }

    h2 {
      margin: 0 0 12px;
      font-size: 24px;
      font-weight: 400;
    }

    p {
      margin: 0;
      line-height: 1.6;
      color: var(--color-black);
    }

  }

}

/* CAROUSEL */

.carousel {
  position: relative;
  width: 100%;

  .carousel-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: calc(100% + 16px);
    padding: 8px;
    margin-left: -8px;

    &::-webkit-scrollbar {
      display: none;
    }

  }

  .carousel-item {
    flex: 0 0 calc((100% - (16px * 3)) / 4);
    min-height: 160px;
    display: grid;
    place-items: center;
    background: var(--color-white);
    padding: 16px 0;
  }

  .carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 36px;
    height: 36px;
    border: 0;
    cursor: pointer;
    background-color: transparent;

    &[hidden] {
      display: none;
    }

    svg {
      width: 36px;
      height: 36px;
      stroke: var(--color-black);
      stroke-width: 1px;
      fill: none;
      stroke-linecap: round;
      stroke-linejoin: round;
    }

  }

  .carousel-arrow-prev {
    left: -42px;
  }

  .carousel-arrow-next {
    right: -42px;
  }

  @media (max-width: 900px) {
    .carousel-item {
      flex: 0 0 calc((100% - 8px) / 2);
    }
  }

  @media (max-width: 560px) {
   .carousel-item {
      flex: 0 0 100%;
    }
  }

  /* Artwork variant: sized to a common height so the row stays even regardless
     of each image's aspect ratio. */

  &.artwork {
    --artwork-image-height: 528px;

    .carousel-track {
      align-items: start;
      padding: 16px 0;
    }

    /* Unlike the product carousel, artwork items aren't a fixed fraction of the
       track: every image is the same height and each item is only as wide as its
       own image, so aspect ratios are preserved and nothing is cropped. The
       min-content column keeps a long credit line wrapping to the image width
       instead of widening the item. */
    .carousel-item {
      flex: 0 0 auto;
      min-height: 0;
      padding: 0;
      grid-template-columns: min-content;
      align-content: start;
    }

    img {
      display: block;
      height: var(--artwork-image-height);
      width: auto;
      max-width: none;
    }

    .image-credit {
      display: block;
      color: var(--color-gray-20);
      font-size: var(--font-size-2);
      margin-top: var(--space-1);
    }

    @media (max-width: 900px) {
      & {
        --artwork-image-height: 380px;
      }
    }

    @media (max-width: 560px) {
      & {
        --artwork-image-height: 280px;
      }
    }

  }

}

/* MODAL */

body.modal-open {
  overflow: hidden;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.375);
  align-items: center;
  justify-content: center;

  &.open {
    display: flex;
  }

  .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    background: none;
    cursor: pointer;
    color: var(--color-gray-15);
    background-color: var(--color-white);
    padding: 6px;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
    border-radius: 50%;

    &:hover {
      color: var(--color-black);
    }
  }

  .modal-box {
    position: relative;
    background: var(--color-white);
  }

  .modal-box.type-image {
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;

    #modal-content {
      width: 100%;
      height: 100%;
    }

    .img-tile {
      width: 100%;
      height: 100%;
    }

    .modal-close {
      color: var(--color-white);
    }

  }

  .modal-box.type-installation {
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;

    #modal-content {
      width: 100%;
      height: 100%;
    }
    .img-contain {
      width: 100%;
      height: 100%;
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
    }
    .modal-close {
      color: var(--color-white);
    }

  }

  .modal-box.type-cart {
    min-width: 360px;
    text-align: center;
    border-radius: 32px;
    padding: 64px 48px 48px 48px;

    p.product-name {
      font-size: 16px;
      font-weight: 700;
      line-height: 1;
      margin-bottom: 12px;
    }

    p.product-color {
      font-size: 16px;
      font-weight: 700;
      color: #000;
      line-height: 1;
      margin-bottom: 36px;
    }

  }

}

/* DIALOG */

/* The shell shared/_dialog renders: panel and backdrop. The rules below dress
   what callers put inside — a heading, an actions row — without requiring it. */
.dialog {
  background: var(--color-white);
  border: 0;
  border-radius: var(--radius-2);
  box-shadow: var(--shadow-2);
  max-width: 32.5rem;
  padding: 0;
  width: calc(100% - var(--space-5) - var(--space-5));

  &::backdrop {
    background: color-mix(in srgb, var(--color-black) 55%, transparent);
  }

  /* The rhythm runs outward: label to control is tighter than field to field,
     which is tighter than the gap before the row that commits the whole thing. */
  .dialog-body {
    display: grid;
    gap: var(--space-5);
    padding: var(--space-6);
  }

  h2 {
    font-size: var(--font-size-5);
    font-weight: normal;
    line-height: var(--line-height-body-tight);
    text-wrap: balance;
  }

  /* The account grid's row gap is tuned for fields sitting side by side; stacked
     full width, it leaves a field no more separated than its own label. */
  .field-grid {
    row-gap: var(--space-4);
  }

  .dialog-actions {
    align-items: center;
    display: flex;
    gap: var(--space-4);
    margin-top: var(--space-2);

    [hidden] {
      display: none !important;
    }

    /* Smaller than the page's own CTAs, which are sized for a product tray. */
    .cta {
      font-size: 13px;
      height: 40px;
      padding-inline: 22px;
    }

    /* The confirmation dialog rides in the layout, so it reaches phones even
       though the palette board does not. 40px is under the touch floor. */
    @media (pointer: coarse) {
      .cta {
        height: 44px;
      }
    }

    /* A muted fill rather than a faded one: the label stays readable while the
       control is plainly inert. pointer-events also kills the hover fill. */
    .cta:disabled {
      background-color: var(--color-gray-3);
      color: var(--color-gray-20);
      cursor: default;
      pointer-events: none;
    }
  }
}

/* The message is the heading, so the panel wants to be narrower than one
   carrying a form. */
.dialog-confirm {
  max-width: 26rem;
}

/* TILE DOWNLOAD CHOOSER */

/* Rides on .modal + .modal-box.type-cart above; only the form needs rules. */
.tile-download-modal {

  .tile-download-intro {
    font-size: 16px;
    line-height: 1.5;
    margin-bottom: 24px;
  }

  .tile-download-choices {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 36px;
  }

  .tile-download-choice {
    display: flex;
    align-items: center;
    gap: 8px;

    label {
      font-size: 14px;
      line-height: 1.5;
      cursor: pointer;
    }

    input[type="radio"] {
      flex-shrink: 0;
      cursor: pointer;
      accent-color: var(--color-primary);
    }
  }

  .tile-download-submit {
    border: none;
    cursor: pointer;
    width: 100%;
    height: 56px;
    padding: 0 24px;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-white);
    border-radius: var(--radius-round);
    background-color: var(--color-primary);
    transition: background-color var(--transition-fast);

    &:hover {
      background-color: var(--color-primary-hover);
    }
  }

}

/* The favorite / compare / palette buttons  */

.pdp-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 56px;
  padding: 0 8px;
  background: var(--color-white);
  align-self: flex-start;

  .tool {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-gray-3);
    cursor: pointer;
    transition: background-color var(--motion-duration-standard) var(--motion-ease-standard);
  }

  /* button_to wraps the heart and the scale in a <button>; strip the UA chrome
     and let it fill the disc, so the whole circle is the target. */
  .tool button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: none;
    cursor: pointer;
  }

  /* The disc carries the hover; the glyph keeps whatever color its state
     gives it, so an active tool stays red under the cursor. */
  .tool:hover {
    background: var(--color-gray-5);
  }

  .tool.favorited .icon {
    stroke: var(--color-red);
    fill: var(--color-red);
  }

  /* The scale has no interior to fill — the stroke alone carries the state. */
  .tool.compared .icon {
    stroke: var(--color-red);
  }

}

/* EXPANDABLE BUTTON */

/* Outer shell */
/* border-radius: 28px = 50% of the 56px collapsed height.
   overflow: hidden clips children to the rounded rect.
   No fixed height — the container grows with its content. */

.expandable-btn {
  min-width: 150px;
  border-radius: 28px;
  overflow: hidden;
  background: var(--color-gray-15);
  align-self: flex-start;
  &:hover {
    background: var(--color-gray-16);
  }

  &.expandable-btn-primary {
    color: var(--color-white);
    background: var(--color-primary);
    &:hover {
      background: var(--color-primary-hover);
    }
  }

}

/* Trigger <a> */
.expandable-btn-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 24px;
  height: 56px;
  color: var(--color-white);
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* The Bruce Sample link borrows the same pill but has no chevron, so the
   padding asymmetry that makes room for one would push its label off-centre. */
.bruce-sample .expandable-btn-trigger {
  justify-content: center;
  padding: 0 24px;
}

/* Icon + label grouped on the left with 8px gap */
.trigger-label {
  display: flex;
  align-items: center;
  gap: 16px;
  transform: translateY(1px);
}

.trigger-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--color-white);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: translateY(-1px);
}

/* Chevron: points right (→) when closed */
.chevron {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--color-white);
  stroke-width: 2px;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: rotate(0deg);
  transform-origin: center center;
  transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Chevron: rotates clockwise to point down (↓) when open */
.expandable-btn.open .chevron {
  transform: rotate(90deg);
}

/* Sub-button wrapper */
/* grid-template-rows animates from 0 to full content height —
   works with any number of sub-buttons, no fixed px values. */
.sub-items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.expandable-btn.open {
  .sub-items {
    grid-template-rows: 1fr;
  }

  /* Stagger reveal on open */
  .sub-btn:nth-child(1) { transition-delay: 0.10s; opacity: 1; transform: none; }
  .sub-btn:nth-child(2) { transition-delay: 0.17s; opacity: 1; transform: none; }
  .sub-btn:nth-child(3) { transition-delay: 0.24s; opacity: 1; transform: none; }
  .sub-btn:nth-child(4) { transition-delay: 0.31s; opacity: 1; transform: none; }
  .sub-btn:nth-child(5) { transition-delay: 0.38s; opacity: 1; transform: none; }

}

/* overflow: hidden on the inner div is required for the grid trick */
.sub-items-inner {
  overflow: hidden;
  padding: 0 8px 8px;
}

.sub-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 20px;
  background: transparent;
  color: var(--color-white);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
  opacity: 0;
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;

  &.tinted {
    background: rgba(255, 255, 255, 0.1875);
  }

  &::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
  }

  /* Hover background fades in */
  &:hover::before {
    opacity: 1;
  }

  .icon  {
    width: 16px;
    height: 16px;
    stroke: var(--color-white);
    stroke-width: 1.5px;
    position: relative;
  }

  .label {
    position: relative;
    transform: translateY(1px);
  }

}

.qty-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 8px 0 28px 0;

  button {
    width: 2rem;
    height: 2rem;
    background: none;
    font-size: 1.2rem;
    color: var(--color-white);
    cursor: pointer;

    &:disabled {
      opacity: 0.35;
      cursor: not-allowed;
    }
  }

  span {
    font-size: 16px;
    min-width: 16px;
    text-align: center;
  }

  input[type="number"] {
    width: 2.25rem;
    border: none;
    background: none;
    font: inherit;
    font-size: 16px;
    color: inherit;
    text-align: center;
    appearance: textfield;
    -moz-appearance: textfield;

    &::-webkit-outer-spin-button,
    &::-webkit-inner-spin-button {
      appearance: none;
      margin: 0;
    }
  }
}
