/**
 * Stats Cards Section — ADGO style
 * Light theme tokens live in style.css ([data-theme='light'])
 */

.bg-background-muted {
    background-color: var(--color-background-muted);
}

/* Section — 60% of previous full-viewport height (reduced 40%) */
.cards-section {
    box-sizing: border-box;
    height: 60svh;
    min-height: min(60svh, 22rem);
    max-height: 60svh;
    padding-top: clamp(2rem, 4vw, 5rem);
    padding-bottom: clamp(2rem, 4vw, 5rem);
}

.cards-section .grid-container {
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
}

@media (max-width: 1023px) {
    .cards-section {
        height: auto;
        min-height: 0;
        max-height: none;
    }

    .cards-section .grid-layout,
    .cards-section .grid-span-12 {
        height: auto;
    }

    #cards-grid {
        height: auto;
        flex: 0 0 auto;
    }

    #cards-grid .card-item {
        min-height: 11rem;
    }

    #cards-grid .card-item:first-child {
        min-height: 14rem;
    }
}

@media (min-width: 1024px) {
    .cards-section .grid-layout {
        height: 100%;
        min-height: 0;
        grid-template-rows: 1fr;
    }

    .cards-section .grid-span-12 {
        height: 100%;
        min-height: 0;
    }

    #cards-grid {
        grid-auto-rows: 1fr;
        height: 100%;
    }

    #cards-grid .card-item {
        height: 100%;
    }
}

#cards-grid .card-item {
    opacity: 0;
    min-width: 0;
}

#cards-grid .stat-card {
    container-type: inline-size;
    container-name: stat-card;
}

#cards-grid.is-ready .card-item,
#cards-grid.is-static .card-item {
    opacity: 1;
}

/* Stat card — number top, scramble label bottom, generous inset */
.cards-section .stat-card {
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 24px;
    box-sizing: border-box;
}

@media (min-width: 1024px) {
    .cards-section .stat-card {
        gap: 20px;
        padding: 32px;
    }
}

.cards-section .stat-headline {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    min-height: 0;
    max-width: 100%;
    padding-top: 2px;
    padding-right: 0.12em;
    font-weight: 300;
    font-size: clamp(2.5rem, 1.75rem + 11cqi, 4.25rem);
    line-height: 1;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
    overflow: visible;
}

@media (min-width: 1024px) {
    .cards-section .stat-headline {
        font-size: clamp(3rem, 1.5rem + 14cqi, 4.5rem);
    }
}

.cards-section .stat-headline__value {
    display: block;
    max-width: 100%;
    overflow-wrap: anywhere;
}

/* Digit roller */
.roller-number {
    display: inline-flex;
    align-items: flex-start;
    justify-content: flex-start;
    max-width: 100%;
    overflow: visible;
    line-height: 1;
    font-size: inherit;
}

.roller-number__prefix,
.roller-number__suffix {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

.roller-number__suffix {
    padding-right: 0.06em;
}

.roller-number__strip {
    display: flex;
    flex-direction: column;
    will-change: transform;
}

.roller-number__digit-cell {
    height: 1em;
    font-variant-numeric: tabular-nums;
}

.roller-number__column {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    width: 1ch;
    height: 1em;
}

/* Brand square — desktop hover indicator (12×12px) */
.brand-square {
    position: absolute;
    top: 0.35em;
    left: 0;
    width: 12px;
    height: 12px;
    transform: scale(0) rotate(-90deg);
    transform-origin: center center;
    will-change: transform;
}

@media (max-width: 1023px) {
    .brand-square {
        display: none;
    }
}

.cards-section .label-wrapper {
    position: relative;
    width: 100%;
    flex: 0 0 auto;
    margin-top: auto;
    overflow: visible;
    padding-top: 0;
    padding-bottom: 2px;
    padding-right: 4px;
}

.cards-section .label-text {
    display: block;
    width: 100%;
    max-width: 100%;
    text-align: left;
    font-family: var(--font-ui);
    font-size: clamp(14px, 3.6cqi, 17px);
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: -0.02em;
    color: var(--color-foreground);
    text-transform: uppercase;
    overflow-wrap: anywhere;
    word-break: break-word;
    will-change: transform;
}

@media (min-width: 1024px) {
    .cards-section .label-text {
        font-size: clamp(15px, 4.2cqi, 18px);
        line-height: 1.45;
    }

    .cards-section .label-wrapper {
        padding-bottom: 4px;
        min-height: 0;
    }
}

/* Locale labels — typography tuning (font via --font-ui) */
html[lang='th'] .cards-section .label-text,
html[lang='zh-Hans'] .cards-section .label-text,
html[lang='ja'] .cards-section .label-text {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.5;
}

html[lang='ja'] .cards-section .label-text {
    line-height: 1.35;
}

@container stat-card (max-width: 180px) {
    .cards-section .stat-headline {
        font-size: clamp(2rem, 1.25rem + 8cqi, 3rem);
    }

    .cards-section .label-text {
        font-size: 12px;
    }
}

/* Label scramble — dual-layer color (brand → foreground) */
.cards-section .label-text .scramble-brand {
    color: var(--color-brand);
}

.cards-section .label-text .scramble-foreground {
    color: var(--color-foreground);
}

.cards-section .scramble-brand {
    color: var(--color-brand);
}

.cards-section .scramble-foreground {
    color: var(--color-foreground);
}

@media (prefers-reduced-motion: reduce) {
    #cards-grid .card-item {
        opacity: 1;
        transform: none !important;
    }

    .roller-number__strip {
        transform: none !important;
        will-change: auto;
    }
}

/* Card 1 — live AdGo Player preview badge */
.adgo-player-card-badge {
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 999px;
    backdrop-filter: blur(6px);
}

.adgo-player-live-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: currentColor;
    animation: adgo-player-live-pulse 1.6s ease-in-out infinite;
}

@keyframes adgo-player-live-pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.25;
    }
}
