/* Objectives and their task trees. Buttons, status badges and progress bars
   come from application.css; this file only lays out the cards and rows.
   Task rows keep their secondary actions quiet (ghost and icon buttons) so
   the title and checkbox stay the obvious thing to look at. */

/* ---------- Index cards --------------------------------------------------------- */

.objectives-list {
    display: grid;
    gap: 16px;
}

.objective-card {
    transition: box-shadow 0.2s var(--ease-out), border-color 0.2s;
}

.objective-card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
}

.objective-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.objective-title-row h2 {
    font-size: 1.15rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.objective-title-row h2 a {
    color: var(--ink);
    text-decoration: none;
}

.objective-title-row h2 a:hover {
    color: var(--teal-ink);
}

.objective-description {
    margin-bottom: 14px;
    color: var(--body);
    font-size: 0.93rem;
    line-height: 1.55;
}

.objective-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.progress-text {
    min-width: 40px;
    color: var(--ink-soft);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.objective-tasks {
    margin-bottom: 8px;
    border-top: 1px solid var(--line-soft);
}

.task-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-soft);
}

.task-item:last-child {
    border-bottom: none;
}

.task-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
}

.task-toggle .task-checkbox {
    margin-top: 2px;
}

.task-title {
    color: var(--ink-soft);
    font-size: 0.94rem;
    line-height: 1.4;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.task-title.completed {
    color: var(--faint);
    text-decoration: line-through;
}

.task-notes {
    display: block;
    margin: 3px 0 0 28px;
    color: var(--muted);
    font-size: 0.86rem;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.task-deadline {
    color: var(--muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.objective-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-top: 6px;
}

.objective-meta {
    color: var(--muted);
    font-size: 0.82rem;
}

/* ---------- Detail ----------------------------------------------------------------- */

.objective-detail {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.objective-detail-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.objective-detail-header h1 {
    font-size: clamp(1.5rem, 3.4vw, 1.9rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    overflow-wrap: anywhere;
}

.objective-detail-description {
    color: var(--body);
    font-size: 0.98rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

.objective-detail-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
}

.objective-detail-progress .progress-bar {
    flex: none;
    height: 10px;
    background: var(--line);
}

.tasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.tasks-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    font-weight: 700;
}

.tasks-count {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--muted);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 600;
}

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.subtasks-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 6px 0 0 18px;
    padding-left: 14px;
    border-left: 2px solid var(--line);
}

.subtasks-list[hidden] {
    display: none;
}

.task-item-large {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 10px 10px 4px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: border-color 0.15s, background-color 0.15s;
}

.task-item-large:hover {
    border-color: var(--line-strong);
}

.task-content,
.task-summary {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 3px;
}

.task-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    margin: 6px 0 0 28px;
}

.task-scheduled {
    color: var(--teal-ink);
    font-size: 0.78rem;
    font-weight: 600;
}

.task-inline-action {
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 0.78rem;
    text-decoration: underline;
    cursor: pointer;
}

.task-inline-action:hover {
    color: var(--danger);
}

.task-actions {
    display: flex;
    flex: none;
    align-items: center;
    gap: 2px;
}

/* Secondary actions stay faint until the row is hovered or focused. */
.task-item-large .task-actions {
    opacity: 0.55;
    transition: opacity 0.15s;
}

.task-item-large:hover .task-actions,
.task-item-large:focus-within .task-actions {
    opacity: 1;
}

.task-drag-handle {
    flex: none;
    width: 22px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--faint);
    font-size: 0.8rem;
    letter-spacing: -2px;
    cursor: grab;
}

.task-drag-handle:hover {
    color: var(--ink-soft);
    background: var(--surface-sunken);
}

.task-drag-handle:active {
    cursor: grabbing;
}

.task-tree-item.is-dragging {
    opacity: 0.45;
}

.task-sort-status:empty {
    display: none;
}

.task-sort-status {
    color: var(--body);
    font-size: 0.88rem;
}

/* Updates: a dated log of how the objective is moving, newest first. */

