/* CodinGame hub, projects-page entry and replay tiles. Uses the site tokens from bundle.css. */

/* ---------- Hub ---------- */

.cg-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s5);
    margin: var(--s5) 0 var(--s6);
}

.cg-stats p {
    margin: 0;
    padding-top: var(--s4);
    border-top: 1px solid var(--border-strong);
}

.cg-stats strong {
    display: block;
    font-family: var(--mono);
    font-size: clamp(1.5rem, 4vw, 2.25rem);
    font-weight: 600;
    line-height: 1.15;
}

.cg-stats .meta {
    display: block;
    margin-top: var(--s2);
}

.article .cg-lede {
    margin-bottom: 0;
}

.cg-postmortem-list .item + .item {
    margin-top: var(--s6);
}

.article .item-title {
    margin: 0 0 var(--s2);
}

.cg-postmortem-list p:last-child,
.cg-about p {
    margin-bottom: 0;
}

.cg-about p {
    font-size: 0.9375rem;
    color: var(--fg-muted);
}

/* ---------- Projects page ---------- */

.cg-postmortems {
    margin: var(--s3) 0 0;
    font-size: 0.9375rem;
}

.cg-postmortems a {
    position: relative;
}

/* ---------- Post-mortem pages ---------- */

.case-summary {
    margin: 0 0 var(--s6);
}

.case-summary dl {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--s3) var(--s5);
    margin: 0;
}

.case-summary dt {
    padding-top: 0.2em;
    font-family: var(--mono);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--fg-muted);
}

.case-summary dd {
    margin: 0;
    max-width: var(--measure);
    text-wrap: pretty;
}

.case-summary b {
    font-variant-numeric: tabular-nums;
}

@media screen and (max-width: 640px) {
    .case-summary dl {
        grid-template-columns: 1fr;
        gap: var(--s1);
    }

    .case-summary dd {
        margin-bottom: var(--s3);
    }
}

/* ---------- Replay tiles ---------- */

.cg-gallery {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--s3);
    margin: var(--s4) 0 0;
    padding: 0;
    list-style: none;
    max-width: none;
}

.cg-gallery > li {
    grid-column: span 2;
    min-width: 0;
    margin: 0;
}

.cg-gallery > li:nth-child(-n + 2) {
    grid-column: span 3;
}

.cg-tile {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--bg-color);
}

.cg-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3 / 2;
    overflow: hidden;
}

.cg-canvas {
    display: block;
    opacity: 0;
    transition: opacity 0.4s;
}

.cg-tile.ready .cg-canvas {
    opacity: 1;
}

.cg-tile figcaption {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 8px 38px 9px 12px;
    border-top: 1px solid var(--border-strong);
    background: var(--bg-lighter);
    font-size: 0.8125rem;
    line-height: 1.35;
}

.cg-name {
    font-weight: 600;
}

a.cg-name {
    text-decoration: none;
}

a.cg-name:hover {
    text-decoration: underline;
}

.cg-kind {
    color: var(--fg-muted);
}

a.cg-name::after {
    content: "";
    position: absolute;
    inset: 0;
}

.cg-tile:has(a.cg-name:hover) {
    border-color: var(--link);
}

.cg-tile:has(a.cg-name:focus-visible) {
    outline: 2px solid var(--link);
    outline-offset: 3px;
}

.cg-tile a.cg-name:focus-visible {
    outline: none;
}

.cg-help {
    position: absolute;
    right: 8px;
    bottom: 8px;
    z-index: 3;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--control-border);
    border-radius: 50%;
    background: var(--bg-color);
    color: var(--fg-color);
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    font-family: inherit;
    cursor: help;
}

.cg-help:hover,
.cg-help.is-open {
    border-color: var(--link);
    color: var(--link);
}

.cg-help:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

.cg-tip {
    position: fixed;
    z-index: 100;
    display: none;
    width: max-content;
    max-width: min(260px, calc(100vw - 16px));
    margin: 0;
    padding: 8px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--bg-lighter);
    color: var(--fg-color);
    box-shadow: 0 4px 14px rgb(0 0 0 / 0.18);
    font-size: 0.8125rem;
    line-height: 1.4;
    pointer-events: none;
    text-wrap: pretty;
}

.cg-tip.show {
    display: block;
}

.cg-tip::after {
    content: "";
    position: absolute;
    left: var(--arrow-x, 50%);
    width: 8px;
    height: 8px;
    margin-left: -4px;
    background: var(--bg-lighter);
    transform: rotate(45deg);
}

.cg-tip[data-side="top"]::after {
    bottom: -5px;
    border: solid var(--border-strong);
    border-width: 0 1px 1px 0;
}

.cg-tip[data-side="bottom"]::after {
    top: -5px;
    border: solid var(--border-strong);
    border-width: 1px 0 0 1px;
}

/* Compact strip inside the projects-page item */

.cg-gallery.cg-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--s2);
    margin: var(--s4) 0 0;
}

.cg-strip > li,
.cg-strip > li:nth-child(-n + 2),
.cg-strip > li:last-child {
    grid-column: auto;
}

.cg-strip .cg-kind {
    display: none;
}

.cg-strip figcaption {
    padding: 5px 34px 6px 8px;
    font-size: 0.75rem;
}

.cg-strip .cg-help {
    right: 5px;
    bottom: 5px;
    width: 22px;
    height: 22px;
}

.cg-stats .board {
    display: block;
    margin-bottom: var(--s2);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

@media screen and (max-width: 700px) {
    .cg-gallery.cg-strip {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        padding-bottom: var(--s2);
    }

    .cg-strip > li {
        flex: 0 0 172px;
        scroll-snap-align: start;
    }
}

@media screen and (max-width: 560px) {
    .cg-stats {
        gap: var(--s4);
    }

    .cg-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--s2);
    }

    .cg-gallery > li,
    .cg-gallery > li:nth-child(-n + 2) {
        grid-column: span 1;
    }

    .cg-gallery > li:last-child {
        grid-column: span 2;
    }

    .cg-tile figcaption {
        padding: 6px 38px 7px 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cg-canvas {
        transition: none;
    }
}

@media screen and (max-width: 480px) {
    .cg-stats {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--s4);
    }
}
