/* ==========================================================================
   Riddle Educat – Google Reviews section (Home + About)
   Everything is scoped under .rd-reviews. Colours come from the host page's
   existing variables (--navy / --primary) with brand hex fallbacks.
   ========================================================================== */

section.rd-reviews {
  --rdr-navy: var(--navy, var(--primary, #14213d));
  --rdr-gold: var(--accent, #c8962c);
  --rdr-gold-deep: var(--secondary, #a97a1e);
  --rdr-star: #e0a100;
  --rdr-star-off: #d9dee7;
  --rdr-ink: #1f2a3d;
  --rdr-muted: #55627a;
  --rdr-line: #e3e8ef;
  --rdr-paper: #f7f8fb;
  --rdr-heading-font: inherit;
  --rdr-heading-weight: 800;
  background: var(--rdr-paper);
  padding: 90px 0;
  color: var(--rdr-ink);
}
section.rd-reviews[hidden] { display: none; }
section.rd-reviews--serif {
  --rdr-heading-font: 'Fraunces', Georgia, serif;
  --rdr-heading-weight: 600;
  background: #fff;
}
section.rd-reviews--compact { padding: 72px 0; }

/* ---------- Heading ---------- */
.rd-reviews__head { text-align: center; max-width: 640px; margin: 0 auto 44px; }
.rd-reviews__title {
  font-family: var(--rdr-heading-font);
  font-weight: var(--rdr-heading-weight);
  font-size: clamp(1.6rem, 2.6vw, 2.1rem);
  line-height: 1.2;
  color: var(--rdr-navy);
  margin: 0;
}
.rd-reviews__sub { margin: 10px 0 0; color: var(--rdr-muted); font-size: .98rem; line-height: 1.6; }

/* ---------- Two-column body ---------- */
.rd-reviews__body { display: grid; gap: 32px; align-items: start; }

.rd-reviews__summary {
  background: #fff;
  border: 1px solid var(--rdr-line);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 1px 2px rgba(15, 36, 56, .04), 0 10px 24px -16px rgba(15, 36, 56, .22);
}
.rd-reviews--serif .rd-reviews__summary { background: var(--rdr-paper); box-shadow: none; }

.rd-reviews__score { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rd-reviews__rating {
  font-family: var(--rdr-heading-font);
  font-weight: var(--rdr-heading-weight);
  font-size: 3.2rem;
  line-height: 1;
  color: var(--rdr-navy);
  font-variant-numeric: lining-nums;
}
.rd-reviews__meta { display: grid; gap: 6px; }
.rd-reviews__count { font-size: .9rem; color: var(--rdr-muted); }

.rd-reviews__actions { display: grid; gap: 10px; margin-top: 22px; }
.rd-reviews__actions:first-child { margin-top: 0; }

.rd-rbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 22px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  text-align: center;
  border: 1.5px solid var(--rdr-navy);
  cursor: pointer;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.rd-rbtn--primary { background: var(--rdr-navy); color: #fff; }
.rd-rbtn--primary:hover { background: var(--rdr-gold-deep); border-color: var(--rdr-gold-deep); color: #fff; }
.rd-rbtn--ghost { background: transparent; color: var(--rdr-navy); }
.rd-rbtn--ghost:hover { background: var(--rdr-navy); color: #fff; }
.rd-rbtn:focus-visible,
.rd-review a:focus-visible,
.rd-review__more:focus-visible,
.rd-rnav:focus-visible { outline: 2px solid var(--rdr-gold); outline-offset: 3px; }

.rd-reviews__attrib {
  margin: 18px 0 0;
  font-size: .78rem;
  line-height: 1.55;
  color: #5e5e5e;
}
.rd-reviews__attrib strong { font-weight: 500; color: #3c4043; }

/* Buttons-only layout (Place ID set, no API key / API unavailable) */
.rd-reviews--links .rd-reviews__body { grid-template-columns: 1fr; max-width: 520px; margin: 0 auto; }
.rd-reviews--links .rd-reviews__summary { text-align: center; }
.rd-reviews--links .rd-reviews__actions { grid-template-columns: 1fr; }

/* ---------- Stars ---------- */
.rd-stars {
  position: relative;
  display: inline-block;
  font-size: 1.1rem;
  line-height: 1;
  letter-spacing: 2px;
  color: var(--rdr-star-off);
  white-space: nowrap;
}
.rd-stars::before { content: "\2605\2605\2605\2605\2605"; }
.rd-stars > span {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: var(--rd-fill, 0%);
  overflow: hidden;
  color: var(--rdr-star);
}
.rd-stars > span::before { content: "\2605\2605\2605\2605\2605"; }
.rd-stars--lg { font-size: 1.3rem; }

/* ---------- Review carousel ---------- */
.rd-reviews__carousel { position: relative; min-width: 0; }
.rd-reviews__track {
  list-style: none;
  margin: 0;
  padding: 4px 2px 10px;
  display: flex;
  gap: 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.rd-reviews__track::-webkit-scrollbar { display: none; }

.rd-review {
  flex: 0 0 min(360px, 86%);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--rdr-line);
  border-radius: 14px;
  padding: 22px 22px 18px;
  box-shadow: 0 1px 2px rgba(15, 36, 56, .04), 0 10px 24px -16px rgba(15, 36, 56, .22);
  transition: border-color .25s ease, box-shadow .25s ease;
}
.rd-reviews--serif .rd-review { background: #fff; border-color: var(--rdr-line); }
@media (hover: hover) {
  .rd-review:hover { border-color: rgba(200, 150, 44, .6); box-shadow: 0 1px 2px rgba(15, 36, 56, .05), 0 16px 32px -18px rgba(15, 36, 56, .3); }
}

.rd-review__top { display: flex; align-items: center; gap: 12px; }
.rd-review__avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  flex: none;
  object-fit: cover;
  background: #e8edf4;
}
.rd-review__initial {
  width: 42px; height: 42px;
  border-radius: 50%;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--rdr-navy);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
}
.rd-review__who { min-width: 0; display: grid; gap: 2px; }
.rd-review__name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--rdr-navy);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
a.rd-review__name:hover { text-decoration: underline; }
.rd-review__when { font-size: .8rem; color: var(--rdr-muted); }

.rd-review__text {
  margin: 0;
  font-size: .93rem;
  line-height: 1.65;
  color: var(--rdr-ink);
  white-space: pre-line;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  line-clamp: 6;
  overflow: hidden;
}
.rd-review.is-expanded .rd-review__text { -webkit-line-clamp: unset; line-clamp: unset; display: block; }
.rd-review__text--empty { color: var(--rdr-muted); font-style: italic; }

.rd-review__more {
  align-self: flex-start;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  color: var(--rdr-gold-deep);
  cursor: pointer;
}
.rd-review__more:hover { text-decoration: underline; }
.rd-review__src {
  margin-top: auto;
  padding-top: 4px;
  font-size: .8rem;
  color: var(--rdr-muted);
  text-decoration: none;
}
.rd-review__src:hover { color: var(--rdr-navy); text-decoration: underline; }

/* Carousel arrows (only shown when there is something to scroll) */
.rd-reviews__nav { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.rd-reviews__nav[hidden] { display: none; }
.rd-rnav {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--rdr-line);
  background: #fff;
  color: var(--rdr-navy);
  font-size: 1.5rem;
  line-height: 1;
  padding-bottom: 3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color .2s ease, background-color .2s ease, color .2s ease, opacity .2s ease;
}
.rd-rnav:hover:not(:disabled) { background: var(--rdr-navy); border-color: var(--rdr-navy); color: #fff; }
.rd-rnav:disabled { opacity: .4; cursor: default; }

/* Entrance (runs once, when the data arrives and the section is near the viewport) */
@media (prefers-reduced-motion: no-preference) {
  .rd-reviews.is-ready .rd-reviews__summary,
  .rd-reviews.is-ready .rd-review {
    animation: rd-rise .5s ease both;
    animation-delay: calc(var(--i, 0) * 70ms);
  }
  @keyframes rd-rise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: none; }
  }
}

/* ---------- Breakpoints ---------- */
@media (min-width: 900px) {
  .rd-reviews__body { grid-template-columns: 330px minmax(0, 1fr); gap: 36px; }
  .rd-reviews--links .rd-reviews__body { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  section.rd-reviews { padding: 60px 0; }
  section.rd-reviews--compact { padding: 56px 0; }
  .rd-reviews__head { margin-bottom: 30px; }
  .rd-reviews__rating { font-size: 2.7rem; }
  .rd-review { flex-basis: 88%; padding: 20px 18px 16px; }
}
