/*
 * The product page, /products/{url} (views/product.hbs).
 *
 * These rules lived in a <style> block inside the template, re-sent
 * with every page view (cnas#4). They are the same rules, in the same
 * place in the cascade: the template links this sheet where the block
 * used to be, after app.css.
 */

:root {
  --brand-green: #3e533f;
  --brand-green-hover: #2c3f2d;
  --brand-yellow: #ffdc52;
  --bg-light: #fafafa;
  --text-dark: #333;
  --text-muted: #555;
  --border-default: #ccc;
  --radius: 8px;
  --gap: 20px;
  --font-sans: Arial, sans-serif;
  --wa-green: #25D366;
  --wa-green-hover: #1da851;
}

body {
  margin: 0;
  padding: 0;

  background: #fff;
  color: #000;
}

/* ─── Header ─────────────────── */

.page-header {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fff;
  padding: var(--gap);
  position: relative;
}

.page-header img {
  max-height: 70px;
}

/* ─── Main ───────────────────── */

main {
  padding: var(--gap);
  max-width: 1200px;
  margin: auto;
  padding-bottom: 100px;
  /*
   * These three lines are why the phone layout was broken.
   *
   * `body` is a COLUMN flex container, so `main` is a flex item
   * and its width is the cross size — normally stretched to the
   * body's 412px. But an `auto` margin on the cross axis disables
   * that stretch, and `margin: auto` above sets both. So `main`
   * fell back to shrink-to-fit its CONTENT: the thumbnail strip's
   * max-content width is all ten images side by side, ~1160px, so
   * `main` grew to its 1200px max-width inside a 412px phone.
   *
   * The document then scrolled sideways, and the footer — which
   * correctly filled the 412px body — rendered as a narrow column
   * with dead space beside it. The strip's `overflow-x: auto`
   * never got a chance to scroll, because nothing downstream was
   * ever narrow.
   *
   * `width: 100%` stops it being content-sized; `min-width: 0`
   * lets the flex chain below actually shrink; `border-box` keeps
   * the 20px padding inside the 100%.
   */
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* ─── Product Section ────────── */

.product-section {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}

.product-images {
  flex: 1 1 400px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.product-images .main-image {
  width: 100%;
  border: none;
}

.product-images .main-image img {
  width: 100%;
  height: auto;
  display: block;
  min-height: 300px;
}

.product-images .thumbnails {
  display: flex;
  /* Same reason as `main` above: without this the strip reports a
     min-content width of every image combined and pushes the page
     wide instead of scrolling. */
  min-width: 0;
  gap: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /*
   * No scroll snapping. `x mandatory` re-centred an image at the
   * end of every drag, so the strip yanked itself into position
   * instead of letting go — the "it keeps selecting and putting
   * images into view" complaint. A drag now just scrolls.
   */
  padding-bottom: 10px;
}

.product-images .thumbnails img {
  height: 70px;
  cursor: pointer;
  border-radius: 5px;
  /*
   * A resting border, not a transparent one. These are cut-outs
   * on a white page, so with only a gap between them two
   * neighbouring bottles read as one picture — the gap is there,
   * it just isn't visible. The border is what makes each
   * thumbnail read as its own tile.
   */
  border: 2px solid var(--border-default, #e5e3dd);
  background: #fff;
  transition: border-color 0.2s;
}

.product-images .thumbnails img:hover,
.product-images .thumbnails img.active {
  border-color: var(--brand-green);
}

/* ─── Product Info ────────────── */

.product-info {
  flex: 1 1 400px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.product-info h1 {
  font-size: 28px;
  font-weight: bold;
  color: var(--brand-green);
  margin: 0;
}

.product-rating {
  display: flex;
  align-items: center;
}

.product-rating .stars {
  color: var(--brand-yellow);
  font-size: 16px;
  margin-right: 10px;
}

.product-rating .reviews-link {
  color: var(--brand-green);
  text-decoration: none;
  font-size: 14px;
}

.product-description {
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-dark);
  margin: 0;
  white-space: pre-wrap;
}

.product-price-section {
  font-size: x-small;
  color: var(--text-dark);
}

.product-price-section strong {
  font-size: 24px;
  display: block;
  margin-bottom: 5px;
  color: var(--brand-green);
}

.product-price-section ul {
  padding-left: 20px;
  margin: 5px 0;
}

.product-price-section ul li a {
  text-decoration: none;
  color: var(--brand-green);
}

/* ─── Variant / Quantity ──────── */

.variant-selector {
  margin-bottom: 15px;
}

.variant-selector label {
  font-weight: bold;
  display: block;
  margin-bottom: 8px;
}

.variant-selector select {
  width: 100%;
  height: 40px;
  border-radius: 5px;
  border: 1px solid var(--border-default);
  padding: 0 10px;
  font-size: 14px;
}

/* ─── CTA Buttons ────────────── */

.cta-btns {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
}

.buy-now-btn {
  background-color: var(--brand-green);
  color: #fff;
  border: none;
  padding: 10px 20px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  /*
   * Was a hard `width: 250px`. Two of these side by side gave
   * .product-info a ~510px floor it could not shrink below, so
   * once the desktop row stopped wrapping the columns overflowed
   * and the page scrolled sideways at ~800px. Shrinkable now,
   * capped at the old width so nothing looks different where
   * there is room.
   */
  flex: 1 1 160px;
  min-width: 150px;
  max-width: 250px;
  text-align: center;
  display: block;
  margin: 0;
  transition: background-color 0.2s;
}

.buy-now-btn:hover {
  background-color: var(--brand-green-hover);
}

/*
 * The dark "add to cart" variant. This was an inline
 * `style="background-color: …; width: auto; min-width: 150px"`,
 * and the inline `width: auto` is what kept the mobile rule's
 * `width: 100%` from ever applying — so the two CTAs sized
 * themselves to their own label text and came out different
 * widths. A class can be overridden by a media query; an inline
 * style cannot.
 */
.buy-now-btn--secondary {
  background-color: var(--text-dark);
}

.buy-now-btn--secondary:hover {
  background-color: var(--text-dark);
  opacity: .9;
}

.buy-now-btn.is-disabled,
.buy-now-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─── Size picker (cnas#27) ──── */

.size-picker {
  margin-bottom: 15px;
}

.size-picker__label {
  font-weight: bold;
  display: block;
  margin-bottom: 8px;
}

.size-picker__options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.size-pill {
  min-height: 40px;
  padding: 6px 14px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--bg-light);
  color: var(--text-dark);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.size-pill[aria-pressed="true"] {
  border-color: var(--text-dark);
  background: var(--text-dark);
  color: #fff;
}

.size-pill:disabled {
  opacity: .5;
  cursor: not-allowed;
  text-decoration: line-through;
}

.size-pill__note {
  font-size: 12px;
}

/* ─── Benefits ────────────────── */

.product-benefits {
  list-style-type: none;
  padding: 0;
  font-size: 14px;
  color: var(--text-muted);
  margin: 0;
}

.product-benefits li {
  margin-bottom: 3px;
}

.product-benefits a {
  color: var(--brand-green);
  text-decoration: none;
}

.product-benefits a:hover {
  text-decoration: underline;
}

/* ─── Test Banner ─────────────── */

.test-banner {
  display: flex;
  align-items: start;
  background-color: #f0f4f2;
  padding: 10px;
  border-radius: var(--radius);
  gap: 15px;
  max-width: 70%;
}

.test-banner img {
  width: 60px;
  height: 60px;
}

.test-cta-wp {
  display: flex;
  flex-direction: column;
}

.test-cta-wp a {
  color: var(--brand-green);
  text-decoration: none;
  font-weight: bold;
}

.test-cta-wp .find-out-link {
  color: var(--brand-green);
  font-size: small;
  font-weight: normal;
  margin-top: 10px;
}

.test-cta-wp .find-out-link:hover {
  text-decoration: underline;
}

/* ─── FAQ Section ─────────────── */

.faq-section {
  max-width: 1200px;
  margin: 40px auto;
  display: flex;
  gap: 50px;
  align-items: flex-start;
  flex-direction: row;
  border-top: 1px solid var(--border-default);
  padding-top: 20px;
}

.faq-title {
  flex: 1;
  font-size: 28px;
  font-weight: bold;
  color: var(--brand-green);
  line-height: 1.4;
}

.faq-container {
  flex: 2;

}

.faq {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-default);
}

.faq-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  cursor: pointer;
}

.faq-header h3 {
  margin: 0;
  font-size: 18px;
}

.faq-header .faq-icon {
  font-size: 18px;
  color: var(--brand-green);
}

.faq-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.faq-content p {
  margin: 0;
  padding: 10px 0;
  font-size: 16px;
}

.faq.open .faq-content {
  max-height: 200px;
}

/* ─── Reviews Section ────────── */

.reviews {
  background: var(--bg-light);
  padding: var(--gap);
  border-radius: var(--radius);
  margin-top: 40px;
  color: var(--text-dark);
}

.reviews h2.reviews-title {
  font-size: 24px;
  color: var(--brand-green);
  text-align: center;
  margin-bottom: 30px;
  font-weight: normal;
}

.reviews-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 40px;
}

.average-wrapper {
  font-size: 16px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  color: var(--brand-green);
  font-weight: bold;
  margin: auto;
}

.average-wrapper .average-score {
  font-size: 60px;
  font-weight: normal;
  line-height: 1;
}

.average-sum-wrapper {
  display: flex;
  flex-direction: column;
  text-align: left;
  margin: 0;
}

.reviews-vertical-border {
  border-right: 1px solid gray;
  height: 100px;
}

.reviews-distribution {
  display: flex;
  flex-direction: column;
  max-width: 300px;
  width: 300px;
}

.rating-bar {
  display: flex;
  align-items: center;
  font-size: 14px;
  margin-bottom: 5px;
}

.star-label {
  width: 30px;
  color: var(--text-dark);
}

.bar {
  flex: 1;
  background: #e0e0e0;
  height: 8px;
  border-radius: 4px;
  margin: 0 10px;
  position: relative;
  overflow: hidden;
}

.bar-fill {
  background: var(--brand-green);
  height: 8px;
}

.count {
  width: 20px;
  text-align: right;
  color: var(--text-dark);
}

/* ─── Stars ───────────────────── */

.stars {
  color: var(--brand-yellow);
  font-size: 16px;
  vertical-align: middle;
}

.stars-outer {
  position: relative;
  display: inline-block;
  width: fit-content;
}

.stars-inner {
  position: absolute;
  top: 0;
  left: 0;
  white-space: nowrap;
  overflow: hidden;
  width: 0;
}

.stars-outer::before {
  content: "★★★★★";
  font-size: 18px;
  color: #ccc;
}

.stars-inner::before {
  content: "★★★★★";
  font-size: 18px;
  color: var(--brand-yellow);
}

/* ── Trust Signals ────────────── */

.trust-signals {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.trust-signals img {
  height: 50px;
  width: auto;
}

/* ── Schema.org hidden data ──── */

.schema-data {
  display: none;
}

/* ── Footer ───────────────────── */

/*
 * Desktop: images and copy always side by side.
 *
 * `.product-section` is `flex-wrap: wrap` with both columns at
 * `flex: 1 1 400px`, so anywhere under ~840px of content box the
 * description wrapped underneath the gallery — on a desktop
 * window, which is not what the layout is for. Wrapping is a
 * mobile behaviour and the mobile rules below already handle it
 * with `display: block`.
 *
 * `min-width: 0` matters: without it a flex child refuses to
 * shrink below its content's intrinsic width and the columns
 * overflow instead of sharing the row.
 */
@media (min-width: 769px) {
  .product-section {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  /*
   * Every image on one row, no scrollbar. The strip was sized by
   * a fixed 70px height and let to overflow, so ten slides ran
   * off the column and painted a scrollbar under the gallery.
   * `flex: 1 1 0` + `min-width: 0` makes them share the column
   * instead, however many there are.
   */
  .product-images .thumbnails {
    overflow-x: hidden;
    flex-wrap: nowrap;
  }

  .product-images .thumbnails img {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    height: 62px;
    object-fit: cover;
  }

  .product-images,
  .product-info {
    flex: 1 1 50%;
    min-width: 0;
  }
}

/* ── Responsive ───────────────── */

@media (max-width: 768px) {
  .product-images .main-image {
    display: none;
  }

  .product-images .thumbnails img {
    height: 160px;
  }

  .product-images .thumbnails {
    overflow-x: auto;
    /* The strip IS the mobile carousel (the main image is hidden
       above), so it has to stay scrollable — but the scrollbar
       itself sat across the images and read as a broken element. */
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .product-images .thumbnails::-webkit-scrollbar {
    display: none;
  }

  .product-section {
    display: block;
  }

  .cta-btns {
    flex-direction: column;
    /* Centres the quantity stepper too — it is `width:
       max-content`, so without this it hugs the left edge while
       the buttons below it sit centred. */
    align-items: center;
  }

  /*
   * `flex: 1 1 160px` from the desktop rule means 160px of HEIGHT
   * once this container is a column — which is what made these
   * two buttons enormous on a phone. The basis only makes sense
   * along a row.
   *
   * `max-width` is capped rather than released: full-bleed edge
   * to edge on a wide phone makes a 40px-tall button look like a
   * banner. Both CTAs take the same width because both take this
   * rule — that is the point of removing the inline widths.
   */
  .buy-now-btn {
    width: 100%;
    flex: 0 0 auto;
    min-width: 0;
    max-width: 340px;
  }

  .test-banner {
    max-width: 100%;
  }

  .faq-section {
    flex-direction: column;
    gap: 20px;
  }

  .reviews-top-row {
    flex-direction: column;
    gap: 20px;
  }

  .reviews-vertical-border {
    display: none;
  }

  .reviews-distribution {
    width: 100%;
  }
}

/* ─── Individual review cards ─── */

.reviews-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
  margin-top: 30px;
}

.review-card {
  background: #fff;
  border: 1px solid var(--border-default);
  border-radius: var(--radius);
  padding: 18px;
}

.review-card-title {
  font-size: 16px;
  color: var(--text-dark);
  margin: 8px 0 6px;
}

.review-card-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dark);
  margin: 0 0 12px;
}

.review-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.reviews-see-all {
  display: block;
  text-align: center;
  margin-top: 24px;
  color: var(--brand-green);
  font-weight: bold;
  text-decoration: none;
}

.reviews-empty {
  color: var(--text-muted);
  text-align: center;
  margin-top: 20px;
}
