/* =========================================================
   Bento Stats Widget — Front-end Styles (mobile-first)
   ========================================================= */

/* ─── CSS Custom Properties (brand: primary #00358b, accent #B1833C; light gray blocks on light bg) ─── */
.bsw-section {
    --bsw-primary: #00358b;
    --bsw-primary-90: rgba(0, 53, 139, 0.9);
    --bsw-primary-70: rgba(0, 53, 139, 0.7);
    --bsw-primary-55: rgba(0, 53, 139, 0.55);
    --bsw-primary-40: rgba(0, 53, 139, 0.4);
    --bsw-primary-28: rgba(0, 53, 139, 0.28);
    --bsw-primary-20: rgba(0, 53, 139, 0.2);
    --bsw-primary-12: rgba(0, 53, 139, 0.12);
    --bsw-primary-08: rgba(0, 53, 139, 0.08);
    --bsw-accent: #b1833c;
    --bsw-accent-15: rgba(177, 131, 60, 0.15);
    --bsw-accent-08: rgba(177, 131, 60, 0.08);
    --bsw-white: #ffffff;

    /* Very light gray block surfaces (on white/light page background) */
    --bsw-bg: #ffffff;
    --bsw-surface: #f0f2f5;
    --bsw-surface-raised: #e8eaef;
    --bsw-border: var(--bsw-primary-20);
    --bsw-border-bright: var(--bsw-primary-28);
    /* Text: very dark gray for contrast on light background */
    --bsw-text-primary: #1a1a1a;
    --bsw-text-secondary: #4a4a4a;
    --bsw-text-muted: #6b6b6b;
    --bsw-radius: 20px;
    --bsw-gap: 10px;

    background: #ffffff;
    padding: 16px;
    color: var(--bsw-text-primary);
    box-sizing: border-box;
}

.bsw-section *,
.bsw-section *::before,
.bsw-section *::after {
    box-sizing: border-box;
}

/* ─── Section Label ─────────────────────────────────── */
.bsw-section-label {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bsw-text-muted);
    margin: 0 0 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.bsw-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--bsw-border);
}

/* ─── Grid ──────────────────────────────────────────── */
.bsw-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--bsw-gap);
    align-items: start;
}

/* Column spans: mobile-first, full width by default */
.col-2,
.col-3,
.col-4,
.col-5,
.col-6,
.col-7,
.col-8,
.col-12 {
    grid-column: span 12;
}

/* ─── Base Card (always very light gray on light background) ─── */
.bsw-card {
    background: var(--bsw-surface);
    border: 1px solid var(--bsw-border);
    color: var(--bsw-text-primary);
    border-radius: var(--bsw-radius);
    align-self: stretch;
    padding: 18px;
    position: relative;
    overflow: hidden;
    transition:
        border-color 0.3s ease,
        transform 0.3s ease;
    animation: bsw-fadeUp 0.55s cubic-bezier(0.23, 1, 0.32, 1) both;
}

.bsw-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
    border-radius: var(--bsw-radius);
    pointer-events: none;
    opacity: 0.08;
}

.bsw-card:hover {
    border-color: var(--bsw-border-bright);
    transform: translateY(-3px);
}

@keyframes bsw-fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─── Hero Card ─────────────────────────────────────── */
.bsw-card--hero {
    min-height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bsw-surface-raised);
}

/* ─── Medium Card ───────────────────────────────────── */
.bsw-card--medium {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* ─── Sparkline Card ────────────────────────────────── */
.bsw-card--sparkline {
    min-height: 190px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.bsw-spark-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.bsw-sparkline-wrap {
    height: 80px;
    margin: 0 -18px -18px;
    opacity: 0.65;
}

.bsw-sparkline-wrap svg {
    width: 100%;
    height: 100%;
    color: currentColor; /* inherited from inline style on card */
    display: block;
}

/* ─── Progress Card ─────────────────────────────────── */
.bsw-card--progress {
    min-height: 200px;
}

.bsw-progress-bars {
    display: flex;
    flex-direction: column;
    gap: 13px;
    margin-top: 20px;
}

.bsw-progress-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.bsw-progress-row-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--bsw-text-secondary);
}

.bsw-progress-track {
    height: 4px;
    background: var(--bsw-primary-08);
    border-radius: 2px;
    overflow: hidden;
}

