/* statistics.css */

/* Shared statistics cards */
.reading-dashboard .stat-box {
    position: relative;
    height: auto;
    margin-bottom: 1.5rem;
    padding: 1.4rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid rgba(24, 21, 17, 0.08);
    border-radius: 20px;
    box-shadow: 0 16px 36px rgba(24, 21, 17, 0.07);
}

.reading-dashboard .stat-box.h-100 {
    height: 100% !important;
    margin-bottom: 0;
}

.reading-dashboard .stat-box::before {
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, #d9b15f, #77a36a 52%, #6ca7b5);
    content: "";
    opacity: 0.7;
}

.reading-dashboard .stat-box h2,
.reading-dashboard .stat-box h3 {
    margin: 0 0 1rem !important;
    color: var(--ink);
    font-size: clamp(1.18rem, 1.8vw, 1.45rem);
    font-weight: 800;
    line-height: 1.2;
}

.reading-dashboard .stat-box > .text-muted,
.reading-dashboard .stat-box > h3 + p {
    margin: -0.55rem 0 1.2rem;
    color: var(--muted) !important;
    font-size: 0.9rem;
    line-height: 1.5;
}

.reading-dashboard .stat-box .table {
    width: 100%;
    margin: 0;
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
    background: transparent;
    border: 1px solid rgba(24, 21, 17, 0.07);
    border-radius: 14px;
}

.reading-dashboard .stat-box .table > :not(caption) > * > * {
    padding: 0.78rem 0.9rem;
    background: rgba(255, 249, 233, 0.52);
    border-bottom: 1px solid rgba(24, 21, 17, 0.07);
    color: var(--ink);
    vertical-align: middle;
}

.reading-dashboard .stat-box .table > :not(caption) > *:nth-child(even) > * {
    background: rgba(240, 247, 233, 0.55);
}

.reading-dashboard .stat-box .table > :not(caption) > *:last-child > * {
    border-bottom: 0;
}

