/**
 * Runtime HUD and optional stage-time presentation.
 */

.bgf-hud {
    position: absolute;
    z-index: 5;
    inset: max(10px, var(--boost-game-safe-area-top)) auto auto 10px;
    display: grid;
    width: min(280px, calc(100% - 20px));
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid color-mix(in srgb, var(--boost-ui-secondary) 14%, var(--boost-ui-border));
    border-radius: 14px;
    background: color-mix(in srgb, var(--boost-ui-surface) 90%, transparent);
    box-shadow: 0 10px 24px color-mix(in srgb, var(--boost-ui-secondary) 12%, transparent);
    backdrop-filter: blur(3px);
    pointer-events: none;
}

.bgf-hud__metrics {
    display: grid;
    gap: 5px;
}

.bgf-hud--compact {
    width: max-content;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.bgf-hud__metric,
.bgf-hud__resource {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 8px;
    min-width: 0;
}

.bgf-hud__label {
    overflow: hidden;
    font-size: clamp(0.58rem, 1.3vw, 0.76rem);
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bgf-hud__value {
    font-size: clamp(0.65rem, 1.4vw, 0.82rem);
    font-weight: 800;
}

.bgf-hud__meter {
    grid-column: 1 / -1;
    height: 6px;
    background: var(--boost-ui-bg-alt);
}

.bgf-hud__meter > span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--boost-ui-success);
    transition: width 120ms steps(6, end);
}

.bgf-hud__resource[data-bgf-state="warning"] .bgf-hud__meter > span {
    background: var(--boost-ui-warning);
}

.bgf-hud__resource[data-bgf-state="critical"] .bgf-hud__meter > span {
    background: var(--boost-ui-error);
}

.bgf-hud__metric--compact {
    grid-template-columns: 22px auto;
    align-items: center;
    width: max-content;
    min-width: 84px;
    padding: 4px 6px;
    border: 1px solid color-mix(in srgb, var(--boost-ui-secondary) 14%, var(--boost-ui-border));
    border-radius: 12px;
    background: color-mix(in srgb, var(--boost-ui-bg) 72%, transparent);
}

.bgf-hud__metric--compact .bgf-hud__value {
    min-width: 4.5ch;
    font-size: clamp(0.72rem, 1.8vw, 0.95rem);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.bgf-hud__icon {
    position: relative;
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-radius: 50%;
}

.bgf-hud__icon::before,
.bgf-hud__icon::after {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2px;
    content: "";
    background: currentColor;
    transform-origin: 50% 0;
}

.bgf-hud__icon::before {
    height: 5px;
    transform: translate(-1px, -1px);
}

.bgf-hud__icon::after {
    height: 4px;
    transform: translate(-1px, -1px) rotate(120deg);
}

.bgf-hud__metric--compact[data-bgf-state="warning"] {
    color: var(--boost-ui-warning);
    border-color: var(--boost-ui-warning);
}

.bgf-hud__metric--compact[data-bgf-state="critical"] {
    color: var(--boost-ui-error);
    border-color: var(--boost-ui-error);
}

@media (max-width: 720px) {
    .bgf-hud {
        width: min(250px, calc(100% - 16px));
        inset-inline-start: 8px;
        padding: 6px 8px;
    }
}

.bgf-hud__life-icons {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    min-width: max-content;
    max-width: 100%;
    overflow: hidden;
}

.bgf-hud__life-icon,
.bgf-hud__life-icon.bgf-icon,
.bgf-hud__life-icon.bgf-icon--image {
    display: inline-block;
    width: 0.95em;
    height: 0.95em;
    max-width: 0.95em;
    max-height: 0.95em;
    flex: 0 0 auto;
}

.bgf-hud__metric [data-bgf-hud-metric-value] {
    min-width: 0;
}

.bgf-hud__life-icon--empty {
    opacity: 0.46;
}

.bgf-hud__life-icon.bgf-icon--image {
    object-fit: contain;
}

.bgf-hud__active-effects {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.bgf-hud__active-effect {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 2px 6px;
    min-width: 86px;
    padding: 4px 6px;
    border: 1px solid color-mix(in srgb, var(--boost-ui-primary) 28%, var(--boost-ui-border));
    border-radius: 9px;
    background: color-mix(in srgb, var(--boost-ui-primary) 9%, var(--boost-ui-surface));
    color: var(--boost-ui-text);
    line-height: 1.1;
}

.bgf-hud__active-effect-label {
    max-width: 88px;
    overflow: hidden;
    font-size: 0.68rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bgf-hud__active-effect-time {
    color: var(--boost-ui-text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-align: right;
}

.bgf-hud__active-effect-meter {
    grid-column: 1 / -1;
    overflow: hidden;
    height: 3px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--boost-ui-border) 65%, transparent);
}

.bgf-hud__active-effect-meter > span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--boost-ui-primary);
}

.bgf-hud[data-bgf-hud-position="top-right"] {
    inset: max(10px, var(--boost-game-safe-area-top)) 10px auto auto;
}

.bgf-hud[data-bgf-hud-position="top-center"] {
    inset: max(10px, var(--boost-game-safe-area-top)) auto auto 50%;
    transform: translateX(-50%);
}

.bgf-hud[data-bgf-hud-position="bottom-left"] {
    inset: auto auto max(10px, var(--boost-game-safe-area-bottom)) 10px;
}

.bgf-hud[data-bgf-hud-position="bottom-right"] {
    inset: auto 10px max(10px, var(--boost-game-safe-area-bottom)) auto;
}

.bgf-hud[data-bgf-hud-position="bottom-center"] {
    inset: auto auto max(10px, var(--boost-game-safe-area-bottom)) 50%;
    transform: translateX(-50%);
}

.bgf-hud[data-bgf-hud-variant="glass"] {
    background: color-mix(in srgb, var(--boost-ui-surface) 72%, transparent);
    backdrop-filter: blur(8px);
}

.bgf-hud[data-bgf-hud-variant="solid"] {
    background: var(--boost-ui-surface);
    backdrop-filter: none;
}

.bgf-hud[data-bgf-hud-variant="minimal"] {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.bgf-hud[data-bgf-hud-density="compact"] {
    gap: 4px;
    padding: 5px 7px;
}

.bgf-hud[data-bgf-hud-density="compact"] .bgf-hud__metrics {
    gap: 3px;
}

.bgf-hud[data-bgf-hud-density="compact"] .bgf-hud__label {
    font-size: clamp(0.52rem, 1vw, 0.68rem);
}

.bgf-hud[data-bgf-hud-density="compact"] .bgf-hud__value {
    font-size: clamp(0.58rem, 1.1vw, 0.72rem);
}

.bgf-hud[data-bgf-hud-metrics-layout="inline"] .bgf-hud__metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 9px;
    align-items: center;
}

.bgf-hud[data-bgf-hud-metrics-layout="inline"] .bgf-hud__metric {
    display: inline-flex;
    gap: 5px;
    align-items: baseline;
}

.bgf-hud[data-bgf-hud-show-labels="false"] .bgf-hud__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.bgf-hud[data-bgf-hud-show-labels="false"] .bgf-hud__metric,
.bgf-hud[data-bgf-hud-show-labels="false"] .bgf-hud__resource {
    grid-template-columns: auto;
}

.bgf-hud[data-bgf-hud-resource-style="value"] .bgf-hud__meter {
    display: none;
}

