/*
 * Google Reviews — module stylesheet
 * packages/logicai/statamic-google-reviews/resources/css/google-reviews.css
 *
 * Published to public/vendor/google-reviews/ and <link>ed via the host's
 * {{ asset_version }} tag, which hashes file contents — so republishing busts
 * the cache without anyone bumping a ?v= by hand.
 *
 * ── Theming contract ──────────────────────────────────────────────────────
 * Every colour, radius, spacing and font-size is a --gr-* custom property with
 * a literal default. That is not decoration, it is the portability guarantee:
 * the module must look finished in a project that defines nothing, AND retheme
 * completely from one block in the host stylesheet. Reading the host's own
 * tokens directly (--ink, --rule) was rejected for exactly this reason — it
 * renders unstyled in any project that happens not to define them.
 *
 * To retheme, redeclare on .gr in your own stylesheet:
 *
 *     .gr {
 *       --gr-star: var(--rating-star);
 *       --gr-text-strong: var(--ink);
 *       --gr-border: var(--rule);
 *       --gr-focus-ring: var(--lacros-orange);
 *       --gr-font: var(--font-sans);
 *     }
 *
 * Defaults below are deliberately tuned to land on the Lacros palette already,
 * so that block is a refinement rather than a requirement.
 *
 * ── No motion ─────────────────────────────────────────────────────────────
 * There is no carousel, no scroll-snap, no autoplay and no entrance animation
 * anywhere in this file. The only transitions are hover colour changes, and
 * even those are switched off under prefers-reduced-motion.
 */

.gr {
  /* Brand / accent */
  --gr-star:            #FBBC04;   /* filled star (Google's own yellow) */
  --gr-star-empty:      #DADCE0;   /* the unfilled track behind it */

  /* Type colours. Contrast checked against --gr-surface and #FBFAF8:
     text 9.5:1, muted 5.6:1, strong 16.9:1 — all clear AA, muted clears AA
     at small sizes too, which is where it is actually used. */
  --gr-text:            #3C4043;
  --gr-text-strong:     #161616;
  --gr-text-muted:      #5F6368;

  /* Surfaces */
  --gr-surface:         #FFFFFF;
  --gr-surface-sunken:  #F5F5F5;   /* owner-reply block */
  --gr-border:          #E6E2DC;
  --gr-section-bg:      transparent;

  /* Interaction */
  --gr-link:            inherit;
  --gr-link-hover:      #161616;
  --gr-focus-ring:      #F05010;
  --gr-focus-width:     2px;
  --gr-focus-offset:    2px;

  /* Shape + rhythm */
  --gr-radius:          10px;
  --gr-radius-sm:       6px;
  --gr-gap:             20px;
  --gr-card-padding:    24px;
  --gr-section-padding: 84px 0;

  /* Type */
  --gr-font:            inherit;
  --gr-font-size:       14.5px;
  --gr-font-size-sm:    13px;
  --gr-line-height:     1.6;

  /* Star row sizes */
  --gr-stars-width-sm:  85px;
  --gr-stars-width-md:  110px;
  --gr-stars-width-lg:  170px;

  /* How many lines of a review body are visible before the visual clamp.
     The full text is always in the DOM — see _review.antlers.html. */
  --gr-clamp-lines:     6;

  /* Avatar */
  --gr-avatar-size:     40px;
  --gr-avatar-bg:       #F2EFEA;

  font-family: var(--gr-font);
  color: var(--gr-text);
}

.gr *,
.gr *::before,
.gr *::after { box-sizing: border-box; }

/* Visually hidden but readable by assistive tech. Used for the reviewer name
   appended to each "Read on Google" link, so a link list is navigable. */
.gr-sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Focus is never removed, only restyled. Every interactive element in the
   module is an <a>, so this one rule covers all of them. */
.gr a:focus-visible {
  outline: var(--gr-focus-width) solid var(--gr-focus-ring);
  outline-offset: var(--gr-focus-offset);
  border-radius: var(--gr-radius-sm);
}

/* ──────────────────────────────────────────────────────────────────────────
   Stars
   Two stacked copies of the same SVG. The fill layer is clipped by a
   percentage width set inline as --gr-stars-fill, which is what makes 4.6
   render as 4.6 rather than rounding to 5 and overstating the rating.
   ────────────────────────────────────────────────────────────────────────── */

