/* PDP ürün seçenekleri — JS: content/js/myt-product-options.js
 * Tüm Twig temaları: index.php _inject_global_assets ile yüklenir (myt-campaign-cart-bundle.css ile aynı kuyruk).
 * Galeri: yalnızca secenek_tip === 4 (Görsel eşlemeli) image_ids ile.
 * Tema-bağımsız: Kök #myt-product-options kendi font-family + font-size'ını kurar;
 *   Luxeva'nın html{font-size:62.5%} tabanında dahi küçülmez. Tüm iç değerler px tabanlıdır.
 *   BS4 .form-control kalıntıları (fiyat kutusu/select) nötralize edilir.
 */
#myt-product-options {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #212529;
}

#myt-product-options.myt-po__hidden {
  display: none !important;
}

#myt-product-options .myt-po__group {
  margin-bottom: 12px;
}

#myt-product-options .myt-po__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #212529;
  line-height: 1.45;
}

#myt-product-options .myt-po__req {
  color: #dc3545;
}

#myt-product-options .myt-po__choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

#myt-product-options .myt-po__choice {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  cursor: pointer;
  font-size: 15px;
  font-weight: 400;
  line-height: 1.45;
  color: #212529;
  border: none;
  background: transparent;
  padding: 0;
  vertical-align: middle;
  width: auto;
  max-width: none;
}

/* Yerel radyo/checkbox daireleri — swatch + metin etiketi özel arayüz; input görünmez kalır */
#myt-product-options .myt-po__choices .myt-po__choice-input[type='radio'],
#myt-product-options .myt-po__choices .myt-po__choice-input[type='checkbox'] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
}

#myt-product-options .myt-po__choices .myt-po__choice-input[type='radio']:focus,
#myt-product-options .myt-po__choices .myt-po__choice-input[type='checkbox']:focus {
  outline: none;
}

@supports selector(:has(*)) {
  #myt-product-options .myt-po__choice:has(.myt-po__choice-input:focus-visible) {
    outline: 2px solid var(--bs-primary, #0d6efd);
    outline-offset: 2px;
    border-radius: 6px;
  }
}

#myt-product-options .myt-po__choice--disabled {
  opacity: 0.55;
  cursor: not-allowed;
  text-decoration: line-through;
}

#myt-product-options .myt-po__choice-input:disabled + .myt-po__swatch-wrap,
#myt-product-options .myt-po__choice-input:disabled ~ .myt-po__choice-label {
  opacity: inherit;
}

#myt-product-options .myt-po__choice-label {
  font-size: 15px;
  line-height: 1.45;
}

#myt-product-options .myt-po__choice--active .myt-po__choice-label {
  font-weight: 600;
}

#myt-product-options .myt-po__choice-input:checked ~ .myt-po__choice-label {
  font-weight: 600;
}

/* Seçili satır vurgusu — renk swatch varsa sadece swatch ring (çift çerçeve olmasın) */
#myt-product-options .myt-po__choice.myt-po__choice--active {
  outline: 2px solid var(--bs-dark, #212529);
  outline-offset: 2px;
  border-radius: 4px;
  padding: 2px 4px;
}

@supports selector(:has(*)) {
  #myt-product-options .myt-po__choice.myt-po__choice--active:has(.myt-po__swatch-wrap) {
    outline: none;
    padding: 0;
    border-radius: 0;
  }
}

/* ── Renk swatch (HEX) — Shopify tarzı: yüzey + ring + tooltip ── */

#myt-product-options .myt-po__swatch-wrap {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
  vertical-align: middle;
  isolation: isolate;
}

#myt-product-options .myt-po__swatch-face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  transition: transform 0.3s ease;
  will-change: transform;
  z-index: 1;
}

#myt-product-options .myt-po__swatch {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-sizing: border-box;
  border: 2px solid rgba(0, 0, 0, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

/* Tooltip (::before) */
#myt-product-options .myt-po__swatch-wrap[data-title]::before {
  content: attr(data-title);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  z-index: 5;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  color: #fff;
  background: rgba(15, 15, 15, 0.92);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(6px);
  transition:
    opacity 0.28s ease,
    transform 0.28s ease;
}

