/* css/todo.css */
/* TODO reading experience — intentionally quiet, using the promotion palette. */
.todo-search__status {
    margin-top: var(--space-4);
    color: var(--color-text-muted);
}

.todo-document__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-5);
}

.todo-page {
    min-width: 20rem;
    background: var(--color-surface);
}

.todo-page.todo-modal-open {
    overflow: hidden;
}

.todo-dashboard {
    width: min(100%, var(--container-content));
    min-height: 100vh;
    margin: 0 auto;
    padding: var(--space-36) var(--space-6) var(--space-32);
}

.todo-dashboard:focus {
    outline: none;
}

.todo-dashboard__title {
    color: var(--color-text);
    font-size: var(--font-size-5xl);
    font-weight: var(--font-weight-extrabold);
    letter-spacing: -0.04em;
    line-height: 1.05;
}

.todo-search {
    position: relative;
    margin-top: var(--space-11);
}

.todo-search__icon {
    position: absolute;
    top: 50%;
    left: var(--space-4-5);
    display: grid;
    color: var(--color-text-subtle);
    pointer-events: none;
    transform: translateY(-50%);
}

.todo-search__input {
    width: 100%;
    height: var(--space-14);
    padding: 0 var(--space-5) 0 var(--space-13);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-sm);
    font-size: var(--font-size-base);
    line-height: 1.5;
    outline: none;
    transition:
        border-color var(--duration-fast) ease,
        box-shadow var(--duration-fast) ease;
}

.todo-search__input::placeholder {
    color: var(--color-text-subtle);
}

.todo-search__input:focus {
    border-color: var(--color-brand);
    box-shadow:
        var(--shadow-focus),
        var(--shadow-sm);
}

.todo-search__input::-webkit-search-cancel-button {
    display: none;
}

.todo-section {
    margin-top: var(--space-14);
}

.todo-list {
    border-top: 1px solid var(--color-border);
}

.todo-list__item {
    border-bottom: 1px solid var(--color-border);
}

.todo-list__link {
    display: flex;
    min-height: var(--space-17);
    align-items: center;
    justify-content: space-between;
    gap: var(--space-8);
    margin: 0 calc(-1 * var(--space-3));
    padding: var(--space-5) var(--space-3);
    border-radius: var(--radius-lg);
    transition:
        background-color var(--duration-fast) ease,
        color var(--duration-fast) ease;
}

.todo-list__link:hover,
.todo-list__link:focus-visible {
    background: var(--color-surface-subtle);
}

.todo-list__link:focus-visible {
    outline-offset: -2px;
}

.todo-list__title {
    min-width: 0;
    color: var(--color-text-strong);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.012em;
    line-height: 1.55;
}

.todo-list__priority {
    width: var(--space-13);
    flex: 0 0 var(--space-13);
    text-align: right;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: var(--space-5);
}

.todo-list__priority--high {
    color: var(--color-priority-high);
}

.todo-list__priority--medium {
    color: var(--color-priority-medium);
}

.todo-list__priority--low {
    color: var(--color-priority-low);
}

.todo-list__priority--unknown {
    color: var(--color-priority-unknown);
}

.todo-priority-marker {
    display: inline-block;
    width: var(--space-2);
    height: var(--space-2);
    flex: 0 0 var(--space-2);
    border-radius: var(--radius-full);
    vertical-align: 0.08em;
}

.todo-priority-marker--high {
    background: var(--color-priority-high);
}

.todo-priority-marker--medium {
    background: var(--color-priority-medium);
}

.todo-priority-marker--low {
    background: var(--color-priority-low);
}

.todo-priority-marker--unknown {
    background: var(--color-priority-unknown);
}

.todo-list__empty {
    padding: var(--space-8) 0;
    color: var(--color-text-muted);
    font-size: var(--font-size-body-sm);
}

.todo-history {
    margin-top: var(--space-28);
}

