/*
 * /stats: the portals in numbers. Square corners and strong rules like the rest of the site: a hero with the day's
 * figures, the last 24 hours hour by hour, who published most, a card per portal, and a side column with ads.
 */

.stats-shell {
    display: grid;
    gap: 1.5rem;
    padding-top: 1.25rem;
    padding-bottom: 1rem;
}

/* Hero: the text and, beside it, the four figures. */
.stats-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 1.5rem 2.5rem;
    align-items: end;
    padding: 1.75rem 2rem;
    background: var(--panel);
    border: 1px solid var(--news-rule);
    border-left: 6px solid var(--news-accent);
}

.stats-kicker {
    display: inline-block;
    margin: 0 0 0.75rem;
    padding: 0.2rem 0.55rem;
    color: #fff;
    background: var(--news-accent);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stats-hero h1 {
    margin: 0;
    color: var(--news-ink);
    font-size: clamp(2rem, 1.4rem + 2.2vw, 3.1rem);
    font-weight: 900;
    line-height: 1.05;
}

.stats-lead {
    max-width: 38rem;
    margin: 0.85rem 0 0;
    color: var(--news-soft-ink);
    font-size: 1.05rem;
    line-height: 1.55;
}

.stats-live {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
}

.stats-live strong {
    color: var(--news-accent);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stats-live-dot {
    width: 0.6rem;
    height: 0.6rem;
    background: var(--news-accent);
    border-radius: 50%;
    animation: stats-pulse 1.8s ease-in-out infinite;
}

@keyframes stats-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.45); }
    50% { box-shadow: 0 0 0 0.4rem rgba(180, 35, 24, 0); }
}

.stats-figures {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    border-top: 3px solid var(--news-ink);
}

.stats-figures > div {
    padding: 0.85rem 1rem 0.85rem 0;
    border-bottom: 1px solid var(--news-rule);
}

.stats-figures > div:nth-child(even) {
    padding-left: 1rem;
    border-left: 1px solid var(--news-rule);
}

.stats-figures dt,
.stats-source-figures dt {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.stats-figures dd {
    margin: 0.2rem 0 0;
    color: var(--news-ink);
    font-family: var(--news-font-head);
    font-size: clamp(1.7rem, 1.3rem + 1.2vw, 2.4rem);
    font-weight: 900;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.stats-figures > div:first-child dd,
.stats-source-figures > div:first-child dd {
    color: var(--news-accent);
}

/* The page and its side column. */
.stats-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 336px);
    gap: 1.5rem;
    align-items: start;
}

.stats-main,
.stats-aside {
    display: grid;
    gap: 1.75rem;
    min-width: 0;
}

.stats-aside {
    align-content: start;
    gap: 1rem;
}

.stats-block-title {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin: 0 0 1rem;
    padding-bottom: 0.45rem;
    color: var(--news-ink);
    font-size: 1.05rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border-bottom: 3px solid var(--news-ink);
}

.stats-block-title i {
    color: var(--news-accent);
}

/* The last 24 hours, hour by hour: one bar per clock hour, the current (unfinished) one hatched. */
.stats-chart-panel {
    padding: 1.6rem 1.25rem 0.75rem;
    background: var(--panel);
    border: 1px solid var(--news-rule);
}

.stats-chart,
.stats-chart-axis,
.stats-spark {
    display: grid;
    grid-template-columns: repeat(24, minmax(0, 1fr));
    margin: 0;
    padding: 0;
    list-style: none;
}

.stats-chart {
    align-items: end;
    gap: 4px;
    height: 12rem;
    border-bottom: 2px solid var(--news-ink);
}

.stats-chart-bar {
    position: relative;
    height: max(var(--value), 2px);
    background: #3b4453;
    transition: background-color 0.15s ease;
}

.stats-chart-bar:hover {
    background: var(--news-accent);
}

