/* ======================================================================
 *  习惯养成打卡墙 /tool/habit-tracker
 *  依赖 calc-common.css 共享样式 + home.css 全局变量，支持黑夜模式
 * ====================================================================== */

@import url('./calc-common.css');

/* ---------- emoji 选择器 ---------- */
.ht-emoji-picker {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}
.ht-emoji-btn {
    height: 42px;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    background: var(--c-surface-soft);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    transition: border-color 0.16s ease, transform 0.12s ease, box-shadow 0.16s ease;
}
.ht-emoji-btn:hover { border-color: var(--c-primary); transform: translateY(-2px); }
.ht-emoji-btn.active {
    border-color: rgba(0, 150, 220, 0.55);
    background: linear-gradient(135deg, rgba(0, 150, 220, 0.16), rgba(0, 150, 220, 0.08));
    box-shadow: 0 0 0 3px var(--c-primary-soft);
}

/* ---------- 打卡墙 ---------- */
.ht-wall {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}
.ht-empty {
    text-align: center;
    padding: 34px 16px;
    color: var(--c-text-muted);
    font-size: 13.5px;
    line-height: 1.8;
}
.ht-empty .emoji { font-size: 42px; opacity: 0.75; margin-bottom: 10px; }
.ht-empty[hidden] { display: none !important; }

