/* Election statistics band (Dashboard module, Mvc/Views/Dashboard/List.DashboardNoIcons.cshtml).
   Sits between the Election Hero and the quick-links band and shares their look:
   Inter type, the same fixed flag photo under a slate tint, glass tiles like the
   quick links. Header row (name + updated time) above a grid of stat tiles. */

.dc-stats {
    position: relative;
    margin: 0;
    padding: 2.25rem 0 3rem; /* below lg the hero photo ends here, so give the heading room */
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #fff;
    background-color: #0b1220;
    background-image: url("/voterinsight/backgrounds/voterinsight-bck5.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Same tint the quick-links band uses so the three sections read as one surface */
.dc-stats::before {
    content: "";
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: linear-gradient(180deg, rgba(11, 18, 32, .30) 0%, rgba(11, 18, 32, .22) 100%);
    pointer-events: none;
}

.dc-stats > .container {
    position: relative;
    z-index: 1;
}

/* ---------- Header row ---------- */
.dc-stats__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: .5rem 1.5rem;
    margin: 0 0 1.1rem;
    padding: 0 .25rem;
    animation: dcStatsRise .7s ease-out .3s both;
}

.dc-stats__eyebrow {
    margin: 0 0 .3rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: #bfdbfe;
}

.dc-stats__title {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.01em;
    text-transform: none;
    color: #fff;
}

.dc-stats__meta {
    margin: 0;
    font-size: .82rem;
    color: rgba(255, 255, 255, .65);
    white-space: nowrap;
}

.dc-stats__meta em {
    margin-right: .4rem;
    color: #93c5fd;
}

/* ---------- Tile grid ---------- */
.dc-stats__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .85rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.dc-stat {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 9.5rem;
    padding: 1.25rem .9rem 1.15rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .18);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform .25s ease, background .25s ease, border-color .25s ease, box-shadow .25s ease;
    animation: dcStatsRise .7s ease-out both;
}

/* Stagger the tiles in after the header */
.dc-stat:nth-child(1) { animation-delay: .40s; }
.dc-stat:nth-child(2) { animation-delay: .48s; }
.dc-stat:nth-child(3) { animation-delay: .56s; }
.dc-stat:nth-child(4) { animation-delay: .64s; }
.dc-stat:nth-child(5) { animation-delay: .72s; }
.dc-stat:nth-child(6) { animation-delay: .80s; }
.dc-stat:nth-child(n+7) { animation-delay: .88s; }

.dc-stat:hover {
    transform: translateY(-.25rem);
    background: rgba(255, 255, 255, .13);
    border-color: rgba(147, 197, 253, .55);
    box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
}

/* Icon chip, same recipe as the quick-link tiles */
.dc-stat__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.6rem;
    height: 2.6rem;
    margin-bottom: .8rem;
    border-radius: .7rem;
    font-size: 1rem;
    color: #bfdbfe;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .2);
    transition: background .25s ease, color .25s ease, border-color .25s ease;
}

.dc-stat:hover .dc-stat__icon {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.dc-stat__value {
    display: block;
    font-size: 1.9rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -.02em;
    color: #fff;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

.dc-stat__label {
    display: block;
    margin-top: .5rem;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #bfdbfe;
}

/* Help control: a real button so it is keyboard reachable; the popover carries the description */
.dc-stat__help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3rem;
    height: 1.3rem;
    margin-left: .3rem;
    padding: 0;
    vertical-align: -.3em;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 50%;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: .65rem;
    line-height: 1;
    cursor: help;
    transition: background .2s ease, border-color .2s ease;
}

.dc-stat__help:hover,
.dc-stat__help:focus {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    outline: none;
}

.dc-stat__help:focus-visible {
    box-shadow: 0 0 0 3px rgba(147, 197, 253, .45);
}

/* Popover: dark glass card to match, instead of Bootstrap's white default */
.dc-stat-popover {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    max-width: 18rem;
    font-size: .85rem;
    background: rgba(15, 23, 42, .96);
    border: 1px solid rgba(147, 197, 253, .35);
    border-radius: .75rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
    color: #e2e8f0;
}

.dc-stat-popover .popover-header {
    padding: .6rem .9rem .45rem;
    background: transparent;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #bfdbfe;
}

.dc-stat-popover .popover-body {
    padding: .6rem .9rem .75rem;
    color: #e2e8f0;
    line-height: 1.5;
}

.dc-stat-popover .popover-body p:last-child { margin-bottom: 0; }

.dc-stat-popover.bs-popover-top > .arrow::before,
.dc-stat-popover.bs-popover-auto[x-placement^="top"] > .arrow::before { border-top-color: rgba(147, 197, 253, .35); }
.dc-stat-popover.bs-popover-top > .arrow::after,
.dc-stat-popover.bs-popover-auto[x-placement^="top"] > .arrow::after { border-top-color: rgba(15, 23, 42, .96); }
.dc-stat-popover.bs-popover-bottom > .arrow::before,
.dc-stat-popover.bs-popover-auto[x-placement^="bottom"] > .arrow::before { border-bottom-color: rgba(147, 197, 253, .35); }
.dc-stat-popover.bs-popover-bottom > .arrow::after,
.dc-stat-popover.bs-popover-auto[x-placement^="bottom"] > .arrow::after { border-bottom-color: rgba(15, 23, 42, .96); }

/* ---------- Columns by stat count (class set server-side: dc-stats__grid--N) ---------- */
@media (min-width: 768px) {
    .dc-stats__grid { gap: 1rem; }
    .dc-stats__grid--1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .dc-stats__grid--2,
    .dc-stats__grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dc-stats__grid--3,
    .dc-stats__grid--5,
    .dc-stats__grid--6,
    .dc-stats__grid--9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dc-stats__grid--7,
    .dc-stats__grid--8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (min-width: 992px) {
    .dc-stats { padding-top: 0; }           /* the hero bottom padding carries the gap on desktop */
    .dc-stats__bar { margin-top: -1rem; }   /* sit just under the hero lead */
    .dc-stats__grid--1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
    .dc-stats__grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dc-stats__grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dc-stats__grid--4,
    .dc-stats__grid--7,
    .dc-stats__grid--8 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .dc-stats__grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
    .dc-stats__grid--6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .dc-stats__grid--9 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

    /* Scale with the viewport so six-figure numbers never crowd a six-column row */
    .dc-stats__grid--5 .dc-stat__value,
    .dc-stats__grid--6 .dc-stat__value { font-size: clamp(1.35rem, 1.75vw, 2rem); }
    .dc-stats__grid--5 .dc-stat,
    .dc-stats__grid--6 .dc-stat { padding-left: .6rem; padding-right: .6rem; }
}

/* ---------- Motion ---------- */
@keyframes dcStatsRise {
    from { opacity: 0; transform: translateY(1.25rem); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .dc-stats__bar,
    .dc-stat { animation: none; }
    .dc-stat:hover { transform: none; }
}

@media (max-width: 767.98px) {
    .dc-stats { background-attachment: scroll; }
    .dc-stats__bar { justify-content: center; text-align: center; }
}
