/**
 * Star Ratings (ptpstarratings) - front
 *
 * @author    Patripe
 * @copyright 2026 Patripe
 * @license   MIT, see LICENSE.md
 */

:root {
  --ptp-star-color: #f5b301;
  --ptp-star-empty: #dcdcdc;
  --ptp-text-muted: #6b6b6b;
  --ptp-border: #ececec;
  --ptp-bg-soft: #f7f7f7;
}

/* ---------- Row of stars (partial fill, 3 designs) ----------
   Colours go on each piece of the SVG. Themes that paint every SVG black need the
   forced colours of themes/warehouse.css (compatibility mode). */
.ptp-starratings__stars { position: relative; display: inline-block; line-height: 0; vertical-align: middle; white-space: nowrap; }
.ptp-starratings__stars-base, .ptp-starratings__stars-fill { display: inline-flex; gap: 1px; }
.ptp-starratings__stars-fill { position: absolute; top: 0; left: 0; overflow: hidden; }
.ptp-starratings__stars svg.ptp-starratings__svg { flex: 0 0 auto; display: block; max-width: none; }
.ptp-starratings__stars-base .ptp-starratings__star, .ptp-starratings__stars-base .ptp-starratings__bg { fill: var(--ptp-star-empty); stroke: none; }
.ptp-starratings__stars-fill .ptp-starratings__star, .ptp-starratings__stars-fill .ptp-starratings__bg { fill: var(--ptp-star-color); stroke: none; }
.ptp-starratings__stars-base .ptp-starratings__round { stroke: var(--ptp-star-empty); stroke-width: 3.4px; stroke-linejoin: round; }
.ptp-starratings__stars-fill .ptp-starratings__round { stroke: var(--ptp-star-color); stroke-width: 3.4px; stroke-linejoin: round; }
.ptp-starratings__stars .ptp-starratings__in { fill: #fff; stroke: none; }
.ptp-starratings__stars--sm svg.ptp-starratings__svg { width: 14px; height: 14px; }
.ptp-starratings__stars--md svg.ptp-starratings__svg { width: 19px; height: 19px; }
.ptp-starratings__stars--lg svg.ptp-starratings__svg { width: 28px; height: 28px; }
.ptp-starratings__stars--boxed .ptp-starratings__stars-base, .ptp-starratings__stars--boxed .ptp-starratings__stars-fill { gap: 2px; }
.ptp-starratings__stars--boxed.ptp-starratings__stars--sm svg.ptp-starratings__svg { width: 15px; height: 15px; }

.ptp-starratings__count { font-size: 13px; color: var(--ptp-text-muted); vertical-align: middle; }

/* ---------- Miniatures: aligned with the start of the title, no extra space ---------- */
.ptp-starratings__list { display: flex; align-items: center; justify-content: flex-start; gap: 5px; margin: 2px 0 4px; padding: 0; line-height: 1; text-align: left; }
.ptp-starratings__list .ptp-starratings__count { font-size: 12px; line-height: 1; }
.text-center .ptp-starratings__list, .product-miniature.text-center .ptp-starratings__list { justify-content: center; }

/* ---------- Product page: under the name ---------- */
.ptp-starratings__summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.ptp-starratings__summary .ptp-starratings__count { font-size: 14px; text-decoration: none; }
.ptp-starratings__summary a.ptp-starratings__count:hover { color: inherit; text-decoration: underline; }
.ptp-starratings__summary .ptp-starratings__sep { color: #ccc; font-size: 13px; }
.ptp-starratings__summary .ptp-starratings__write-link { font-size: 14px; color: var(--ptp-text-muted); text-decoration: underline; cursor: pointer; }
.ptp-starratings__summary .ptp-starratings__write-link:hover { color: inherit; }
/* Until the script moves it (or in quick view) it is shown where the hook paints it */
.product-additional-info .ptp-starratings__summary { margin-top: 10px; }

/* ---------- "Reviews" tab ---------- */
.ptp-starratings__reviews { max-width: 900px; margin: 0 auto; padding: 8px 0; }

.ptp-starratings__box {
  display: grid;
  grid-template-columns: 200px 1fr 220px;
  border: 1px solid var(--ptp-border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.ptp-starratings__box > div { padding: 22px 20px; }
.ptp-starratings__box-score { background: var(--ptp-bg-soft); text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.ptp-starratings__box-avg { line-height: 1; }
.ptp-starratings__box-avg strong { font-size: 44px; font-weight: 700; color: #222; }
.ptp-starratings__box-avg span { font-size: 20px; color: var(--ptp-text-muted); margin-left: 2px; }
.ptp-starratings__box-nb { font-size: 13px; color: var(--ptp-text-muted); }

.ptp-starratings__box-bars { display: flex; flex-direction: column; justify-content: center; gap: 8px; border-left: 1px solid var(--ptp-border); border-right: 1px solid var(--ptp-border); }
.ptp-starratings__bar { display: grid; grid-template-columns: 38px 1fr 42px; align-items: center; gap: 10px; font-size: 13px; color: #444; }
.ptp-starratings__bar-label { display: inline-flex; align-items: center; gap: 3px; }
.ptp-starratings__bar-icon { display: inline-flex; line-height: 0; }
.ptp-starratings__bar-icon svg.ptp-starratings__svg { width: 13px; height: 13px; }
.ptp-starratings__bar-icon .ptp-starratings__star, .ptp-starratings__bar-icon .ptp-starratings__bg { fill: var(--ptp-star-color); }
.ptp-starratings__bar-icon .ptp-starratings__round { stroke: var(--ptp-star-color); stroke-width: 3.4px; stroke-linejoin: round; }
.ptp-starratings__bar-icon .ptp-starratings__in { fill: #fff; }
.ptp-starratings__bar-track { height: 8px; border-radius: 4px; background: #eee; overflow: hidden; }
.ptp-starratings__bar-value { display: block; height: 100%; border-radius: 4px; background: var(--ptp-star-color); }
.ptp-starratings__bar-pct { text-align: right; font-weight: 600; }

.ptp-starratings__box-cta { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px; }
.ptp-starratings__box-cta p { margin: 0; font-size: 14px; color: #444; }
.ptp-starratings__write { white-space: normal; }

.ptp-starratings__section-head { margin: 30px 0 20px; }
.ptp-starratings__section-head.nav { flex-wrap: nowrap; }
.ptp-starratings__section-head .nav-link { cursor: default; }
.ptp-starratings__in-tab .ptp-starratings__section-head { display: none; }
.ptp-starratings__modal .ptp-starratings__section-head { display: flex; margin-top: 0; }
.ptp-starratings__reviews--footer { padding-top: 10px; }
.ptp-starratings__latest { margin: 28px 0 10px; font-size: 16px; text-transform: uppercase; letter-spacing: .04em; }

/* What our box already summarises is hidden from the native list */
.ptp-starratings__reviews #product-comments-list-header,
.ptp-starratings__reviews #product-comments-list-footer .btn-comment-big { display: none; }

.ptp-starratings__reviews .product-comment-list-item { border-bottom: 1px solid var(--ptp-border); padding: 16px 0; margin: 0; }
.ptp-starratings__reviews .product-comment-list-item:last-child { border-bottom: 0; }

/* Stars of the native list and form: same colour as ours */
.ptp-starratings__reviews .star-content div.star,
.ptp-starratings__reviews .star-content div.star-on,
.ptp-starratings__reviews .star-content div.star-hover,
#post-product-comment-modal .star-content div.star,
#post-product-comment-modal .star-content div.star-on,
#post-product-comment-modal .star-content div.star-hover {
  background: var(--ptp-star-empty);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.94 6.26 6.86.8-5.08 4.7 1.36 6.78L12 17.6l-6.08 3.44 1.36-6.78-5.08-4.7 6.86-.8z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2.5l2.94 6.26 6.86.8-5.08 4.7 1.36 6.78L12 17.6l-6.08 3.44 1.36-6.78-5.08-4.7 6.86-.8z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.ptp-starratings__reviews .star-content div.star-on,
.ptp-starratings__reviews .star-content div.star-hover,
#post-product-comment-modal .star-content div.star-on,
#post-product-comment-modal .star-content div.star-hover { background: var(--ptp-star-color); }

/* ---------- Reviews pop-up ---------- */
.ptp-starratings__modal { display: none; position: fixed; inset: 0; z-index: 1030; }
.ptp-starratings__modal.is-open { display: block; }
.ptp-starratings__modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .5); }
.ptp-starratings__modal-dialog {
  position: relative; margin: 4vh auto; width: min(960px, calc(100% - 24px)); max-height: 92vh;
  overflow-y: auto; background: #fff; border-radius: 8px; padding: 28px 24px 24px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25);
}
.ptp-starratings__modal-close {
  position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 32px; line-height: 1;
  color: #666; cursor: pointer; padding: 4px 8px;
}
.ptp-starratings__modal-close:hover { color: #000; }
html.ptp-starratings-modal-open, html.ptp-starratings-modal-open body { overflow: hidden; }

/* ---------- Mobile ---------- */
@media (max-width: 767px) {
  .ptp-starratings__box { grid-template-columns: 1fr; }
  .ptp-starratings__box-bars { border-left: 0; border-right: 0; border-top: 1px solid var(--ptp-border); border-bottom: 1px solid var(--ptp-border); }
}


/* ---------- Split by criterion (only with 2 or more criteria) ---------- */
.ptp-starratings__criteria { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 28px; margin: 14px 0 0; padding: 16px 20px; border: 1px solid var(--ptp-border); border-radius: 6px; background: #fff; }
.ptp-starratings__crit { display: grid; grid-template-columns: minmax(90px, 1fr) 1.3fr 32px; align-items: center; gap: 10px; font-size: 13px; color: #444; }
.ptp-starratings__crit-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptp-starratings__crit-avg { text-align: right; font-weight: 700; }

/* ---------- Public reviews page ---------- */
.ptp-starratings__page { display: grid; grid-template-columns: 280px 1fr; gap: 32px; align-items: start; margin: 8px 0 32px; }
.ptp-starratings__page *, .ptp-starratings__page *::before, .ptp-starratings__page *::after { box-sizing: border-box; }
.ptp-starratings__page-intro { margin: 0 0 20px; color: #4b5563; }
.ptp-starratings__page-summary { position: sticky; top: 20px; background: #fff; border: 1px solid var(--ptp-border); border-radius: 10px; padding: 22px 20px; text-align: center; }
.ptp-starratings__page-avg { line-height: 1; margin-bottom: 8px; }
.ptp-starratings__page-avg strong { font-size: 48px; font-weight: 800; color: #222; }
.ptp-starratings__page-avg span { font-size: 18px; color: var(--ptp-text-muted); }
.ptp-starratings__page-total { margin: 8px 0 16px; color: var(--ptp-text-muted); font-size: 14px; }
.ptp-starratings__page-bars { list-style: none; margin: 0; padding: 0; text-align: left; }
.ptp-starratings__page-bars li { margin: 0 0 4px; }
.ptp-starratings__page-bars a { display: grid; grid-template-columns: 38px 1fr 40px; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; color: #444; text-decoration: none; font-size: 13px; }
.ptp-starratings__page-bars a:hover, .ptp-starratings__page-bars a.is-active { background: var(--ptp-bg-soft); }
.ptp-starratings__page-bars a.is-active { font-weight: 700; }
.ptp-starratings__page-bars .ptp-starratings__page-n { text-align: right; color: var(--ptp-text-muted); }
.ptp-starratings__page-clear { display: inline-block; margin-top: 12px; font-size: 13px; }
.ptp-starratings__page-howto { margin: 16px 0 0; font-size: 12px; color: var(--ptp-text-muted); line-height: 1.4; }
.ptp-starratings__page-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 0 0 12px; color: var(--ptp-text-muted); font-size: 14px; }
.ptp-starratings__page-list { list-style: none; margin: 0; padding: 0; }
.ptp-starratings__page-item { display: grid; grid-template-columns: 72px 1fr; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--ptp-border); }
.ptp-starratings__page-item:first-child { padding-top: 0; }
.ptp-starratings__page-img { display: block; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--ptp-bg-soft); }
.ptp-starratings__page-img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.ptp-starratings__page-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 6px; font-size: 13px; color: var(--ptp-text-muted); }
.ptp-starratings__page-author { font-weight: 700; color: #222; }
.ptp-starratings__page-title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: #222; }
.ptp-starratings__page-text { margin: 0 0 8px; color: #333; line-height: 1.55; }
.ptp-starratings__page-product { font-size: 13px; }
.ptp-starratings__page-product a { font-weight: 600; }
.ptp-starratings__page-empty { padding: 24px; border: 1px dashed #d1d5db; border-radius: 10px; text-align: center; color: var(--ptp-text-muted); }
.ptp-starratings__page-pages { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 24px 0 0; padding: 0; list-style: none; }
.ptp-starratings__page-pages a, .ptp-starratings__page-pages span { display: inline-block; min-width: 38px; padding: 8px 10px; border: 1px solid var(--ptp-border); border-radius: 8px; text-align: center; text-decoration: none; font-size: 14px; }
.ptp-starratings__page-pages .is-current { background: #222; border-color: #222; color: #fff; font-weight: 700; }
.ptp-starratings__page-pages .is-gap { border-color: transparent; }
@media (max-width: 767px) {
  .ptp-starratings__page { grid-template-columns: 1fr; gap: 20px; }
  .ptp-starratings__page-summary { position: static; }
  .ptp-starratings__page-item { grid-template-columns: 56px 1fr; gap: 12px; }
  .ptp-starratings__page-img { width: 56px; height: 56px; }
  .ptp-starratings__crit { grid-template-columns: minmax(80px, 1fr) 1fr 32px; }
}

/* ---------- Star picker of the "Write a review" form ---------- */
#post-product-comment-modal .grade-stars.ptp-starratings__has-pick, #post-product-comment-form .grade-stars.ptp-starratings__has-pick { position: static; height: auto; min-width: 0; display: inline-block; vertical-align: middle; }
#post-product-comment-modal .criterion-rating { align-items: center; gap: 8px; flex-wrap: wrap; }
.ptp-starratings__pick { display: inline-flex; align-items: center; gap: 2px; line-height: 0; }
.ptp-starratings__pick-star { display: inline-block; padding: 2px; margin: 0; border: 0; background: none; cursor: pointer; line-height: 0; box-shadow: none; }
.ptp-starratings__pick-star:focus-visible { outline: 2px solid var(--ptp-star-color); outline-offset: 1px; border-radius: 3px; }
.ptp-starratings__pick-star svg.ptp-starratings__svg { width: 28px; height: 28px; display: block; max-width: none; }
.ptp-starratings__pick-star .ptp-starratings__star, .ptp-starratings__pick-star .ptp-starratings__bg { fill: var(--ptp-star-empty); stroke: none; }
.ptp-starratings__pick-star .ptp-starratings__round { stroke: var(--ptp-star-empty); stroke-width: 3.4px; stroke-linejoin: round; }
.ptp-starratings__pick-star .ptp-starratings__in { fill: #fff; stroke: none; }
.ptp-starratings__pick-star.is-on .ptp-starratings__star, .ptp-starratings__pick-star.is-on .ptp-starratings__bg, .ptp-starratings__pick:hover .ptp-starratings__pick-star .ptp-starratings__star, .ptp-starratings__pick:hover .ptp-starratings__pick-star .ptp-starratings__bg { fill: var(--ptp-star-color); }
.ptp-starratings__pick-star.is-on .ptp-starratings__round, .ptp-starratings__pick:hover .ptp-starratings__pick-star .ptp-starratings__round { stroke: var(--ptp-star-color); }
.ptp-starratings__pick .ptp-starratings__pick-star:hover ~ .ptp-starratings__pick-star .ptp-starratings__star, .ptp-starratings__pick .ptp-starratings__pick-star:hover ~ .ptp-starratings__pick-star .ptp-starratings__bg { fill: var(--ptp-star-empty); }
.ptp-starratings__pick .ptp-starratings__pick-star:hover ~ .ptp-starratings__pick-star .ptp-starratings__round { stroke: var(--ptp-star-empty); }
@media (max-width: 575px) { .ptp-starratings__pick-star svg.ptp-starratings__svg { width: 32px; height: 32px; }
}
