/* ============================================================
   Retail product detail — motion + surface polish
   ------------------------------------------------------------
   details.css is ~7,000 lines and drives every state of the retail
   detail page. Rewriting it to "restyle" the page would be reckless,
   so this file is a narrow layer on top of it that changes only:

     • entrance motion (one rise per layer, staggered children)
     • hover / focus / active feedback on the actions
     • responsive type scale via clamp() instead of fixed px
     • rhythm: consistent gaps in the summary column
     • dark-mode and reduced-motion behaviour for the bits above

   Rules of the layer:
     - No colour literals for text or surfaces — those come from
       tokens.css / theme.css so dark mode keeps working.
     - Property changes here never affect layout height, so CLS does
       not move when the layer loads.
     - Everything animated is switched off under
       prefers-reduced-motion: reduce.
   ============================================================ */

/* ---------- entrance motion ---------- */

@keyframes dt-rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes dt-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* The summary column rises in as one block; its children follow with a
   small stagger so the eye lands on name → price → actions. */
.layer1 .productSummary {
  animation: dt-rise 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.layer1 .productSummary > * {
  animation: dt-fade 0.4s ease both;
  animation-delay: calc(var(--dt-i, 0) * 55ms + 90ms);
}

.layer1 .productSummary > :nth-child(1) { --dt-i: 0; }
.layer1 .productSummary > :nth-child(2) { --dt-i: 1; }
.layer1 .productSummary > :nth-child(3) { --dt-i: 2; }
.layer1 .productSummary > :nth-child(4) { --dt-i: 3; }
.layer1 .productSummary > :nth-child(5) { --dt-i: 4; }
.layer1 .productSummary > :nth-child(6) { --dt-i: 5; }

.layer1 .imageContainer {
  animation: dt-fade 0.5s ease both;
}

/* Content that arrives after fetch fades instead of popping. */
#pName-js,
#pPrice-js,
#pDesc-js,
#wsTerms-js:not([hidden]),
.attr-chips:not(:empty),
.posted {
  animation: dt-fade 0.35s ease both;
}

/* ---------- type ---------- */

/* Sizes stay owned by details.css, which reads them from the theme scale
   (--h2, --h4 …). Restating a clamp() here would bypass that scale and
   fight the theme editor, so only long-word safety is added.
   .productSummary .productName span and .Pprice span carry higher
   specificity, which is correct — the theme wins. */

.productDescription,
.info {
  overflow-wrap: anywhere;
}

/* ---------- rhythm ---------- */

/* .layer1 .productSummary is already a flex column in details.css and its
   children carry their own margins. This layer does NOT redefine that
   layout or reset those margins — doing so would silently re-space the
   whole summary column. Only the action row is re-laid out below. */

.ctaSection {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.ctaSection > div { display: flex; }

.ctaSection .buyProduct,
.ctaSection .offerProduct,
.ctaSection .escrowProduct,
.ctaSection .compareProduct,
.ctaSection .deliveryProduct {
  width: 100%;
  min-height: 46px;
  border-radius: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease,
    background-color 0.16s ease, border-color 0.16s ease;
}

.ctaSection .buyProduct:hover,
.ctaSection .offerProduct:hover,
.ctaSection .escrowProduct:hover,
.ctaSection .compareProduct:hover,
.ctaSection .deliveryProduct:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(1, 42, 70, 0.14);
}

.ctaSection .buyProduct:active,
.ctaSection .offerProduct:active,
.ctaSection .escrowProduct:active,
.ctaSection .compareProduct:active,
.ctaSection .deliveryProduct:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Focus must never be hidden behind sticky chrome: draw the ring inside. */
.ctaSection button:focus-visible,
#wishlistBtn:focus-visible,
.dt-breadcrumb a:focus-visible,
#thumbnail-js img:focus-visible {
  outline: 2px solid var(--brand-orange-500, var(--brand-orange-500));
  outline-offset: 2px;
  border-radius: 10px;
}

.productSummary button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---------- attribute chips ---------- */

/* .productInfo .info rows are already laid out in details.css (and re-tuned
   at two breakpoints), so this layer leaves them alone and only adds the
   chip feedback the design was missing. */

.attr-chip {
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.attr-chip:hover { transform: translateY(-1px); }

/* ---------- thumbnails ---------- */

#thumbnail-js img {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

#thumbnail-js img:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(1, 42, 70, 0.18);
}

/* ---------- dark mode ---------- */

/* NOTE: .ws-terms (the bulk-terms block) is fully styled in details.css,
   including its own dark-mode rules. This layer deliberately does not
   re-skin it — only the fade-in above applies — so the two files cannot
   drift into fighting over the same surface. */

[data-theme="dark"] .ctaSection .buyProduct:hover,
[data-theme="dark"] .ctaSection .offerProduct:hover,
[data-theme="dark"] .ctaSection .escrowProduct:hover,
[data-theme="dark"] .ctaSection .compareProduct:hover,
[data-theme="dark"] .ctaSection .deliveryProduct:hover,
[data-theme="dark"] #thumbnail-js img:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55);
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .layer1 .productSummary,
  .layer1 .productSummary > *,
  .layer1 .imageContainer,
  #pName-js,
  #pPrice-js,
  #pDesc-js,
  #wsTerms-js,
  .attr-chips,
  .posted {
    animation: none;
  }

  .ctaSection button,
  .attr-chip,
  #thumbnail-js img { transition: none; }

  .ctaSection button:hover,
  .attr-chip:hover,
  #thumbnail-js img:hover { transform: none; }
}

/* ---------- Windows high-contrast ---------- */

@media (forced-colors: active) {
  .ctaSection button:focus-visible { outline: 2px solid Highlight; }
}