.todo-history__title {
    margin-bottom: var(--space-6);
    color: var(--color-text);
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--tracking-tight);
    line-height: 1.3;
}

.todo-list--history .todo-list__link {
    justify-content: flex-start;
}

.todo-list--history .todo-list__title {
    font-size: var(--font-size-base);
}

/* Dialog */
.todo-dialog {
    width: calc(100vw - var(--space-12));
    max-width: none;
    height: calc(100dvh - var(--space-12));
    max-height: none;
    margin: auto;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-3xl);
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: var(--shadow-dialog);
}

.todo-dialog[open] {
    animation: todo-dialog-enter var(--duration-dialog) ease-out both;
}

.todo-dialog[open]:not(:modal) {
    position: fixed;
    inset: calc(var(--header-height) + 1px) 0 0;
    width: 100%;
    height: calc(100dvh - var(--header-height) - 1px);
    margin: 0;
    border-radius: 0;
    animation: none;
}

.todo-dialog::backdrop {
    background: rgb(var(--palette-gray-900) / 0.72);
    animation: todo-backdrop-enter var(--duration-dialog) ease-out both;
}

.todo-dialog.todo-dialog--closing {
    animation: todo-dialog-leave var(--duration-dialog) ease-in both;
}

.todo-dialog.todo-dialog--closing::backdrop {
    animation: todo-backdrop-leave var(--duration-dialog) ease-in both;
}

.todo-dialog__viewport {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
    flex-direction: column;
}

.todo-dialog__toolbar {
    position: relative;
    z-index: 2;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    min-height: var(--space-19);
    padding: var(--space-4) var(--space-8);
    background: var(--color-surface);
}

.todo-dialog__back {
    padding: var(--space-2) 0;
    border: 0;
    background: transparent;
    color: var(--color-priority-unknown);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    line-height: var(--space-5);
    transition: color var(--duration-fast) ease;
}

.todo-dialog__back:hover {
    color: var(--color-text);
}

.todo-dialog__scroller {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scroll-padding-top: var(--space-8);
}

.todo-dialog__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, var(--container-reading)) minmax(0, 1fr);
    min-height: 100%;
    padding: var(--space-4) var(--space-6) var(--space-32);
}

.todo-document {
    grid-column: 2;
    width: 100%;
    min-width: 0;
}

.todo-document__header {
    margin-bottom: var(--space-16);
}

.todo-document__title {
    color: var(--color-text);
    font-size: 2.75rem;
    font-weight: var(--font-weight-extrabold);
    letter-spacing: -0.042em;
    line-height: 1.12;
    overflow-wrap: anywhere;
}

.todo-document__metadata {
    display: grid;
    gap: var(--space-2-5);
    margin-top: var(--space-9);
    color: var(--color-text-secondary);
    font-size: var(--font-size-body-sm);
    line-height: 1.6;
}

.todo-document__metadata > div {
    display: grid;
    grid-template-columns: var(--space-28) minmax(0, 1fr);
    gap: var(--space-4);
}

.todo-document__metadata dt {
    color: var(--color-text-muted);
    font-weight: var(--font-weight-medium);
}

.todo-document__metadata dd {
    min-width: 0;
    color: var(--color-text-secondary);
    overflow-wrap: anywhere;
}

.todo-document__metadata a,
.todo-document__body a {
    color: var(--color-link);
    text-decoration: underline;
    text-decoration-color: rgb(var(--palette-red-700) / 0.35);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    transition:
        color var(--duration-fast) ease,
        text-decoration-color var(--duration-fast) ease;
}

.todo-document__metadata a:hover,
.todo-document__body a:hover {
    color: var(--color-link-hover);
    text-decoration-color: currentColor;
}

.todo-document__body {
    color: var(--color-text-secondary);
    font-size: var(--font-size-body);
    line-height: 1.78;
    overflow-wrap: break-word;
}

.todo-document__body > :first-child {
    margin-top: 0;
}

