/* ========== Week planner ========== */
.week-section {
    padding-top: 5rem;
    padding-bottom: 3rem;
}

/* ── Header ── */
.week-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.week-header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ── Spread: 4-column grid, 2 rows ── */
.week-spread {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2.5rem;
}

.week-spread .week-day-cell:nth-child(4n) { border-right: none; }
.week-spread .week-day-cell:nth-child(n+5) { border-bottom: none; }

/* ── Day cell ── */
.week-day-cell {
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    min-height: 240px;
    padding: 0;
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.week-day-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem 0.4rem;
    min-height: 2.25rem;
    box-sizing: border-box;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-dark);
}

.week-today-link {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    text-decoration: none;
    border-radius: 6px;
    transition: opacity 0.15s;
}

.week-today-link:hover {
    opacity: 0.75;
}

/* ── Day header labels ── */
.week-day-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.week-day-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.week-day-today {
    color: var(--accent) !important;
}

.week-today-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Tasks inside a day ── */
.week-day-tasks {
    flex: 1;
    padding: 0.4rem 0.5rem;
    overflow-y: auto;
    min-height: 2rem;
    max-height: 340px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.week-day-tasks::-webkit-scrollbar {
    width: 4px;
}

.week-day-tasks::-webkit-scrollbar-track {
    background: transparent;
}

.week-day-tasks::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.week-day-tasks:hover::-webkit-scrollbar-thumb {
    background: var(--text-muted);
}

.week-day-tasks .task-item,
.week-task-item {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: default;
    transition: background 0.15s;
}

.week-task-item:hover {
    background: var(--accent-glow);
}

.week-task-item[data-task-id] {
    cursor: grab;
}

.week-task-item[data-task-id]:active {
    cursor: grabbing;
}

/* Task title: always wrap inside the spread (overrides tasks.css truncation).
   The title group is normal flowing text (not flex) so the title and the
   trailing tags/time cluster behave like a paragraph with an inline badge:
   the badge tucks into whatever space is left at the end of the last
   wrapped line, and only drops to its own line when it truly doesn't fit
   there — a flex row can only place the badge before or fully below the
   title, never mid-line, which wasted space after a short trailing line. */
.week-day-tasks .task-title-group {
    display: block;
    overflow: visible !important;
}
.week-day-tasks .task-title {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: unset !important;
    overflow-wrap: break-word;
    line-height: 1.35;
}
.week-day-tasks .task-title-meta {
    margin-left: 0.4rem;
    vertical-align: middle;
}


.week-task-done .week-task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ── Week task checkbox — circular Material Icons ── */
.week-complete-icon {
    font-family: 'Material Icons';
    font-size: 18px;
    font-weight: normal;
    font-style: normal;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    color: var(--text-muted);
    transition: color 0.2s;
    line-height: 1;
    user-select: none;
}

.week-complete-icon:hover {
    color: var(--accent);
}

.week-complete-icon.checkbox-icon-done {
    color: var(--green);
}

.week-task-done .week-complete-icon {
    color: var(--green);
}


/* ── Drop zone highlight ── */
.week-drop-zone {
    transition: background-color 0.15s, box-shadow 0.15s;
    min-height: 2rem;
}

.week-drop-zone.week-drag-over,
.week-project-drop-zone.week-drag-over {
    background: var(--accent-glow);
    box-shadow: inset 0 0 0 2px var(--accent);
    border-radius: 4px;
}


.week-task-item .week-day-unschedule-btn .material-icons,
.week-task-item .unschedule-btn .material-icons {
    font-size: 15px;
}

.week-task-item .week-day-archive-btn .material-icons,
.week-task-item .archive-btn .material-icons {
    font-size: 15px;
}

@media (hover: none) {
    .week-task-item .icon-btn {
        opacity: 1;
    }
}

/* Hover-revealed action buttons (unschedule/archive) overlay the row on
   pointer devices instead of reserving inline flex width. In these
   already-narrow day columns, `.task-item-actions` (two icon-btns, ~48px
   combined at the 15px icon size used here, see the font-size overrides
   above) was eating a meaningful share of a row's width *permanently* —
   it's hidden via `opacity:0` at rest (tasks.css), not `display:none`, so
   it still occupied its full flex-layout footprint even when invisible.
   Taking it out of flow lets `.task-item-content` (flex:1) claim that
   width for the title instead, with no reflow on hover since the title's
   own box never changes size — the pill just appears on top of it.
   Scoped to `hover:hover` because touch devices already show these
   buttons permanently (see the block above) and have plenty of row width
   at the single-column mobile breakpoint, so there's nothing to reclaim
   there and no reason to risk the icons overlapping tapped text. */
@media (hover: hover) {
    .week-day-tasks .task-item {
        position: relative;
    }

    .week-day-tasks .task-item-actions {
        position: absolute;
        top: 0.15rem;
        right: 0.3rem;
        background: var(--bg-card);
        border-radius: 20px;
        padding: 1px 3px;
        box-shadow: var(--shadow-drop);
        opacity: 0;
        /* Invisible-but-absolutely-positioned at rest — without this it can
           still intercept clicks meant for whatever sits underneath it
           (e.g. an "Add a task" row's own controls in the same corner). */
        pointer-events: none;
        transition: opacity 0.15s;
        z-index: 1;
    }

    .week-day-tasks .task-item:hover .task-item-actions,
    .week-day-tasks .task-item:focus-within .task-item-actions {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ── This Week column ── */
.week-this-week-cell {
    border-left: 2px solid var(--amber) !important;
}

.week-this-week-header {
    background: rgba(212, 131, 86, 0.06) !important;
    align-items: center !important;
    gap: 0.4rem;
}

.week-this-week-icon {
    font-size: 14px !important;
    line-height: 1;
    color: var(--amber);
    flex-shrink: 0;
}

.week-this-week-label {
    line-height: 1;
    color: var(--amber) !important;
}

.week-this-week-drop-zone.week-drag-over {
    background: var(--amber-glow) !important;
    box-shadow: inset 0 0 0 2px var(--amber) !important;
    border-radius: 4px;
}

/* ── Unscheduled strip ── */
.week-unscheduled-item {
    cursor: grab;
}

.week-unscheduled-item:active {
    cursor: grabbing;
}

.week-unscheduled-bullet {
    font-size: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ── Responsive ── */

/* Shrunk desktop / tablet landscape: 3 columns.
   A laptop window un-maximized to ~1000-1300px (a very common width —
   half-tiled windows, 13" laptops, iPad-landscape-ish viewports) has
   room for a genuinely readable 3rd column but not a comfortable 4th
   one; jumping straight to 2 columns there under-uses the width and
   shows fewer days at a glance than the view's "see the whole week"
   purpose calls for.

   The grid holds 8 cells (7 days + the "this week" bucket, current week
   only) which doesn't divide evenly into 3 — the last row only fills 2
   of 3 columns. That's fine to leave as-is rather than special-cased:
   `nth-child(n+7)` already targets exactly that last row (cells 7-8, or
   just 7 on non-current weeks) for the bottom-border suppression, same
   offset as the 2-column tier below. For the right border, only
   `nth-child(3n)` (cells 3, 6) needs suppressing — the trailing empty
   grid slot in the partial row has no cell to render a border on, and
   it shows through as the grid's own `--border-color` background, which
   is visually identical to a border line, so cell 8's right border
   (left in place) is an invisible seam against it. */
@media (max-width: 1300px) {
    .week-spread[data-cols],
    .week-spread {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .week-spread .week-day-cell {
        border-right: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
    }
    .week-spread .week-day-cell:nth-child(3n) { border-right: none; }
    .week-spread .week-day-cell:nth-child(n+7) { border-bottom: none; }
}

/* Narrow tablet / phone landscape: 2 columns. */
@media (max-width: 900px) {
    .week-spread[data-cols],
    .week-spread {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    /* Reset all per-layout border rules and apply 2-col rules */
    .week-spread .week-day-cell {
        border-right: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
    }
    .week-spread .week-day-cell:nth-child(2n) { border-right: none; }
    .week-spread .week-day-cell:nth-child(n+7) { border-bottom: none; }
}

/* Mobile: 1 column */
@media (max-width: 540px) {
    .week-spread[data-cols],
    .week-spread {
        grid-template-columns: 1fr;
    }
    .week-day-cell {
        min-height: auto;
        border-right: none !important;
    }
    .week-spread .week-day-cell { border-bottom: 1px solid var(--border-color); }
    .week-spread .week-day-cell:last-child { border-bottom: none; }
}