.objective-note-form {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.objective-note-form textarea {
    width: 100%;
    box-sizing: border-box;
}

.objective-notes-empty {
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.objective-notes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.objective-note {
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.objective-note-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
}

.objective-note-body {
    color: var(--body);
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.objective-note-body p {
    margin: 4px 0 0;
}

.objective-note-edit {
    margin-top: 6px;
    font-size: 0.8rem;
}

.objective-note-edit summary {
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

.objective-note-edit[open] summary {
    margin-bottom: 6px;
}

.objective-detail-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}

.objective-delete-form {
    margin-left: auto;
}

.task-show {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.task-show-notes p {
    color: var(--body);
    line-height: 1.6;
}

.task-index-list {
    padding-block: 8px;
}

@media (hover: none) {
    .task-item-large .task-actions {
        opacity: 1;
    }
}

@media (max-width: 640px) and (pointer: fine) {
    .task-item-large {
        flex-wrap: wrap;
    }

    .task-content {
        flex: 1 1 calc(100% - 40px);
    }

    .task-actions {
        flex: 1 1 100%;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

@media (max-width: 640px) {
    .subtasks-list {
        margin-left: 8px;
        padding-left: 10px;
    }
}

/* ---------- Task view toggle & board --------------------------------------- */

.tasks-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tasks-view-toggle {
    padding: 3px;
}

.tasks-view-btn {
    padding: 5px 14px;
    border-radius: 9px;
    color: var(--body);
    font-size: 0.84rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.tasks-view-btn:hover {
    color: var(--ink);
}

.tasks-view-btn.active {
    background: var(--surface);
    color: var(--teal-ink);
    box-shadow: var(--shadow-sm);
}

.task-status-badge {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.task-status-badge.status-in-progress {
    background: var(--indigo-wash);
    color: var(--indigo);
}

.task-status-badge.status-blocked {
    background: var(--danger-wash);
    color: var(--danger-ink);
}

.task-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
}

.board-status {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.board-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 160px;
    padding: 12px;
    border: 1px solid var(--line);
    border-top: 3px solid var(--faint);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    transition: border-color 0.15s, background-color 0.15s;
}

.board-column-in-progress { border-top-color: var(--indigo); }
.board-column-blocked { border-top-color: var(--danger); }
.board-column-done { border-top-color: var(--green); }

.board-column.is-drop-target {
    border-color: var(--teal);
    background: var(--teal-wash);
}

.board-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.board-column-header h3 {
    margin: 0;
    font-size: 0.9rem;
}

.board-column-count {
    min-width: 24px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--surface-sunken);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.board-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.board-empty {
    margin: 0;
    padding: 16px 0;
    color: var(--faint);
    font-size: 0.8rem;
    text-align: center;
}

.board-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: grab;
}

.board-card.is-dragging {
    opacity: 0.45;
}

.board-card-title {
    color: var(--ink);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.board-card-title:hover {
    color: var(--teal-ink);
}

.board-column-done .board-card-title {
    color: var(--muted);
    text-decoration: line-through;
}

.board-card-note {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    font-style: italic;
}

.board-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    color: var(--faint);
    font-size: 0.74rem;
}

.board-card-footer {
    display: flex;
    align-items: center;
    gap: 6px;
}

.board-card-footer .board-card-status {
    flex: 1;
    min-width: 0;
}

.board-card-priority {
    display: inline-flex;
    flex: none;
    gap: 2px;
}

.board-card-blocker {
    display: grid;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 8px;
    background: var(--surface-sunken);
    font-size: 0.78rem;
}

.board-card-blocker.is-long-blocked {
    background: var(--danger-wash);
    color: var(--danger-ink);
}

.board-card-blocker p {
    margin: 0;
}

.board-card-blocker-since {
    color: var(--faint);
    font-size: 0.72rem;
}

.board-card-blocker.is-long-blocked .board-card-blocker-since {
    color: var(--danger-ink);
    font-weight: 600;
}

.board-card-blocker-edit summary {
    cursor: pointer;
    font-weight: 600;
}

.board-card-blocker-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    margin-top: 4px;
}

.board-card-blocker-form input[type="text"] {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.board-subtasks {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.board-subtask {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
}

.board-card-status select {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-xs);
    background: var(--surface-soft);
    color: var(--body);
    font-size: 0.78rem;
}

@media (max-width: 900px) {
    .task-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.board-column-tabs {
    display: none;
}

@media (max-width: 560px) {
    .task-board {
        grid-template-columns: minmax(0, 1fr);
    }

    .has-column-tabs .board-column-tabs {
        position: sticky;
        top: 68px;
        z-index: 5;
        display: flex;
        gap: 2px;
        overflow-x: auto;
        scrollbar-width: none;
        padding: 4px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
    }

    .has-column-tabs .board-column:not(.is-current) {
        display: none;
    }

    .tasks-header {
        flex-wrap: wrap;
    }
}

.board-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* Objective names can be long; a chip wraps rather than running off a
   phone's screen. Short ones still sit on one line. */
.board-filters .chip {
    max-width: 100%;
    text-decoration: none;
    white-space: normal;
    overflow-wrap: anywhere;
}

.board-filters .chip:hover {
    color: var(--ink);
}

.board-column-note {
    margin: -4px 0 0;
    color: var(--faint);
    font-size: 0.74rem;
}

.board-card-objective {
    color: var(--teal-ink);
    font-size: 0.74rem;
    font-weight: 500;
}

.board-wip-nudge {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--indigo-wash);
    color: var(--body);
    font-size: 0.78rem;
    line-height: 1.4;
}

.board-wip-nudge p {
    flex: 1;
    margin: 0;
}

.board-wip-dismiss {
    flex: none;
    border: 0;
    background: transparent;
    color: var(--faint);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0 2px;
}

.board-wip-dismiss:hover {
    color: var(--ink);
}

.board-column-tab {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 44px;
    padding: 0 4px;
    border: none;
    border-radius: 8px;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.board-column-tab[aria-selected="true"] {
    background: var(--indigo-wash);
    color: var(--indigo);
}

.board-column-tab .board-column-count {
    min-width: 0;
    padding: 1px 6px;
}

.board-column-tab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(91, 108, 240, 0.25);
}

/* Fingers need bigger targets than the compact desktop controls. 16px text
   also stops iOS from zooming in when the select opens. */
@media (pointer: coarse) {
    .board-card-status select {
        min-height: 44px;
        font-size: 16px;
    }

    .board-card-priority .tray-priority-btn,
    .tray-task-priority .tray-priority-btn {
        min-width: 44px;
        min-height: 44px;
        font-size: 1rem;
    }
}

/* Touch screens: one ⋯ button opens the task's actions in the bottom sheet
   instead of a row of small buttons, and the drag handle (mouse only) goes. */
.task-more {
    display: none;
}

@media (pointer: coarse) {
    .task-item-large .task-actions > :not([data-task-collapse-target="toggle"]),
    .task-drag-handle {
        display: none;
    }

    .task-item-large .task-actions {
        flex: none;
    }

    .task-more {
        display: grid;
        place-items: center;
        flex: none;
        width: 44px;
        height: 44px;
        margin: -8px -8px -8px 0;
        border: 0;
        border-radius: 12px;
        background: none;
        color: var(--muted);
        font-size: 1.4rem;
        line-height: 1;
        cursor: pointer;
    }

    .task-more:active {
        background: var(--surface-sunken);
    }
}