.todo-document__body h2,
.todo-document__body h3,
.todo-document__body h4 {
    color: var(--color-text);
    font-weight: var(--font-weight-bold);
    letter-spacing: var(--tracking-tight);
    scroll-margin-top: var(--space-8);
}

.todo-document__body h2 {
    margin-top: var(--space-18);
    margin-bottom: var(--space-6);
    font-size: 1.75rem;
    line-height: 1.35;
}

.todo-document__body h3 {
    margin-top: var(--space-12);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-xl);
    line-height: 1.45;
}

.todo-document__body h4 {
    margin-top: var(--space-9);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-body);
    line-height: 1.5;
}

.todo-document__body p,
.todo-document__body ul,
.todo-document__body ol,
.todo-document__body blockquote,
.todo-document__body pre,
.todo-document__body .todo-document__table-scroll {
    margin-top: var(--space-5);
    margin-bottom: var(--space-5);
}

.todo-document__body ul,
.todo-document__body ol {
    padding-left: 1.6rem;
}

.todo-document__body ul {
    list-style: disc;
}

.todo-document__body ol {
    list-style: decimal;
}

.todo-document__body li + li {
    margin-top: 0.45rem;
}

.todo-document__body li > ul,
.todo-document__body li > ol {
    margin-top: 0.45rem;
    margin-bottom: 0;
}

.todo-document__body strong {
    color: var(--color-text-strong);
    font-weight: var(--font-weight-bold);
}

.todo-document__body code {
    border-radius: 0.3rem;
    background: var(--color-surface-muted);
    padding: 0.14em 0.34em;
    color: var(--color-text-strong);
    font-size: 0.88em;
}

.todo-document__body pre {
    max-width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-xl);
    background: var(--color-text);
    padding: var(--space-5) var(--space-6);
    color: var(--color-surface-muted);
    font-size: var(--font-size-sm);
    line-height: 1.7;
    tab-size: 4;
}

.todo-document__body pre code {
    border-radius: 0;
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.todo-document__body blockquote {
    border-left: 3px solid rgb(var(--palette-gray-300));
    padding-left: var(--space-5);
    color: var(--color-priority-unknown);
}

.todo-document__body blockquote > :first-child {
    margin-top: 0;
}

.todo-document__body blockquote > :last-child {
    margin-bottom: 0;
}

.todo-document__body hr {
    margin: var(--space-14) 0;
    border: 0;
    border-top: 1px solid var(--color-border);
}

.todo-document__table-scroll {
    max-width: 100%;
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
}

.todo-document__body table {
    width: 100%;
    min-width: 36rem;
    border-collapse: collapse;
    font-size: var(--font-size-body-sm);
    line-height: 1.55;
}

.todo-document__body th,
.todo-document__body td {
    padding: 0.8rem var(--space-4);
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    vertical-align: top;
}

.todo-document__body th:last-child,
.todo-document__body td:last-child {
    border-right: 0;
}

.todo-document__body tr:last-child td {
    border-bottom: 0;
}

.todo-document__body th {
    background: var(--color-surface-subtle);
    color: var(--color-text-strong);
    font-weight: var(--font-weight-semibold);
}

.todo-document__body input[type="checkbox"] {
    width: var(--space-4);
    height: var(--space-4);
    margin-right: 0.45rem;
    accent-color: var(--color-brand);
    vertical-align: -0.1em;
}

.todo-document__body .contains-task-list,
.todo-document__body .task-list-item {
    list-style: none;
}

.todo-document__body .contains-task-list {
    padding-left: 0;
}

.todo-toc-rail {
    grid-column: 3;
    min-width: 0;
    padding-left: clamp(var(--space-8), 4vw, var(--space-18));
}

.todo-toc-rail[hidden] {
    display: none;
}

.todo-toc {
    position: sticky;
    top: var(--space-4);
    width: min(100%, 11rem);
}

.todo-toc__label {
    margin-bottom: var(--space-4);
    color: var(--color-text-secondary);
    font-size: var(--font-size-caption);
    font-weight: var(--font-weight-bold);
    line-height: var(--space-5);
}

.todo-toc__list {
    display: grid;
    gap: 0.7rem;
}

.todo-toc__link {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--font-size-caption);
    line-height: 1.45;
    overflow-wrap: anywhere;
    transition: color var(--duration-fast) ease;
}

