/* Racket comparison: three columns of real characteristics, aligned row by row. */

.cmp {
    --cols: 3;
}

.cmp__head,
.cmp__row {
    display: grid;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    gap: 0 clamp(16px, 3vw, 48px);
}

.cmp__head {
    position: sticky;
    top: var(--hdr-top);
    z-index: 5;
    padding: 12px 0;
    background: var(--white);
    border-bottom: 1px solid var(--studio-2);
}

.cmp__select {
    appearance: none;
    width: 100%;
    min-height: 48px;
    padding: 0 40px 0 16px;
    background: var(--ink) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e6f53a' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 16px;
    border: 0;
    color: var(--white);
    font-stretch: 87.5%;
    font-weight: 700;
    font-size: .875rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-overflow: ellipsis;
    cursor: pointer;
    clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}

.cmp__select:hover {
    background-color: var(--ink-3);
}

.cmp__row {
    padding: 28px 0;
    border-bottom: 1px solid var(--studio-2);
}

.cmp__row--product {
    padding-top: 32px;
    border-bottom: 0;
}

.cmp__val {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 8px;
    text-align: center;
    animation: cmp-swap .45s var(--ease);
}

@keyframes cmp-swap {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.cmp__val b {
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.3;
}

.cmp__big {
    font-stretch: 100%;
    font-weight: 800 !important;
    font-size: 2.6rem !important;
    line-height: 1 !important;
}

.cmp__label {
    font-size: .8125rem;
    color: var(--muted);
}

.cmp__group {
    margin-top: clamp(40px, 5vw, 64px);
    padding-bottom: 14px;
    border-bottom: 3px solid var(--ink);
    font-size: clamp(1.8rem, 3vw, 2.4rem);
}

/* Product row */

.cmp__img {
    display: block;
    width: min(100%, 300px);
    aspect-ratio: 1;
    background: var(--studio);
}

.cmp__img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8%;
    transition: transform .5s var(--ease);
}

.cmp__img:hover img {
    transform: rotate(-4deg) scale(1.04);
}

.cmp__name {
    margin-top: 10px;
    font-size: clamp(1.4rem, 2.2vw, 1.9rem);
}

.cmp__price {
    margin: 0;
    font-size: 1.6rem;
    line-height: 1;
}

.cmp__go {
    min-height: 44px;
    margin-top: 6px;
    font-size: .875rem;
}

/* Visual helpers */

.cmp__shape {
    width: 44px;
    height: 70px;
    fill: var(--blue);
}

.cmp__scale {
    position: relative;
    width: min(100%, 200px);
    height: 8px;
    margin-top: 6px;
    background: var(--studio-2);
}

.cmp__scale i {
    position: absolute;
    top: 0;
    bottom: 0;
    min-width: 6px;
    background: var(--blue);
}

.cmp__scale-ends {
    display: flex;
    justify-content: space-between;
    width: min(100%, 200px);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.cmp__meter {
    display: flex;
    gap: 4px;
}

.cmp__meter i {
    width: 28px;
    height: 10px;
    background: var(--studio-2);
    clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

.cmp__meter i.is-on {
    background: var(--blue);
}

.cmp__big small {
    margin-left: 2px;
    font-size: .45em;
    color: var(--muted);
}

.cmp__bar {
    width: min(100%, 200px);
    height: 8px;
    background: linear-gradient(90deg, var(--blue) calc(var(--v) * 10%), var(--studio-2) 0);
}

.cmp__rate {
    margin: -2px 0 0;
    font-size: .8125rem;
    color: var(--muted);
}

/* "Only differences": rows equal in every column fold away. */
.cmp.is-diff .is-same {
    display: none;
}

.cmp__more {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px 40px;
    margin-top: 40px;
    padding: 24px 28px;
    background: var(--studio);
}

.cmp__more p {
    max-width: 52ch;
    margin: 0;
}

@media (max-width: 760px) {
    /* The markup sets --cols inline, which a media query cannot override: set the grid itself. */
    .cmp__head,
    .cmp__row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cmp [data-col="2"],
    .cmp [data-col="3"] {
        display: none;
    }

    .cmp__select {
        font-size: .75rem;
        padding: 0 30px 0 10px;
        background-position: right 10px center;
    }

    .cmp__row {
        padding: 20px 0;
    }

    .cmp__val b {
        font-size: 1rem;
    }

    .cmp__big {
        font-size: 1.5rem !important;
    }

    /* Two columns at phone width: keep names, prices and values inside their cell. */
    .cmp__name {
        font-size: 1.05rem;
    }

    .cmp__price {
        font-size: 1.25rem;
    }

    .cmp__val {
        overflow-wrap: anywhere;
    }
}
