/* Product variants: colour / photo swatches for radio and checkbox options.
   Uses the storefront brand tokens so the picker matches the rest of the theme. */

.ms-opt { margin-bottom: 22px; }

.ms-opt-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ms-opt-label {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #22302e;
  letter-spacing: .01em;
  justify-self: start;
}

/* The chosen value sits in the middle of the option row as a compact filled chip:
   brand gradient, white text, a check mark and a tight shadow - no tall empty box. */
.ms-opt-chosen {
  justify-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 14px;
  line-height: 1.25;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-deep, #0f5f5e) 0%, var(--brand, #17807f) 60%, var(--brand-soft, #2a9d9a) 100%);
  border: 0;
  border-radius: 9px;
  box-shadow: 0 5px 12px -7px rgba(var(--brand-rgb, 23, 128, 127), .95), inset 0 1px 0 rgba(255, 255, 255, .3);
  overflow-wrap: anywhere;
}

.ms-opt-chosen:not(:empty)::before {
  content: '\2713';
  font-size: 11px;
  line-height: 1;
  opacity: .95;
}

.ms-opt-chosen:empty {
  color: #a7b5b2;
  background: #f4f7f7;
  box-shadow: inset 0 0 0 1px #e3ebea;
}

.ms-opt-chosen:empty::before { content: '—'; font-weight: 600; }

.ms-opt-hint { font-size: 12px; color: #5b6a67; justify-self: end; }

/* On phones the group label and the selected-value chip share one row instead of stacking, so the
   picker stays short. They only stack when the two genuinely cannot fit side by side. */
@media (max-width: 480px) {
  .ms-opt-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 10px;
  }
  .ms-opt-label { flex: 0 1 auto; min-width: 0; }
  .ms-opt-chosen,
  .ms-opt-hint { margin-left: auto; }
}

/* Every option box sits on its own equal track, and every row is the same height, so a long
   choice name can never make one box bigger than the others. */
.ms-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 104px), 1fr));
  grid-auto-rows: 1fr;
  gap: 10px;
  align-items: stretch;
}

.ms-sw {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  min-width: 0;
  height: 100%;
  margin: 0;
  cursor: pointer;
}

.ms-sw input {
  position: absolute !important;
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
  margin: 0 !important;
  pointer-events: none;
}

.ms-sw-face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  gap: 9px;
  min-height: 46px;
  padding: 8px 15px;
  border: 2px solid #dbe7e6;
  border-radius: 12px;
  background: #fff;
  color: #22302e;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.ms-sw-name { min-width: 0; overflow-wrap: anywhere; }

.ms-sw:hover .ms-sw-face { border-color: var(--brand-soft, #2a9d9a); }

.ms-sw input:checked + .ms-sw-face {
  border-color: var(--brand, #17807f);
  background: var(--brand-tint, #f2faf9);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 23, 128, 127), .16);
}

.ms-sw input:focus-visible + .ms-sw-face {
  outline: 2px solid var(--brand, #17807f);
  outline-offset: 2px;
}

.ms-sw-dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 1px rgba(0, 0, 0, .14);
  flex: 0 0 auto;
}

.ms-sw-tick {
  display: none !important;
  color: var(--brand, #17807f);
  font-size: 12px;
}

.ms-sw input:checked + .ms-sw-face .ms-sw-tick { display: inline-block !important; }

.ms-sw-photo .ms-sw-face {
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  min-width: 96px;
}

.ms-sw-photo .ms-sw-face img {
  width: 74px;
  height: 74px;
  object-fit: cover;
  border-radius: 9px;
  display: block;
}

.ms-sw-photo .ms-sw-name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  max-width: 96px;
  line-height: 1.3;
}

.ms-sw-photo .ms-sw-tick {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  align-items: center;
  justify-content: center;
}

.ms-sw-photo input:checked + .ms-sw-face .ms-sw-tick { display: flex !important; }

.ms-sw-price {
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #55645f;
}

/* Big picture tiles: used when an option would otherwise be a plain dropdown, so the buyer
   can see the actual item instead of reading a list of names. They are grid tracks that share
   the row evenly and only wrap once a card would have to shrink below ~70% of its comfy size. */
.ms-swatches-lg {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 92px), 1fr));
  grid-auto-rows: 1fr;
  gap: 12px;
  align-items: stretch;
}

.ms-swatches-lg .ms-sw-lg {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 220px;
}

/* keeps the prices of a row on one baseline even when one name wraps to two lines */
.ms-swatches-lg .ms-sw-price { margin-top: auto; }

.ms-swatches-lg .ms-sw-lg .ms-sw-face {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-start;
  padding: 8px;
  border-radius: 14px;
  gap: 8px;
}

.ms-swatches-lg .ms-sw-lg .ms-sw-face img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  object-fit: cover;
  display: block;
  background: #f3f6f6;
}

.ms-swatches-lg .ms-sw-lg .ms-sw-name {
  max-width: 100%;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.ms-sw-lg .ms-sw-tick {
  top: 9px;
  right: 9px;
  width: 22px;
  height: 22px;
}

@media (max-width: 480px) {
  .ms-sw-face { min-height: 44px; padding: 7px 12px; font-size: 13px; }
  .ms-swatches {
    gap: 8px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 92px), 1fr));
  }
  .ms-sw-photo .ms-sw-face img { width: 64px; height: 64px; }
  .ms-sw-photo .ms-sw-face { min-width: 84px; }

  /* keep the big tiles big on phones - but let three of them share the row instead of
     pushing the last card down when there is still room for it */
  .ms-swatches-lg {
    gap: 9px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 74px), 1fr));
  }
  .ms-swatches-lg .ms-sw-lg .ms-sw-face { padding: 6px; }
  .ms-swatches-lg .ms-sw-lg .ms-sw-name { font-size: 12px; }
}

/* The buyer came from a listing page with a product that needs a choice: highlight the picker until one
   is made. Injected by common.js when the cart sends them back here. */
.ms-choose-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid #f5c78a;
  border-left: 4px solid #e08b1a;
  background: #fff8ee;
  color: #7a4a08;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.45;
}

.ms-choose-note i { color: #e08b1a; font-size: 15px; }

.ms-opt-attention > .ms-swatches,
.ms-opt-attention > .ms-swatches-lg {
  border-radius: 14px;
  outline: 2px solid rgba(224, 139, 26, .55);
  outline-offset: 6px;
  animation: ms-opt-pulse 1.8s ease-in-out 2;
}

@keyframes ms-opt-pulse {
  0%, 100% { outline-color: rgba(224, 139, 26, .18); }
  50% { outline-color: rgba(224, 139, 26, .7); }
}

@media (prefers-reduced-motion: reduce) {
  .ms-opt-attention > .ms-swatches,
  .ms-opt-attention > .ms-swatches-lg { animation: none; }
  .ms-sw-face { transition: none; }
}
