/* ── Connections Game Stats  v1.2.0 ── */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;900&display=swap');

/* ═══════════════════════════════════════════════════════════════════
   SHARED TOKENS
═══════════════════════════════════════════════════════════════════ */
:root {
    --cgs-font:    'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    --cgs-text:    #1a1a1a;
    --cgs-muted:   #666;
    --cgs-border:  #e0e0e0;
    --cgs-bg:      #F9F9F9;
    --cgs-card:    #ffffff;
    --cgs-bar:     #1a1a1a;
    --cgs-bar-best:#5a8a00;
    --cgs-radius:  10px;
}

/* ═══════════════════════════════════════════════════════════════════
   RESULT SCREEN — two-button row + stats button
═══════════════════════════════════════════════════════════════════ */
.cg-result-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
/* Stats trigger button inside the game result */
.cg-stats-btn {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    padding: 13px 24px;
    border-radius: 100px;
    border: 2px solid #1a1a1a;
    background: transparent;
    color: #1a1a1a;
    cursor: pointer;
    transition: background .15s, color .15s;
    line-height: 1.4;
    letter-spacing: 0;
}
.cg-stats-btn:hover { background: #1a1a1a; color: #fff; }

/* ═══════════════════════════════════════════════════════════════════
   PERSONAL STATS MODAL  (Option A)
═══════════════════════════════════════════════════════════════════ */
#cg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
    animation: cgs-fade-in .2s ease;
}

#cg-modal {
    background: var(--cgs-card);
    border-radius: var(--cgs-radius);
    padding: 28px 24px 24px;
    max-width: 400px;
    width: 100%;
    position: relative;
    direction: rtl;
    font-family: var(--cgs-font);
    animation: cgs-slide-up .25s cubic-bezier(.18,.89,.32,1.2);
    max-height: 90vh;
    overflow-y: auto;
}

#cg-modal-close {
    position: absolute;
    top: 14px;
    left: 14px;        /* left in RTL = logical end */
    background: none;
    border: none;
    font-size: 18px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background .15s;
}
#cg-modal-close:hover { background: #eee; color: #333; }

#cg-modal h3 {
    margin: 0 0 20px;
    font-size: 20px;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0;
    color: var(--cgs-text);
}
#cg-modal h4 {
    font-size: 14px;
    font-weight: 700;
    text-align: center;
    margin: 18px 0 12px;
    color: var(--cgs-text);
    letter-spacing: 0;
    text-transform: none;
}

/* 4-cell stat grid */
.cg-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}
.cg-stat-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.cg-stat-num {
    font-size: 28px;
    font-weight: 900;
    line-height: 1.1;
    color: var(--cgs-text);
}
.cg-stat-lbl {
    font-size: 11px;
    color: var(--cgs-muted);
    text-align: center;
    line-height: 1.3;
}

/* Distribution bars (modal) */
.cg-distribution { display: flex; flex-direction: column; gap: 5px; }

.cg-dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cg-dist-label {
    font-size: 13px;
    font-weight: 700;
    min-width: 18px;
    text-align: center;
    color: var(--cgs-text);
}
.cg-dist-bar-wrap {
    flex: 1;
    background: #efefef;
    border-radius: 4px;
    overflow: hidden;
    height: 26px;
}
.cg-dist-bar {
    height: 100%;
    background: var(--cgs-bar);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-left: 8px;       /* LTR inner — number sits at bar end */
    min-width: 26px;
    transition: width .4s ease;
}
.cg-dist-bar.best { background: var(--cgs-bar-best); }
.cg-dist-bar span {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   COMMUNITY STATS WIDGET  (Option C — [connections_stats] shortcode)
═══════════════════════════════════════════════════════════════════ */
#cg-stats-root {
    font-family: var(--cgs-font);
    max-width: 500px;
    margin: 0 auto;
    padding: 8px;
    direction: rtl;
    -webkit-font-smoothing: antialiased;
}

.cgs-loading, .cgs-error, .cgs-empty {
    text-align: center;
    padding: 32px 20px;
    color: var(--cgs-muted);
    font-size: 14px;
    line-height: 1.7;
}
.cgs-error { color: #b32d2e; }

.cgs-wrap {
    background: var(--cgs-card);
    border: 1px solid var(--cgs-border);
    border-radius: var(--cgs-radius);
    padding: 24px 20px;
    color: var(--cgs-text);
}

.cgs-title {
    font-size: 18px;
    font-weight: 900;
    text-align: center;
    margin: 0 0 20px;
    letter-spacing: 0;
    color: var(--cgs-text);
}

/* Top 3 numbers */
.cgs-top-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--cgs-border);
}
.cgs-top-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.cgs-top-num {
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
    color: var(--cgs-text);
}
.cgs-top-lbl {
    font-size: 12px;
    color: var(--cgs-muted);
    text-align: center;
    line-height: 1.4;
}

/* Section */
.cgs-section { margin-bottom: 20px; }
.cgs-section h4 {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 10px;
    text-align: right;
    letter-spacing: 0;
    text-transform: none;
    color: var(--cgs-text);
}

/* Distribution (community widget) */
.cgs-distribution { display: flex; flex-direction: column; gap: 5px; }
.cgs-dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cgs-dist-label {
    font-size: 13px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
    color: var(--cgs-text);
    flex-shrink: 0;
}
.cgs-dist-bar-wrap {
    flex: 1;
    background: #efefef;
    border-radius: 4px;
    overflow: hidden;
    height: 26px;
}
.cgs-dist-bar {
    height: 100%;
    background: #1a1a1a;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 8px;
    min-width: 26px;
    transition: width .6s ease;
    animation: cgs-grow .6s ease both;
}
.cgs-dist-bar.best { background: var(--cgs-bar-best); }
.cgs-dist-bar span {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

/* Category solve rate */
.cgs-categories { display: flex; flex-direction: column; gap: 8px; }
.cgs-cat-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cgs-cat-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}
.cgs-cat-bar-wrap {
    flex: 1;
    background: #efefef;
    border-radius: 4px;
    height: 20px;
    overflow: hidden;
}
.cgs-cat-bar {
    height: 100%;
    border-radius: 4px;
    min-width: 4px;
    transition: width .6s ease;
    animation: cgs-grow .7s ease both;
    opacity: .85;
}
.cgs-cat-pct {
    font-size: 13px;
    font-weight: 700;
    min-width: 36px;
    text-align: left;
    color: var(--cgs-muted);
    flex-shrink: 0;
}

/* ── Keyframes ────────────────────────────────────────────────── */
@keyframes cgs-fade-in  { from{opacity:0} to{opacity:1} }
@keyframes cgs-slide-up { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }
@keyframes cgs-grow     { from{width:0!important} to{} }

/* Responsive */
@media (max-width: 380px) {
    .cg-stat-num  { font-size: 22px; }
    .cgs-top-num  { font-size: 26px; }
    .cgs-cat-name { min-width: 70px; font-size: 11px; }
    #cg-modal     { padding: 22px 16px 18px; }
}
