/* Ratings and reviews: the form at /rate/:token (src/server/ratePage.ts), the
 * /reviews page (src/server/reviewsPage.ts) and the rating line on the product
 * pages. Uses marketing.css's tokens (--accent, --border, --text-secondary,
 * --bg), which every page that links this also loads. */

.stars {
  display: inline-flex;
  gap: 2px;
  vertical-align: middle;
}

.stars {
  color: var(--accent);
}

.stars__on,
.stars__off,
.stars__part {
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.stars__on {
  fill: var(--accent);
}

.stars__off {
  fill: var(--bg);
}

/* --- The form ------------------------------------------------------------ */

.rate-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 34rem;
}

.rate-form h1 {
  margin-bottom: -16px;
}

.rate-order {
  color: var(--text-secondary);
}

.rate-box {
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
}

.rate-stars {
  border: 0;
  padding: 0;
  margin: 0;
}

.rate-stars legend,
.rate-field label,
.rate-field__title {
  font-weight: 600;
  font-size: 17px;
}

.rate-stars legend {
  padding: 0;
  margin-bottom: 8px;
}

.rate-stars__row {
  display: inline-flex;
  flex-direction: row-reverse;
  gap: 4px;
}

.rate-stars__row input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.rate-stars__row label {
  display: flex;
  width: 52px;
  height: 52px;
  padding: 6px;
  cursor: pointer;
}

.rate-stars__row svg {
  width: 40px;
  height: 40px;
}

.rate-stars__row path {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 1.4;
  stroke-linejoin: round;
}

/* The DOM runs 5..1, so a checked star and every one after it in the DOM are
 * the chosen star and those to its left. Hover previews the same way. */
.rate-stars__row input:checked ~ label path,
.rate-stars__row label:hover path,
.rate-stars__row label:hover ~ label path {
  fill: var(--accent);
}

.rate-stars__row input:focus-visible + label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.rate-stars__words {
  min-height: 1.4em;
  color: var(--text-secondary);
}

.rate-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.rate-error {
  color: #a3271c;
  font-weight: 600;
  margin-bottom: 8px;
}

/* Everything below the stars waits for a rating. Only where :has() works:
 * elsewhere it is simply all shown. */
.rate-more {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@supports selector(:has(*)) {
  .rate-form:not(:has(input[name="rating"]:checked)) .rate-more {
    display: none;
  }
}

.rate-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rate-field .rate-field label {
  font-weight: 400;
  font-size: 15px;
}

.rate-optional {
  font-weight: 400;
  color: var(--text-secondary);
}

.rate-hint {
  font-size: 15px;
  color: var(--text-secondary);
}

.rate-field input,
.rate-field textarea {
  font: inherit;
  font-size: 16px;
  color: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cdbfa9;
  border-radius: 8px;
  background: var(--bg);
}

.rate-field textarea {
  resize: vertical;
  line-height: 1.45;
}

.rate-field input:focus,
.rate-field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.rate-name {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem;
  gap: 12px;
  margin: 6px 0 8px;
}

.rate-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rate-preview[hidden] {
  display: none;
}

.rate-private {
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.rate-send {
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  cursor: pointer;
}

.rate-send:hover {
  background: var(--accent-hover);
}

.rate-small {
  font-size: 15px;
  color: var(--text-secondary);
}

.rate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

.marketing-main a.rate-button,
.rate-button {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  padding: 0 18px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  background: var(--bg);
  border: 1px solid #cdbfa9;
  border-radius: 999px;
  cursor: pointer;
}

/* --- The rating line on /photo-book and /prices -------------------------- */

.marketing-main a.rating-line,
.rating-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.rating-line span:last-child {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.rating-line strong {
  font-weight: 600;
}

/* Under /prices' centred price box. */
.prices-rating {
  text-align: center;
  margin-top: 14px;
}

/* --- /reviews ------------------------------------------------------------ */

.reviews-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 24px 40px;
  align-items: center;
  margin: 24px 0;
  padding: 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.reviews-summary__figure {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--text-secondary);
}

.reviews-summary__average {
  font-size: 52px;
  line-height: 1;
  font-weight: 700;
  color: var(--text);
}

.reviews-summary__bars {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reviews-bar {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 2rem;
  gap: 12px;
  align-items: center;
  font-size: 15px;
}

.reviews-bar span:last-child {
  text-align: right;
  color: var(--text-secondary);
}

.reviews-bar__track {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  overflow: hidden;
}

.reviews-bar__fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.reviews-how {
  margin-top: 40px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* --- A review ------------------------------------------------------------ */

.review-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  margin: 16px 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.review-card p {
  margin: 0;
  /* A reviewer's unbroken string (a URL, a row of letters) wraps rather than
   * pushing the page sideways. */
  overflow-wrap: anywhere;
}

.review-card__body {
  white-space: pre-line;
}

.review-card__byline {
  font-size: 14px;
  color: var(--text-secondary);
}

.review-card__free {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border: 1px solid #cdbfa9;
  border-radius: 999px;
}

.review-card__reply {
  margin: 6px 0 0 20px;
  padding: 12px 14px;
  border-left: 0;
  background: var(--page);
  border-radius: 8px;
}

.review-card__reply-by {
  font-size: 14px;
  font-weight: 600;
}
