/*
 * Shared close control
 *
 * This file is loaded last so legacy dialog-specific close styles can keep
 * their positioning hooks while every rendered close control uses one visual
 * language.
 */
button.snv-unified-close-button.snv-analysis-result-window-button {
    display: inline-flex;
    box-sizing: border-box !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 36px !important;
    min-height: 36px !important;
    flex: 0 0 36px !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    overflow: visible;
    border: 1px solid #dce3ed !important;
    border-radius: 10px !important;
    background: #ffffff !important;
    box-shadow: none !important;
    color: #667085 !important;
    cursor: pointer;
    font: inherit;
    font-size: 0 !important;
    line-height: 1;
    text-indent: 0;
    appearance: none;
    transform: none !important;
    transition: border-color .15s ease, background .15s ease,
                color .15s ease, box-shadow .15s ease, transform .15s ease;
}

button.snv-unified-close-button.snv-analysis-result-window-button:hover {
    border-color: #b9c7df !important;
    background: #edf3ff !important;
    color: #285dd0 !important;
    box-shadow: 0 5px 12px rgba(37, 99, 235, .10) !important;
    transform: translateY(-1px) !important;
}

button.snv-unified-close-button.snv-analysis-result-window-button:active {
    box-shadow: none !important;
    transform: translateY(0) !important;
}

button.snv-unified-close-button.snv-analysis-result-window-button:focus-visible {
    outline: 3px solid #2563eb !important;
    outline-offset: 2px !important;
}

button.snv-unified-close-button.snv-analysis-result-window-button::before,
button.snv-unified-close-button.snv-analysis-result-window-button::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 2px;
    border: 0;
    border-radius: 999px;
    background: currentColor;
    content: '';
    pointer-events: none;
}

button.snv-unified-close-button.snv-analysis-result-window-button::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

button.snv-unified-close-button.snv-analysis-result-window-button::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

button.snv-unified-close-button > * {
    display: none !important;
}

/* Result headers keep their two-button flex group. */
.snv-analysis-result-window-actions > .snv-unified-close-button {
    position: relative !important;
    inset: auto !important;
}

/* Older 30–46px SquareBox headers still need an explicit top-right anchor. */
.SquareBox_title:not(.snv-dialog-header):not(.snv-tool-header):not(.snv-analysis-result-header)
    > .snv-unified-close-button {
    position: absolute !important;
    top: calc(50% - 18px) !important;
    right: 8px !important;
    bottom: auto !important;
    left: auto !important;
}

/* Measurement badges need enough room for the same 36px control. */
.distanceBox {
    box-sizing: border-box;
    width: 164px;
    height: 44px;
    padding: 0 44px 0 8px;
    line-height: 42px;
    border: 1px solid #dce3ed;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
    pointer-events: none;
}

#distanceBox {
    padding-left: 44px;
    padding-right: 44px;
    align-items: center;
    justify-content: center;
    transform: none;
    pointer-events: none;
}

#distanceBox_text {
    display: block;
    width: 100%;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}

#distanceBox_close {
    pointer-events: auto;
}

/*
 * Area values can be much wider than the other measurement labels. Keep the
 * value centered against the full badge (including the close-button space),
 * then let the badge grow until it reaches the viewport-safe ceiling.
 */
#areaBox {
    width: max-content;
    min-width: 164px;
    max-width: calc(100vw - 24px);
    padding-left: 44px;
    padding-right: 44px;
    align-items: center;
    justify-content: center;
}

#areaBox_text {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    line-height: 1.2;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#digreeBox {
    padding-left: 44px;
    padding-right: 44px;
    align-items: center;
    justify-content: center;
}

#digreeBox_text {
    display: block;
    width: 100%;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.distanceBox > .snv-unified-close-button {
    position: absolute !important;
    top: 3px !important;
    right: 3px !important;
    bottom: auto !important;
    left: auto !important;
    pointer-events: auto;
}

/* The legacy light-result minimize image sits immediately left of close. */
#lightcheck_resultbox_change {
    right: 52px !important;
}

@media (prefers-reduced-motion: reduce) {
    button.snv-unified-close-button.snv-analysis-result-window-button {
        transition: none;
    }
}
