/*
 * My Custom Google Reviews — Frontend
 *
 * GRUNDREGELN (die Vorversion verstiess gegen alle drei)
 *  1. Alles unter .mgrp-widget-wrapper gescoped. Keine globalen :root-Variablen.
 *  2. Kein !important als Reflex. Die wenigen Ausnahmen unten sind einzeln
 *     begruendet — es sind genau die Stellen, an denen Divi zurueckschlaegt.
 *  3. Keine Dashicons. Die Sterne sind Inline-SVG: skalieren sauber, faerben
 *     sich ueber currentColor und sparen den kompletten Icon-Font.
 *
 * ANPASSEN
 *  Die Akzentfarbe steht als Variable ganz oben. Eine Zeile im Theme genuegt:
 *      .mgrp-widget-wrapper { --mgrp-accent: #ed681c; }
 */

/* ------------------------------------------------------------------ */
/* Tokens — bewusst auf dem Wrapper, nicht auf :root                   */
/* ------------------------------------------------------------------ */
.mgrp-widget-wrapper {
    --mgrp-accent:      #1a73e8;  /* Google-Blau. Ueberschreibbar. */
    --mgrp-accent-dark: #1557b0;
    --mgrp-star:        #f5a524;
    --mgrp-star-off:    #dfe3e8;

    --mgrp-surface:     #ffffff;
    --mgrp-surface-alt: #f7f9fb;
    --mgrp-line:        #e4e8ed;
    --mgrp-text:        #1b1f23;
    --mgrp-text-dim:    #67727e;

    --mgrp-radius:      14px;
    --mgrp-shadow:      0 1px 2px rgba(16, 24, 40, 0.05),
                        0 10px 28px -14px rgba(16, 24, 40, 0.22);
    --mgrp-shadow-lift: 0 2px 4px rgba(16, 24, 40, 0.06),
                        0 16px 36px -14px rgba(16, 24, 40, 0.28);

    /* Wird vom Shortcode als Inline-Style gesetzt */
    --mgrp-columns:   3;
    --mgrp-star-size: 1.4em;

    box-sizing: border-box;
    max-width: 1200px;
    margin: 28px auto;
    padding: 0 8px;
    color: var(--mgrp-text);
    font-family: inherit;
}

.mgrp-widget-wrapper *,
.mgrp-widget-wrapper *::before,
.mgrp-widget-wrapper *::after {
    box-sizing: border-box;
}

/* ------------------------------------------------------------------ */
/* Sterne (Inline-SVG)                                                 */
/* ------------------------------------------------------------------ */
.mgrp-stars {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    line-height: 1;
}

.mgrp-stars svg {
    width: 1em;
    height: 1em;
    display: block;
    flex-shrink: 0;
}

.mgrp-stars .mgrp-star-on   { color: var(--mgrp-star); }
.mgrp-stars .mgrp-star-half { color: var(--mgrp-star); }
.mgrp-stars .mgrp-star-off  { color: var(--mgrp-star-off); }

/* ------------------------------------------------------------------ */
/* Kopfzeile: Gesamtbewertung                                          */
/* ------------------------------------------------------------------ */
.mgrp-summary {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding: 16px 22px;
    margin-bottom: 22px;
    background: var(--mgrp-surface);
    border: 1px solid var(--mgrp-line);
    border-radius: var(--mgrp-radius);
    box-shadow: var(--mgrp-shadow);
}

.mgrp-summary__brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.mgrp-summary__logo {
    width: 20px;
    height: 20px;
    object-fit: contain;
    display: block;
}

.mgrp-summary__label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--mgrp-text);
    white-space: nowrap;
}

/* Die grosse Zahl ist der Blickfang. Tabellenziffern, damit sie ruhig steht. */
.mgrp-summary__value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    color: var(--mgrp-text);
}

.mgrp-summary__stars {
    font-size: 1.15rem;
}

.mgrp-summary__count {
    font-size: 0.9rem;
    color: var(--mgrp-text-dim);
    white-space: nowrap;
}

/* ------------------------------------------------------------------ */
/* Slider-Rahmen (traegt Pfeile und Punkte)                            */
/* ------------------------------------------------------------------ */
.mgrp-slider {
    position: relative;
    padding: 0 0 34px;
}

