/*
 * Vildmark configurator info tooltips.
 *
 * PHP (inc/product-vildmark-tooltips.php) prints a hidden .uw-vm-tips block
 * per group; product-vildmark.js's initTips() moves each .uw-vm-tip out of
 * it, next to an "i" trigger button it creates, then opens/closes it as a
 * Popover-API popover (native, top layer) or, on a browser with no Popover
 * API, an inline disclosure toggled through the hidden attribute. This file
 * only lays both states out; product-vildmark-fields.css owns the swatch
 * and row chrome it sits on top of and is not edited here.
 *
 * Tokens (--vm-forest-*, --vm-wood-*, --vm-radius*, --vm-shadow) come from
 * .uw-vm in product-vildmark.css, already in scope under .uw-vm-config.
 *
 * No !important anywhere in this file: the one existing rule this file
 * overrides (the selected-swatch checkmark badge below) carries none of
 * its own, so ordinary cascade order (this file is enqueued after
 * product-vildmark-fields.css) is enough to win it.
 */

/* ---------- Trigger button, shared base ---------- */

/*
 * 1.5rem (24px) visible circle everywhere: small enough that, in the
 * radio/checkbox row below, it never becomes the row's tallest child
 * (matched deliberately to the option label's own 21px line height) and
 * so the row never grows. The ::after pseudo-element below is what turns
 * this into the 28px+ hit area the contract asks for: it is positioned
 * out of flow, so it does not itself add width or height anywhere.
 */
.uw-vm-config .uw-vm-tip-btn {
    position: relative;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    color: var(--vm-forest-700);
    background: #fff;
    border: 1.5px solid var(--vm-forest-700);
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}

.uw-vm-config .uw-vm-tip-btn::after {
    content: '';
    position: absolute;
    inset: -.25rem;
}

.uw-vm-config .uw-vm-tip-btn span {
    font-family: Georgia, 'Times New Roman', serif;
    font-style: italic;
    font-weight: 700;
    font-size: .8125rem;
    line-height: 1;
}

.uw-vm-config .uw-vm-tip-btn:hover {
    background: var(--vm-forest-50);
}

.uw-vm-config .uw-vm-tip-btn:focus-visible {
    outline: 2px solid var(--vm-forest-700);
    outline-offset: 2px;
}

/* ---------- Group trigger: last child of .wc-pao-addon-name ---------- */

.uw-vm-config .wc-pao-addon-name .uw-vm-tip-btn {
    margin-left: .5rem;
    vertical-align: middle;
}

/*
 * Below 768px product-vildmark.js's placeGroupTips() moves this same
 * button into the <details> summary instead (see that function's own
 * header comment): .wc-pao-addon-name is the element
 * product-vildmark-fields.css visually clips to 1px there once the
 * summary restates its text, so a trigger left behind on the heading
 * would be present but unreachable. flex: none keeps it at its own
 * size rather than sharing the row's flex-grow/shrink with the name
 * (which truncates) and the chevron (which does not).
 */
.uw-vm-config .uw-vm-field-summary .uw-vm-tip-btn {
    flex: none;
}

/* ---------- Option trigger: radio / checkbox row ---------- */

/*
 * Shrunk from the 24px base to 21px (matching the row's own single-line
 * label height exactly, see product-vildmark-fields.css's label rule) so
 * a one-line option never grows the row; a two-line option's own label is
 * already taller than either size, so it is unaffected either way. The
 * hit area is widened to match (21px + 6px each side = 33px).
 */
.uw-vm-config .wc-pao-addon-wrap > div > .uw-vm-tip-btn {
    width: 1.3125rem;
    height: 1.3125rem;
    margin-left: .25rem;
}

.uw-vm-config .wc-pao-addon-wrap > div > .uw-vm-tip-btn::after {
    inset: -.375rem;
}

/* ---------- Option trigger: image swatch ---------- */

/*
 * Inserted as a flex sibling right after the swatch anchor (never inside
 * it, see the JS header comment for why). align-self overrides the row's
 * default stretch so this stays a small badge instead of matching the
 * tile's full height. The three margins pull it up and left so it straddles
 * the tile's outer top-right corner (half on the tile, half off it) rather
 * than sitting flush inside that corner, which is already spoken for by
 * the selected-swatch checkmark badge (product-vildmark-fields.css,
 * ::before at top/right: .375rem): flush placement would sit on top of
 * that checkmark whenever the swatch is selected. margin-right then
 * cancels what is left of the button's 1.5rem width after margin-left, so
 * the button takes up no track space at all and the next swatch in the
 * row sits exactly where it would without it. The desktop row has no gap
 * of its own: its tiles are spaced by the `margin: 0 8px 8px 0` that
 * inc/woocommerce.php injects on every .wc-pao-addon-image-swatch, which
 * a zero-width flex item leaves untouched. (Measured on the live page,
 * 2026-09-16: with -.75rem here the pairs with a button sat 10px closer
 * than the pairs without.)
 */
