/*
 * /projects (learn/projects.php, projects-page.js): the head with its tools, the two tabs, the search bar and the lists, one
 * row per project or link, and the New project dialog. On learn-shell.css's tokens; each kind has its own colour (--k),
 * on its tile here and in the dialog.
 */
/* As tall as the screen under the navbar, so the footer starts below it however few projects there are */
.pj {
    min-height: calc(100vh - var(--nav-h));
    max-width: 1080px;
    margin: 0 auto;
    padding: 30px 24px 48px;
}

.pj-head {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 24px;
    align-items: end;
    justify-content: space-between;
}

.pj-head h1 {
    margin: 0;
    font-size: clamp(32px, 4.4vw, 42px);
}

.pj-where {
    margin: 6px 0 0;
    color: var(--ink-2);
}

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

.pj-tabs {
    display: flex;
    gap: 4px;
    margin: 22px 0 16px;
    border-bottom: 1px solid var(--line);
}

.pj-tabs button {
    margin-bottom: -1px;
    padding: 9px 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--ink-2);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.pj-tabs button[aria-selected="true"] {
    border-color: var(--brand);
    color: var(--ink);
}

.pj-tabs span {
    color: var(--ink-3);
    font-size: 13px;
}

.pj-said {
    margin: 0 0 14px;
    padding: 9px 14px;
    border-radius: 10px;
    background: var(--brand-soft);
}

.pj-said.is-bad,
.pj-danger {
    color: var(--bad);
}

.pj-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.pj-bar .filter-chips {
    flex: 1;
    margin: 0;
}

.pj-search {
    position: relative;
    flex: 0 1 300px;
}

.pj-search .ic {
    position: absolute;
    top: 50%;
    left: 11px;
    width: 16px;
    height: 16px;
    color: var(--ink-3);
    transform: translateY(-50%);
}

.pj-bar input,
.pj-bar select,
.pj-rename,
.pj-dialog input[type="text"] {
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    font-size: 14.5px;
}

.pj-search input {
    width: 100%;
    padding-left: 34px;
}

.pj-picked {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-2);
}

.pj-picked span {
    flex: 1;
    min-width: 12em;
}

/* ---------- The lists: a card of rows ---------- */
.pj-list {
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
    list-style: none;
}

.pj-item {
    display: flex;
    gap: 14px;
    align-items: center;
    min-height: 68px;
    padding: 12px 16px;
}

.pj-item + .pj-item {
    border-top: 1px solid var(--line);
}

.pj-item:hover,
.pj-item:focus-within {
    background: var(--surface-2);
}

.pj-item:first-child {
    border-radius: 15px 15px 0 0;
}

.pj-item:last-child {
    border-radius: 0 0 15px 15px;
}

.pj-item:only-child {
    border-radius: 15px;
}

.pj-item > input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand);
}

/* A kind's tile: its icon on its colour */
.pj-tile {
    --k: var(--brand);
    display: grid;
    flex: none;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--k) 13%, transparent);
    color: var(--k);
}

.pj-tile .ic {
    width: 20px;
    height: 20px;
}

.pj-k-python {
    --k: #3776AB;
}

.pj-k-pyodide {
    --k: #7C3AED;
}

.pj-k-pygame {
    --k: #16A34A;
}

.pj-k-turtle {
    --k: #0D9488;
}

.pj-k-tkinter {
    --k: #EA580C;
}

.pj-k-link {
    --k: var(--ink-2);
}

.pj-main {
    flex: 1;
    min-width: 0;
}

.pj-name {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    color: var(--ink);
    font-size: 15.5px;
    font-weight: 650;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space: nowrap;
}

a.pj-name:hover {
    color: var(--brand);
    text-decoration: none;
}

.pj-main .chip {
    margin-left: 8px;
    font-size: 12px;
}

.pj-about,
.pj-why {
    display: block;
    overflow: hidden;
    margin-top: 2px;
    color: var(--ink-3);
    font-size: 13px;
    text-overflow: ellipsis;
}

.pj-about {
    white-space: nowrap;
}

.pj-why {
    color: var(--lv2);
}

.pj-rename {
    width: min(26em, 100%);
}

/* Where it is kept: a pill, green in the account */
.pj-kept {
    display: inline-flex;
    flex: none;
    gap: 6px;
    align-items: center;
    padding: 3px 10px 3px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.pj-kept .ic {
    width: 14px;
    height: 14px;
}

.pj-kept.is-account {
    background: color-mix(in srgb, var(--done) 12%, transparent);
    color: var(--done);
}

.pj-acts {
    display: flex;
    flex: none;
    gap: 2px;
}

/* With a mouse, a row's actions show when it is pointed at or in focus; nothing moves, they are only faint until then */
@media (hover: hover) {
    .pj-acts {
        opacity: .35;
        transition: opacity .15s;
    }

    .pj-item:hover .pj-acts,
    .pj-item:focus-within .pj-acts,
    .pj-item:has(.pj-more[aria-expanded="true"]) .pj-acts {
        opacity: 1;
    }
}

.pj-act {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink-2);
    cursor: pointer;
}

