/*
 * Google Reviews by Am2pm — storefront widget styles.
 *
 * Static and fully cacheable: everything a merchant can change is a CSS custom property set
 * on `.agr-root` by the runtime, so editing a colour never invalidates this file.
 *
 * Every selector is scoped under `.agr-root` and every property is stated explicitly rather
 * than inherited, because this markup lands inside an unknown theme whose reset we cannot
 * predict.
 */

.agr-root {
  --agr-offset-x: 20px;
  --agr-offset-y: 20px;

  box-sizing: border-box;
  display: block;
  width: 100%;
  max-width: var(--agr-width, 100%);
  margin-inline: auto;
  /* Deliberately no `color` here. Elements on the theme's own background must inherit the
     store's text colour; only the surfaces we paint below set --agr-text. Setting it on the
     root made a Dark widget's heading white on a light store — invisible. */
  font-family: var(--agr-font, inherit);
  font-size: var(--agr-body-size, 14px);
  line-height: 1.5;
  text-align: start;
  background-color: var(--agr-widget-bg, transparent);
  background-image: var(--agr-widget-image, none);
  background-size: cover;
  background-position: center;
}

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

.agr-shell {
  display: flex;
  flex-direction: column;
  gap: var(--agr-gap, 16px);
}

.agr-heading {
  margin: 0;
  /* Inherits the theme's text colour unless the merchant picked a custom one — the heading
     sits on the store's background, not on one of our cards. */
  color: var(--agr-heading, inherit);
  font-size: var(--agr-title-size, 22px);
  font-weight: var(--agr-title-weight, 600);
  line-height: 1.25;
  text-align: center;
}

.agr-empty {
  margin: 0;
  padding: 24px;
  /* Sits on the theme's background, so it follows the theme rather than our card palette. */
  color: var(--agr-heading, inherit);
  opacity: 0.7;
  text-align: center;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

.agr-header {
  color: var(--agr-text);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: var(--agr-radius, 8px);
  background: var(--agr-card-bg);
  box-shadow: var(--agr-shadow);
}

.agr-header-centered {
  flex-direction: column;
  text-align: center;
}

.agr-header-compact {
  padding: 10px 14px;
}

.agr-align-center .agr-header-left {
  align-items: center;
}
.agr-align-right .agr-header-left {
  align-items: flex-end;
}

.agr-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-start;
  min-width: 0;
}

.agr-logo svg {
  display: block;
  height: 26px;
  width: auto;
}

