/* ===========================================================================
   SINGLE PRODUCT PAGE — assets/pages/product.css
   ---------------------------------------------------------------------------
   Scoped styling for the single product template. Loaded ONLY on product pages,
   after all shared stylesheets (tokens.css, style.css, commerce.css,
   storefront.css).

   Concerns:
   - Product image gallery sizing and layout
   - Title, price, and purchase controls placement and hierarchy
   - Stock status and product details presentation
   - Related products grid at the end
   - Payment methods styling (PayPal plugin)
   - Responsive layout at all widths (320–1366px)
   ========================================================================= */

/* ---------------------------------------------------------------------------
   PRODUCT LAYOUT — two-column wrapper (gallery + summary)
   Mobile: stack; desktop: side-by-side
   --------- --------------------------------------------------- ----------- */

.dp-product {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-12);
  padding: var(--space-8) 0;
}

@media (min-width: 768px) {
  .dp-product {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    gap: var(--space-16);
  }
}

@media (max-width: 600px) {
  .dp-product {
    gap: var(--space-6);
    padding: var(--space-4) 0;
  }
}

/* ---------------------------------------------------------------------------
   GALLERY — image container, ensure square aspect ratio with fallback
   --------- --------------------------------------------------- ----------- */

.dp-gallery {
  background: var(--label);
  border: var(--line);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
}

.dp-gallery .woocommerce-product-gallery {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dp-gallery .woocommerce-product-gallery__wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dp-gallery .woocommerce-product-gallery__image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dp-gallery img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  padding: var(--space-6);
}

/* Fallback when no image exists — show a light placeholder */
.dp-gallery .woocommerce-product-gallery--without-images {
  background: var(--label);
  color: var(--graphite);
  font-size: var(--text-small);
  font-family: var(--body);
}

/* ---------------------------------------------------------------------------
   SUMMARY — right column: title, price, purchase controls, specs
   --------- --------------------------------------------------- ----------- */

.entry-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

/* Eyebrow — brand or department label in mono */
.entry-summary .dp-eyebrow {
  margin: 0;
  margin-bottom: var(--space-3);
}

/* Product title — large, bold, natural wrapping */
.entry-summary .dp-ptitle {
  margin: 0;
  line-height: 1.3;
  color: var(--wrap-deep);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Price section — prominent, spaced */
.entry-summary .dp-pprice {
  margin: var(--space-3) 0 0;
  font-size: 28px;
  font-weight: 700;
  font-family: var(--body);
  font-variant-numeric: tabular-nums;
  color: var(--wrap-deep);
}

.entry-summary .dp-pprice .dp-now {
  color: var(--wrap-deep);
}

/* Strike price (old list price) — smaller, muted */
.entry-summary .dp-pprice .dp-list {
  font-size: 18px;
  color: var(--graphite);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  margin-right: var(--space-2);
  font-weight: 400;
}

/* Stock status — clear yes/no statement */
.entry-summary .dp-pstock {
  margin: 0;
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--tally);
}

.entry-summary .dp-pstock.dp-oos {
  color: var(--stamp);
}

/* Note about shipping — optional, smaller text */
.entry-summary .dp-product-note {
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--text-small);
  color: var(--graphite);
  line-height: 1.5;
}

.entry-summary .dp-product-note a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Stock count (Woo native) — hide or minimize */
.entry-summary .stock {
  display: none;
}

/* ---------------------------------------------------------------------------
   PURCHASE FORM — quantity + add-to-cart button, stacked on mobile
   --------- --------------------------------------------------- ----------- */

.entry-summary form.cart {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
  align-items: center;
  margin: var(--space-2) 0 var(--space-6);
}

.entry-summary form.cart .quantity {
  display: flex;
  align-items: center;
  margin: 0;
  float: none;
}

.entry-summary form.cart .qty {
  min-height: var(--touch);
  min-width: 70px;
  max-width: 90px;
  font-size: var(--text-body);
  font-family: var(--body);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--rule);
  background: #fff;
  color: var(--wrap-deep);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.entry-summary form.cart .qty:focus {
  outline: 3px solid var(--stamp);
  outline-offset: 1px;
  border-color: var(--wrap);
}

.entry-summary form.cart .single_add_to_cart_button {
  min-height: var(--touch);
  padding: var(--space-3) var(--space-6);
  flex: 1;
  min-width: 180px;
  font-size: var(--text-body);
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: .09em;
  text-transform: uppercase;
  background: var(--wrap);
  color: #fff;
  border: 1px solid var(--wrap);
  border-radius: 0;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
  text-decoration: none;
}

.entry-summary form.cart .single_add_to_cart_button:hover {
  background: var(--wrap-deep);
  border-color: var(--wrap-deep);
  color: #fff;
}

.entry-summary form.cart .single_add_to_cart_button:focus-visible {
  outline: 3px solid var(--stamp);
  outline-offset: 2px;
}

/* Disabled state (out of stock, etc.) */
.entry-summary form.cart .single_add_to_cart_button:disabled {
  background: var(--graphite);
  border-color: var(--graphite);
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 600px) {
  .entry-summary form.cart {
    flex-direction: column;
    gap: var(--space-2);
  }

  .entry-summary form.cart .qty {
    width: 100%;
    min-width: auto;
    max-width: none;
  }

  .entry-summary form.cart .single_add_to_cart_button {
    width: 100%;
    min-width: auto;
    flex: none;
  }
}

