/* The portfolio index: big names in rows, hairline rules, status on a dot. */
.works__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.works__head h2 {
    font-size: 18px;
    font-weight: 800;
    font-stretch: 125%;
}

.works__count {
    color: var(--muted);
    font-size: 14px;
}

.project-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(200px, 300px) 96px;
    align-items: center;
    gap: 28px;
    padding: 24px 0;
    border-bottom: 1px solid var(--line);
}

/* The name and its tags step aside under the pointer. Moved, not padded: a
   narrowing column would re-wrap the name halfway through. */
.project-card__main {
    transition: transform 280ms var(--ease-smooth-out);
}

.project-card h3 {
    font-size: clamp(30px, 3.4vw, 48px);
    font-weight: 800;
    font-stretch: 112%;
    line-height: 1;
    letter-spacing: -0.025em;
    text-wrap: balance;
    transition: color 200ms var(--ease-smooth-out);
}

/* Only where the pointer hovers: on a touch screen a tap would leave the row
   shifted and lit until the next tap elsewhere. */
@media (hover: hover) {
    a.project-card:hover .project-card__main {
        transform: translateX(14px);
    }

    a.project-card:hover h3 {
        color: var(--accent);
    }
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.project-tag {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--raised);
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.project-card__desc {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}

.project-meta {
    display: grid;
    justify-items: end;
    gap: 2px;
    color: var(--muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-weight: 600;
}

.status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.status--active { color: var(--status-active); }
.status--wip { color: var(--status-wip); }
.status--oss { color: var(--status-oss); }
.status--archived { color: var(--status-archived); }

/* ── the grind: GitHub activity rendered from assets/github.json ── */

.grind {
    /* One line of a list: a push, a commit. */
    --row-h: 36px;
    container-type: inline-size;
}

/* Under a finger the lines grow into proper touch targets. */
@media (pointer: coarse) {
    .grind {
        --row-h: 44px;
    }
}

.grind__sentence {
    max-width: 34ch;
    margin-top: 28px;
    color: var(--muted);
    font-size: clamp(28px, 3.2vw, 44px);
    font-weight: 700;
    font-stretch: 112%;
    line-height: 1.12;
    letter-spacing: -0.02em;
    text-wrap: balance;
}

.grind__sentence strong {
    color: var(--fg);
    font-weight: 800;
}

/* The sentence runs full width above; the year and the latest pushes sit
   side by side underneath. The list keeps a fixed width and the heatmap takes
   the rest, which sizes its cells so both panels end at about the same height.
   A second row follows in the same columns: the records and the latest
   commits under the year, the dial (day-dial.css) under the pushes. */
.grind__body {
    display: grid;
    /* Past ~1100px the cells would swell; extra width goes to the list. */
    grid-template-columns: minmax(0, 1100px) minmax(320px, 1fr);
    gap: 20px;
    margin-top: 32px;
}

/* The heatmap sets the row height (square cells, so its height follows its
   width); the pushes panel takes no height of its own and shows as many
   pushes as fit beside it. */
.heatmap {
    position: relative;
    min-width: 0;
}

.pushes {
    display: flex;
    flex-direction: column;
    min-width: 0;
    contain: size;
}

.heatmap,
.pushes {
    border-radius: var(--radius-lg);
    background: var(--panel);
    padding: 20px;
}

/* The month labels already add height above the cells; trimming the top
   padding keeps the cells optically centred in the panel. */
.heatmap {
    padding-top: 14px;
}

.heatmap__scroll {
    overflow-x: auto;
    scrollbar-width: none;
}

.heatmap__months,
.heatmap__grid {
    display: grid;
    grid-template-columns: repeat(var(--weeks, 53), minmax(9px, 1fr));
    column-gap: 4px;
    min-width: 560px;
}

.heatmap__months {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.heatmap__grid {
    grid-template-rows: repeat(7, auto);
    grid-auto-flow: column;
    row-gap: 4px;
}

.heatmap__cell {
    aspect-ratio: 1;
    border-radius: 2px;
    background: var(--raised);
    transition: opacity 200ms ease, box-shadow 120ms ease-out;
}

/* A record under the pointer (grind-records.js) keeps its own days lit. */
.heatmap__grid.is-marking .heatmap__cell:not(.is-marked) {
    opacity: 0.2;
}

.heatmap__cell.is-pad {
    visibility: hidden;
}

.heatmap__cell[data-level="1"] { background: var(--heat-1); }
.heatmap__cell[data-level="2"] { background: var(--heat-2); }
.heatmap__cell[data-level="3"] { background: var(--heat-3); }
.heatmap__cell[data-level="4"] { background: var(--accent); }

/* An inset ring, not an outline: the scroll wrapper clips anything drawn
   outside the cell, which cut the ring off the edge rows. */
.heatmap__cell:not(.is-pad):hover {
    box-shadow: inset 0 0 0 1.5px var(--fg);
}

/* --x and --y (github-activity.js) are the top middle of the cell it reads.
   Placed by translate and grown by scale, so each keeps its own clock: once
   shown it glides from cell to cell, and only its coming and going fade. */
.heatmap__tip {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    padding: 5px 10px;
    border-radius: var(--radius-xs);
    background: var(--fg);
    color: var(--on-accent);
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    translate: calc(var(--x, 0px) - 50%) calc(var(--y, 0px) - 100% - 6px);
    scale: var(--tt-scale);
    transform-origin: 50% 100%;
    transition:
        opacity var(--tt-out-dur) var(--tt-ease),
        scale var(--tt-out-dur) var(--tt-ease),
        translate var(--tt-move-dur) var(--tt-move-ease);
}

/* The wait before it shows belongs to showing alone: leaving hides it at once. */
.heatmap__tip.is-visible {
    opacity: 1;
    scale: 1;
    transition:
        opacity var(--tt-in-dur) var(--tt-ease) var(--tt-delay),
        scale var(--tt-in-dur) var(--tt-ease) var(--tt-delay),
        translate var(--tt-move-dur) var(--tt-move-ease);
}

/* What a panel of the grind is, in a line above its contents. */
.grind__label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
}

/* auto-fill makes one row per push that fits; the rest land in zero-height
   implicit rows and stay hidden, so a short panel never clips a push in half. */
.pushes__list {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(auto-fill, var(--row-h));
    grid-auto-rows: 0;
    overflow: hidden;
    margin-top: 6px;
}

.pushes__list li {
    overflow: hidden;
}

/* One line per push: repo on the left, language and time on the right, so
   five of them stand about as tall as the heatmap beside them. */
.push {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    height: var(--row-h);
    border-bottom: 1px solid var(--line);
}



.push__name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 15px;
}

.push__owner {
    color: var(--muted);
}

.push strong {
    font-weight: 600;
    transition: color 200ms var(--ease-smooth-out);
}

@media (hover: hover) {
    .push:hover strong,
    .commit:hover .commit__message {
        color: var(--accent);
    }
}

.push__meta {
    flex: none;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

.push__lang {
    display: inline-block;
    margin-right: 8px;
    vertical-align: 1px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lang, var(--muted));
}

/* Under the heatmap, beside the dial: the year's records at the top and the
   latest commits along the bottom, so the two columns end level. */
.grind__notes {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 28px;
    min-width: 0;
    padding: 12px 4px 0;
}

/* One line per commit, ruled like the pushes. */
.commits__list {
    margin-top: 6px;
}

.commit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 20px;
    min-height: var(--row-h);
    border-bottom: 1px solid var(--line);
}