@media (hover: hover) and (pointer: fine) {
  #myt-product-options .myt-po__choice:not(.myt-po__choice--disabled):hover .myt-po__swatch-wrap[data-title]::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }

  #myt-product-options .myt-po__choice:not(.myt-po__choice--disabled):hover .myt-po__swatch-face {
    transform: scale(1.15);
  }

  #myt-product-options .myt-po__choice:not(.myt-po__choice--disabled):hover .myt-po__swatch-wrap::after {
    opacity: 1;
    transform: scale(1);
    border-color: rgba(0, 0, 0, 0.16);
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.9) inset,
      0 2px 12px rgba(0, 0, 0, 0.1);
  }
}

#myt-product-options .myt-po__choice:focus-within .myt-po__swatch-wrap[data-title]::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

#myt-product-options .myt-po__swatch-wrap.is-po-tip[data-title]::before {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Dış halka (::after) */
#myt-product-options .myt-po__swatch-wrap::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  box-sizing: border-box;
  border: 2px solid transparent;
  opacity: 0;
  transform: scale(0.92);
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    border-color 0.3s ease,
    box-shadow 0.3s ease;
  pointer-events: none;
  z-index: 0;
}

#myt-product-options .myt-po__choice:not(.myt-po__choice--disabled):active .myt-po__swatch-face {
  transform: scale(1.08);
}

/* Seçili — .myt-po__choice--active (JS + :checked ile senkron) */
#myt-product-options .myt-po__choice.myt-po__choice--active .myt-po__swatch-face {
  transform: scale(1.1);
}

#myt-product-options .myt-po__choice.myt-po__choice--active .myt-po__swatch-wrap::after {
  opacity: 1;
  transform: scale(1);
  border-color: rgba(26, 26, 26, 0.82);
  border-width: 2px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.95) inset,
    0 0 0 1px rgba(26, 26, 26, 0.35),
    0 4px 16px rgba(0, 0, 0, 0.12);
}

#myt-product-options .myt-po__choice--disabled .myt-po__swatch-wrap::after {
  opacity: 0 !important;
}

#myt-product-options .myt-po__choice--disabled .myt-po__swatch-face {
  transform: none !important;
  filter: grayscale(0.35);
}

@media (prefers-reduced-motion: reduce) {
  #myt-product-options .myt-po__swatch-face,
  #myt-product-options .myt-po__swatch-wrap::after,
  #myt-product-options .myt-po__swatch-wrap[data-title]::before {
    transition-duration: 0.01ms;
  }

  @media (hover: hover) and (pointer: fine) {
    #myt-product-options .myt-po__choice:not(.myt-po__choice--disabled):hover .myt-po__swatch-face {
      transform: none;
    }
  }

  #myt-product-options .myt-po__choice.myt-po__choice--active .myt-po__swatch-face {
    transform: none;
  }
}

/* Açılır liste + metin — BS4/BS5 ortak (form-select yalnızca BS5).
   .form-control / .custom-select gibi tema sınıflarının rem tabanlı boyutlarını nötralize
   etmek için px kullanıyoruz. */
#myt-product-options .myt-po__select,
#myt-product-options select.myt-po__select,
#myt-product-options .myt-po__input,
#myt-product-options input.myt-po__input {
  display: block;
  width: 100%;
  max-width: 352px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 44px;
  box-shadow: none;
  appearance: auto;
  -webkit-appearance: auto;
}

#myt-product-options .myt-po__select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23495057' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='3 6 8 11 13 6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px;
  -webkit-appearance: none;
  appearance: none;
}

#myt-product-options .myt-po__select:focus,
#myt-product-options .myt-po__input:focus {
  border-color: #86b7fe;
  outline: 0;
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
}

#myt-product-options .myt-po__input {
  font-size: 15px;
  padding: 8px 11px;
  min-height: 40px;
}

/* BS4 ".form-control" override'larının içerideki height'i eskitmesini engelle */
#myt-product-options select.form-control.myt-po__select,
#myt-product-options input.form-control.myt-po__input {
  height: auto;
}