/* ---------- 习惯卡片 ---------- */
.ht-habit {
    position: relative;
    border: 1px solid var(--c-border);
    border-radius: 14px;
    background: var(--c-surface-soft);
    padding: 14px 16px;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.ht-habit:hover { border-color: rgba(0, 150, 220, 0.4); box-shadow: var(--shadow-sm); }
.ht-habit.is-done-today { border-color: rgba(52, 199, 89, 0.45); background: rgba(52, 199, 89, 0.05); }
.ht-habit.is-new { animation: htPop 0.45s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes htPop {
    0% { opacity: 0; transform: translateY(10px) scale(0.96); }
    60% { transform: translateY(-2px) scale(1.01); }
    100% { opacity: 1; transform: none; }
}

.ht-habit-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding-right: 26px;
}
.ht-habit-emoji {
    width: 40px;
    height: 40px;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    border-radius: 12px;
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
}
.ht-habit-name {
    font-size: 14.5px;
    font-weight: 800;
    color: var(--c-text);
    word-break: break-all;
    line-height: 1.35;
}
.ht-habit-freq {
    font-size: 11.5px;
    color: var(--c-text-muted);
    margin-top: 2px;
}
.ht-habit-del {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--c-text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: background 0.14s ease, color 0.14s ease;
}
.ht-habit-del:hover { background: rgba(224, 68, 124, 0.12); color: #e0447c; }

/* 连续火焰徽章 */
.ht-streak-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.ht-streak-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 12.5px;
    font-weight: 800;
    background: linear-gradient(135deg, rgba(255, 140, 66, 0.16), rgba(255, 94, 98, 0.10));
    border: 1px solid rgba(255, 140, 66, 0.4);
    color: #e06c2a;
}
.ht-streak-badge.is-cold {
    background: var(--c-surface-soft);
    border-color: var(--c-border);
    color: var(--c-text-muted);
}
.ht-streak-badge .fire { font-size: 13px; }
.ht-habit-meta {
    font-size: 11.5px;
    color: var(--c-text-muted);
}
.ht-habit-meta b { color: var(--c-text-sub); }

/* 打卡按钮 */
.ht-check-btn {
    width: 100%;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--c-border);
    background: var(--c-bg-card);
    color: var(--c-text-sub);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.16s ease;
    margin-bottom: 12px;
}
.ht-check-btn:hover { border-color: rgba(52, 199, 89, 0.6); color: #1f9d43; }
.ht-check-btn.is-done {
    background: linear-gradient(135deg, rgba(52, 199, 89, 0.92), rgba(35, 170, 75, 0.92));
    border-color: rgba(52, 199, 89, 0.6);
    color: #fff;
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.32);
}
.ht-check-btn.is-done:hover { color: #fff; opacity: 0.92; }
.ht-check-btn.is-pop { animation: htCheckPop 0.35s ease; }
@keyframes htCheckPop {
    0% { transform: scale(1); }
    45% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

/* ---------- 热力图 ---------- */
.ht-heat {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
}
.ht-heat-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
    cursor: default;
}
.ht-heat-cell.is-today {
    box-shadow: 0 0 0 2px rgba(0, 150, 220, 0.55);
}
/* 完成度 4 级（仿 GitHub 贡献图） */
.ht-heat-cell.lv1 { background: rgba(52, 199, 89, 0.30); border-color: rgba(52, 199, 89, 0.25); }
.ht-heat-cell.lv2 { background: rgba(52, 199, 89, 0.55); border-color: rgba(52, 199, 89, 0.4); }
.ht-heat-cell.lv3 { background: rgba(40, 175, 80, 0.85); border-color: rgba(40, 175, 80, 0.6); }
.ht-heat-cell.lv4 { background: #1e9e4a; border-color: #1e9e4a; }
.ht-heat-cell:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    padding: 4px 9px;
    border-radius: 7px;
    background: rgba(20, 26, 36, 0.92);
    color: #fff;
    font-size: 11px;
    z-index: 5;
    pointer-events: none;
}
.ht-heat-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 10px;
    font-size: 11px;
    color: var(--c-text-muted);
}
.ht-heat-legend i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--c-surface-soft);
    border: 1px solid var(--c-border);
}
.ht-heat-legend i.lv1 { background: rgba(52, 199, 89, 0.30); border-color: rgba(52, 199, 89, 0.25); }
.ht-heat-legend i.lv2 { background: rgba(52, 199, 89, 0.55); border-color: rgba(52, 199, 89, 0.4); }
.ht-heat-legend i.lv3 { background: rgba(40, 175, 80, 0.85); border-color: rgba(40, 175, 80, 0.6); }
.ht-heat-legend i.lv4 { background: #1e9e4a; border-color: #1e9e4a; }

/* 总览热力图区块 */
.ht-all-heat { margin-top: 14px; }
.ht-all-heat .ht-heat-title {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--c-text-sub);
    margin: 0 0 8px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
    .ht-wall { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
    .ht-wall { grid-template-columns: 1fr; }
    .ht-emoji-picker { grid-template-columns: repeat(6, 1fr); }
    .ht-heat { grid-template-columns: repeat(10, 1fr); gap: 3px; }
}

/* ---------- 黑夜模式 ---------- */
[data-theme="dark"] .ht-emoji-btn { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .ht-habit { background: rgba(255, 255, 255, 0.03); }
[data-theme="dark"] .ht-habit.is-done-today { background: rgba(52, 199, 89, 0.08); border-color: rgba(52, 199, 89, 0.4); }
[data-theme="dark"] .ht-habit-emoji { background: rgba(255, 255, 255, 0.05); }
[data-theme="dark"] .ht-check-btn { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .ht-check-btn:hover { color: #4ede78; border-color: rgba(52, 199, 89, 0.5); }
[data-theme="dark"] .ht-check-btn.is-done { color: #fff; }
[data-theme="dark"] .ht-streak-badge { background: rgba(255, 140, 66, 0.14); color: #ffab70; }
[data-theme="dark"] .ht-streak-badge.is-cold { background: rgba(255, 255, 255, 0.04); color: var(--c-text-muted); }
[data-theme="dark"] .ht-heat-cell { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .ht-heat-cell.lv1 { background: rgba(52, 199, 89, 0.24); }
[data-theme="dark"] .ht-heat-cell.lv2 { background: rgba(52, 199, 89, 0.45); }
[data-theme="dark"] .ht-heat-cell.lv3 { background: rgba(52, 199, 89, 0.7); }
[data-theme="dark"] .ht-heat-cell.lv4 { background: #2ecb5e; border-color: #2ecb5e; }
[data-theme="dark"] .ht-heat-legend i { background: rgba(255, 255, 255, 0.04); }
[data-theme="dark"] .ht-heat-legend i.lv1 { background: rgba(52, 199, 89, 0.24); }
[data-theme="dark"] .ht-heat-legend i.lv2 { background: rgba(52, 199, 89, 0.45); }
[data-theme="dark"] .ht-heat-legend i.lv3 { background: rgba(52, 199, 89, 0.7); }
[data-theme="dark"] .ht-heat-legend i.lv4 { background: #2ecb5e; border-color: #2ecb5e; }