.reading-dashboard .stat-box .table th {
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.reading-dashboard .stat-box .table td:last-child,
.reading-dashboard .stat-box .table th:last-child,
.reading-dashboard .stat-box .table .text-right {
    text-align: right;
}

.reading-dashboard .stat-box .table td:last-child:not(:only-child) {
    color: var(--accent-dark);
    font-weight: 800;
    white-space: nowrap;
}

.reading-dashboard .stat-box .table a {
    color: var(--ink);
    font-weight: 700;
    text-decoration-color: rgba(66, 117, 62, 0.3);
    text-underline-offset: 0.18em;
}

.reading-dashboard .stat-box .table a:hover {
    color: var(--accent-dark);
    text-decoration-color: currentColor;
}

.reading-dashboard .stat-box canvas {
    max-width: 100%;
}

/* Personal author and series surfaces */
.reading-dashboard .series-group-card,
.reading-dashboard .reader-summary-card {
    --card-tint: rgba(240, 247, 233, 0.92);
    --card-tint-soft: rgba(255, 250, 239, 0.82);
    --card-edge: rgba(77, 121, 68, 0.24);
    --card-accent: #77a36a;
    background:
        radial-gradient(circle at 100% 0, rgba(255, 255, 255, 0.72), transparent 35%),
        linear-gradient(135deg, var(--card-tint), var(--card-tint-soft));
    border-color: var(--card-edge);
    box-shadow: 0 16px 38px color-mix(in srgb, var(--card-accent) 15%, transparent);
}

.reading-dashboard .series-group-card::before,
.reading-dashboard .reader-summary-card::before {
    height: 5px;
    background: var(--card-accent);
    opacity: 0.9;
}

.reading-dashboard .series-group-card--blue,
.reading-dashboard .reader-summary-card--series {
    --card-tint: rgba(226, 242, 248, 0.94);
    --card-tint-soft: rgba(238, 248, 244, 0.86);
    --card-edge: rgba(72, 143, 164, 0.28);
    --card-accent: #579aae;
}

.reading-dashboard .series-group-card--amber,
.reading-dashboard .reader-summary-card--unread {
    --card-tint: rgba(255, 241, 204, 0.92);
    --card-tint-soft: rgba(255, 249, 229, 0.86);
    --card-edge: rgba(190, 137, 47, 0.28);
    --card-accent: #d29c3d;
}

.reading-dashboard .series-group-card--green,
.reading-dashboard .reader-summary-card--author {
    --card-tint: rgba(226, 242, 219, 0.94);
    --card-tint-soft: rgba(243, 248, 225, 0.86);
    --card-edge: rgba(83, 135, 70, 0.27);
    --card-accent: #6f9d60;
}

.reading-dashboard .series-group-card--violet {
    --card-tint: rgba(238, 228, 247, 0.94);
    --card-tint-soft: rgba(247, 239, 246, 0.86);
    --card-edge: rgba(137, 94, 157, 0.25);
    --card-accent: #9a72ad;
}

.reading-dashboard .series-group-card--rose {
    --card-tint: rgba(249, 226, 225, 0.94);
    --card-tint-soft: rgba(251, 239, 230, 0.86);
    --card-edge: rgba(174, 91, 86, 0.26);
    --card-accent: #bd736e;
}

.reading-dashboard .series-group-card .list-group {
    gap: 0.55rem;
}

.reading-dashboard .series-group-card .series-overview-row {
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 13px;
    color: var(--ink);
    transition: transform 150ms ease, background-color 150ms ease, box-shadow 150ms ease;
}

.series-library-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1.1rem;
    color: var(--ink);
    background: linear-gradient(105deg, #e8f5fa, #f1f7e9);
    border: 1px solid #bed8d5;
    border-radius: 14px;
    text-decoration: none;
}

.series-library-link strong,
.series-library-link small {
    display: block;
}

.series-library-link small {
    margin-top: 0.15rem;
    color: var(--muted);
}

.series-library-link__action {
    flex: none;
    color: var(--accent-dark);
    font-size: 0.85rem;
    font-weight: 800;
}

.series-library-link:hover {
    color: var(--ink);
    border-color: #83b4ad;
}

@media (max-width: 575px) {
    .series-library-link {
        align-items: flex-start;
        flex-direction: column;
    }
}

.reading-dashboard .series-group-card .series-overview-row:hover {
    z-index: 1;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 18px color-mix(in srgb, var(--card-accent) 14%, transparent);
    transform: translateY(-1px);
}

.reading-dashboard .reader-summary-card .progress {
    height: 0.65rem;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.reading-dashboard .reader-summary-card .progress-bar {
    background: linear-gradient(90deg, var(--card-accent), #77a36a);
}

.reading-dashboard .reader-summary-card--author {
    color: #496148;
}

.reading-dashboard .author-summary-metric {
    padding: 1rem 1.05rem;
    background: rgba(255, 255, 255, 0.42);
    border: 1px solid rgba(83, 135, 70, 0.13);
    border-radius: 14px;
}

.reading-dashboard .author-summary-label {
    margin-bottom: 0.45rem;
    color: #73826d;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.reading-dashboard .author-summary-value {
    color: #477444;
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.2;
}

.reading-dashboard .author-summary-detail {
    color: #50634d;
    font-size: 1.05rem;
    font-weight: 650;
    line-height: 1.45;
}

.reading-dashboard .author-summary-ranking {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    color: inherit;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

.reading-dashboard .author-summary-ranking .author-summary-label,
.reading-dashboard .author-summary-ranking .author-summary-value {
    display: block;
}

.reading-dashboard .author-summary-ranking:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(45, 38, 30, 0.1);
}

.reading-dashboard .author-summary-detail > span {
    color: #78856f;
    font-weight: 600;
}

.reading-dashboard .author-summary-dates {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    column-gap: 0.65rem;
    row-gap: 0.2rem;
}

.reading-dashboard .author-summary-dates .author-summary-date-separator {
    color: #8eae80;
}

.reading-dashboard > .row + .row {
    margin-top: 0;
}

@media (max-width: 767.98px) {
    .reading-dashboard .stat-box,
    .reading-dashboard .stat-box.h-100 {
        height: auto !important;
        margin-bottom: 0;
        padding: 1.1rem;
    }

    .reading-dashboard .row.g-4 + .row.g-4 {
        margin-top: 0;
    }

    .reading-dashboard .stat-box .table > :not(caption) > * > * {
        padding: 0.7rem 0.75rem;
    }
}

.stats-overview-card {
    height: 100%;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(24, 21, 17, 0.08);
    border-radius: 20px;
    box-shadow: 0 16px 36px rgba(24, 21, 17, 0.08);
}

.stats-overview-header {
    margin-bottom: 1.25rem;
}

.stats-overview-header h2 {
    margin: 0;
    font-size: clamp(1.4rem, 2vw, 1.75rem);
}

.stats-metric-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0;
}

.stats-metric-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stats-metric-grid--four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-metric-grid--five {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.stats-metric {
    min-width: 0;
    padding: 1rem;
    background: #fff9e9;
    border: 1px solid #eadbb0;
    border-radius: 15px;
}

.stats-metric:nth-child(4n + 2) {
    background: #f0f7e9;
    border-color: #d4e2c8;
}

.stats-metric:nth-child(4n + 3) {
    background: #faf1e9;
    border-color: #e5d8cc;
}

.stats-metric:nth-child(4n + 4) {
    background: #eaf6f5;
    border-color: #c9e0de;
}

.stats-metric--wide {
    grid-column: 1 / -1;
}

.stats-metric--span-two {
    grid-column: span 2;
}

.stats-metric dt {
    margin-bottom: 0.4rem;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.3;
    text-transform: uppercase;
}

.stats-metric dd {
    margin: 0;
    color: var(--ink);
    font-family: "DM Serif Display", Georgia, serif;
    font-size: clamp(1.55rem, 3vw, 2.1rem);
    line-height: 1;
}

.stats-metric dd small {
    color: var(--muted);
    font-family: "DM Sans", "Segoe UI", sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
}

@media (max-width: 420px) {
    .stats-overview-card {
        padding: 1rem;
    }

    .stats-metric-grid {
        grid-template-columns: 1fr;
    }

    .stats-metric--wide {
        grid-column: auto;
    }

    .stats-metric--span-two {
        grid-column: auto;
    }
}

@media (min-width: 421px) and (max-width: 767.98px) {
    .stats-metric-grid--three,
    .stats-metric-grid--four,
    .stats-metric-grid--five {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .stats-metric-grid--four,
    .stats-metric-grid--five {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.stat-section-title {
    font-size: 1.5rem;
    font-weight: 600;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 0.3rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

/* Scoped grid for achievements only */
.achievement-section {
    margin-bottom: 2rem;
}

.achievement-section .achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.achievement-section .achievement-card {
    border-radius: 1rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    height: 100%;
    /*box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);*/
    transition: box-shadow 0.2s ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.achievement-section .achievement-description {
    flex-grow: 1;
    text-align: center;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.achievement-section .achievement-date {
    text-align: center;
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 1rem;
}

.stat-card {
    border-radius: 1rem;
    padding: 1.2rem;
    transition: box-shadow 0.2s ease-in-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-title {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: #495057;
}

.stat-value.emotional {
    color: #c0392b;
}

.stat-value.progress {
    color: #2e86de;
}

.stat-value.highlight {
    color: #16a085;
}

.badge-pastel, .badge-reason, .badge-impression {
    padding: 0.5em 0.75em;
    font-size: 0.85rem;
    border-radius: 0.5rem;
    font-weight: 500;
}
