/* Option value hints (pcm_option_hint, docs/option-hints.md) - the tooltip of
 * an option value and the chosen value's hint under a select.
 * Sizes in rem of the theme (html { font-size: 10px }); logical properties, so
 * it works in RTL as is. The tooltip is placed by pcm_option_hint.js. */

/* The value's chip keeps room at its end for the button. */
.pcm-hint-item {
    position: relative;
}

.pcm-hint-item .ui-check__option {
    padding-inline-end: 4rem;
}

/* Centred on the 4rem chip; li has 0.5rem side padding. */
.pcm-hint {
    position: absolute;
    top: 0.6rem;
    inset-inline-end: 1.1rem;
    width: 2.8rem;
    height: 2.8rem;
}

.pcm-hint__btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    /* 4:1 on the chip's #F7F7FB */
    color: #6f7891;
    cursor: help;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.2s;
}

.pcm-hint__btn svg {
    display: block;
    width: 1.7rem;
    height: 1.7rem;
    pointer-events: none;
}

.pcm-hint__btn:hover,
.pcm-hint-item.is-hint-open .pcm-hint__btn {
    color: var(--theme-primary-color, #7266F3);
}

.pcm-hint__btn:focus-visible {
    outline: 2px solid var(--theme-primary-color, #7266F3);
    outline-offset: 1px;
}

.pcm-hint__btn:focus:not(:focus-visible) {
    outline: none;
}

/* The tooltip: the look of the theme's .tooltip-inner. position: fixed, so
 * overflow: hidden around the options does not cut it. */
.pcm-hint__bubble {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 99999;
    display: block;
    box-sizing: border-box;
    width: max-content;
    max-width: min(30rem, calc(100vw - 16px));
    padding: 1.2rem 1.4rem;
    border-radius: 5px;
    background: #fff;
    box-shadow: 0 0 20px rgba(170, 189, 206, 0.45), 0 2px 6px rgba(52, 52, 52, 0.08);
    color: #343434;
    font-size: 1.4rem;
    line-height: 1.4;
    font-weight: 400;
    text-align: start;
    cursor: default;
}

.pcm-hint__bubble[hidden] {
    display: none;
}

/* The page's direction, also in the quick view: fancybox lays its stage out
 * ltr (.fancybox-stage { direction: ltr }). */
html[dir="rtl"] .pcm-hint__bubble,
html[dir="rtl"] .pcm-hint-note {
    direction: rtl;
}

/* The arrow, at the x the script puts in --pcm-hint-arrow (physical, as is the
 * script's measure). */
.pcm-hint__bubble::before {
    content: '';
    position: absolute;
    top: 100%;
    left: var(--pcm-hint-arrow, 50%);
    margin-left: -7px;
    border: 7px solid transparent;
    border-top-color: #fff;
}

.pcm-hint__bubble[data-side="bottom"]::before {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #fff;
}

/* Fills the gap to the button: the mouse crossing it stays on the hint. */
.pcm-hint__bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 12px;
}

.pcm-hint__bubble[data-side="bottom"]::after {
    top: auto;
    bottom: 100%;
}

/* The picture and the text. A tooltip taller than the room next to its button
 * gets a max-height from the script and this scrolls, so the tooltip itself
 * keeps overflow: visible for its arrow and the bridge to the button. Out of
 * the Tab order (tabindex="-1"): arrows on the button scroll it. */
.pcm-hint__body {
    display: block;
    overflow-y: auto;
    overscroll-behavior: contain;
    outline: none;
}

/* A fixed box whatever the picture's proportions: the tooltip is placed when
 * it opens, before the picture has loaded. */
.pcm-hint__image {
    display: block;
    width: 12rem;
    max-width: 100%;
    height: 12rem;
    margin: 0 auto 1rem;
    border-radius: 3px;
    object-fit: contain;
}

.pcm-hint__text {
    display: block;
    white-space: pre-line;
    overflow-wrap: break-word;
}

@media (prefers-reduced-motion: no-preference) {
    .pcm-hint__bubble:not([hidden]) {
        animation: pcm-hint-in 0.15s ease-out;
    }
}

@keyframes pcm-hint-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* A select: the chosen value's hint under it. The spacing is the hint's own:
 * the list of hints stays in the page while none shows, and margins of its
 * own would still pull the next option up through it. */
.pcm-hint-note {
    display: flex;
    align-items: flex-start;
    gap: 1.2rem;
    margin: -1rem 0 2rem;
    padding: 1rem 1.2rem;
    border-radius: 4px;
    background: #f7f7fb;
    color: #343434;
    font-size: 1.3rem;
    line-height: 1.4;
}

.pcm-hint-note[hidden] {
    display: none;
}

.pcm-hint-note__image {
    flex: 0 0 auto;
    width: 6rem;
    height: auto;
    border-radius: 3px;
}

.pcm-hint-note__text {
    min-width: 0;
    white-space: pre-line;
    overflow-wrap: break-word;
}

@media print {
    .pcm-hint,
    .pcm-hint-notes {
        display: none;
    }

    .pcm-hint-item .ui-check__option {
        padding-inline-end: 1.5rem;
    }
}