.todo-toc__link:hover,
.todo-toc__link:focus-visible {
    color: var(--color-text);
}

.todo-toc__item--depth-3 {
    padding-left: var(--space-3);
}

@keyframes todo-dialog-enter {
    from {
        opacity: 0;
        transform: translateY(6px) scale(0.995);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes todo-dialog-leave {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(4px) scale(0.997);
    }
}

@keyframes todo-backdrop-enter {
    from {
        background: rgb(var(--palette-gray-900) / 0);
    }
    to {
        background: rgb(var(--palette-gray-900) / 0.72);
    }
}

@keyframes todo-backdrop-leave {
    from {
        background: rgb(var(--palette-gray-900) / 0.72);
    }
    to {
        background: rgb(var(--palette-gray-900) / 0);
    }
}

@media (max-width: 1024px) {
    .todo-dialog {
        width: 100vw;
        height: 100dvh;
        margin: 0;
        border-radius: 0;
    }

    .todo-dialog__toolbar {
        min-height: calc(var(--space-16) + env(safe-area-inset-top));
        padding: calc(var(--space-3) + env(safe-area-inset-top)) var(--space-6) var(--space-3);
    }

    .todo-dialog__layout {
        display: block;
        padding: var(--space-5) var(--space-6) calc(var(--space-20) + env(safe-area-inset-bottom));
    }

    .todo-toc-rail {
        display: none !important;
    }
}

@media (max-width: 639px) {
    .todo-dashboard {
        padding: var(--space-33) var(--space-5) var(--space-24);
    }

    .todo-dashboard__title {
        font-size: var(--font-size-4xl);
        letter-spacing: -0.035em;
    }

    .todo-search {
        margin-top: var(--space-9);
    }

    .todo-search__input {
        height: var(--space-13);
        padding-left: var(--space-12);
    }

    .todo-search__icon {
        left: var(--space-4);
    }

    .todo-section {
        margin-top: var(--space-12);
    }

    .todo-list__link {
        gap: var(--space-5);
        padding-top: var(--space-4);
        padding-bottom: var(--space-4);
    }

    .todo-list__title {
        font-size: var(--font-size-base);
    }

    .todo-history {
        margin-top: var(--space-22);
    }

    .todo-dialog__toolbar {
        padding-right: var(--space-5);
        padding-left: var(--space-5);
    }

    .todo-dialog__layout {
        padding-right: var(--space-5);
        padding-left: var(--space-5);
    }

    .todo-document__header {
        margin-bottom: var(--space-12);
    }

    .todo-document__title {
        font-size: 2rem;
        line-height: 1.18;
    }

    .todo-document__metadata {
        margin-top: var(--space-7);
    }

    .todo-document__metadata > div {
        grid-template-columns: var(--space-22) minmax(0, 1fr);
        gap: var(--space-3);
    }

    .todo-document__body {
        font-size: var(--font-size-base);
        line-height: 1.75;
    }

    .todo-document__body h2 {
        margin-top: var(--space-15);
        font-size: var(--font-size-2xl);
    }

    .todo-document__body h3 {
        margin-top: var(--space-10);
        font-size: 1.1875rem;
    }

    .todo-document__body pre {
        margin-right: calc(-1 * var(--space-1));
        margin-left: calc(-1 * var(--space-1));
        padding: var(--space-4);
    }
}

@media (prefers-reduced-motion: reduce) {
    .todo-page *,
    .todo-page *::before,
    .todo-page *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .todo-dialog[open],
    .todo-dialog.todo-dialog--closing {
        transform: none;
    }
}