.commit__message {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 15px;
    transition: color 200ms var(--ease-smooth-out);
}

.commit__repo,
.commit__when {
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
}

/* The opening sentence's voice, a size down. */
.grind__records {
    max-width: 44ch;
    color: var(--muted);
    font-size: clamp(20px, 2.2cqi, 28px);
    font-weight: 700;
    font-stretch: 112%;
    line-height: 1.3;
    letter-spacing: -0.015em;
    text-wrap: pretty;
}

.grind__records strong {
    color: var(--fg);
    font-weight: 800;
}

/* The records are underlined as things to point at: hovered or tapped
   (grind-records.js), each one shows its days on the heatmap. */
.grind__records strong {
    cursor: default;
    text-decoration: underline 2px color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 0.2em;
    transition: color 200ms var(--ease-smooth-out), text-decoration-color 200ms var(--ease-smooth-out);
    -webkit-tap-highlight-color: transparent;
}

.grind__records strong.is-pointed {
    color: var(--accent);
    text-decoration-color: currentColor;
}

.grind.is-error .grind__body {
    display: none;
}

/* Side by side only when the section is wide enough for ~13px cells next
   to the list; otherwise the year takes the full width and the pushes drop
   under it. Measured on the section, not the viewport, because the pinned
   bio column eats a different share at every width. */
@container (max-width: 1100px) {
    /* The records and the dial keep their two columns underneath. */
    .grind__body {
        grid-template-columns: minmax(0, 1fr) 320px;
    }

    .heatmap,
    .pushes {
        grid-column: 1 / -1;
    }

    /* Stacked, the list has its own row again and shows every push. */
    .pushes {
        contain: none;
    }

    .pushes__list {
        grid-template-rows: none;
        grid-auto-rows: var(--row-h);
    }
}