.gr-stars {
  position: relative;
  display: inline-block;
  width: var(--gr-stars-width-md);
  line-height: 0;
  flex: none;                    /* never let a flex parent squash the row */
  vertical-align: middle;
}

.gr-stars--sm { width: var(--gr-stars-width-sm); }
.gr-stars--md { width: var(--gr-stars-width-md); }
.gr-stars--lg { width: var(--gr-stars-width-lg); }

.gr-stars-track,
.gr-stars-fill { display: block; }

.gr-stars-track { color: var(--gr-star-empty); }

.gr-stars-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--gr-stars-fill, 0%);
  overflow: hidden;
  color: var(--gr-star);
}

/* The inner SVG must keep the full row width inside the clipped fill layer,
   or the stars would squash instead of being cut off. */
.gr-stars-svg {
  display: block;
  width: 100%;
  height: auto;
  fill: currentColor;
}

.gr-stars-fill .gr-stars-svg { width: var(--gr-stars-track-width, 100%); }
.gr-stars--sm .gr-stars-fill .gr-stars-svg { width: var(--gr-stars-width-sm); }
.gr-stars--md .gr-stars-fill .gr-stars-svg { width: var(--gr-stars-width-md); }
.gr-stars--lg .gr-stars-fill .gr-stars-svg { width: var(--gr-stars-width-lg); }

.gr-google-mark { flex: none; vertical-align: middle; }

/* ──────────────────────────────────────────────────────────────────────────
   Variant: summary — inline trust signal
   min-height reserves the row before the mark and stars paint, so the ribbon
   cannot reflow around it.
   ────────────────────────────────────────────────────────────────────────── */

.gr-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  color: var(--gr-link);
  text-decoration: none;
  font-size: var(--gr-font-size-sm);
  white-space: nowrap;
}

.gr-summary-score { color: var(--gr-text-strong); font-weight: 700; }
.gr-summary-sep   { color: var(--gr-text-muted); }
.gr-summary-count { text-decoration: underline; text-underline-offset: 2px; }
.gr-summary:hover .gr-summary-count { text-decoration: none; }

/* ──────────────────────────────────────────────────────────────────────────
   Variant: badge — centred vertical lockup
   ────────────────────────────────────────────────────────────────────────── */

.gr-badge-wrap { display: block; text-align: center; padding: 24px 0 72px; }

.gr-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 96px;
  color: var(--gr-link);
  text-decoration: none;
}

.gr-badge-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--gr-text-strong);
}

.gr-badge-brand .gr-google-mark { width: 20px; height: 20px; }

.gr-badge-score { font-size: 15px; color: var(--gr-text-strong); }
.gr-badge-sep   { color: var(--gr-text-muted); margin: 0 6px; }
.gr-badge-count { text-decoration: underline; text-underline-offset: 2px; }
.gr-badge:hover .gr-badge-count { text-decoration: none; }

/* ──────────────────────────────────────────────────────────────────────────
   Variant: grid — the full section
   ────────────────────────────────────────────────────────────────────────── */

.gr-section { background: var(--gr-section-bg); padding: var(--gr-section-padding); }

/* Matches the host's .lx-wrap measure. A host with its own wrapper can zero
   this out from its own stylesheet without touching the partial. */
.gr-section-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.gr-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 40px;
}

.gr-eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--gr-focus-ring);
}

.gr-heading {
  margin: 0;
  color: var(--gr-text-strong);
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.15;
}

.gr-aggregate { text-align: right; margin-left: auto; }

.gr-aggregate-score {
  margin: 0;
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  color: var(--gr-text-strong);
}

.gr-aggregate-count { margin: 6px 0 0; font-size: var(--gr-font-size-sm); color: var(--gr-text-muted); }

.gr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--gr-gap);
  /* Cards stretch to the tallest in their row (the grid default), matching the
     host's own .lx-reviews-grid. `start` was tried and reads ragged, because a
     rating-only review is a third the height of a long one. Combined with the
     margin-top:auto on .gr-card-link, every card in a row ends up with its
     Google link on the same baseline. */
}

/* ──────────────────────────────────────────────────────────────────────────
   Review card
   ────────────────────────────────────────────────────────────────────────── */