/* ---------------------------------------------------------------------------
   PAYMENT METHODS — PayPal plugin buttons (ppcp-gateway)
   The PayPal buttons carry their own bright colors (yellow, blue) which
   conflict with the apothecary-editorial palette. Since these are not part
   of the core Woo checkout flow (that's handled by WooCommerce Payments),
   we scale them down and mute their styling to avoid visual dominance.
   --------- --------------------------------------------------- ----------- */

.ppcp-messages {
  /* "OR PAY DIRECTLY" message — scale down, mute color */
  margin: var(--space-4) 0 var(--space-3);
  font-size: var(--text-small);
  color: var(--graphite);
}

/* PayPal button wrapper */
.ppc-button-wrapper {
  margin: var(--space-4) 0 var(--space-6);
}

/* Hide if this is truly catalog mode (woocommerce_is_purchasable returns false).
   If purchasing is live, the buttons display but with reduced prominence. */
#ppc-button-ppcp-gateway {
  /* The iframe rendering PayPal buttons will keep its native styling, but
     we can constrain its space and make it less prominent visually. */
}

#ppc-button-ppcp-gateway iframe {
  max-width: 100%;
}

/* ---------------------------------------------------------------------------
   PRODUCT DETAILS TABLE — specs, brand, condition, item code
   --------- --------------------------------------------------- ----------- */

.dp-spec {
  margin: var(--space-6) 0;
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body);
  background: var(--label);
  border: 1px solid var(--rule);
}

.dp-spec caption {
  /* Screen reader only */
}

.dp-spec th {
  text-align: left;
  font-weight: 600;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
  background: var(--label);
  color: var(--wrap);
  font-family: var(--body);
  font-size: var(--text-small);
}

.dp-spec td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
  color: var(--wrap-deep);
}

.dp-spec tr:last-child td {
  border-bottom: none;
}

@media (max-width: 600px) {
  .dp-spec {
    font-size: var(--text-small);
  }

  .dp-spec th,
  .dp-spec td {
    padding: var(--space-2) var(--space-3);
  }
}

/* ---------------------------------------------------------------------------
   FULFILLMENT SECTION — shipping times, handling, policy link
   --------- --------------------------------------------------- ----------- */

.dp-fulfil {
  margin: var(--space-6) 0 0;
  padding-top: var(--space-6);
  border-top: var(--line);
  font-size: var(--text-body);
  line-height: 1.6;
}

.dp-fulfil h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-lead);
  font-weight: 600;
  font-family: var(--body);
  color: var(--wrap);
  letter-spacing: -.02em;
}

.dp-fulfil p {
  margin: 0 0 var(--space-3);
  color: var(--wrap-deep);
}

.dp-fulfil p:last-child {
  margin-bottom: 0;
}

.dp-fulfil strong {
  font-weight: 600;
  color: var(--wrap-deep);
}

.dp-fulfil a {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--wrap);
}

.dp-fulfil a:hover {
  color: var(--stamp);
}

/* ---------------------------------------------------------------------------
   PRODUCT DESCRIPTION — "About this item" section
   --------- --------------------------------------------------- ----------- */

.dp-product-description {
  margin: var(--space-8) 0 0;
  padding: var(--space-6) 0 0;
  border-top: var(--line);
  font-size: var(--text-body);
  line-height: 1.6;
  color: var(--wrap-deep);
  max-width: var(--measure);
}

.dp-product-description h2 {
  margin: 0 0 var(--space-4);
  font-size: var(--text-lead);
  font-weight: 600;
  font-family: var(--body);
  color: var(--wrap);
  letter-spacing: -.02em;
}

.dp-product-description p {
  margin: 0 0 var(--space-4);
}

.dp-product-description p:last-child {
  margin-bottom: 0;
}

.dp-product-description ul,
.dp-product-description ol {
  margin: var(--space-3) 0 var(--space-4);
  padding-left: var(--space-8);
  list-style-position: outside;
}

.dp-product-description li {
  margin: 0 0 var(--space-2);
}

.dp-product-description a {
  text-decoration: underline;
  text-underline-offset: 2px;
  color: var(--wrap);
}

.dp-product-description a:hover {
  color: var(--stamp);
}

/* ---------------------------------------------------------------------------
   RELATED PRODUCTS SECTION — "More from the beauty shelf" grid
   --------- --------------------------------------------------- ----------- */

.dp-front {
  margin-top: var(--space-12);
  padding-top: var(--space-12);
  border-top: var(--line);
}

.dp-sechead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.dp-sechead h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 400;
  font-family: var(--display);
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--wrap);
  flex: 1;
  min-width: 240px;
}

.dp-sechead > a {
  font-size: var(--text-small);
  font-weight: 600;
  font-family: var(--body);
  color: var(--wrap);
  text-decoration: none;
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}

.dp-sechead > a:hover {
  color: var(--stamp);
}

.dp-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-6);
  list-style: none;
  margin: 0;
  padding: 0;
}

@media (max-width: 1000px) {
  .dp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .dp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .dp-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }

  .dp-sechead {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: var(--space-6);
  }

  .dp-sechead h2 {
    font-size: 22px;
  }
}

/* Breadcrumbs */
.dp-crumbs {
  margin: var(--space-4) 0 var(--space-8);
  font-size: var(--text-small);
  color: var(--graphite);
}

.dp-crumbs a {
  color: var(--wrap);
  text-decoration: none;
}

.dp-crumbs a:hover {
  color: var(--stamp);
  text-decoration: underline;
}

.dp-crumbs .sep {
  margin: 0 var(--space-2);
  color: var(--rule);
}
