/* =========================================================================
   practice-heatmap.css — 练习活动热力图
   移植自 zyzReading-main，视觉上适配「杂志阅读风 · 纸质暖调」主题。
   单元格配色沿用原项目的绿色分级（热力图通用认知），外围改用纸卡质感。
   ========================================================================= */

.practice-heatmap-widget {
    margin-top: 24px;
}

/* ---------- 标题栏 + 月份切换 ---------- */
.practice-heatmap-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.practice-heatmap-widget__header .hero-panel__title {
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.practice-heatmap-month-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.practice-heatmap-month-controls[hidden] {
    display: none !important;
}

.practice-heatmap-month-label {
    min-width: 76px;
    color: #6b5f4d;
    font-size: 0.84rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
}

.practice-heatmap-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 1px solid #d5c9b4;
    border-radius: 2px;
    background: #fffdf8;
    color: #6b5f4d;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    outline: none;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}

.practice-heatmap-icon-btn:hover,
.practice-heatmap-icon-btn:focus-visible {
    background: #f3ede2;
    border-color: #9c3d2e;
    color: #9c3d2e;
}

.practice-heatmap-icon-btn:disabled,
.practice-heatmap-icon-btn[aria-disabled="true"] {
    cursor: default;
    opacity: 0.42;
}

/* ---------- 热力图主体 ---------- */
.practice-heatmap {
    --practice-heatmap-cell: clamp(22px, 2.35vw, 26px);
    --practice-heatmap-gap: 6px;
    display: flex;
    flex: 1 1 auto;
    min-height: 194px;
    align-items: center;
    justify-content: center;
    margin-top: 14px;
    overflow: visible;
}

.practice-heatmap__body {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    align-items: center;
}

.practice-heatmap__weekdays,
.practice-heatmap__grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    column-gap: var(--practice-heatmap-gap);
}

.practice-heatmap__weekdays {
    color: #857763;
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    opacity: 0.9;
}

.practice-heatmap__weekday {
    min-width: 0;
}

.practice-heatmap__grid {
    grid-template-rows: repeat(var(--practice-heatmap-weeks, 5), var(--practice-heatmap-cell));
    row-gap: var(--practice-heatmap-gap);
    align-content: center;
}

.practice-heatmap__cell {
    --practice-heatmap-color: #f3ede2;
    position: relative;
    width: 100%;
    height: var(--practice-heatmap-cell);
    border: 1px solid #e0d6c6;
    border-radius: 2px;
    background: var(--practice-heatmap-color);
    outline: none;
    cursor: default;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

/* 绿色分级（沿用原项目配色） */
.practice-heatmap__cell[data-level="0"] {
    --practice-heatmap-color: #f3ede2;
}

.practice-heatmap__cell[data-level="1"] {
    --practice-heatmap-color: #d8f5d3;
}

.practice-heatmap__cell[data-level="2"] {
    --practice-heatmap-color: #9be28e;
}

.practice-heatmap__cell[data-level="3"] {
    --practice-heatmap-color: #45bf63;
}

.practice-heatmap__cell[data-level="4"] {
    --practice-heatmap-color: #1f8f46;
}

.practice-heatmap__cell.is-outside-month {
    opacity: 0.26;
}

.practice-heatmap__cell:hover,
.practice-heatmap__cell:focus-visible {
    border-color: #9c3d2e;
    box-shadow: 0 0 0 2px rgba(156, 61, 46, 0.18);
    transform: translateY(-2px) scale(1.06);
    z-index: 4;
}

/* 悬浮提示 */
.practice-heatmap__cell::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: 160px;
    padding: 6px 8px;
    border-radius: 2px;
    background: #362f26;
    color: #fffdf8;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    white-space: normal;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 4px);
    transition: opacity 160ms ease, transform 160ms ease;
    z-index: 30;
}

.practice-heatmap__cell:hover::after,
.practice-heatmap__cell:focus-visible::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- 底部汇总 + 图例 ---------- */
.practice-heatmap__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    color: #6b5f4d;
    font-size: 0.78rem;
    font-weight: 700;
    flex-wrap: wrap;
}

.practice-heatmap__legend {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex: 0 0 auto;
}

.practice-heatmap__legend-cell {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border: 1px solid #e0d6c6;
}

.practice-heatmap__legend-cell--0 { background: #f3ede2; }
.practice-heatmap__legend-cell--1 { background: #d8f5d3; }
.practice-heatmap__legend-cell--2 { background: #9be28e; }
.practice-heatmap__legend-cell--3 { background: #45bf63; }
.practice-heatmap__legend-cell--4 { background: #1f8f46; }
