/* Quick view dialog (TK11730). */

.hbe-quick-view-open {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: #635ea7;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    min-height: 44px;
}

.hbe-quick-view-open:focus-visible,
.hbe-quick-view-dialog button:focus-visible {
    outline: 2px solid #635ea7;
    outline-offset: 2px;
}

/* aria-busy is set for the length of the fetch. */
[data-quick-view][aria-busy='true'] {
    cursor: progress;
}

/* Delayed in, so a cached open doesn't flash a spinner. */
[data-quick-view][aria-busy='true']::after {
    content: '';
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-inline-start: 0.5em;
    border: 2px solid currentcolor;
    border-block-start-color: transparent;
    border-radius: 50%;
    vertical-align: -0.1em;
    animation:
        hbe-qv-spin 0.6s linear infinite,
        hbe-qv-appear 1ms linear 150ms both;
}

@keyframes hbe-qv-spin {
    to {
        rotate: 360deg;
    }
}

@keyframes hbe-qv-appear {
    from {
        opacity: 0;
    }
}

.hbe-quick-view-dialog {
    width: min(46rem, 100%);
    max-height: 85dvh;
    padding: 0;
    border: 0;
    overflow: auto;
    background: #fff;
    color: #374151;
    /* Undoes the centring the cards inherit. */
    text-align: start;

    /* Closed state; no @starting-style means it just appears. */
    opacity: 0;
    translate: 0 0.5rem;
    scale: 0.98;
    transition-property: opacity, translate, scale, display, overlay;
    transition-duration: 220ms;
    transition-timing-function: cubic-bezier(0.2, 0, 0, 1);
    transition-behavior: allow-discrete;

    &::backdrop {
        background-color: rgb(17 24 39 / 0);
        transition-property: background-color, display, overlay;
        transition-duration: 220ms;
        transition-behavior: allow-discrete;
    }

    :is(h3, h4) {
        font-family: inherit;
    }

    img {
        border-radius: 6px;
    }
}

.hbe-quick-view-dialog[open] {
    opacity: 1;
    translate: none;
    scale: 1;

    @starting-style {
        opacity: 0;
        translate: 0 0.5rem;
        scale: 0.98;
    }

    &::backdrop {
        background-color: rgb(17 24 39 / 0.55);

        @starting-style {
            background-color: rgb(17 24 39 / 0);
        }
    }
}

.hbe-quick-view-head {
    position: sticky;
    inset-block-start: 0;
    z-index: 1;
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 1.25rem 1rem 1.5rem;
    background: #fff;

    h3 {
        margin: 0;
        font-size: 1.05rem;
        font-weight: 700;
        line-height: 1.3;
        color: #111827;
    }
}

.hbe-quick-view-dialog .hbe-quick-view-close {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    /* Optical: levels the glyph with the title. */
    margin: -0.6rem -0.6rem 0 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-size: 1.75rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
}

.hbe-quick-view-body {
    padding: 0 1.5rem 1.5rem;
}

.hbe-quick-view-related {
    margin-top: 2rem;

    h4 {
        margin: 0 0 0.75rem;
        font-size: 0.7rem;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: #9ca3af;
    }

    ul {
        display: grid;
        gap: 0.85rem;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    li {
        display: flex;
        align-items: center;
        gap: 0.85rem;
        font-size: 0.85rem;
        line-height: 1.4;
    }

    img {
        flex: none;
        width: 56px;
        height: auto;
    }
}

.hbe-quick-view-panel {
    display: grid;
    gap: 1.25rem;

    img {
        width: 100%;
        height: 20rem;
        object-fit: contain;
        background: #f7f7fa;
    }
}

.hbe-quick-view-summary {
    font-size: 0.85rem;
    line-height: 1.6;

    :is(h2, h3, h4, h5) {
        margin: 1rem 0 0.4rem;
        font-size: 0.9rem;
        font-weight: 700;
    }

    p {
        margin: 0 0 0.5rem;
    }

    ul {
        margin: 0.5rem 0;
        padding-inline-start: 1.1rem;
    }
}

.hbe-quick-view-dialog .shop_attributes {
    width: 100%;
    margin: 1rem 0 0;
    border: 0;
    border-collapse: collapse;
    font-size: 0.8rem;

    tr,
    th,
    td {
        border: 0;
        background: none;
    }

    th,
    td {
        padding: 0.35rem 0.75rem 0.35rem 0;
        text-align: start;
        vertical-align: top;
    }

    th {
        width: 40%;
        font-weight: 600;
        color: #6b7280;
    }

    p {
        margin: 0;
    }
}

.hbe-quick-view-actions {
    position: sticky;
    inset-block-end: 0;
    padding: 1rem 1.5rem calc(1rem + env(safe-area-inset-bottom));
    background: #fff;

    button {
        width: 100%;
        min-height: 48px;
        padding: 0.75rem 1.5rem;
        border: 0;
        border-radius: 50px;
        background: linear-gradient(135deg, #635ea7 0%, #574fa5 100%);
        font: inherit;
        font-weight: 700;
        color: #fff;
        cursor: pointer;
    }
}

@media (min-width: 30rem) {
    .hbe-quick-view-related ul {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 40rem) {
    .hbe-quick-view-dialog {
        width: 100%;
        max-width: none;
        max-height: 90dvh;
        margin-block: auto 0;
        margin-inline: 0;
        translate: 0 1.5rem;
        scale: 1;
    }

    .hbe-quick-view-dialog[open] {
        @starting-style {
            translate: 0 1.5rem;
            scale: 1;
        }
    }
}

@media (prefers-reduced-motion: reduce) {
    /* A steady ring still reads as waiting. */
    [data-quick-view][aria-busy='true']::after {
        animation: hbe-qv-appear 1ms linear 150ms both;
        border-block-start-color: currentcolor;
        opacity: 0.5;
    }

    .hbe-quick-view-dialog {
        translate: none;
        scale: 1;
        transition-duration: 100ms;
    }

    .hbe-quick-view-dialog[open] {
        @starting-style {
            translate: none;
            scale: 1;
        }
    }
}
