/* ═══════════════════════════════════════════════════════════════
   TASK LIST — Digital Rust
   ═══════════════════════════════════════════════════════════════ */

.task-list-item-container,
.markdown-content ul li:has(> input[type="checkbox"]),
.editor-preview ul li:has(> input[type="checkbox"]),
.version-content ul li:has(> input[type="checkbox"]) {
    display: block;
    position: relative;
    margin-bottom: 0.5rem;
    list-style-type: none !important;
}

/* Nested indentation */
.task-list-item-container[data-indent-level="1"],
.markdown-content ul ul li:has(> input[type="checkbox"]),
.editor-preview ul ul li:has(> input[type="checkbox"]),
.version-content ul ul li:has(> input[type="checkbox"]) { margin-left: 1.5rem; }

.task-list-item-container[data-indent-level="2"],
.markdown-content ul ul ul li:has(> input[type="checkbox"]),
.editor-preview ul ul ul li:has(> input[type="checkbox"]),
.version-content ul ul ul li:has(> input[type="checkbox"]) { margin-left: 3rem; }

.task-list-item-container[data-indent-level="3"],
.markdown-content ul ul ul ul li:has(> input[type="checkbox"]),
.editor-preview ul ul ul ul li:has(> input[type="checkbox"]) { margin-left: 4.5rem; }

.task-list-item-container[data-indent-level="4"],
.markdown-content ul ul ul ul ul li:has(> input[type="checkbox"]),
.editor-preview ul ul ul ul ul li:has(> input[type="checkbox"]) { margin-left: 6rem; }

.task-list-item-container[data-indent-level="5"],
.markdown-content ul ul ul ul ul ul li:has(> input[type="checkbox"]),
.editor-preview ul ul ul ul ul ul li:has(> input[type="checkbox"]) { margin-left: 7.5rem; }

.task-list-item,
.markdown-content li:has(> input[type="checkbox"]),
.editor-preview li:has(> input[type="checkbox"]),
.version-content li:has(> input[type="checkbox"]) {
    position: relative;
    line-height: 1.5;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: flex-start;
}

.task-checkbox,
.markdown-content li input[type="checkbox"],
.editor-preview li input[type="checkbox"],
.version-content li input[type="checkbox"] {
    margin-right: 8px !important;
    margin-top: 4px !important;
    position: relative;
    width: 16px; height: 16px; min-width: 16px;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    border: 2px solid var(--dr-dark-packet);
    border-radius: var(--dr-radius-sm);
    background-color: var(--dr-surface-base);
    display: inline-block !important;
    outline: none;
    vertical-align: middle;
    cursor: default;
    flex-shrink: 0;
    box-sizing: border-box;
    opacity: 1 !important;
    visibility: visible !important;
    transition: border-color var(--dr-transition-fast), background-color var(--dr-transition-fast);
    /* Touch target: extend hit area beyond visual checkbox bounds */
}

.task-checkbox::before,
.markdown-content li input[type="checkbox"]::before,
.editor-preview li input[type="checkbox"]::before,
.version-content li input[type="checkbox"]::before {
    content: '';
    position: absolute;
    inset: -14px;
}

.task-checkbox:checked,
.markdown-content li input[type="checkbox"]:checked,
.editor-preview li input[type="checkbox"]:checked,
.version-content li input[type="checkbox"]:checked {
    border-color: var(--dr-accent);
    background-color: var(--dr-accent);
}

.task-checkbox:checked::after,
.markdown-content li input[type="checkbox"]:checked::after,
.editor-preview li input[type="checkbox"]:checked::after,
.version-content li input[type="checkbox"]:checked::after {
    content: "";
    position: absolute;
    top: 1px; left: 4px;
    width: 4px; height: 8px;
    border: solid var(--dr-text-on-accent);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    display: block;
}

.task-checkbox:focus-visible,
.markdown-content li input[type="checkbox"]:focus-visible,
.editor-preview li input[type="checkbox"]:focus-visible,
.version-content li input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--dr-focus-ring);
    outline-offset: 2px;
}

.task-text { display: inline; unicode-bidi: plaintext; }

/* Save state indicator */
.save-state {
    position: absolute; top: 0; left: 28px;
    font-size: var(--dr-text-xs);
    font-family: var(--dr-font-mono);
    font-weight: var(--dr-font-weight);
    padding: 4px 8px;
    border-radius: var(--dr-radius-sm);
    text-align: center;
    z-index: 10; pointer-events: none;
    opacity: 0; transform: translateY(-5px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    white-space: nowrap; width: fit-content;
}

.save-state:not(:empty) { opacity: 1; transform: translateY(0); }
.save-state.saved { background: var(--dr-memory-leek); color: var(--dr-text-on-accent); }
.save-state.error { background: var(--dr-amber-alert); color: var(--dr-text-on-accent); }

/* Remove bullets from task lists */
.markdown-content ul li:has(> input[type="checkbox"]),
.editor-preview ul li:has(> input[type="checkbox"]),
.version-content ul li:has(> input[type="checkbox"]) {
    list-style-type: none !important;
    margin-left: -1.5em;
}

.markdown-content ul ul li:has(> input[type="checkbox"]),
.editor-preview ul ul li:has(> input[type="checkbox"]),
.version-content ul ul li:has(> input[type="checkbox"]) { margin-left: 0; }

.markdown-content ul:has(li > input[type="checkbox"]),
.editor-preview ul:has(li > input[type="checkbox"]),
.version-content ul:has(li > input[type="checkbox"]) { padding-left: 1.5rem; }

/* Inline task formatting */
.task-list-item strong, .task-list-item a, .task-list-item em, .task-list-item code,
.markdown-content li:has(> input[type="checkbox"]) strong,
.markdown-content li:has(> input[type="checkbox"]) a,
.markdown-content li:has(> input[type="checkbox"]) em,
.markdown-content li:has(> input[type="checkbox"]) code,
.editor-preview li:has(> input[type="checkbox"]) strong,
.editor-preview li:has(> input[type="checkbox"]) a,
.editor-preview li:has(> input[type="checkbox"]) em,
.editor-preview li:has(> input[type="checkbox"]) code,
.version-content li:has(> input[type="checkbox"]) strong,
.version-content li:has(> input[type="checkbox"]) a,
.version-content li:has(> input[type="checkbox"]) em,
.version-content li:has(> input[type="checkbox"]) code {
    margin-left: 2px; margin-right: 2px;
}

/* Mobile: larger checkboxes for touch interaction */
@media (max-width: 950px) {
    .task-checkbox,
    .markdown-content li input[type="checkbox"],
    .editor-preview li input[type="checkbox"],
    .version-content li input[type="checkbox"] {
        width: 20px; height: 20px; min-width: 20px;
    }
    .task-checkbox::before,
    .markdown-content li input[type="checkbox"]::before,
    .editor-preview li input[type="checkbox"]::before,
    .version-content li input[type="checkbox"]::before {
        inset: -12px;
    }
}