.mgrp-reviews-container {
    width: 100%;
    overflow: hidden;
    /* Etwas Luft, damit der Karten-Schatten nicht abgeschnitten wird */
    padding: 6px 4px 10px;
    margin: -6px -4px -10px;
}

.mgrp-reviews-container .swiper-wrapper {
    align-items: stretch;
}

/* Swiper setzt .swiper-slide { height: 100% }. Eine Prozenthoehe ist keine
   auto-Hoehe — und nur bei auto greift align-items: stretch. Ohne diese Regel
   bleibt jede Karte auf ihrer Eigenhoehe, und die mit dem laengsten Text ragt
   heraus.
   Der Konter laeuft bewusst ueber SPEZIFITAET (0,2,0 gegen Swipers 0,1,0),
   nicht ueber die Ladereihenfolge: Divi und Caching-Plugins fassen Stylesheets
   zusammen und koennen die Reihenfolge drehen. Dann gewaenne Swiper wieder. */
.mgrp-reviews-container .swiper-slide {
    height: auto;
}

/* ------------------------------------------------------------------ */
/* Bewertungskarte                                                     */
/* ------------------------------------------------------------------ */
.mgrp-review-item {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 22px;
    background: var(--mgrp-surface);
    border: 1px solid var(--mgrp-line);
    border-radius: var(--mgrp-radius);
    box-shadow: var(--mgrp-shadow);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.mgrp-review-item:hover {
    box-shadow: var(--mgrp-shadow-lift);
    transform: translateY(-2px);
}

/* Kopf: Bild + Name + Datum */
.mgrp-review-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.mgrp-reviewer-photo-wrapper {
    position: relative;
    width: 46px;
    height: 46px;
    flex-shrink: 0;
}

.mgrp-reviewer-photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    /* Divi setzt img{max-width:100%} plus eigene Rahmen — hier gegenhalten */
    border: none !important;
    padding: 0 !important;
}

/* Das kleine Google-G unten rechts am Bild */
.mgrp-google-badge {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--mgrp-surface);
    background-image: url("../images/google-g-logo.png");
    background-size: 68%;
    background-repeat: no-repeat;
    background-position: center;
    border: 1px solid var(--mgrp-line);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.18);
}

.mgrp-author-info {
    min-width: 0;
    flex: 1;
}

.mgrp-reviewer-name {
    display: block;
    font-weight: 650;
    font-size: 0.98rem;
    line-height: 1.3;
    color: var(--mgrp-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mgrp-review-date {
    display: block;
    font-size: 0.8rem;
    color: var(--mgrp-text-dim);
    margin-top: 2px;
}

/* Sterne der Einzelbewertung */
.mgrp-review-stars-row {
    margin-bottom: 12px;
    font-size: var(--mgrp-star-size);
}

/* Text */
.mgrp-review-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--mgrp-text);
    /* Divi setzt p{padding-bottom:1em} — das reisst die Karte auseinander */
    margin: 0 !important;
    padding: 0 !important;
    flex-grow: 1;
}

.mgrp-review-text-full {
    display: none;
}

.mgrp-review-text.is-expanded .mgrp-review-text-short { display: none; }
.mgrp-review-text.is-expanded .mgrp-review-text-full  { display: inline; }

/* Weiterlesen / weniger anzeigen */
.mgrp-toggle {
    display: inline;
    margin-left: 4px;
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--mgrp-accent);
    cursor: pointer;
    text-decoration: none;
}

.mgrp-toggle:hover {
    text-decoration: underline;
}

