/* ========== Чеклисты в заметках ========== */

.task-list-block {
    margin: 1.25rem 0;
    padding: 14px 16px;
    background: var(--color-bg-subtle);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.task-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

.task-list-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.task-list-stats {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.task-list-stats--complete {
    color: var(--color-success-hover);
}

.task-list-progress {
    height: 4px;
    background: var(--color-border);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 14px;
}

.task-list-progress-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--color-primary), var(--color-success));
    border-radius: 999px;
    transition: width 0.35s var(--ease-out);
}

.task-list,
#post-content .task-list,
.add-post-preview-body .task-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-item,
#post-content .task-item,
.add-post-preview-body .task-item {
    margin: 0;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}

.task-item:hover,
#post-content .task-item:hover,
.add-post-preview-body .task-item:hover {
    background: rgba(255, 255, 255, 0.7);
}

.task-label,
#post-content .task-label,
.add-post-preview-body .task-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    line-height: 1.55;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-out);
}

.task-label:hover,
#post-content .task-label:hover,
.add-post-preview-body .task-label:hover {
    background: rgba(59, 130, 246, 0.04);
}

.task-checkbox,
#post-content .task-checkbox,
.add-post-preview-body .task-checkbox {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    pointer-events: none;
}

.task-checkmark,
#post-content .task-checkmark,
.add-post-preview-body .task-checkmark {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    flex-shrink: 0;
    border: 2px solid var(--color-border-strong);
    border-radius: 6px;
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--duration-normal) var(--ease-out),
                background var(--duration-normal) var(--ease-out),
                transform var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out);
}

.task-checkmark::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    margin-top: -2px;
    transition: transform 0.2s var(--ease-out);
}

.task-checkbox:checked + .task-checkmark,
#post-content .task-checkbox:checked + .task-checkmark,
.add-post-preview-body .task-checkbox:checked + .task-checkmark {
    background: var(--color-success);
    border-color: var(--color-success);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.35);
}

.task-checkbox:checked + .task-checkmark::after,
#post-content .task-checkbox:checked + .task-checkmark::after,
.add-post-preview-body .task-checkbox:checked + .task-checkmark::after {
    transform: rotate(45deg) scale(1);
}

.task-label:active .task-checkmark,
#post-content .task-label:active .task-checkmark,
.add-post-preview-body .task-label:active .task-checkmark {
    transform: scale(0.92);
}

.task-checkbox:disabled + .task-checkmark,
#post-content .task-checkbox:disabled + .task-checkmark,
.add-post-preview-body .task-checkbox:disabled + .task-checkmark {
    opacity: 0.55;
}

.task-text,
#post-content .task-text,
.add-post-preview-body .task-text {
    flex: 1;
    color: var(--color-text);
    font-size: var(--text-reading);
    padding-top: 1px;
    transition: color 0.25s var(--ease-out),
                opacity 0.25s var(--ease-out);
    position: relative;
}

.task-item.task-done .task-text,
.task-checkbox:checked ~ .task-text,
#post-content .task-item.task-done .task-text,
#post-content .task-checkbox:checked ~ .task-text,
.add-post-preview-body .task-item.task-done .task-text,
.add-post-preview-body .task-checkbox:checked ~ .task-text {
    color: var(--color-text-muted);
    opacity: 0.72;
}

.task-item.task-done .task-text::after,
.task-checkbox:checked ~ .task-text::after,
#post-content .task-item.task-done .task-text::after,
#post-content .task-checkbox:checked ~ .task-text::after,
.add-post-preview-body .task-item.task-done .task-text::after,
.add-post-preview-body .task-checkbox:checked ~ .task-text::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1.5px;
    background: var(--color-text-subtle);
    transform: scaleX(0);
    transform-origin: left center;
    animation: taskStrike 0.28s var(--ease-out) forwards;
    pointer-events: none;
}

@keyframes taskStrike {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.task-item.task-done .task-text strong,
.task-item.task-done .task-text em,
.task-item.task-done .task-text code,
.task-checkbox:checked ~ .task-text strong,
.task-checkbox:checked ~ .task-text em,
.task-checkbox:checked ~ .task-text code {
    color: inherit;
    opacity: inherit;
}

.task-item--saving .task-checkmark {
    animation: taskPulse 0.8s ease-in-out infinite;
}

@keyframes taskPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
}

.task-save-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    background: var(--color-heading);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.25s var(--ease-out), transform 0.25s var(--ease-out);
    pointer-events: none;
}

.task-save-toast.visible {
    opacity: 1;
    transform: translateY(0);
}

.task-save-toast--error {
    background: var(--color-danger);
}

.task-save-toast--success {
    background: var(--color-success-hover);
}

.task-list-block--readonly .task-label,
#post-content .task-list-block--readonly .task-label {
    cursor: default;
    pointer-events: none;
}

.task-list-block--readonly .task-label:hover,
#post-content .task-list-block--readonly .task-label:hover {
    background: transparent;
}

@media (max-width: 480px) {
    .task-list-block {
        padding: 12px;
    }

    .task-label,
    #post-content .task-label,
    .add-post-preview-body .task-label {
        padding: 10px 8px;
        gap: 10px;
    }

    .task-save-toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
        justify-content: center;
    }
}