.uw-vm-config .wc-pao-addon-image-swatch + .uw-vm-tip-btn {
    align-self: flex-start;
    z-index: 2;
    margin-top: -.75rem;
    margin-left: -1.375rem;
    margin-right: -.125rem;
    color: #fff;
    background: var(--vm-forest-700);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

/*
 * Below 768px product-vildmark-fields.css turns the swatch row into a
 * horizontal scroller (overflow-y: hidden, no top padding) with a .625rem
 * gap between flex items, which changes both sums above. The gap is paid
 * on both sides of a flex item however narrow it is, so margin-left grows
 * by one gap to keep the badge on the same spot of the tile's corner, and
 * the net track space becomes -.625rem instead of 0 (one gap taken back)
 * so a tile pair with a badge between them stays as far apart as a pair
 * without. The scroller's clipping is answered with room above the tiles
 * for the badge's top half: same selector as the scroller rule itself,
 * and this file loads after that one, so no !important is needed.
 * (Measured live at 360px, 2026-09-16: without these the badge lost its
 * top 12px to the clip and its right 2px overlapped the next tile.)
 */
@media (max-width: 767px) {
    .uw-vm-config .uw-vm-field-group .wc-pao-addon-wrap:has(> .wc-pao-addon-image-swatch) {
        padding-top: .75rem;
    }

    .uw-vm-config .uw-vm-field-group .wc-pao-addon-image-swatch + .uw-vm-tip-btn {
        margin-left: -2rem;
        margin-right: -.125rem;
    }
}

.uw-vm-config .wc-pao-addon-image-swatch + .uw-vm-tip-btn:hover {
    background: var(--vm-forest-800);
}

/*
 * Answers product-vildmark-fields.css's own selected-swatch checkmark
 * (::before, right: .375rem): moved left by this badge's full width plus
 * a small clearance so a selected tile never shows the two overlapping.
 * No !important: that rule does not carry one, and this file loads after
 * it, so plain cascade order already wins.
 */
.uw-vm-config .wc-pao-addon-image-swatch.selected::before,
.uw-vm-config .wc-pao-addon-image-swatch[aria-checked="true"]::before {
    right: 1.75rem;
}

/* ---------- Popover body ---------- */

/*
 * position: fixed and the show/hide rule below apply the same way whether
 * the browser used tip.popover = 'auto' (top layer, native light-dismiss
 * and Esc) or the no-Popover-API fallback (plain fixed element, hidden
 * attribute toggled by hand): the JS header comment covers why both exist.
 * width is left auto on purpose: initTips() sets only top/left on wide
 * viewports (auto width then shrinks to content, capped by max-width
 * below) and both left and right on narrow ones (auto width then exactly
 * fills the gap between them), so one rule serves both shapes.
 */
.uw-vm-config .uw-vm-tip {
    position: fixed;
    display: none;
    flex-direction: column;
    margin: 0;
    padding: 2.25rem 1.25rem 1.25rem;
    /* A group tip lives inside the group heading (.wc-pao-addon-name, a
       600-weight label), so reset what it would otherwise inherit. */
    font-weight: 400;
    text-align: left;
    cursor: auto;
    color: var(--vm-wood-800);
    background: #fff;
    border: 1px solid var(--vm-wood-100);
    border-radius: var(--vm-radius);
    box-shadow: var(--vm-shadow);
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    z-index: 9999; /* load-bearing only for the fallback; a native popover is
                       already promoted to the top layer regardless. */
}

.uw-vm-config .uw-vm-tip:popover-open,
.uw-vm-config .uw-vm-tip:not([popover]):not([hidden]) {
    display: flex;
}

@media (min-width: 480px) {
    .uw-vm-config .uw-vm-tip {
        max-width: 22rem;
    }
}

.uw-vm-config .uw-vm-tip-close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    color: var(--vm-wood-700);
    background: var(--vm-wood-50);
    border: 0;
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color .15s ease;
}

.uw-vm-config .uw-vm-tip-close::after {
    content: '';
    position: absolute;
    inset: -.25rem;
}

.uw-vm-config .uw-vm-tip-close:hover {
    background: var(--vm-wood-100);
}

.uw-vm-config .uw-vm-tip-close:focus-visible {
    outline: 2px solid var(--vm-forest-700);
    outline-offset: 2px;
}

.uw-vm-config .uw-vm-tip-title {
    display: block;
    margin: 0 1.5rem .25rem 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--vm-wood-900);
}

.uw-vm-config .uw-vm-tip p {
    margin: 0;
    font-size: .9375rem;
    line-height: 1.5;
    color: var(--vm-wood-800);
}

.uw-vm-config .uw-vm-tip p + p {
    margin-top: .5rem;
}

.uw-vm-config .uw-vm-tip strong {
    color: var(--vm-wood-900);
}

@media (prefers-reduced-motion: reduce) {
    .uw-vm-config .uw-vm-tip-btn,
    .uw-vm-config .uw-vm-tip-close {
        transition: none;
    }
}

/* ---------- Group description shown as a tooltip ---------- */

/*
 * On this template a group's wp-admin description is tooltip copy: PHP
 * (Urbanwild_Product_Vildmark_Tooltips::container_classes()) marks its
 * container and copies the same text into the group's tip, so the
 * plugin's inline copy stays hidden until the customer opens the "i"
 * button (client review 2026-11-20, L25). The fieldset's
 * aria-describedby still points at it; screen readers read a
 * referenced description even when it is not displayed.
 */
.uw-vm-config .uw-vm-desc-tip .wc-pao-addon-description {
    display: none;
}