.mgrp-toggle:focus-visible {
    outline: 2px solid var(--mgrp-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.mgrp-review-text.is-expanded .mgrp-toggle--more,
.mgrp-review-text:not(.is-expanded) .mgrp-toggle--less {
    display: none;
}

/* ------------------------------------------------------------------ */
/* Pfeile                                                              */
/* ------------------------------------------------------------------ */
.mgrp-nav {
    position: absolute;
    top: calc(50% - 17px);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--mgrp-line);
    border-radius: 50%;
    background: var(--mgrp-surface);
    color: var(--mgrp-text);
    box-shadow: 0 2px 10px rgba(16, 24, 40, 0.14);
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.15s ease, opacity 0.2s ease;
}

.mgrp-nav svg {
    width: 16px;
    height: 16px;
    display: block;
}

.mgrp-nav:hover {
    box-shadow: 0 4px 16px rgba(16, 24, 40, 0.22);
    transform: scale(1.07);
}

.mgrp-nav:focus-visible {
    outline: 3px solid var(--mgrp-accent);
    outline-offset: 2px;
}

.mgrp-nav--prev { left: -6px; }
.mgrp-nav--next { right: -6px; }

/* Swiper setzt diese Klasse am Ende bzw. Anfang, wenn kein Loop laeuft */
.mgrp-nav.swiper-button-disabled {
    opacity: 0;
    pointer-events: none;
}

/* Wenn alles auf einen Blick passt, braucht es keine Pfeile */
.mgrp-nav.swiper-button-lock {
    display: none;
}

/* ------------------------------------------------------------------ */
/* Punkte                                                              */
/* ------------------------------------------------------------------ */
.mgrp-pagination {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.mgrp-pagination .swiper-pagination-bullet {
    width: 8px;
    height: 8px;
    margin: 0;
    border-radius: 999px;
    background: #c8cfd7;
    opacity: 1;
    transition: width 0.28s ease, background-color 0.28s ease;
}

.mgrp-pagination .swiper-pagination-bullet-active {
    width: 22px;
    background: var(--mgrp-accent);
}

.mgrp-pagination.swiper-pagination-lock {
    display: none;
}

/* ------------------------------------------------------------------ */
/* Bewertung schreiben                                                 */
/* ------------------------------------------------------------------ */
.mgrp-write-review {
    text-align: center;
    margin-top: 22px;
}

.mgrp-write-review a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 999px;
    background: var(--mgrp-accent);
    /* Divi faerbt Links per Theme-Option um — hier muss die Farbe halten */
    color: #fff !important;
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.12s ease;
}

.mgrp-write-review a:hover {
    background: var(--mgrp-accent-dark);
    color: #fff !important;
}

.mgrp-write-review a:active {
    transform: translateY(1px);
}

.mgrp-write-review a:focus-visible {
    outline: 3px solid var(--mgrp-accent);
    outline-offset: 3px;
}

/* ------------------------------------------------------------------ */
/* Leerer Zustand                                                      */
/* ------------------------------------------------------------------ */
.mgrp-empty {
    padding: 28px;
    text-align: center;
    color: var(--mgrp-text-dim);
    background: var(--mgrp-surface-alt);
    border: 1px dashed var(--mgrp-line);
    border-radius: var(--mgrp-radius);
}

/* ------------------------------------------------------------------ */
/* Debug-Kasten (nur Admins)                                           */
/* ------------------------------------------------------------------ */
.mgrp-debug {
    margin: 16px 0;
    padding: 14px 16px;
    border: 1px solid #f0c36d;
    border-left: 4px solid #e8912d;
    border-radius: 8px;
    background: #fdf6e7;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    color: #5c4813;
}

.mgrp-debug strong { color: #3d2f08; }
.mgrp-debug__error { color: #a8321e; display: block; margin: 8px 0; }

/* ------------------------------------------------------------------ */
/* Schmale Fenster                                                     */
/* ------------------------------------------------------------------ */
@media (max-width: 782px) {
    .mgrp-summary {
        gap: 8px 12px;
        padding: 14px 16px;
    }
    .mgrp-summary__value { font-size: 1.7rem; }
    .mgrp-summary__label { font-size: 0.9rem; }
}

@media (max-width: 600px) {
    .mgrp-widget-wrapper { padding: 0 4px; margin: 20px auto; }

    /* Auf dem Handy wird gewischt — Pfeile waeren nur im Weg. */
    .mgrp-nav { display: none; }

    .mgrp-review-item { padding: 18px; }
    .mgrp-review-text { font-size: 0.92rem; }
}

/* ------------------------------------------------------------------ */
/* Bewegung reduzieren                                                 */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .mgrp-review-item,
    .mgrp-nav,
    .mgrp-pagination .swiper-pagination-bullet,
    .mgrp-write-review a {
        transition: none;
    }
    .mgrp-review-item:hover {
        transform: none;
    }
}
