/* ==========================================================================
   PeakShops Quick Add Window
   Opened from product cards (quick-add.js). A native <dialog>: Esc closes
   it, the page behind is inert, and the browser keeps focus inside.
   Desktop: centred two-column window. Phones: bottom sheet with a sticky
   add-to-cart bar.
   ========================================================================== */

dialog.peak-qa {
  width: min(900px, calc(100vw - 48px));
  max-width: none;
  max-height: min(660px, calc(100dvh - 48px));
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: #ffffff;
  color: var(--color-text-dark, #1E293B);
  box-shadow: 0 24px 64px rgba(19, 34, 53, 0.28);
  overflow: hidden;
  font-family: var(--font-primary);
}

dialog.peak-qa[open] {
  display: flex;
  animation: peak-qa-in 0.22s ease-out;
}

dialog.peak-qa::backdrop {
  background: rgba(19, 34, 53, 0.55);
  backdrop-filter: blur(2px);
}

@keyframes peak-qa-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.peak-qa-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 5;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--color-navy, #132235);
  box-shadow: 0 2px 10px rgba(19, 34, 53, 0.15);
  cursor: pointer;
}

.peak-qa-close:hover {
  background: var(--color-navy, #132235);
  color: #ffffff;
}

.peak-qa-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: 100%;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   Photos
   -------------------------------------------------------------------------- */
.peak-qa-media {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px;
  background: var(--color-peach-bg, #FDF3E7);
  min-height: 0;
}

.peak-qa-main {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
}

.peak-qa-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Badge look comes from product-card.css; here only its place. */
.peak-qa-badge {
  position: absolute;
  top: 10px;
  left: 10px;
}

.peak-qa-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.peak-qa-thumbs::-webkit-scrollbar {
  display: none;
}

.peak-qa-thumb {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  cursor: pointer;
}

.peak-qa-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.peak-qa-thumb[aria-current="true"] {
  border-color: var(--color-amber, #C56E1A);
}

/* --------------------------------------------------------------------------
   Details
   -------------------------------------------------------------------------- */
.peak-qa-details {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.peak-qa-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px 28px 8px;
}

.peak-qa-category {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted, #64748B);
}

.peak-qa-title {
  margin: -6px 48px 0 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-navy, #132235);
}

.peak-qa-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--color-amber-text, #A85B12);
}

.peak-qa-price ins {
  order: -1;
  background: none;
  text-decoration: none;
}

.peak-qa-price del {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-muted, #64748B);
}

.peak-qa-excerpt {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #475569;
}

/* Options */
.peak-qa-attr {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.peak-qa-attr legend {
  margin-bottom: 8px;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-navy, #132235);
}

.peak-qa-attr legend span {
  font-weight: 500;
  color: var(--color-text-muted, #64748B);
}

.peak-qa-attr.has-error legend {
  color: #B42318;
}

.peak-qa-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.peak-qa-option {
  min-height: 38px;
  padding: 0 14px;
  border: 1.5px solid #E2E8F0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--color-navy, #132235);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.peak-qa-option:hover {
  border-color: var(--color-navy, #132235);
}

.peak-qa-option[aria-pressed="true"] {
  border-color: var(--color-navy, #132235);
  background: var(--color-navy, #132235);
  color: #ffffff;
}

.peak-qa-option.is-unavailable {
  color: #94A3B8;
  text-decoration: line-through;
}

.peak-qa-option.is-unavailable[aria-pressed="true"] {
  color: #ffffff;
}

/* Colour swatches */
.peak-qa-option.is-swatch {
  width: 38px;
  height: 38px;
  min-height: 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--swatch, #cccccc);
  box-shadow: 0 0 0 1.5px #CBD5E1;
}

/* Chosen colour: navy ring plus a check mark, so it never looks like the
   amber keyboard-focus ring. The check flips to dark on light colours. */
.peak-qa-option.is-swatch[aria-pressed="true"] {
  border-color: #ffffff;
  background: var(--swatch, #cccccc);
  box-shadow: 0 0 0 2.5px var(--color-navy, #132235);
  position: relative;
}

.peak-qa-option.is-swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 6px;
  height: 11px;
  border: solid #ffffff;
  border-width: 0 2.5px 2.5px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

.peak-qa-option.is-swatch.is-light[aria-pressed="true"]::after {
  border-color: var(--color-navy, #132235);
}

body.peak-qa-open {
  overflow: hidden;
}

.peak-qa-option.is-swatch.is-unavailable {
  opacity: 0.4;
  text-decoration: none;
}

.peak-qa-option:focus-visible,
.peak-qa-thumb:focus-visible,
.peak-qa-close:focus-visible,
.peak-qa-qty button:focus-visible,
.peak-qa-submit:focus-visible {
  outline: 2px solid var(--color-amber, #C56E1A);
  outline-offset: 2px;
}

.peak-qa-stock {
  margin: 0;
  font-size: 13px;
  color: #1E6B40;
}

.peak-qa-stock.is-out {
  color: #B42318;
}

.peak-qa-stock:empty {
  display: none;
}

/* Quantity + add to cart */
.peak-qa-buy {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: 16px 28px 24px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.peak-qa-buy-row {
  display: flex;
  gap: 10px;
}

.peak-qa-qty {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  height: 50px;
  border: 1.5px solid #E2E8F0;
  border-radius: 10px;
  overflow: hidden;
}

.peak-qa-qty button {
  width: 40px;
  height: 100%;
  border: 0;
  background: transparent;
  color: var(--color-navy, #132235);
  font-size: 18px;
  cursor: pointer;
}

.peak-qa-qty button:hover {
  background: #F1F5F9;
}

.peak-qa-qty input {
  width: 40px;
  height: 100%;
  border: 0;
  text-align: center;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-navy, #132235);
  -moz-appearance: textfield;
  appearance: textfield;
}

.peak-qa-qty input::-webkit-outer-spin-button,
.peak-qa-qty input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.peak-qa-submit {
  flex: 1 1 auto;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  background: var(--color-navy, #132235);
  color: #ffffff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.peak-qa-submit:hover {
  background: var(--color-amber-hover, #b05f14);
}

.peak-qa-submit:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
}

.peak-qa-submit.is-busy {
  opacity: 0.75;
  cursor: progress;
}

.peak-qa-msg {
  margin: 0;
  font-size: 13px;
  color: #B42318;
}

.peak-qa-msg:empty {
  display: none;
}

.peak-qa-link {
  align-self: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-navy, #132235);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.peak-qa-link:hover {
  color: var(--color-amber-text, #A85B12);
}

/* Loading */
.peak-qa-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 320px;
}

.peak-qa-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #E2E8F0;
  border-top-color: var(--color-amber, #C56E1A);
  border-radius: 50%;
  animation: peak-qa-spin 0.8s linear infinite;
}

@keyframes peak-qa-spin {
  to { transform: rotate(360deg); }
}

.peak-qa-error {
  padding: 48px 28px;
  text-align: center;
  width: 100%;
}

/* --------------------------------------------------------------------------
   Phones: bottom sheet
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  dialog.peak-qa {
    width: 100vw;
    max-height: 92dvh;
    margin: auto 0 0;
    border-radius: 18px 18px 0 0;
  }

  dialog.peak-qa[open] {
    animation-name: peak-qa-up;
  }

  @keyframes peak-qa-up {
    from { transform: translateY(40px); opacity: 0.6; }
    to   { transform: none; opacity: 1; }
  }

  .peak-qa-inner {
    grid-template-columns: 1fr;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .peak-qa-media {
    padding: 12px 12px 8px;
  }

  .peak-qa-main {
    flex: none;
    width: 100%;
    max-height: 34dvh;
  }

  .peak-qa-thumb {
    flex-basis: 48px;
    width: 48px;
    height: 48px;
  }

  .peak-qa-details {
    overflow: visible;
  }

  .peak-qa-info {
    gap: 10px;
    padding: 16px 16px 4px;
  }

  .peak-qa-title {
    margin: 0;
    font-size: 18px;
  }

  .peak-qa-price {
    font-size: 18px;
  }

  .peak-qa-excerpt {
    font-size: 13px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .peak-qa-buy {
    padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid #EEF2F6;
    box-shadow: 0 -6px 16px rgba(19, 34, 53, 0.06);
  }

  .peak-qa-qty,
  .peak-qa-submit {
    height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  dialog.peak-qa[open] {
    animation: none;
  }
}
