/*
* --------------------------------------------------
* Shared colour swatch (app/features/meat-paper/components/MeatPaperSwatch.jsx), 2026-10-05.
* One look on every PDP, card and campaign page: a round chip read like a lens in its frame
* (outer ring = frame colour, centre = lens, hairline = metal parts). Fixed size, never stretched by the label.
* Loaded after app.css (root.jsx).
* --------------------------------------------------
*/
.mp-swatches {
  --mp-sw-size: 34px;
  --mp-sw-item: 60px;
  display: block;
  margin: 0 0 16px;
  min-width: 0;
  position: relative;
  z-index: 4;
}

.mp-swatches--card {
  --mp-sw-size: 20px;
  margin: 8px 0 0;
}

.mp-swatches.mc-swatches {
  display: block;
}

.mp-swatches__row {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 4px;
  justify-content: flex-start;
}

.mp-swatches--card .mp-swatches--card .mp-swatch__number {
  border-width: 1px;
  font-size: 0.52rem;
  height: 14px;
  inset-block-start: -7px;
  inset-inline-end: -6px;
  min-width: 14px;
}

.mp-swatches--card .mp-swatch:has(.mp-swatch__number) {
  margin-inline-end: 5px;
}

.mp-swatches__active {
  margin-top: 2px;
}

.mp-swatches--card .mp-swatches__row {
  gap: 0 1px;
}

.mp-swatch {
  -webkit-tap-highlight-color: transparent;
  align-items: center;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--paper-ink, #050505);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 var(--mp-sw-item);
  flex-direction: column;
  gap: 6px;
  margin: 0;
  min-width: 0;
  padding: 5px 2px 0;
  position: relative;
  width: var(--mp-sw-item);
}

.mp-swatches--card .mp-swatch {
  flex: 0 0 auto;
  justify-content: center;
  min-height: 28px;
  min-width: 28px;
  padding: 4px;
  width: auto;
}

.mp-swatch__chip {
  display: block;
  flex: none;
  height: var(--mp-sw-size);
  position: relative;
  width: var(--mp-sw-size);
}

.mp-swatch__dot {
  --mp-sw-ring: 21%;
  background: var(--mp-sw-frame, #8a8a86);
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(5, 5, 5, 0.22),
    0 2px 5px rgba(5, 5, 5, 0.16);
  display: block;
  height: 100%;
  overflow: hidden;
  position: relative;
  transition:
    box-shadow 140ms ease,
    transform 140ms ease;
  width: 100%;
}

/* Lens centre (with a soft glass sheen). */
.mp-swatch__dot::after {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 46%),
    var(--mp-sw-lens, transparent);
  border-radius: 50%;
  content: '';
  inset: var(--mp-sw-ring);
  position: absolute;
}

.mp-swatch__dot[data-lens='none']::after {
  display: none;
}