.pj-act:hover,
.pj-act:focus-visible,
.pj-more[aria-expanded="true"] {
    background: var(--brand-soft);
    color: var(--brand);
}

.pj-act[data-act="delete"]:hover,
.pj-act[data-act="delete"]:focus-visible {
    background: color-mix(in srgb, var(--bad) 12%, transparent);
    color: var(--bad);
}

.pj-act .ic {
    width: 16px;
    height: 16px;
}

/* A project's More button and its list: phones only (below) */
.pj-acts .pj-more,
.pj-menu {
    display: none;
}

/* A question in a row (removing one from the account) in place of its actions */
.pj-ask {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    max-width: 30em;
    font-size: 14px;
}

.pj-ask span {
    flex: 1 1 14em;
}

.is-expired .pj-name {
    color: var(--ink-3);
}

.pj-empty {
    display: grid;
    gap: 4px;
    padding: 34px 20px;
    color: var(--ink-2);
    text-align: center;
}

/* ---------- New project ---------- */
.pj-dialog {
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
}

.pj-dialog::backdrop {
    background: rgba(13, 27, 51, .45);
}

.pj-dialog form {
    display: grid;
    gap: 10px;
    padding: 22px 24px 20px;
}

.pj-dialog h2 {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0 0 6px;
    font-size: 20px;
}

.pj-dialog h2 .ic {
    width: 20px;
    height: 20px;
    color: var(--brand);
}

.pj-field {
    padding: 0;
    color: var(--ink);
    font-size: 14px;
    font-weight: 650;
}

.pj-dialog input[type="text"] {
    width: 100%;
    height: 42px;
    font-size: 15px;
}

.pj-dialog input[type="text"]:focus {
    border-color: var(--brand);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}

.pj-kinds-pick {
    margin: 4px 0 0;
    padding: 0;
    border: 0;
}

.pj-kinds-pick legend {
    margin-bottom: 8px;
}

/* The four kinds two by two */
.pj-kinds-pick > div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

/* A kind: its tile, name and what it is for; the chosen one in the kind's colour */
.pj-kind-opt {
    position: relative;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color .15s, background-color .15s;
}

.pj-kind-opt:hover {
    background: var(--surface-2);
}

.pj-kind-opt input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* is-on, from projects-page.js: Chrome doesn't always take :has(:checked) off the card a choice left */
.pj-kind-opt.is-on {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.pj-kind-opt:has(input:focus-visible) {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.pj-kind-opt .pj-tile {
    width: 36px;
    height: 36px;
}

.pj-kind-opt span:last-child {
    display: grid;
    min-width: 0;
}

.pj-kind-opt b {
    font-size: 14px;
    font-weight: 650;
}

.pj-kind-opt small {
    color: var(--ink-3);
    font-size: 12.5px;
}

.pj-sync {
    display: flex;
    gap: 9px;
    align-items: center;
    margin-top: 4px;
    font-size: 14px;
    cursor: pointer;
}

.pj-sync[hidden] {
    display: none;
}

.pj-sync input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--brand);
}

.pj-dialog-note {
    margin: 2px 0 0;
    color: var(--ink-3);
    font-size: 13px;
}

.pj-dialog-acts {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

/* Phones: a row's details under its name, the actions on their own line */
@media (max-width: 680px) {
    .pj {
        padding: 22px 16px 40px;
    }

    .pj-search {
        flex: 1 1 100%;
    }

    .pj-item {
        flex-wrap: wrap;
        gap: 10px 12px;
    }

    .pj-main {
        flex-basis: calc(100% - 92px);
    }

    .pj-kept {
        margin-left: 82px;
    }

    .pj-acts {
        margin-left: auto;
    }

    /* A project's row: the name beside one More button, which lists the actions under it; where it is kept on the line
       below (the checkbox, the tile and the button with their gaps take 130px) */
    .pj-proj .pj-main {
        flex: 1 1 calc(100% - 130px);
    }

    .pj-proj .pj-kept {
        order: 1;
    }

    .pj-proj .pj-ask {
        order: 2;
        flex-basis: 100%;
    }

    .pj-proj .pj-acts {
        position: relative;
    }

    .pj-proj .pj-acts > .pj-act {
        display: none;
    }

    .pj-proj .pj-acts > .pj-more {
        display: grid;
    }

    .pj-menu:not([hidden]) {
        position: absolute;
        top: calc(100% + 4px);
        right: 0;
        z-index: 5;
        display: grid;
        min-width: 220px;
        padding: 6px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: var(--shadow-pop);
    }

    .pj-menu button {
        display: flex;
        gap: 10px;
        align-items: center;
        min-height: 44px;
        padding: 0 12px;
        border: 0;
        border-radius: 8px;
        background: none;
        color: var(--ink);
        font: inherit;
        font-size: 15px;
        text-align: left;
        cursor: pointer;
    }

    .pj-menu button:hover,
    .pj-menu button:focus-visible {
        background: var(--brand-soft);
        color: var(--brand);
    }

    .pj-menu [data-act="delete"] {
        color: var(--bad);
    }

    .pj-menu .ic {
        flex: none;
        width: 16px;
        height: 16px;
    }
}
