/* Stats — three headline figures at the top of the home screen, each a raised
   card with an "i" info button in the top corner. */

/* Lead row — the supporting phrase with a small, fixed-size "share" icon
   button to its right, on the same line and aligned to the right. */
.stats-lead-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--theme-space-2);
    margin-top: var(--theme-space-3);
}

.stats-lead {
    margin: 0;
    font-size: var(--theme-font-sm);
    line-height: 1.5;
    text-align: end;
    color: var(--theme-text-secondary);
}

.stats-share {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--theme-color-primary);
    border-radius: var(--theme-radius-md);
    background: transparent;
    color: var(--theme-color-primary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.stats-share:hover {
    background: var(--theme-color-primary);
    color: var(--theme-text-inverse);
    transform: translateY(-1px);
}

.stats-share:focus-visible {
    outline: 2px solid var(--theme-color-primary);
    outline-offset: 2px;
}

/* Share modal — a grid of brand buttons, each tinted with its brand color. */
.stats-share-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--theme-space-3);
}

.stats-share-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--theme-space-2);
    padding: var(--theme-space-4) var(--theme-space-2);
    border: 1px solid var(--theme-border-subtle);
    border-radius: var(--theme-radius-md);
    background: var(--theme-surface-raised);
    color: var(--theme-text-primary);
    font: inherit;
    font-size: var(--theme-font-sm);
    font-weight: var(--theme-font-weight-medium);
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.stats-share-option:hover {
    border-color: var(--stats-share-color);
    box-shadow: var(--theme-shadow-sm);
    transform: translateY(-2px);
}

.stats-share-option:focus-visible {
    outline: 2px solid var(--stats-share-color);
    outline-offset: 2px;
}

/* Icon sits in a filled circle of the brand color. */
.stats-share-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--theme-radius-full);
    background: var(--stats-share-color);
    color: #ffffff;
}

.stats-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--theme-space-3);
    list-style: none;
    margin: 0;
    padding: 0;
}

.stats-card {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--theme-space-3);
    padding: var(--theme-space-3) var(--theme-space-4);
    background: var(--theme-surface-raised);
    border: 1px solid var(--theme-border-subtle);
    border-radius: var(--theme-radius-md);
    box-shadow: var(--theme-shadow-sm);
}

.stats-card-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Info button — sits in the top corner, honoring writing direction. */
.stats-info {
    position: absolute;
    top: var(--theme-space-2);
    inset-inline-end: var(--theme-space-2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: var(--theme-radius-full);
    background: transparent;
    color: var(--theme-text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.stats-info:hover {
    background: color-mix(in srgb, var(--theme-color-primary) 12%, transparent);
    color: var(--theme-color-primary);
}

.stats-info:focus-visible {
    outline: 2px solid var(--theme-color-primary);
    outline-offset: 2px;
}

.stats-card-icon {
    display: inline-flex;
    flex-shrink: 0;
    color: var(--theme-color-primary);
}

.stats-value {
    font-size: var(--theme-font-2xl, var(--theme-font-xl));
    font-weight: var(--theme-font-weight-bold);
    line-height: 1.1;
    color: var(--theme-text-primary);
}

.stats-label {
    font-size: var(--theme-font-sm);
    font-weight: var(--theme-font-weight-medium);
    color: var(--theme-text-secondary);
}

/* Info text modal — a short, plain explanation. */
.stats-info-text {
    margin: 0;
    line-height: 1.6;
    color: var(--theme-text-primary);
}

/* Countries modal — a scrollable, single-column bulleted list. */
.stats-countries {
    position: relative;
}

.stats-countries-list {
    max-height: 62vh;
    overflow-y: auto;
    margin: 0;
    padding-inline-start: var(--theme-space-5);
    padding-inline-end: var(--theme-space-2);
}

.stats-countries-item {
    margin-bottom: var(--theme-space-2);
    color: var(--theme-text-primary);
}

/* Scroll-down hint — a fading bar with a bouncing chevron, shown only while
   there is more of the list to scroll into view. */
.stats-countries-scroll {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 48px;
    padding-bottom: var(--theme-space-1);
    color: var(--theme-color-primary);
    background: linear-gradient(to top,
        var(--theme-surface-raised) 0%,
        color-mix(in srgb, var(--theme-surface-raised) 55%, transparent) 55%,
        transparent 100%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.stats-countries--scrollable .stats-countries-scroll {
    opacity: 1;
}

.stats-countries--scrollable .stats-countries-scroll svg {
    animation: stats-countries-bounce 1.4s ease-in-out infinite;
}

@keyframes stats-countries-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(4px); }
}

@media (max-width: 640px) {
    /* Keep the three cards on a single row even on narrow screens: tighten the
       gap and stack each card's icon above its text so they fit. */
    .stats-cards {
        gap: var(--theme-space-2);
    }

    .stats-card {
        flex-direction: column;
        align-items: center;
        gap: var(--theme-space-1);
        padding: var(--theme-space-3) var(--theme-space-2);
        text-align: center;
    }

    .stats-card-text {
        align-items: center;
    }
}
