/*
    INTERACTIVE EISENHOWER MATRIX

    Markup: src/includes/eisenhower-matrix-tool.njk, behaviour:
    eisenhower-matrix-tool.N.js. Uses the --pf-* tokens of the site-wide
    "modern shell" in index.NN.css. The deploy caches this file for a year:
    bump N in its name (and in the include) whenever it changes.
*/

.eisenhower {
    --em-ink: var(--text-color-light);
    --em-muted: #77746f;
    --em-button-bg: rgba(255, 255, 255, 0.75);
    --em-button-bg-hover: #fff;
    --em-line: var(--pf-line);
    --em-field: rgba(255, 255, 255, 0.85);
    --em-task: rgba(255, 255, 255, 0.8);
    --em-do: rgba(229, 134, 106, 0.16);
    --em-schedule: rgba(249, 212, 119, 0.3);
    --em-delegate: rgba(143, 163, 199, 0.18);
    --em-eliminate: rgba(49, 48, 48, 0.05);

    max-width: 760px;
    margin: 30px auto 40px;
    font-family: var(--pf-font);
    font-weight: 400;
    letter-spacing: normal;
    color: var(--em-ink);
    scroll-margin-top: 40px;
}

body.dark .eisenhower {
    --em-ink: var(--text-color-dark);
    --em-muted: rgba(255, 255, 255, 0.62);
    --em-button-bg: rgba(255, 255, 255, 0.08);
    --em-button-bg-hover: rgba(255, 255, 255, 0.16);
    --em-line: var(--pf-line-dark);
    --em-field: rgba(255, 255, 255, 0.08);
    --em-task: rgba(255, 255, 255, 0.07);
    --em-do: rgba(229, 134, 106, 0.16);
    --em-schedule: rgba(249, 212, 119, 0.14);
    --em-delegate: rgba(143, 163, 199, 0.16);
    --em-eliminate: rgba(255, 255, 255, 0.04);
}

.eisenhower__card {
    padding: 22px 24px;
    border: 1px solid var(--em-line);
    border-radius: 18px;
    background: var(--pf-surface);
    box-shadow: var(--pf-shadow-card), var(--pf-inset);
}

/* adding a task */

