/**
 * Statistics page.
 *
 * @package jpd-theme
 */

.jpd-page--statistics {
    background: #fff;
}

.jpd-statistics {
    padding-top: clamp(48px, 7vw, 92px);
    padding-bottom: clamp(72px, 9vw, 120px);
}

.jpd-statistics__header {
    max-width: 820px;
    margin-bottom: clamp(54px, 8vw, 92px);
}

.jpd-statistics__header h1 {
    display: inline-block;
    margin: 0;
    padding: 10px 34px;
    border-radius: 999px;
    background: linear-gradient(90deg, #fff3bd 0%, #ffc53d 50%, #fff7d5 100%);
    color: #161616;
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    font-weight: 800;
    line-height: 1.2;
}

.jpd-statistics__header p {
    max-width: 720px;
    margin: 24px 0 0;
    color: var(--jpd-text-light);
    font-size: 1.05rem;
}

.jpd-statistics__accordion {
    display: grid;
    gap: 14px;
}

.jpd-statistics__report {
    min-width: 0;
    border: 0;
}

.jpd-statistics__report:not([open]) > .jpd-statistics__panel {
    display: none;
}

.jpd-statistics__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 76px;
    padding: 18px clamp(22px, 4vw, 54px);
    border: 1px solid transparent;
    border-radius: 8px;
    background: #f3d249;
    color: #fff;
    font-size: clamp(1rem, 1.55vw, 1.25rem);
    font-weight: 800;
    line-height: 1.35;
    cursor: pointer;
    list-style: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.jpd-statistics__summary::-webkit-details-marker {
    display: none;
}

.jpd-statistics__summary:hover,
.jpd-statistics__summary:focus-visible {
    border-color: #df9f0c;
    box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.2);
    outline: 0;
}

.jpd-statistics__summary-icon {
    position: relative;
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
}

.jpd-statistics__summary-icon::before,
.jpd-statistics__summary-icon::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    content: '';
    transform: translate(-50%, -50%);
    transition: transform 0.2s ease;
}

.jpd-statistics__summary-icon::after {
    transform: translate(-50%, -50%) rotate(90deg);
}

.jpd-statistics__report[open] .jpd-statistics__summary-icon::after {
    transform: translate(-50%, -50%) rotate(0deg);
}

.jpd-statistics__panel {
    min-width: 0;
    padding: clamp(38px, 6vw, 72px) clamp(4px, 2vw, 24px) clamp(54px, 7vw, 88px);
}

.jpd-statistics__blocks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(36px, 5vw, 72px) clamp(28px, 4vw, 52px);
    align-items: start;
}

.jpd-statistics__block--full {
    grid-column: 1 / -1;
}

.jpd-statistics__block,
.jpd-statistics__chart-layout,
.jpd-statistics__table-scroll {
    min-width: 0;
    max-width: 100%;
}

.jpd-statistics__block h2 {
    margin: 0 0 28px;
    color: #0b3a74;
    font-size: clamp(1.2rem, 2vw, 1.65rem);
    text-align: center;
}

.jpd-statistics__chart-layout--classes {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.85fr);
    gap: clamp(28px, 4vw, 52px);
    align-items: start;
}

.jpd-statistics__chart-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
}

.jpd-statistics__chart-wrap:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--jpd-teal-rgb), 0.28);
}

.jpd-statistics__chart-frame {
    position: relative;
    width: 100%;
    min-width: 640px;
    height: 430px;
}

.jpd-statistics__chart-frame canvas {
    display: block;
}

.jpd-statistics__block--half .jpd-statistics__chart-frame {
    height: 390px;
}

.jpd-statistics__copy {
    color: #3e3e3e;
    line-height: 1.75;
}

.jpd-statistics__copy p:last-child {
    margin-bottom: 0;
}

.jpd-statistics__copy--chart {
    max-width: 900px;
    margin: 26px auto 0;
}

.jpd-statistics__table-scroll {
    overflow: auto;
    max-width: 100%;
    border-radius: 4px;
    outline: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
}

.jpd-statistics__table-scroll:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--jpd-teal-rgb), 0.28);
}

.jpd-statistics__table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    background: #fff;
    font-variant-numeric: tabular-nums;
}

.jpd-statistics__table th,
.jpd-statistics__table td {
    box-sizing: border-box;
    padding: 17px 22px;
    border: 2px solid #fff;
    text-align: center;
    vertical-align: middle;
}

.jpd-statistics__table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #ffbf16;
    color: #fff;
    font-weight: 800;
}

.jpd-statistics__table tbody th {
    position: sticky;
    left: 0;
    z-index: 1;
    width: 1%;
    background: #fff5d8;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.jpd-statistics__table thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    width: 1%;
    white-space: nowrap;
}

