/* Client review system: submission dialog, star control, and approved-review cards.
   Everything user-submitted renders through textContent as plain text. */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* "Leave a review" sits beside the section note, above the existing cards. */
.testimonial-head-side { display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
.testimonial-head-side .section-note { margin: 0; }
.testimonial-head-side .review-open { min-height: 48px; }

/* =========================================================
   Approved reviews — continuation of the existing section
   ========================================================= */
.client-reviews { margin-top: clamp(48px, 7vw, 72px); padding-top: clamp(36px, 5vw, 56px); border-top: 1px solid var(--border); }
.client-reviews[hidden] { display: none; }
.client-reviews-head { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; flex-wrap: wrap; margin-bottom: 28px; }
.client-reviews-head h3 { font-size: 1.3rem; margin: 0; }
.reviews-average { margin: 0; font-size: 0.85rem; color: var(--text-2); }
.reviews-average strong { color: var(--text); font-family: var(--font-display); }
.reviews-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; perspective: 1400px; }

/* Review cards reuse the existing .testimonial-card base and add rating details. */
.review-card { transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg)); transition: transform 0.3s ease-out, border-color 0.3s, box-shadow 0.3s; }
.review-card .review-stars { display: inline-flex; gap: 5px; margin-bottom: 18px; font-size: 1.02rem; line-height: 1; letter-spacing: 0.08em; }
.review-card .star { color: var(--accent); }
.review-card .star.is-empty { color: #4c4852; }
.review-card .testimonial-avatar { transform: translate(var(--avatar-x, 0px), var(--avatar-y, 0px)); transition: transform 0.3s ease-out; }
.review-card .testimonial-quote-mark { transition: transform 0.3s var(--ease); }
.review-card .review-verified {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border: 1px solid #655776; border-radius: 999px; background: #2b2633; color: var(--accent);
  font: 600 0.66rem/1.2 var(--font); letter-spacing: 0.07em; text-transform: uppercase;
}
.review-card .review-verified::before { content: "✓"; font-size: 0.72rem; }
.review-card .review-date { margin-left: auto; color: var(--text-2); font: 0.68rem/1.4 var(--font-mono); white-space: nowrap; }
.review-card figcaption { flex-direction: row; align-items: center; gap: 12px; }
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .review-card:hover { border-color: #8a759d; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28); }
  .review-card:hover .testimonial-quote-mark { transform: translateY(-4px); }
}
@media (max-width: 1100px) {
  .reviews-grid { grid-template-columns: 1fr; max-width: 660px; margin-inline: auto; }
}
@media (max-width: 520px) {
  .review-card .review-date { margin-left: 0; }
  .review-card figcaption { flex-wrap: wrap; }
}

/* Stars reveal left to right once the card enters view (motion allowed only). */
@media (prefers-reduced-motion: no-preference) {
  .motion-ready .review-card { opacity: 0; }
  .motion-ready .review-card.is-visible { opacity: 1; animation: review-card-rise 0.6s var(--ease); }
  .motion-ready .review-card .star { opacity: 0; transform: scale(0.5); transition: opacity 0.3s ease, transform 0.3s var(--ease); transition-delay: calc(var(--star-index, 0) * 70ms); }
  .motion-ready .review-card.is-visible .star { opacity: 1; transform: none; }
}
@keyframes review-card-rise { from { opacity: 0; transform: translateY(22px); } }

/* =========================================================
   Review dialog
   ========================================================= */
.review-modal { position: fixed; inset: 0; z-index: 210; display: grid; place-items: center; padding: clamp(12px, 3vw, 32px); }
.review-modal[hidden] { display: none; }
.review-backdrop { position: absolute; inset: 0; background: rgba(12, 11, 15, 0.74); }
.review-dialog {
  position: relative; width: min(640px, 100%); max-height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 16px;
  padding: clamp(22px, 4vw, 36px); box-shadow: 0 40px 90px rgba(0, 0, 0, 0.5);
}
.review-dialog:focus { outline: none; }
.review-dialog:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.review-close {
  position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; padding: 11px;
  display: grid; place-items: center; border: 1px solid var(--border); border-radius: 50%;
  background: transparent; color: var(--text-2); transition: color 0.2s, border-color 0.2s;
}
.review-close:hover { color: var(--text); border-color: var(--accent); }
.review-close svg { width: 20px; height: 20px; }
.review-form h2 { font-size: clamp(1.7rem, 3.4vw, 2.2rem); margin: 0 0 10px; }
.review-intro { font-size: 0.9rem; max-width: 52ch; margin-bottom: 24px; }

.review-form[hidden] { display: none; }
.review-success { text-align: center; padding: 26px 4px 10px; display: grid; justify-items: center; gap: 18px; }
.review-success[hidden] { display: none; }
.review-success-mark {
  width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%;
  background: #26322a; color: #a9d8b4; border: 1px solid #4c7a56; font-size: 1.5rem;
}
.review-success-copy { color: var(--text); font-size: 0.98rem; line-height: 1.7; max-width: 42ch; margin: 0; }

.review-error {
  border: 1px solid #9a6767; background: #2a1d1f; color: #ffd7d7;
  padding: 12px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 20px;
}
.review-error[hidden] { display: none; }

/* Fields */
.review-field { margin: 0 0 18px; border: 0; padding: 0; }
.review-field label, .review-field legend { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text); margin-bottom: 8px; padding: 0; }
.review-field input, .review-field textarea {
  width: 100%; min-height: 48px; padding: 12px 14px; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid #57535e; border-radius: 7px;
}
.review-field textarea { min-height: 120px; resize: vertical; }
.review-field input::placeholder, .review-field textarea::placeholder { color: #93909c; }
.review-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.review-requirement { color: #d9b98a; font-weight: 500; margin-left: 6px; }
.review-optional { color: var(--text-2); font-weight: 400; margin-left: 6px; }
.review-field-note { font-size: 0.76rem; line-height: 1.6; color: var(--text-2); margin: 8px 0 0; }
.review-count-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; }
.review-count-hint { font-size: 0.72rem; color: var(--text-2); }
.review-count { font: 0.72rem/1.5 var(--font-mono); color: var(--text-2); }
.review-count.is-short { color: #d9b98a; }
.review-count.is-ok { color: #9fc7a8; }
.review-consent-label { display: flex; gap: 12px; align-items: flex-start; font-size: 0.82rem; line-height: 1.6; color: var(--text); cursor: pointer; }
.review-consent-label input { width: 19px; height: 19px; margin-top: 3px; flex-shrink: 0; accent-color: var(--accent); }

/* Star radio group: native radios carry the semantics; JS lights stars 1–N. */
.review-rating-field legend { margin-bottom: 10px; }
.review-stars-input { display: flex; gap: 4px; }
.review-star { position: relative; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 8px; cursor: pointer; }
.review-star input { position: absolute; width: 1px; height: 1px; margin: -1px; clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap; }
.review-star .star-glyph { color: #4c4852; font-size: 1.9rem; line-height: 1; transition: color 0.15s ease, transform 0.2s var(--ease); }
.review-star.is-lit .star-glyph { color: var(--accent); }
.review-star.is-lit .star-glyph { transform: scale(1.04); }
.review-star input:checked + .star-glyph { animation: star-pop 0.26s var(--ease); }
.review-star input:focus-visible + .star-glyph { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
.review-star:hover .star-glyph { transform: scale(1.08); }
.review-rating-live { min-height: 1.3em; margin: 8px 0 0; font-size: 0.76rem; color: var(--text-2); }
@keyframes star-pop { 0% { transform: scale(1); } 55% { transform: scale(1.22); } 100% { transform: scale(1.04); } }

/* Honeypot is reachable by bots but invisible to people and assistive technology. */
.review-hp { position: absolute; left: -6000px; top: -6000px; width: 1px; height: 1px; overflow: hidden; }
.review-turnstile { margin-bottom: 18px; }
.review-turnstile[hidden] { display: none; }
.review-actions { margin-top: 24px; }
.review-submit-note { font-size: 0.74rem; line-height: 1.6; color: var(--text-2); margin: 12px 0 0; text-align: center; }
#reviewSubmit { gap: 14px; }
#reviewSubmit:disabled { cursor: wait; opacity: 0.7; }

/* Open transition and restrained field stagger (motion allowed only). */
@media (prefers-reduced-motion: no-preference) {
  .review-modal.is-open .review-backdrop { animation: review-fade 0.25s ease; }
  .review-modal.is-open .review-dialog { animation: review-dialog-in 0.28s var(--ease); }
  .review-modal.is-open .review-form > *, .review-modal.is-open .review-success { animation: review-field-in 0.4s var(--ease) backwards; }
  .review-modal.is-open .review-form > *:nth-child(2) { animation-delay: 40ms; }
  .review-modal.is-open .review-form > *:nth-child(3) { animation-delay: 80ms; }
  .review-modal.is-open .review-form > *:nth-child(4) { animation-delay: 120ms; }
  .review-modal.is-open .review-form > *:nth-child(5) { animation-delay: 160ms; }
  .review-modal.is-open .review-form > *:nth-child(6) { animation-delay: 200ms; }
  .review-modal.is-open .review-form > *:nth-child(7) { animation-delay: 240ms; }
  .review-modal.is-open .review-form > *:nth-child(8) { animation-delay: 280ms; }
  .review-modal.is-open .review-form > *:nth-child(9) { animation-delay: 320ms; }
  .review-modal.is-open .review-form > *:nth-child(n + 10) { animation-delay: 360ms; }
}
@keyframes review-fade { from { opacity: 0; } }
@keyframes review-dialog-in { from { opacity: 0; transform: scale(0.96) translateY(10px); } }
@keyframes review-field-in { from { opacity: 0; transform: translateY(10px); } }

/* Body scroll pauses only while the dialog is open; native scrolling resumes on close. */
body.review-modal-open { overflow: hidden; }
/* The analytics preference panel is normally the highest fixed layer. Temporarily
   remove it while this modal owns focus so the two dialogs never overlap. */
body.review-modal-open .analytics-choice { visibility: hidden; }

@media (max-width: 560px) {
  .review-field-row { grid-template-columns: 1fr; gap: 0; }
  .review-stars-input { gap: 2px; }
  .review-star { width: 41px; height: 44px; }
}
@media (max-width: 360px) {
  .review-star { width: 38px; }
  .review-star .star-glyph { font-size: 1.7rem; }
}