.eisenhower__add {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.eisenhower__input {
    flex: 1 1 260px;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid var(--em-line);
    border-radius: 999px;
    background: var(--em-field);
    color: inherit;
    font: inherit;
    font-size: 16px;
}

.eisenhower__input:focus {
    border-color: var(--pf-primary-deep);
    outline: 2px solid rgba(254, 190, 22, 0.35);
    outline-offset: 0;
}

.eisenhower__flags {
    display: flex;
    gap: 8px;
}

.eisenhower__flag {
    padding: 0.4rem 0.95rem;
    border: 1.5px solid var(--em-line);
    border-radius: 2rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.eisenhower__flag:hover {
    border-color: var(--pf-primary-deep);
    background-color: rgba(255, 212, 101, 0.15);
}

.eisenhower__flag[aria-pressed="true"] {
    border-color: var(--pf-primary-deep);
    background-color: var(--pf-primary);
    color: var(--pf-ink);
    font-weight: 500;
}

.eisenhower__flag[aria-pressed="true"]::before {
    content: "✓ ";
}

.eisenhower__hint {
    display: block;
    margin-top: 8px;
    color: var(--em-muted);
    font-size: 14px;
}

/* the matrix */

.eisenhower__matrix {
    display: grid;
    grid-template-columns: 22px 1fr 1fr;
    grid-template-rows: auto 1fr 1fr;
    grid-template-areas:
        ".         urgent    not-urgent"
        "important do        schedule"
        "not-imp   delegate  eliminate";
    gap: 8px;
    margin-top: 18px;
}

.eisenhower__axis {
    color: var(--em-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
}

.eisenhower__axis--urgent { grid-area: urgent; }
.eisenhower__axis--not-urgent { grid-area: not-urgent; }

.eisenhower__axis--important,
.eisenhower__axis--not-important {
    align-self: center;
    justify-self: center;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.eisenhower__axis--important { grid-area: important; }
.eisenhower__axis--not-important { grid-area: not-imp; }

.eisenhower__quadrant {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 170px;
    padding: 14px 14px 12px;
    border: 1.5px solid transparent;
    border-radius: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.eisenhower__quadrant--do { grid-area: do; background: var(--em-do); }
.eisenhower__quadrant--schedule { grid-area: schedule; background: var(--em-schedule); }
.eisenhower__quadrant--delegate { grid-area: delegate; background: var(--em-delegate); }
.eisenhower__quadrant--eliminate { grid-area: eliminate; background: var(--em-eliminate); }

.eisenhower__quadrant.is-drop-target {
    border-color: var(--pf-primary-deep);
    box-shadow: 0 0 0 3px rgba(254, 190, 22, 0.25);
}

.eisenhower__quadrant-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.eisenhower__quadrant-title {
    font-size: 17px;
    font-weight: 600;
}

.eisenhower__count {
    min-width: 1.6em;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--em-button-bg);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.eisenhower__count:empty {
    display: none;
}

.eisenhower__quadrant-sub {
    color: var(--em-muted);
    font-size: 13px;
}

.eisenhower .eisenhower__list {
    max-width: none;
    margin: 10px 0 0;
    padding: 0;
    font-size: 15px;
    line-height: 1.35;
    letter-spacing: normal;
    list-style: none;
}

.eisenhower__empty {
    margin-top: auto;
    padding-top: 10px;
    color: var(--em-muted);
    font-size: 13px;
    line-height: 1.45;
}

.eisenhower__quadrant:not(.is-empty) .eisenhower__empty {
    display: none;
}

/* a task */

.eisenhower__task {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 4px 6px 2px;
    border-radius: 10px;
    background: var(--em-task);
    box-shadow: var(--pf-shadow-sm);
    user-select: none;
    -webkit-user-select: none;
}

.eisenhower__task + .eisenhower__task {
    margin-top: 6px;
}

.eisenhower__task.is-new {
    animation: eisenhower-pop 0.35s var(--pf-ease-spring);
}

@keyframes eisenhower-pop {
    from {
        transform: scale(0.96);
        opacity: 0;
    }
}

.eisenhower__task.is-dragging {
    opacity: 0.35;
}

.eisenhower__grip {
    display: inline-flex;
    flex: none;
    padding: 4px 3px;
    color: var(--em-muted);
    cursor: grab;
    touch-action: none;
}

.eisenhower__check {
    display: flex;
    flex: 1;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    cursor: pointer;
}

@media (pointer: fine) {
    .eisenhower__check {
        cursor: grab;
    }
}

.eisenhower__check input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: var(--pf-primary-deep);
    cursor: pointer;
}

.eisenhower__task-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.eisenhower__task.is-done .eisenhower__task-text {
    color: var(--em-muted);
    text-decoration: line-through;
}

.eisenhower__icon-button {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--em-muted);
    cursor: pointer;
}

.eisenhower__icon-button:hover,
.eisenhower__icon-button[aria-expanded="true"] {
    background: var(--em-button-bg-hover);
    color: var(--em-ink);
}

body.dark .eisenhower__icon-button:hover,
body.dark .eisenhower__icon-button[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.12);
}

.eisenhower__menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    min-width: 170px;
    padding: 6px;
    border: 1px solid var(--em-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--pf-shadow-card);
}

body.dark .eisenhower__menu {
    background: #413f3c;
}

.eisenhower__menu button {
    padding: 8px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.eisenhower__menu button:hover,
.eisenhower__menu button:focus-visible {
    background: rgba(255, 212, 101, 0.3);
    outline: none;
}

/* the copy that follows the pointer while dragging */
.eisenhower__ghost {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    margin: 0;
    list-style: none;
    font-family: var(--pf-font);
    font-size: 15px;
    color: var(--pf-ink);
    background: #fff;
    box-shadow: var(--pf-shadow-lg);
    pointer-events: none;
    rotate: 1.5deg;
}

.is-dragging,
.is-dragging * {
    cursor: grabbing !important;
}

/* toolbar */

.eisenhower__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.eisenhower__button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--em-line);
    border-radius: 999px;
    background: var(--em-button-bg);
    color: inherit;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s var(--pf-ease-spring), background-color 0.2s;
}

.eisenhower__button:hover {
    background: var(--em-button-bg-hover);
    transform: translateY(-1px);
}

.eisenhower__button--primary,
.eisenhower__button--primary:hover {
    border-color: transparent;
    background: var(--pf-primary);
    color: var(--pf-ink);
    font-weight: 600;
}

.eisenhower__button--quiet {
    margin-left: auto;
    border-color: transparent;
    background: transparent;
    color: var(--em-muted);
}

.eisenhower:not(.has-done) [data-action="clear-done"],
.eisenhower:not(.has-tasks) [data-action="clear-all"] {
    display: none;
}

/* under the card */

.eisenhower__tip {
    display: block;
    margin-top: 12px;
    color: var(--em-muted);
    font-size: 14px;
    text-align: center;
}

.eisenhower__visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 680px) {
    .eisenhower__card {
        padding: 16px 12px;
    }

    .eisenhower__add .eisenhower__button--primary {
        flex: 1;
    }

    .eisenhower__matrix {
        grid-template-columns: 1fr;
        grid-template-rows: none;
        grid-template-areas: "do" "schedule" "delegate" "eliminate";
    }

    .eisenhower__axis {
        display: none;
    }

    .eisenhower__quadrant {
        min-height: 0;
    }

    .eisenhower__quadrant-sub {
        margin-bottom: 2px;
    }

    .eisenhower__empty {
        padding-top: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .eisenhower__task.is-new {
        animation: none;
    }

    .eisenhower__button,
    .eisenhower__quadrant {
        transition: none;
    }
}