.jpd-statistics__table tbody tr > * {
    background: #fff5d8;
}

.jpd-statistics__table--highlight tbody th {
    font-weight: 700;
}

.jpd-statistics__table--compact {
    min-width: 1320px;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.jpd-statistics__table--compact th,
.jpd-statistics__table--compact td {
    padding: 9px 10px;
    border: 2px solid #fff;
    text-align: center;
}

.jpd-statistics__table--compact thead th {
    background: #ffbf16;
    color: #fff;
}

.jpd-statistics__table--compact tbody th {
    min-width: 245px;
    background: #fff5d8;
}

.jpd-statistics__note {
    margin: 18px 0 0;
    color: #555;
    font-size: 0.9rem;
    font-style: italic;
    text-align: right;
}

.jpd-statistics__classes {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.jpd-statistics__classes li {
    display: grid;
    grid-template-columns: 112px 52px minmax(0, 1fr);
    min-height: 92px;
    align-items: center;
    overflow: hidden;
    border: 1px solid #edae24;
    border-radius: 8px;
    background: #fff5d8;
}

.jpd-statistics__class-image {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    min-height: 88px;
    border-right: 1px solid #edae24;
    background-color: #fff;
}

.jpd-statistics__class-image img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 88px;
    padding: 7px;
    object-fit: contain;
    box-sizing: border-box;
}

.jpd-statistics__classes strong {
    padding: 8px;
    color: #0d0d0d;
    font-size: 1.45rem;
    text-align: center;
}

.jpd-statistics__classes li > span:last-child {
    padding: 12px 16px 12px 4px;
    color: #111;
    font-size: 0.83rem;
    font-weight: 700;
    line-height: 1.35;
    text-align: center;
}

.jpd-statistics__report-footer {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-end;
    margin-top: 44px;
    padding-top: 22px;
    border-top: 1px solid var(--jpd-border);
    color: var(--jpd-text-light);
    font-size: 0.88rem;
}

.jpd-statistics__report-footer div {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
}

.jpd-statistics__download {
    flex: 0 0 auto;
}

.jpd-statistics__empty {
    padding: 36px;
    border: 1px solid var(--jpd-border);
    border-radius: 8px;
    background: var(--jpd-light);
    text-align: center;
}

@media (max-width: 980px) {
    .jpd-statistics__blocks,
    .jpd-statistics__chart-layout--classes {
        grid-template-columns: 1fr;
    }

    .jpd-statistics__block--half {
        grid-column: 1 / -1;
    }

    .jpd-statistics__classes {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .jpd-statistics {
        padding-top: 36px;
    }

    .jpd-statistics__header {
        margin-bottom: 42px;
    }

    .jpd-statistics__header h1 {
        padding: 10px 20px;
        border-radius: 14px;
    }

    .jpd-statistics__summary {
        min-height: 68px;
        padding: 16px 18px;
    }

    .jpd-statistics__panel {
        padding: 36px 0 56px;
    }

    .jpd-statistics__table {
        width: 100%;
        min-width: 100%;
    }

    .jpd-statistics__table th,
    .jpd-statistics__table td {
        padding: 12px 10px;
    }

    .jpd-statistics__table thead th:first-child,
    .jpd-statistics__table tbody th {
        width: 7.75rem;
        min-width: 7.75rem;
        max-width: 7.75rem;
        padding: 12px 10px;
        white-space: normal;
        line-height: 1.35;
        overflow-wrap: break-word;
        box-shadow: 6px 0 10px -6px rgba(22, 22, 22, 0.2);
    }

    .jpd-statistics__table thead th:not(:first-child),
    .jpd-statistics__table td {
        min-width: 5.25rem;
    }

    .jpd-statistics__table--compact {
        min-width: 100%;
    }

    .jpd-statistics__table--compact th,
    .jpd-statistics__table--compact td {
        padding: 9px 8px;
    }

    .jpd-statistics__table--compact tbody th,
    .jpd-statistics__table--compact thead th:first-child {
        min-width: 7.75rem;
        width: 7.75rem;
        max-width: 7.75rem;
    }

    .jpd-statistics__chart-frame,
    .jpd-statistics__block--half .jpd-statistics__chart-frame {
        height: 360px;
    }

    .jpd-statistics__classes {
        grid-template-columns: 1fr;
    }

    .jpd-statistics__classes li {
        grid-template-columns: 96px 46px minmax(0, 1fr);
    }

    .jpd-statistics__report-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .jpd-statistics__download {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .jpd-statistics__summary,
    .jpd-statistics__summary-icon::before,
    .jpd-statistics__summary-icon::after {
        transition: none;
    }
}