.agr-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.agr-rating-value {
  color: var(--agr-title);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.agr-review-count {
  color: var(--agr-muted);
  font-size: 13px;
}

.agr-write-review {
  flex-shrink: 0;
  padding: 9px 16px;
  border: 0;
  border-radius: calc(var(--agr-radius, 8px) / 2);
  background: var(--agr-accent);
  color: var(--agr-accent-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.15s ease;
}

.agr-write-review:hover {
  filter: brightness(0.92);
  color: var(--agr-accent-text);
}

/* ── Stars ──────────────────────────────────────────────────────────────────── */

.agr-stars {
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  line-height: 0;
  white-space: nowrap;
}

.agr-stars-empty,
.agr-stars-full {
  display: block;
  white-space: nowrap;
}

/* The filled row is clipped to a width percentage, which renders any fraction of a star. */
.agr-stars-full {
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  overflow: hidden;
}

.agr-star {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: top;
}

.agr-stars-empty .agr-star {
  fill: color-mix(in srgb, var(--agr-muted) 35%, transparent);
}

.agr-stars-full .agr-star {
  fill: var(--agr-rating);
}

.agr-stars-lg {
  font-size: 18px;
}
.agr-stars-sm {
  font-size: 14px;
}

/* ── Review grid / list / masonry ───────────────────────────────────────────── */

.agr-reviews {
  display: grid;
  gap: var(--agr-gap, 16px);
  grid-template-columns: repeat(var(--agr-cols-mobile, 1), minmax(0, 1fr));
}

@media (min-width: 750px) {
  .agr-reviews {
    grid-template-columns: repeat(var(--agr-cols-tablet, 2), minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .agr-reviews {
    grid-template-columns: repeat(var(--agr-cols-desktop, 3), minmax(0, 1fr));
  }
}

.agr-layout-list .agr-reviews {
  grid-template-columns: minmax(0, 1fr);
}

/* Masonry uses CSS columns so cards keep their natural height and tile without gaps.
   `break-inside: avoid` is what stops a card being split across two columns. */
.agr-layout-masonry .agr-reviews {
  display: block;
  column-gap: var(--agr-gap, 16px);
  column-count: var(--agr-cols-mobile, 1);
}

@media (min-width: 750px) {
  .agr-layout-masonry .agr-reviews {
    column-count: var(--agr-cols-tablet, 2);
  }
}

@media (min-width: 1100px) {
  .agr-layout-masonry .agr-reviews {
    column-count: var(--agr-cols-desktop, 3);
  }
}

.agr-layout-masonry .agr-card {
  display: inline-block;
  width: 100%;
  margin-bottom: var(--agr-gap, 16px);
  break-inside: avoid;
}

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

.agr-card {
  color: var(--agr-text);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border-radius: var(--agr-radius, 8px);
  background: var(--agr-card-bg);
  box-shadow: var(--agr-shadow);
  outline: none;
}

.agr-card:focus-visible {
  outline: 2px solid var(--agr-accent);
  outline-offset: 2px;
}

.agr-card-minimal {
  padding: 12px 0;
  border-radius: 0;
  background: transparent;
  border-bottom: 1px solid var(--agr-border);
  box-shadow: none;
}

.agr-card-card {
  border: 1px solid var(--agr-border);
}

/* The bubble style points a small tail at the author row below it. */
.agr-card-bubble {
  position: relative;
  margin-bottom: 14px;
  overflow: visible;
}

.agr-card-bubble::after {
  content: "";
  position: absolute;
  inset-inline-start: 24px;
  bottom: -8px;
  width: 16px;
  height: 16px;
  background: var(--agr-card-bg);
  transform: rotate(45deg);
  box-shadow: var(--agr-shadow);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.agr-author-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.agr-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--agr-border);
}

.agr-avatar-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
}

.agr-author-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.agr-author-name {
  color: var(--agr-text);
  font-size: var(--agr-author-size, 14px);
  font-weight: 600;
  text-decoration: underline;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.agr-author-name:hover {
  color: var(--agr-accent);
}

.agr-date {
  color: var(--agr-muted);
  font-size: 12px;
  text-decoration: underline;
}

.agr-text {
  margin: 0;
  color: var(--agr-text);
  font-size: var(--agr-body-size, 14px);
  /* Reviews arrive with author-authored newlines; honour them without allowing overflow. */
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.agr-read-more {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: var(--agr-accent);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.agr-read-more:hover {
  text-decoration: underline;
}

.agr-chevron {
  width: 12px;
  height: 12px;
  fill: currentColor;
  transition: transform 0.15s ease;
}

.agr-read-more[aria-expanded="true"] .agr-chevron {
  transform: rotate(180deg);
}

.agr-reply {
  padding: 10px 12px;
  border-radius: calc(var(--agr-radius, 8px) / 1.5);
  background: color-mix(in srgb, var(--agr-muted) 10%, transparent);
}

.agr-reply-label {
  display: block;
  margin-bottom: 4px;
  color: var(--agr-muted);
  font-size: 12px;
  font-weight: 600;
}

.agr-reply-text {
  margin: 0;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.agr-source {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: auto;
  padding-top: 4px;
}

.agr-source-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.agr-source-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.agr-source-label {
  color: var(--agr-muted);
  font-size: 11px;
}

.agr-source-name {
  color: var(--agr-muted);
  font-size: 12px;
  font-weight: 500;
}

/* ── Load more ──────────────────────────────────────────────────────────────── */

.agr-load-more {
  align-self: center;
  padding: 10px 22px;
  border: 1px solid var(--agr-border);
  border-radius: calc(var(--agr-radius, 8px) / 2);
  background: transparent;
  /* Load more also sits on the theme's background. */
  color: var(--agr-heading, inherit);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
}

.agr-load-more:hover {
  border-color: var(--agr-accent);
  color: var(--agr-accent);
}

/* ── Carousel ───────────────────────────────────────────────────────────────── */

.agr-carousel {
  position: relative;
}

.agr-track {
  display: flex;
  gap: var(--agr-gap, 16px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  /* Hide the scrollbar without disabling scrolling — touch and trackpad still work. */
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}

.agr-track::-webkit-scrollbar {
  display: none;
}

.agr-slide {
  flex: 0 0 calc((100% - (var(--agr-cols-mobile, 1) - 1) * var(--agr-gap, 16px)) / var(--agr-cols-mobile, 1));
  scroll-snap-align: start;
}

@media (min-width: 750px) {
  .agr-slide {
    flex-basis: calc((100% - (var(--agr-cols-tablet, 2) - 1) * var(--agr-gap, 16px)) / var(--agr-cols-tablet, 2));
  }
}

@media (min-width: 1100px) {
  .agr-slide {
    flex-basis: calc((100% - (var(--agr-cols-desktop, 3) - 1) * var(--agr-gap, 16px)) / var(--agr-cols-desktop, 3));
  }
}

.agr-slide .agr-card {
  height: 100%;
}

.agr-arrow {
  position: absolute;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--agr-border);
  border-radius: 50%;
  background: var(--agr-card-bg);
  color: var(--agr-text);
  cursor: pointer;
  transform: translateY(-50%);
  box-shadow: var(--agr-shadow);
}

.agr-arrow svg {
  width: 18px;
  height: 18px;
}

.agr-arrow-prev {
  inset-inline-start: -8px;
}
.agr-arrow-next {
  inset-inline-end: -8px;
}

/* Arrows overlap the cards on narrow screens, where swiping is the natural gesture. */
@media (max-width: 749px) {
  .agr-arrow {
    display: none;
  }
}

.agr-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.agr-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--agr-muted) 35%, transparent);
  cursor: pointer;
  transition: background 0.15s ease;
}

.agr-dot-active {
  background: var(--agr-accent);
}

/* ── Badge / floating badge ─────────────────────────────────────────────────── */

.agr-badge {
  display: inline-block;
}

.agr-badge-floating {
  position: fixed;
  z-index: 2147483000;
}

.agr-pos-bottom_right {
  inset-block-end: var(--agr-offset-y);
  inset-inline-end: var(--agr-offset-x);
}
.agr-pos-bottom_left {
  inset-block-end: var(--agr-offset-y);
  inset-inline-start: var(--agr-offset-x);
}
.agr-pos-top_right {
  inset-block-start: var(--agr-offset-y);
  inset-inline-end: var(--agr-offset-x);
}
.agr-pos-top_left {
  inset-block-start: var(--agr-offset-y);
  inset-inline-start: var(--agr-offset-x);
}

.agr-badge-trigger,
.agr-badge-link {
  color: var(--agr-text);
  display: block;
  padding: 14px 20px;
  border: 1px solid var(--agr-border);
  border-radius: var(--agr-radius, 8px);
  background: var(--agr-card-bg);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}

/* Stacked and centred rather than a horizontal pill. The score is what a shopper scans for,
   so it gets its own line at full size instead of competing with the logo for the same row. */
.agr-badge-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
}

.agr-badge-logo {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.agr-badge-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
}

.agr-badge-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.agr-badge-top {
  display: flex;
  gap: 6px;
  align-items: center;
}

.agr-badge-top .agr-rating-value {
  font-size: 18px;
  font-weight: 700;
}

/* Underlined because the whole card is a link or a panel trigger, and nothing else in the
   card says so. */
.agr-badge-count {
  color: var(--agr-muted);
  font-size: 12px;
  text-decoration: underline;
}

.agr-badge-panel {
  color: var(--agr-text);
  position: absolute;
  inset-block-end: calc(100% + 10px);
  inset-inline-end: 0;
  width: min(360px, calc(100vw - 40px));
  max-height: min(520px, 70vh);
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--agr-border);
  border-radius: var(--agr-radius, 8px);
  background: var(--agr-card-bg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
}

.agr-pos-top_left .agr-badge-panel,
.agr-pos-top_right .agr-badge-panel {
  inset-block-end: auto;
  inset-block-start: calc(100% + 10px);
}

.agr-badge-panel[hidden] {
  display: none;
}

.agr-badge-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.agr-badge-panel-logo {
  height: 22px;
  width: auto;
}

.agr-badge-close {
  display: flex;
  padding: 4px;
  border: 0;
  background: none;
  color: var(--agr-muted);
  cursor: pointer;
}

.agr-badge-close svg {
  width: 16px;
  height: 16px;
}

.agr-badge-reviews {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.agr-badge-reviews .agr-card {
  box-shadow: none;
  border: 1px solid var(--agr-border);
}

/* ── Motion ─────────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .agr-root *,
  .agr-track {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Present for assistive tech, absent visually. Used by the icon-only source style, where the
   attribution wording must still be announced. */
.agr-visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Theme-editor-only notice, rendered when the widget has nothing to show. Styled without the
   widget's CSS variables because it appears precisely when no payload arrived to define them. */
.agr-editor-notice {
  padding: 16px 18px;
  border: 1px dashed #b5b5b5;
  border-radius: 8px;
  background: #fafafa;
  color: #303030;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  text-align: left;
}

.agr-editor-notice p {
  margin: 6px 0 0;
}

.agr-editor-notice p:last-child {
  color: #6a6a6a;
  font-size: 12px;
}