.gr-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--gr-surface);
  border: 1px solid var(--gr-border);
  border-radius: var(--gr-radius);
  padding: var(--gr-card-padding);
}

.gr-card-head { display: flex; align-items: center; gap: 12px; }

.gr-avatar {
  width: var(--gr-avatar-size);
  height: var(--gr-avatar-size);
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  background: var(--gr-avatar-bg);
}

.gr-avatar--initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--gr-text-strong);
  line-height: 1;
}

.gr-card-who { min-width: 0; }   /* lets a long name ellipsis instead of overflowing */

.gr-card-author {
  display: block;
  color: var(--gr-text-strong);
  font-weight: 700;
  font-size: var(--gr-font-size-sm);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.gr-card-author:hover { text-decoration: underline; text-underline-offset: 2px; }

.gr-card-time { display: block; font-size: 12px; color: var(--gr-text-muted); }

/*
 * The visual clamp. The full review text is in the DOM — this only limits how
 * much is painted, so screen readers, copy-paste, find-in-page and text-only
 * browsers all still get the complete review. Do not replace this with a
 * truncated string in the template.
 */
.gr-card-text {
  margin: 0;
  font-size: var(--gr-font-size);
  line-height: var(--gr-line-height);
  color: var(--gr-text);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--gr-clamp-lines);
  line-clamp: var(--gr-clamp-lines);
  overflow: hidden;
}

.gr-card-translated { margin: 0; font-size: 12px; color: var(--gr-text-muted); font-style: italic; }

.gr-card-reply {
  border-left: 2px solid var(--gr-border);
  background: var(--gr-surface-sunken);
  border-radius: var(--gr-radius-sm);
  padding: 12px 14px;
}

.gr-card-reply-label { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--gr-text-strong); }

.gr-card-reply-text {
  margin: 0;
  font-size: var(--gr-font-size-sm);
  line-height: var(--gr-line-height);
  color: var(--gr-text);
}

.gr-card-link {
  margin-top: auto;              /* pins the link to the card foot so a short and
                                    a long review still line up across the row */
  font-size: 12px;
  color: var(--gr-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color .15s ease;
}

.gr-card-link:hover { color: var(--gr-link-hover); }

/* ──────────────────────────────────────────────────────────────────────────
   Attribution
   ────────────────────────────────────────────────────────────────────────── */

.gr-attribution {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 28px;
  font-size: var(--gr-font-size-sm);
  color: var(--gr-text-muted);
}

.gr-attribution-brand { display: inline-flex; align-items: center; gap: 8px; }

.gr-attribution-link {
  color: var(--gr-text-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color .15s ease;
}

.gr-attribution-link:hover { color: var(--gr-focus-ring); }

/* ──────────────────────────────────────────────────────────────────────────
   Responsive. Breakpoints match the host theme's (1100 / 900 / 620) so the
   grid changes column count in step with everything around it.
   ────────────────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .gr-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .gr { --gr-section-padding: 56px 0; --gr-card-padding: 20px; }
  .gr-grid { grid-template-columns: 1fr; }
  .gr-section-head { flex-direction: column; align-items: flex-start; }
  .gr-aggregate { text-align: left; margin-left: 0; }
  .gr-aggregate-score { font-size: 36px; }
  .gr-attribution { justify-content: flex-start; }

  /* The summary lockup lives in a cramped ribbon on phones. Drop the count
     rather than let the row wrap into two lines or scroll sideways — the
     score and stars still carry the claim, and the full sentence is in the
     link's accessible name either way. */
  .gr-summary-count,
  .gr-summary-sep { display: none; }
}

/*
 * The module ships no animation, so this block has little to switch off — but
 * the hover colour fades are a transition, and honouring the preference means
 * honouring it everywhere rather than only where it feels significant.
 */
@media (prefers-reduced-motion: reduce) {
  .gr *,
  .gr *::before,
  .gr *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

/*
 * Forced-colours (Windows high contrast) drops background colours, which would
 * make the fill and track stars indistinguishable — both would paint as system
 * text. Borders keep the cards legible and the star layers keep their contrast.
 */
@media (forced-colors: active) {
  .gr-stars-track { color: GrayText; }
  .gr-stars-fill  { color: Highlight; }
  .gr-card        { border-color: CanvasText; }
}
