/* statistics.css */

/* Reader Profile keeps an editorial treatment within the standard page width. */
.reader-profile {
    margin-inline: auto;
}

.reader-profile__heading {
    max-width: 720px;
    margin-bottom: 1.75rem;
}

.reader-profile__heading h1 {
    margin-bottom: 0.5rem;
    font-size: clamp(2.2rem, 5vw, 4rem);
    letter-spacing: -0.045em;
}

.reader-profile__heading > p:last-child {
    color: var(--muted);
    font-size: 1.08rem;
}

.reader-profile__section {
    padding: clamp(1.25rem, 3vw, 1.8rem);
}

.reader-profile__panel {
    --profile-accent: #78a36d;
    --profile-accent-dark: var(--accent-dark);
    --profile-border: #d4e2c8;
    position: relative;
    margin-bottom: clamp(2rem, 4vw, 3rem);
    overflow: hidden;
    border: 1px solid var(--profile-border);
    border-radius: 20px;
    box-shadow: 0 13px 30px rgba(45, 38, 30, 0.065);
}

.reader-profile__panel::before {
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: var(--profile-accent);
    content: "";
    opacity: 0.78;
}

.reader-profile__panel--authors {
    --profile-accent: #78a36d;
    --profile-accent-dark: #356b3b;
    --profile-border: #d4e2c8;
    background: linear-gradient(135deg, rgba(240, 247, 233, 0.98), rgba(255, 255, 255, 0.86));
}

.reader-profile__panel--genres {
    --profile-accent: #67a2ae;
    --profile-accent-dark: #355d66;
    --profile-border: #c9e0de;
    background: linear-gradient(135deg, rgba(234, 246, 245, 0.98), rgba(255, 255, 255, 0.86));
}

.reader-profile__panel--experience {
    --profile-accent: #c27b4a;
    --profile-accent-dark: #8b4d26;
    --profile-border: #e5d8cc;
    background: linear-gradient(135deg, rgba(250, 241, 233, 0.98), rgba(255, 255, 255, 0.88));
}

.reader-profile__section h2 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(1.45rem, 3vw, 2rem);
}

.reader-profile__summary {
    display: flex;
    flex-wrap: wrap;
    width: fit-content;
    margin: -0.4rem 0 clamp(2rem, 4vw, 3rem);
    overflow: hidden;
    color: var(--ink);
    font-size: 0.9rem;
    font-weight: 700;
    background: linear-gradient(105deg, #fff4d8, #eef6e7 55%, #e5f3f2);
    border: 1px solid #c9e0de;
    border-radius: 999px;
    box-shadow: 0 6px 16px rgba(45, 38, 30, 0.05);
}

.reader-profile__summary span {
    padding: 0.55rem 0.85rem;
}

.reader-profile__summary span + span {
    border-left: 1px solid rgba(103, 162, 174, 0.28);
}

.reader-profile__kicker {
    margin-bottom: 0.75rem;
}

.reader-profile__history-note {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

.reader-profile__section > header .card-kicker {
    color: var(--profile-accent-dark);
}

.reader-profile__section > header {
    margin-bottom: 1.75rem;
}

.reader-profile__list {
    display: grid;
    gap: 1.35rem;
}

.reader-profile__entity {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.25rem;
    padding: clamp(1.2rem, 2.5vw, 1.6rem);
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid color-mix(in srgb, var(--profile-border) 76%, transparent);
    border-radius: 15px;
}

.reader-profile__entity h3,
.reader-profile__contrast h3 {
    margin: 0 0 0.45rem;
    color: var(--ink);
    font-size: 1.15rem;
}

.reader-profile__entity p {
    margin: 0.2rem 0;
    color: var(--muted);
}

.reader-profile__signals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.5rem 0 0.65rem;
}

.reader-profile__signal {
    display: inline-flex;
    align-items: center;
    min-height: 1.7rem;
    padding: 0.25rem 0.55rem;
    color: var(--profile-accent-dark);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.045em;
    line-height: 1.2;
    text-transform: uppercase;
    background: color-mix(in srgb, var(--profile-accent) 17%, white);
    border: 1px solid color-mix(in srgb, var(--profile-accent) 34%, transparent);
    border-radius: 999px;
}

.reader-profile__signal + .reader-profile__signal {
    color: var(--profile-accent-dark);
    background: rgba(255, 255, 255, 0.65);
    border-color: color-mix(in srgb, var(--profile-accent) 25%, var(--line));
}

.reader-profile__entity .reader-profile__evidence-line {
    margin-top: 0.55rem;
    color: var(--ink);
    font-size: 0.9rem;
}

.reader-profile details {
    align-self: start;
    padding: 0.7rem 0.85rem;
    background: rgba(255, 249, 233, 0.65);
    border-radius: 12px;
}

.reader-profile summary {
    color: var(--accent-dark);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 800;
}

.reader-profile details ul {
    margin: 0.8rem 0 0;
    padding-left: 1.2rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.reader-profile__entity > .reader-profile__books {
    grid-column: 1 / -1;
    width: 100%;
}

.reader-profile__book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(92px, 104px));
    gap: 0.9rem;
    margin-top: 0.9rem;
    padding-top: 0.8rem;
    border-top: 1px solid color-mix(in srgb, var(--profile-border) 72%, transparent);
}