/* Clear lens (optical frames, demo lenses): paper glass. */
.mp-swatch__dot[data-lens='clear']::after {
  background:
    linear-gradient(135deg, #ffffff 0%, #ffffff 40%, #e7e5df 100%);
  box-shadow: inset 0 0 0 1px rgba(5, 5, 5, 0.12);
}

/* Metal parts: a hairline between frame and lens. */
.mp-swatch__dot[data-accent='true']::after {
  box-shadow: 0 0 0 2px var(--mp-sw-accent);
}

.mp-swatch__dot[data-accent='true'][data-lens='clear']::after {
  box-shadow:
    0 0 0 2px var(--mp-sw-accent),
    inset 0 0 0 1px rgba(5, 5, 5, 0.12);
}

/* Tortoise / havana: small warm flecks on the dark frame colour. */
.mp-swatch__dot[data-pattern='tortoise'] {
  background:
    radial-gradient(ellipse 14% 10% at 18% 30%, var(--mp-sw-frame-alt, #a8662a) 60%, transparent 100%),
    radial-gradient(ellipse 10% 13% at 46% 12%, var(--mp-sw-frame-alt, #a8662a) 55%, transparent 100%),
    radial-gradient(ellipse 12% 9% at 80% 26%, var(--mp-sw-frame-alt, #a8662a) 55%, transparent 100%),
    radial-gradient(ellipse 9% 12% at 88% 62%, var(--mp-sw-frame-alt, #a8662a) 55%, transparent 100%),
    radial-gradient(ellipse 13% 9% at 62% 88%, var(--mp-sw-frame-alt, #a8662a) 55%, transparent 100%),
    radial-gradient(ellipse 10% 12% at 22% 78%, var(--mp-sw-frame-alt, #a8662a) 55%, transparent 100%),
    radial-gradient(ellipse 7% 6% at 8% 54%, var(--mp-sw-frame-alt, #a8662a) 55%, transparent 100%),
    var(--mp-sw-frame, #3a2216);
}

/* Clear / crystal frame: light checker under a thin tint of the real frame colour. */
.mp-swatch__dot[data-pattern='clear'] {
  background:
    linear-gradient(
      color-mix(in srgb, var(--mp-sw-frame, #e9ecea) 55%, transparent),
      color-mix(in srgb, var(--mp-sw-frame, #e9ecea) 55%, transparent)
    ),
    repeating-conic-gradient(#ffffff 0 25%, #dcdfdc 0 50%) 0 0 / 8px 8px;
}

@media (hover: hover) {
  .mp-swatch:hover .mp-swatch__dot {
    transform: translateY(-1px);
  }
}

/* Selected: ink ring with a paper gap, plus the brand mark under the label. */
.mp-swatch.is-active .mp-swatch__dot {
  box-shadow:
    0 0 0 2px #fffdf8,
    0 0 0 4px var(--paper-ink, #050505),
    0 3px 7px rgba(5, 5, 5, 0.22);
}

.mp-swatch:focus-visible {
  outline: none;
}

.mp-swatch:focus-visible .mp-swatch__dot {
  box-shadow:
    0 0 0 2px #fffdf8,
    0 0 0 4px var(--paper-orange, #e86830);
}

.mp-swatch__label {
  -webkit-box-orient: vertical;
  display: -webkit-box;
  font-family: 'Courier New', monospace;
  font-size: 0.66rem;
  font-weight: 700;
  -webkit-line-clamp: 2;
  letter-spacing: 0;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: center;
  text-transform: uppercase;
}

.mp-swatch__label[lang='ar'] {
  font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
  font-size: 0.74rem;
  text-transform: none;
}

.mp-swatch.is-active .mp-swatch__label {
  font-weight: 900;
}

.mp-swatch.is-active .mp-swatch__label::after {
  background: var(--paper-orange, #e86830);
  content: '';
  display: block;
  height: 3px;
  margin: 3px auto 0;
  width: 22px;
}

.mp-swatch.is-extra .mp-swatch__label {
  opacity: 0.72;
}

/* Campaign video number: a small tag on the chip, never the main label. */
.mp-swatch__number {
  background: var(--paper-ink, #050505);
  border: 1.5px solid #fffdf8;
  border-radius: 999px;
  color: #ffffff;
  display: grid;
  font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  height: 17px;
  inset-block-start: -6px;
  inset-inline-end: -8px;
  line-height: 1;
  min-width: 17px;
  padding: 0 3px;
  place-items: center;
  position: absolute;
}

.mp-swatches__active {
  font-family: 'Courier New', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 8px 0 0;
  text-transform: uppercase;
}

.mp-swatches__active[lang='ar'] {
  font-family: Tahoma, 'Segoe UI', Arial, sans-serif;
  text-transform: none;
}

@media (min-width: 720px) {
  .mp-swatches--pdp {
    --mp-sw-size: 40px;
    --mp-sw-item: 76px;
  }
}

/* Shopify option swatches (generic product template, cart form): same round chip. */
.meat-paper-template__swatch,
.product-option-label-swatch {
  border: 0;
  border-radius: 50%;
  box-shadow:
    0 0 0 1px rgba(5, 5, 5, 0.22),
    0 2px 5px rgba(5, 5, 5, 0.16);
  height: 22px;
  object-fit: cover;
  overflow: hidden;
  width: 22px;
}

@media (prefers-reduced-motion: reduce) {
  .mp-swatch__dot {
    transition: none;
  }
}