.stats-chart-bar.is-now {
    background: repeating-linear-gradient(-45deg, var(--news-accent) 0 4px, #e8a49d 4px 8px);
}

.stats-chart-count {
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    padding: 0.1rem 0.3rem;
    color: #fff;
    background: var(--news-ink);
    font-size: 0.7rem;
    font-weight: 800;
    white-space: nowrap;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.stats-chart-bar:hover .stats-chart-count {
    opacity: 1;
}

.stats-chart-axis {
    gap: 4px;
    margin-top: 0.4rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.stats-chart-axis span {
    white-space: nowrap;
}

.stats-chart-axis span:last-child {
    justify-self: end;
    color: var(--news-accent);
}

/* Who published most in the last 24 hours. */
.stats-ranking {
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--panel);
    border: 1px solid var(--news-rule);
    counter-reset: stats-rank;
}

.stats-ranking li {
    display: grid;
    grid-template-columns: 1.75rem minmax(7rem, 11rem) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--news-rule);
    counter-increment: stats-rank;
}

.stats-ranking li:last-child {
    border-bottom: 0;
}

.stats-ranking li::before {
    color: var(--muted);
    content: counter(stats-rank);
    font-family: var(--news-font-head);
    font-size: 1.1rem;
    font-weight: 900;
}

.stats-ranking li:first-child::before {
    color: var(--news-accent);
}

.stats-ranking-name {
    overflow: hidden;
    color: var(--news-ink);
    font-weight: 900;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-ranking-track {
    height: 0.85rem;
    background: var(--surface);
}

.stats-ranking-fill {
    display: block;
    width: var(--value);
    height: 100%;
    background: #3b4453;
}

.stats-ranking li:first-child .stats-ranking-fill {
    background: var(--news-accent);
}

.stats-ranking-count {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.45rem;
    font-variant-numeric: tabular-nums;
}

.stats-ranking-count strong {
    color: var(--news-ink);
    font-family: var(--news-font-head);
    font-size: 1.1rem;
    font-weight: 900;
}

.stats-ranking-count small {
    min-width: 2.75rem;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: right;
}

/* A card per portal. */
.stats-sources {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
    gap: 1rem;
}

.stats-source {
    display: grid;
    align-content: start;
    gap: 1rem;
    padding: 1.15rem;
    background: var(--panel);
    border: 1px solid var(--news-rule);
    border-top: 4px solid var(--news-ink);
}

.stats-source-head {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.stats-source-logo {
    display: inline-grid;
    flex: 0 0 auto;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    overflow: hidden;
}

.stats-source-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.stats-source-logo span {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    color: #fff;
    background: var(--news-ink);
    font-size: 1.2rem;
    font-weight: 900;
}

.stats-source-name {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
}

.stats-source-name h3 {
    margin: 0;
    color: var(--news-ink);
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.15;
}

.stats-source-name a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: fit-content;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
}

.stats-source-name a i {
    font-size: 0.68rem;
}

.stats-source-name a:hover,
.stats-source-name a:focus-visible {
    color: var(--news-accent);
    text-decoration: underline;
}

.stats-source-figures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0;
    border-top: 1px solid var(--news-rule);
    border-bottom: 1px solid var(--news-rule);
}

.stats-source-figures > div {
    min-width: 0;
    padding: 0.6rem 0.5rem 0.6rem 0;
}

.stats-source-figures > div + div {
    padding-left: 0.75rem;
    border-left: 1px solid var(--news-rule);
}

.stats-source-figures dt {
    overflow: hidden;
    font-size: 0.66rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-source-figures dd {
    margin: 0.15rem 0 0;
    color: var(--news-ink);
    font-family: var(--news-font-head);
    font-size: 1.45rem;
    font-weight: 900;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stats-spark {
    align-items: end;
    gap: 2px;
    height: 2.6rem;
    border-bottom: 1px solid var(--news-rule);
}

.stats-spark li {
    height: max(var(--value), 1px);
    background: #8a93a3;
}

.stats-spark li:last-child {
    background: var(--news-accent);
}

.stats-source-latest {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 0.75rem;
    color: inherit;
    text-decoration: none;
}

.stats-source-latest:has(> img) {
    grid-template-columns: 5.5rem minmax(0, 1fr);
}

.stats-source-latest img {
    width: 5.5rem;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: var(--surface);
}

.stats-source-latest span {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.stats-source-latest small {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.stats-source-latest strong {
    display: -webkit-box;
    overflow: hidden;
    color: var(--news-ink);
    font-family: var(--news-font-head);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.3;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.stats-source-latest:hover strong,
.stats-source-latest:focus-visible strong {
    color: var(--news-accent);
    text-decoration: underline;
}

.stats-source-empty {
    margin: 0;
    color: var(--muted);
    font-weight: 700;
}

@media (max-width: 1199.98px) {
    .stats-hero {
        grid-template-columns: minmax(0, 1fr);
        align-items: start;
    }
}

/* Tablets and phones: the side column goes under the page. */
@media (max-width: 991.98px) {
    .stats-layout {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 575.98px) {
    .stats-shell {
        gap: 1.25rem;
    }

    .stats-hero {
        padding: 1.25rem 1.1rem;
        border-left-width: 4px;
    }

    .stats-chart-panel {
        padding: 1.4rem 0.75rem 0.6rem;
    }

    .stats-chart {
        gap: 2px;
        height: 9rem;
    }

    .stats-chart-axis {
        gap: 2px;
        font-size: 0.64rem;
    }

    .stats-ranking li {
        grid-template-columns: 1.4rem minmax(0, 1fr) auto;
        gap: 0.4rem 0.75rem;
        padding: 0.7rem 0.85rem;
    }

    .stats-ranking-track {
        grid-column: 2 / -1;
        grid-row: 2;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stats-live-dot {
        animation: none;
    }
}