@container (max-width: 700px) {
    .grind__body {
        grid-template-columns: minmax(0, 1fr);
    }

    /* One column, and the records move up to sit right under the year they
       point at: year, records, pushes, commits, dial. The notes wrapper steps
       aside so its two parts can be ordered on their own. */
    .grind__notes {
        display: contents;
    }

    /* In one column the panels are left to the two charts; the pushes are a
       plain ruled list, like the commits under them. */
    .pushes {
        order: 1;
        padding: 0;
        border-radius: 0;
        background: none;
    }

    .pushes,
    .commits {
        margin-top: 8px;
    }
    .commits { order: 2; }
    .dial { order: 3; }

    /* No room for where a commit went; what it says and when stay, and the
       message takes a second line rather than losing its end. */
    .commit {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: baseline;
        padding: 9px 0;
    }

    .commit__repo {
        display: none;
    }

    .commit__message {
        display: -webkit-box;
        white-space: normal;
        line-height: 1.35;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }

    /* The year scrolls sideways here and opens on its latest weeks; the fade
       says there is more to the left. */
    .heatmap__scroll {
        mask-image: linear-gradient(to right, transparent, #000 28px);
    }
}

/* ── narrow: rows stack; touch screens get the inline screenshot reel ── */

@media (max-width: 1100px) {
    .project-card {
        grid-template-columns: minmax(0, 1fr) 96px;
        gap: 10px 20px;
    }

    /* Full width here, and the copy is kept short enough to read whole. */
    .project-card__desc {
        grid-column: 1 / -1;
        grid-row: 2;
        max-width: 60ch;
        -webkit-line-clamp: none;
        line-clamp: none;
    }
}

@media (max-width: 900px) {
    .project-card {
        padding: 20px 0;
    }

    a.project-card:hover .project-card__main {
        transform: none;
    }
}

/* The way to the rest of the works on a phone (works-more.js): a last row of
   the list, ruled like the others. Hidden everywhere else. */
.works__more {
    display: none;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 60px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: none;
    color: var(--fg);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.works__more::after {
    content: "+";
    color: var(--muted);
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
}

/* A phone opens on the projects that have a picture; the others wait behind
   the button until it marks the list whole. All in CSS, so the list never
   paints long and then shortens. Never beside the desktop stage, which lists
   every project. */
@media (max-width: 768px) {
    .js:not(.has-stage) .projects:not(.is-whole) .project-list > li:has(> .project-card:not([data-screenshot])) {
        display: none;
    }

    .js:not(.has-stage) .projects:not(.is-whole) .works__more:not([hidden]) {
        display: flex;
    }
}

/* Touch screens never get the desktop stage, so each card carries its own
   shot, opening once as it scrolls into view and its picture is ready (see
   works-reel.js). */
@media (max-width: 768px) and (hover: none) {
    .project-shot {
        grid-column: 1 / -1;
        display: grid;
        grid-template-rows: 0fr;
        overflow: hidden;
        opacity: 0;
        transition:
            grid-template-rows var(--resize-dur) var(--resize-ease),
            opacity 180ms ease-out;
    }

    .project-shot.is-open {
        grid-template-rows: 1fr;
        opacity: 1;
    }

    /* Opened above the screen, where the reader is already past it: all at
       once, so the page can be held still in the same frame. */
    .project-shot.is-passed {
        transition: none;
    }

    .project-shot__frame {
        overflow: hidden;
        border-radius: var(--radius-md);
        background: var(--panel);
    }

    /* The stage's frame (project-stage.css): one shape for every project,
       the shot whole in it, its margins filled from its own edges. */
    .project-shot img {
        width: 100%;
        aspect-ratio: 16 / 9;
        object-fit: contain;
        background: var(--panel) no-repeat;
        opacity: 0;
        transform: scale(1.04);
        transition:
            opacity var(--reveal-dur) var(--reveal-ease) 60ms,
            transform var(--reveal-dur) var(--reveal-ease) 60ms;
    }

    .project-shot.is-open img {
        opacity: 1;
        transform: none;
    }
}

/* Entrance: the bio column and the heading are simply there; the works list
   cascades in once, row by row, each by its --i (set in index.html ahead of
   the first paint). Without JS it all simply sits there, so nothing depends
   on the animation. */
.js .project-list > li {
    animation: rise-in var(--stagger-dur) var(--stagger-ease) both;
    animation-delay: calc(var(--i, 0) * var(--stagger-stagger));
}