.reader-profile__book {
    min-width: 0;
}

.reader-profile__book > a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.reader-profile__book-cover,
.reader-profile__book-cover img,
.reader-profile__book-placeholder {
    display: block;
    width: 100%;
    aspect-ratio: 2 / 3;
    border-radius: 7px;
}

.reader-profile__book-cover {
    max-width: 104px;
    overflow: hidden;
    background: #efe8dd;
    box-shadow: 0 8px 16px rgba(24, 21, 17, 0.16);
}

.reader-profile__book-cover img {
    object-fit: cover;
    transition: transform 160ms ease;
}

.reader-profile__book > a:hover .reader-profile__book-cover img,
.reader-profile__book > a:focus-visible .reader-profile__book-cover img {
    transform: translateY(-3px);
}

.reader-profile__book-title,
.reader-profile__book-rating {
    display: block;
    margin-top: 0.45rem;
    font-size: 0.78rem;
    line-height: 1.3;
}

.reader-profile__book-title {
    display: -webkit-box;
    overflow: hidden;
    color: var(--ink);
    font-weight: 700;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.reader-profile__book-rating {
    margin-top: 0.2rem;
    color: var(--muted);
    font-weight: 800;
}

.reader-profile .reader-profile__books-more {
    margin-top: 0.75rem;
    padding: 0;
    background: transparent;
}

.reader-profile__books-more > summary {
    width: fit-content;
}

.reader-profile__contrast-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 1.25rem;
}

.reader-profile__contrast {
    padding: 1.2rem;
    background: rgba(255, 255, 255, 0.56);
    border: 1px solid rgba(194, 123, 74, 0.18);
    border-radius: 15px;
}

.reader-profile__contrast > p {
    color: var(--muted);
    line-height: 1.5;
}

@media (max-width: 767.98px) {
    .reader-profile__entity,
    .reader-profile__contrast-grid {
        grid-template-columns: 1fr;
    }

    .reader-profile__panel {
        border-radius: 16px;
    }

    .reader-profile__summary {
        border-radius: 14px;
    }

    .reader-profile__book-grid {
        display: flex;
        gap: 0.8rem;
        padding-bottom: 0.45rem;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
        scroll-snap-type: inline proximity;
    }

    .reader-profile__book {
        flex: 0 0 92px;
        scroll-snap-align: start;
    }
}

/* 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%;
}

/* Let groups with an uneven number of cards fill both columns in reading order. */
.reading-dashboard .statistics-card-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.reading-dashboard .statistics-card-column {
    display: contents;
}

.reading-dashboard .statistics-card-grid .stat-box {
    margin-bottom: 0;
}

@media (max-width: 767.98px) {
    .reading-dashboard .statistics-card-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* 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;
}
