/* Unlimited GBP Reviews — front-end styles for custom blocks. */

.wp-block-shd-reviews-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  line-height: 1;
}

.shd-reviews-rating-stars {
  display: inline-flex;
  gap: 1px;
  color: inherit;
}

.shd-reviews-rating-number {
  font-variant-numeric: tabular-nums;
}

.shd-reviews-review-count {
  font-size: 0.875em;
  color: var(--wp--preset--color--text-muted, #64748b);
}

.wp-block-shd-reviews-platform {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  line-height: 1;
}

.shd-reviews-platform-icon {
  display: inline-block;
  vertical-align: middle;
}

.wp-block-shd-reviews-reviewer-name {
  margin: 0;
  /* Default readable color so the name never falls back to an inherited
     (and possibly invisible) color. Overridden by any block color the
     pattern/user sets, since preset color classes are !important. */
  color: #000;
}

.wp-block-shd-reviews-original-link {
  display: inline-block;
}

.wp-block-shd-reviews-original-link .wp-block-button__link {
  display: inline-block;
}

.wp-block-shd-reviews-aggregate {
  /* Block-level (not inline-flex): an inline-level box does not hold its own
     line in normal flow, so short content (count-only / average-only) tucked up
     beside the preceding element instead of sitting below it. `flex` keeps the
     identical row layout while flowing as a normal block. */
  display: flex;
  align-items: center;
  gap: 0.25em;
  line-height: 1;
}

/* Map the block's text-alignment control to the flex main axis so the toolbar
   alignment visibly positions the rating row. Scoped to this block — no leak. */
.wp-block-shd-reviews-aggregate.has-text-align-center {
  justify-content: center;
}
.wp-block-shd-reviews-aggregate.has-text-align-right {
  justify-content: flex-end;
}
.wp-block-shd-reviews-aggregate.has-text-align-left {
  justify-content: flex-start;
}

/* Masonry pattern — apply CSS columns to the post-template inside a tagged Query Loop. */
.shd-reviews-masonry .wp-block-post-template {
  column-count: 3;
  column-gap: var(--wp--preset--spacing--40, 1rem);
  display: block !important;
}
.shd-reviews-masonry .wp-block-post-template > .wp-block-post {
  break-inside: avoid;
  display: block !important;
  margin-bottom: var(--wp--preset--spacing--40, 1rem);
}
@media (max-width: 900px) {
  .shd-reviews-masonry .wp-block-post-template {
    column-count: 2;
  }
}
@media (max-width: 600px) {
  .shd-reviews-masonry .wp-block-post-template {
    column-count: 1;
  }
}

.shd-reviews-aggregate-avg,
.shd-reviews-aggregate-count {
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
}

.shd-reviews-aggregate-sep {
  opacity: 0.6;
}

.floating-review-card-post-template-block li {
  position: absolute !important;
  width: 320px;
}
.floating-review-card-post-template-block li:nth-child(1) {
  top: 0;
  left: 0;
}
.floating-review-card-post-template-block li:nth-child(2) {
  bottom: 0;
  left: 0;
}
.floating-review-card-post-template-block li:nth-child(3) {
  top: 0;
  right: 0;
}
.floating-review-card-post-template-block li:nth-child(4) {
  bottom: 0;
  right: 0;
}

/* --------------------------------------------------------------------------
 * Colour-role fallbacks.
 *
 * The bundled patterns declare colour the same way a block theme's own patterns
 * do - as preset roles (textColor / backgroundColor). On a theme that defines
 * these roles, WordPress emits the custom properties and the .has-*-color rules
 * itself and everything below is overridden. These declarations only take effect
 * on a theme that does NOT define the role, where they restore the original
 * Google palette value the patterns were designed against.
 *
 * Both halves are deliberately weaker than WordPress's own output, so they can
 * never win against a theme that defines the role:
 *   - `html` is specificity 0-0-1; global styles define these on `:root` (0-1-0).
 *   - the utility rules carry no !important; WordPress's generated ones do.
 * ------------------------------------------------------------------------ */
html {
  --wp--preset--color--background: #f8f9fa;
  --wp--preset--color--surface: #ffffff;
  --wp--preset--color--ink: #3c4043;
  --wp--preset--color--text-muted: #5f6368;
  --wp--preset--color--hairline: #dadce0;
}

.has-background-color { color: var(--wp--preset--color--background, #f8f9fa); }
.has-surface-color { color: var(--wp--preset--color--surface, #ffffff); }
.has-ink-color { color: var(--wp--preset--color--ink, #3c4043); }
.has-text-muted-color { color: var(--wp--preset--color--text-muted, #5f6368); }
.has-hairline-color { color: var(--wp--preset--color--hairline, #dadce0); }

.has-background-background-color { background-color: var(--wp--preset--color--background, #f8f9fa); }
.has-surface-background-color { background-color: var(--wp--preset--color--surface, #ffffff); }
.has-ink-background-color { background-color: var(--wp--preset--color--ink, #3c4043); }
.has-text-muted-background-color { background-color: var(--wp--preset--color--text-muted, #5f6368); }
.has-hairline-background-color { background-color: var(--wp--preset--color--hairline, #dadce0); }
