/* =========================================================
   Review Ratings Widget v2 — Front-End Styles
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&display=swap');

/* ── Variables ─────────────────────────────────────────── */
.rrw-wrapper {
    --rrw-font:         'DM Sans', system-ui, -apple-system, sans-serif;
    --rrw-star:         #F4B400;
    --rrw-star-empty:   #E0E0E0;
    --rrw-radius:       14px;
    --rrw-surface:      #F8F9FC;
    --rrw-border:       rgba(0,0,0,0.07);
    --rrw-shadow:       0 2px 16px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
    --rrw-shadow-hover: 0 8px 32px rgba(0,0,0,0.13), 0 2px 6px rgba(0,0,0,0.05);
    --rrw-text-primary:   #0F1117;
    --rrw-text-secondary: #6B7280;
    --rrw-ease:         cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--rrw-font);
    width: 100%;
    box-sizing: border-box;
}

/* ── Dark Theme ────────────────────────────────────────── */
.rrw-wrapper.rrw-theme--dark {
    --rrw-surface:        #1C1F2A;
    --rrw-border:         rgba(255,255,255,0.08);
    --rrw-shadow:         0 4px 24px rgba(0,0,0,0.4), 0 1px 4px rgba(0,0,0,0.3);
    --rrw-shadow-hover:   0 12px 40px rgba(0,0,0,0.5);
    --rrw-text-primary:   #F9FAFB;
    --rrw-text-secondary: #9CA3AF;
    --rrw-star-empty:     rgba(255,255,255,0.15);
}

/* ── Tagline ───────────────────────────────────────────── */
.rrw-tagline {
    font-family: var(--rrw-font);
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--rrw-text-secondary);
    margin: 0 0 14px;
}

/* ── Cards outer (handles mobile scroll) ──────────────── */
.rrw-cards-outer {
    width: 100%;
}

/* ── Cards container ───────────────────────────────────── */
.rrw-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.rrw-layout--side-by-side .rrw-cards { flex-direction: row; }
.rrw-layout--stacked      .rrw-cards { flex-direction: column; }
.rrw-layout--grid-2       .rrw-cards { flex-direction: row; flex-wrap: wrap; }
.rrw-layout--grid-2       .rrw-card  { flex: 1 1 calc(50% - 6px); min-width: 0; }

/* ── Card ──────────────────────────────────────────────── */
.rrw-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 200px;
    padding: 14px 18px;
    background: var(--rrw-surface);
    border: 1px solid var(--rrw-border);
    border-radius: var(--rrw-radius);
    box-shadow: var(--rrw-shadow);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    transition: transform 0.25s var(--rrw-ease), box-shadow 0.25s ease;
    box-sizing: border-box;
    animation: rrw-fadein 0.4s ease both;
}
.rrw-card:nth-child(2) { animation-delay: 0.07s; }
.rrw-card:nth-child(3) { animation-delay: 0.14s; }
.rrw-card:nth-child(4) { animation-delay: 0.21s; }

a.rrw-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--rrw-shadow-hover);
    text-decoration: none;
}

/* ── Top colour bar ────────────────────────────────────── */
.rrw-card__topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    border-radius: var(--rrw-radius) var(--rrw-radius) 0 0;
    opacity: 0.9;
    pointer-events: none;
}

.rrw-card--google      .rrw-card__topbar { background: linear-gradient(90deg,#4285F4,#34A853,#FBBC05,#EA4335); }
.rrw-card--checkatrade .rrw-card__topbar { background: linear-gradient(90deg,#003087,#0055B8,#0081FF); }
.rrw-card--trustatrader .rrw-card__topbar { background: linear-gradient(90deg,#E8161B,#FF4B50); }
/* custom platform bar colour set inline via PHP */

/* ── Logo ──────────────────────────────────────────────── */
.rrw-card__logo {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.rrw-card__logo--google-logo {
    background: #fff;
    box-shadow: 0 1px 5px rgba(0,0,0,0.13);
    padding: 4px;
}
.rrw-card__logo svg { width: 100%; height: 100%; display: block; }

/* ── Body ──────────────────────────────────────────────── */
.rrw-card__body {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-width: 0;
}

.rrw-card__platform {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--rrw-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rrw-card__rating-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
}

.rrw-card__score {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    color: var(--rrw-text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
}
.rrw-card__score small {
    font-size: 0.65em;
    font-weight: 500;
    color: var(--rrw-text-secondary);
}

.rrw-card__count {
    font-size: 0.73rem;
    font-weight: 500;
    color: var(--rrw-text-secondary);
}

/* ── Stars ─────────────────────────────────────────────── */
.rrw-stars { display: inline-flex; align-items: center; gap: 1px; flex-shrink: 0; }
.rrw-star  { width: 13px; height: 13px; flex-shrink: 0; }
.rrw-star--full    { fill: var(--rrw-star); color: var(--rrw-star); }
.rrw-star--empty   { fill: var(--rrw-star-empty); }
.rrw-star--partial { color: var(--rrw-star); }
.rrw-star--partial polygon { stroke: none; }

/* ── Arrow ─────────────────────────────────────────────── */
.rrw-card__arrow {
    position: absolute;
    top: 12px; right: 12px;
    font-size: 0.8rem;
    color: var(--rrw-text-secondary);
    opacity: 0;
    transform: translate(-3px, 3px);
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
}
a.rrw-card:hover .rrw-card__arrow { opacity: 0.55; transform: translate(0,0); }

/* ── Animation ─────────────────────────────────────────── */
@keyframes rrw-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   MOBILE  (≤ 600px)
   ========================================================== */
@media (max-width: 600px) {

    /* ── Horizontal swipe layout ─── */
    .rrw-mobile--scroll .rrw-cards-outer {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        /* fade-out right edge hint */
        -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
        mask-image: linear-gradient(to right, black 85%, transparent 100%);
    }
    .rrw-mobile--scroll .rrw-cards-outer::-webkit-scrollbar { display: none; }

    .rrw-mobile--scroll .rrw-cards {
        flex-direction: row;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }
    .rrw-mobile--scroll .rrw-card {
        min-width: 200px;
        flex: 0 0 200px;
    }

    /* ── Stacked layout ─── */
    .rrw-mobile--stacked .rrw-cards {
        flex-direction: column;
        flex-wrap: nowrap;
    }
    .rrw-mobile--stacked .rrw-card {
        min-width: 0;
        width: 100%;
        flex: none;
    }

    /* ── 2-column grid ─── */
    .rrw-mobile--grid-2 .rrw-cards {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .rrw-mobile--grid-2 .rrw-card {
        flex: 1 1 calc(50% - 6px);
        min-width: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 12px;
    }
    .rrw-mobile--grid-2 .rrw-card__score { font-size: 1.5rem; }
    .rrw-mobile--grid-2 .rrw-card__rating-row { flex-wrap: wrap; gap: 4px; }

    /* ── Shared mobile tweaks ─── */
    .rrw-card__score { font-size: 1.7rem; }
    .rrw-tagline     { font-size: 0.68rem; margin-bottom: 10px; }
}