.bsw-progress-fill {
    height: 100%;
    border-radius: 2px;
    transform-origin: left;
    transform: scaleX(0);
    animation: bsw-growBar 1.1s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

@keyframes bsw-growBar {
    to {
        transform: scaleX(1);
    }
}

/* ─── Small Card ────────────────────────────────────── */
.bsw-card--small {
    padding: 20px 22px;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* ─── Strip Card (mobile: stacked) ───────────────────── */
.bsw-card--strip {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 20px 18px;
    min-height: 88px;
    flex-wrap: wrap;
}

.bsw-strip-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    padding: 10px 0;
    border-right: none;
    border-bottom: 1px solid var(--bsw-border);
    min-width: 0;
}

.bsw-strip-item:first-child {
    padding-left: 0;
}
.bsw-strip-item--last,
.bsw-strip-item:last-child {
    border-bottom: none;
    padding-right: 0;
}

/* ─── Typography ────────────────────────────────────── */
.bsw-eyebrow {
    font-size: 10px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0.8;
    margin: 0 0 6px;
    line-height: 1.3;
}

.bsw-number,
p.bsw-number {
    line-height: 0.9;
    margin: 0;
}

.bsw-number--hero {
    font-size: 56px;
}
.bsw-number--medium {
    font-size: clamp(40px, 5vw, 58px);
}
.bsw-number--small {
    font-size: clamp(28px, 3.5vw, 40px);
    line-height: 1;
}
.bsw-number--strip {
    font-size: clamp(22px, 2.5vw, 30px);
    line-height: 1;
}

.bsw-unit {
    font-size: 0.45em;
    vertical-align: top;
    margin-top: 0.12em;
    display: inline-block;
}

.bsw-description {
    font-size: 12px;
    font-weight: 300;
    color: var(--bsw-text-secondary);
    line-height: 1.5;
    margin: 0;
    max-width: 220px;
}

.bsw-description--small {
    font-size: 11px;
    color: var(--bsw-text-muted);
}

.bsw-sublabel {
    font-size: 11px;
    color: var(--bsw-text-muted);
    letter-spacing: 0.04em;
    margin: 0;
}

.bsw-strip-label {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bsw-text-muted);
}

/* ─── Card Footer ───────────────────────────────────── */
.bsw-card-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* ─── Trend Badge ───────────────────────────────────── */
.bsw-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 100px;
    white-space: nowrap;
    flex-shrink: 0;
}

.bsw-badge--up {
    background: var(--bsw-primary);
    color: var(--bsw-white);
}
.bsw-badge--down {
    background: var(--bsw-accent-08);
    color: var(--bsw-accent);
}

/* ─── Responsive (mobile-first: min-width) ──────────── */

/* Tablet: 541px and up */
@media (min-width: 541px) {
    .bsw-section {
        padding: 24px;
        --bsw-gap: 14px;
    }

    .bsw-card {
        padding: 28px;
    }

    .col-3 {
        grid-column: span 6;
    }

    .bsw-card--strip {
        flex-direction: row;
        align-items: center;
        padding: 20px 28px;
    }

    .bsw-strip-item {
        border-right: 1px solid var(--bsw-border);
        border-bottom: none;
        width: auto;
        min-width: 100px;
        padding: 8px 20px;
    }

    .bsw-strip-item--last,
    .bsw-strip-item:last-child {
        border-right: none;
        border-bottom: none;
        padding-right: 0;
    }

    .bsw-sparkline-wrap {
        margin: 0 -28px -28px;
    }

    .bsw-number--hero {
        font-size: clamp(64px, 8vw, 100px);
    }

    .bsw-card--sparkline,
    .bsw-card--medium {
        align-self: stretch;
    }
}

/* Desktop: 901px and up */
@media (min-width: 901px) {
    .bsw-section {
        padding: 40px;
    }

    .col-2 {
        grid-column: span 2;
    }
    .col-3 {
        grid-column: span 3;
    }
    .col-4 {
        grid-column: span 4;
    }
    .col-5 {
        grid-column: span 5;
    }
    .col-6 {
        grid-column: span 6;
    }
    .col-7 {
        grid-column: span 7;
    }
    .col-8 {
        grid-column: span 8;
    }
    .col-12 {
        grid-column: span 12;
    }
}
