/* Задачи — виджет для Element.
   Одно семейство шрифтов, линейчатый список, один акцент на действие. */

:root {
    --bg:      #eef1f1;
    --surface: #ffffff;
    --ink:     #16201f;
    --muted:   #6c7a79;
    --line:    #dde3e3;
    --accent:  #1c6c5a;
    --drop:    #a8453a;
    --focus:   #2f7de1;
    --radius:  8px;
}

html[data-theme="dark"],
:root:not([data-theme="light"]) {
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg:      #14181a;
        --surface: #1b2124;
        --ink:     #e3e9e8;
        --muted:   #8b989c;
        --line:    #2b3337;
        --accent:  #4fc3a4;
        --drop:    #e0796b;
        --focus:   #6aa9f4;
        color-scheme: dark;
    }
}

html[data-theme="dark"] {
    --bg:      #14181a;
    --surface: #1b2124;
    --ink:     #e3e9e8;
    --muted:   #8b989c;
    --line:    #2b3337;
    --accent:  #4fc3a4;
    --drop:    #e0796b;
    --focus:   #6aa9f4;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font: 400 15px/1.45 system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

:where(button, input, a):focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---------- вход ---------- */

.gate {
    display: grid;
    place-items: center;
    min-height: 100%;
    padding: 24px 16px;
}

.gate__form {
    width: 100%;
    max-width: 300px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 20px;
}

.gate__title {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.gate__error {
    margin: -6px 0 14px;
    color: var(--drop);
    font-size: 13px;
}

.field { display: block; margin-bottom: 14px; }

.field__label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--muted);
}

.field__input {
    width: 100%;
    padding: 8px 10px;
    font: inherit;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 6px;
}

.field__input:focus {
    border-color: var(--focus);
    outline: none;
}

.btn {
    width: 100%;
    padding: 9px 12px;
    font: 500 15px/1 inherit;
    font-family: inherit;
    color: var(--surface);
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    cursor: pointer;
}

.btn:hover { filter: brightness(1.08); }

/* ---------- список ---------- */

.app {
    max-width: 640px;
    margin: 0 auto;
    padding: 10px 12px 28px;
}

.bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 8px;
    font-size: 12px;
    color: var(--muted);
}

.bar__exit {
    color: var(--muted);
    text-decoration: none;
    border-bottom: 1px solid var(--line);
}

.bar__exit:hover { color: var(--ink); }

.compose { margin: 0; }

.compose__input {
    width: 100%;
    padding: 11px 12px 11px 40px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0;
}

.compose__input::placeholder { color: var(--muted); }

.compose__input:focus {
    outline: none;
    border-color: var(--accent);
}

.list {
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-top: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

.list:empty { border: 0; }

.task {
    display: grid;
    grid-template-columns: 40px 1fr 0fr;
    align-items: start;
    border-top: 1px solid var(--line);
    transition: grid-template-columns 160ms ease;
}

.task:first-child { border-top: 0; }

.task--going { opacity: 0.35; }

.task__text {
    position: relative;
    padding: 11px 6px 11px 0;
    overflow-wrap: anywhere;
}

/* зачёркивание рисуем линией — она прочерчивается слева направо */
.task__text::after {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1.5px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 180ms ease;
}

.task--done .task__text {
    color: var(--muted);
}

.task--done .task__text::after { transform: scaleX(1); }

/* галочки */
.mark {
    display: grid;
    place-items: center;
    padding: 11px 0;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--muted);
}

.mark svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    border: 1.5px solid currentColor;
    border-radius: 5px;
    padding: 2px;
    box-sizing: content-box;
}

.mark--done:hover { color: var(--accent); }

.task--done .mark--done {
    color: var(--accent);
}

.task--done .mark--done svg {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
}

.mark--done svg path { stroke-dasharray: 20; stroke-dashoffset: 20; }
.task--done .mark--done svg path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 180ms ease 60ms;
}

/* вторая галочка появляется только у выполненной задачи */
.mark--drop {
    width: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    color: var(--drop);
    transition: opacity 140ms ease;
}

.mark--drop svg path { stroke-dashoffset: 20; }

.task--done {
    grid-template-columns: 40px 1fr 40px;
}

.task--done .mark--drop {
    width: 40px;
    opacity: 1;
    pointer-events: auto;
}

.task--done .mark--drop:hover svg {
    background: color-mix(in srgb, var(--drop) 16%, transparent);
}

.empty, .offline {
    margin: 14px 4px 0;
    font-size: 13px;
    color: var(--muted);
}

.offline { color: var(--drop); }

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
