/* styles/widgets/habits.css
 *
 * Extracted from styles/main.css during T4#20 (the May-2026
 * CSS-split refactor). Originally lived at lines 4666-5025
 * of main.css. Cascade order is preserved: main.css loads first
 * (themes + base + modal/tab/layout infra), then per-widget
 * files in alphabetical order via <link> tags in index.html.
 */

/* ── HABITS (Phase 2.7) ────────────────────────────────────────
   One row per habit. Each row: icon + name + 7-day strip of
   small circles + streak chip + edit button. Plus a + New habit
   composer at the bottom. */
.habit-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px 0;
}
.habit-empty {
    color: var(--muted);
    text-align: center;
    padding: 16px 8px;
    line-height: 1.5;
}
.habit-row {
    --habit-color: var(--green);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--habit-color);
    border-radius: 8px;
    background: var(--surface2);
}
.habit-icon {
    font-size: 20px;
    flex: 0 0 auto;
    width: 24px;
    text-align: center;
}
.habit-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.habit-strip {
    display: flex;
    gap: 3px;
    flex: 0 0 auto;
}
.habit-dot {
    --habit-color: var(--green);
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: transparent;
    cursor: pointer;
    padding: 0;
    transition: transform 0.1s, border-color 0.1s, background 0.1s;
}
.habit-dot:hover { transform: scale(1.15); border-color: var(--habit-color); }
.habit-dot.habit-dot-done {
    background: var(--habit-color);
    border-color: var(--habit-color);
}
.habit-dot.habit-dot-today {
    /* Subtle ring around today so the user can find it without
       counting positions. */
    box-shadow: 0 0 0 2px color-mix(in oklab, var(--habit-color) 35%, transparent);
}
.habit-streak {
    flex: 0 0 auto;
    font-size: 11px;
    font-weight: 700;
    color: var(--habit-color);
    min-width: 32px;
    text-align: right;
}
.habit-streak-zero {
    color: var(--muted);
    font-weight: 400;
    opacity: 0.6;
}
.habit-edit-btn {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
    line-height: 1;
}
.habit-edit-btn:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--surface);
}

.habit-add-row {
    display: flex;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}
.habit-add-input {
    flex: 1 1 auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    padding: 6px 9px;
    font-family: inherit;
}
.habit-add-input:focus {
    outline: none;
    border-color: var(--accent);
}
.habit-add-btn {
    flex: 0 0 auto;
    width: 32px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    color: var(--bg);
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
}
.habit-add-btn:hover { filter: brightness(1.1); }
.habit-add-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Habit editor modal - reuses the modal-overlay / modal stack. */
.habit-edit-modal { width: min(440px, 92vw); }
.habit-edit-icon-input { width: 80px; font-size: 20px; text-align: center; }
.habit-edit-color-input { width: 60px; height: 32px; padding: 2px; cursor: pointer; }
.habit-edit-danger-row {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* Frequency picker (Slice 2) */
.habit-freq-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.habit-freq-opt {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    background: var(--surface);
    user-select: none;
}
.habit-freq-opt:hover { border-color: var(--accent); }
.habit-freq-opt input[type="radio"] { margin: 0; }
.habit-freq-opt input[type="radio"]:checked + span { color: var(--accent); font-weight: 600; }
.habit-freq-detail { margin-top: 8px; }
.habit-freq-detail-row { display: flex; gap: 4px; flex-wrap: wrap; }
.habit-weekly-input {
    width: 56px;
    text-align: center;
    display: inline-block;
    margin: 0 4px;
}
.habit-day-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    background: var(--surface);
    user-select: none;
}
.habit-day-chip:hover { border-color: var(--accent); }
.habit-day-chip input[type="checkbox"] { margin: 0; }
.habit-day-chip input[type="checkbox"]:checked + span { color: var(--accent); font-weight: 700; }

/* Frequency-aware dot states (Slice 2) */
.habit-dot.habit-dot-miss {
    /* Required day, in the past, not done - soft red ring. */
    border-color: var(--red);
    background: color-mix(in oklab, var(--red) 18%, transparent);
}
.habit-dot.habit-dot-optional {
    /* Rest day for custom / weekly habits - keep visible but
       very faint so the eye understands "not required today". */
    opacity: 0.4;
    border-style: dashed;
}
.habit-dot.habit-dot-done.habit-dot-optional {
    /* Optional day done - full color, no opacity dim. */
    opacity: 1;
}

/* Frequency hint label under the habit name. */
.habit-name-col {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1 1 auto;
    min-width: 0;
}
.habit-name-col .habit-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.habit-freq-hint {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

/* Reorder arrows + edit button group (Slice 2) */
.habit-row-tools {
    display: flex;
    gap: 2px;
    flex: 0 0 auto;
}
.habit-arrow-btn {
    width: 22px; height: 22px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.habit-arrow-btn:hover:not(:disabled) {
    border-color: var(--border);
    background: var(--surface);
    color: var(--text);
}
.habit-arrow-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Expand button + wrap row (Slice 3) */
.habit-row-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.habit-row-expand-btn {
    flex: 0 0 auto;
    width: 18px; height: 22px;
    background: transparent;
    border: none;
    color: var(--muted);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    padding: 0;
}
.habit-row-expand-btn:hover { color: var(--accent); }
.habit-row-expanded {
    border-radius: 8px 8px 0 0;
    border-bottom: none;
}

/* "+ New habit" block button replaces the inline input. */
.habit-add-btn-block {
    display: block;
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px dashed var(--accent);
    border-radius: 8px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    margin-top: 6px;
}
.habit-add-btn-block:hover {
    background: color-mix(in oklab, var(--accent) 10%, transparent);
}

/* Heatmap expanded view (Slice 3) */
.habit-expand {
    --habit-color: var(--green);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 10px;
    background: var(--surface2);
    margin-bottom: 0;
}
.habit-expand-meta {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 11px;
    color: var(--muted);
    margin-bottom: 8px;
}
.habit-expand-meta strong {
    color: var(--text);
    font-weight: 700;
}
.habit-expand-pct {
    margin-left: auto;
    font-size: 13px;
    color: var(--habit-color);
    font-weight: 700;
}
.habit-heat-grid {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: repeat(7, 1fr);
    gap: 2px;
}
.habit-heat-cell, .habit-heat-empty {
    width: 100%;
    aspect-ratio: 1 / 1;
    min-width: 8px;
    min-height: 8px;
    border-radius: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
}
.habit-heat-empty {
    visibility: hidden;
    cursor: default;
}
.habit-heat-cell:hover { border-color: var(--habit-color); }
.habit-heat-cell-done {
    background: var(--habit-color);
    border-color: var(--habit-color);
}
.habit-heat-cell-miss {
    border-color: color-mix(in oklab, var(--red) 70%, transparent);
}
.habit-heat-cell-optional { opacity: 0.5; border-style: dashed; }
.habit-heat-cell-done.habit-heat-cell-optional { opacity: 1; }

