/* Weapon detail popup and the perk columns inside it. */

.popup-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.72);
}

.popup {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: fit-content;
    max-width: 100%;
    max-height: 100%;
    padding: 10px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.7);
}

.popup:focus {
    outline: none;
}

/* Scoped rather than editing base.css's global button/h1 rules — the popup's
   buttons carry an icon beside their label, and its h1 sits tighter above the
   pill rows than the app default (filters.css's .filter-pill is untouched
   too; the popup gets its own .popup-pill* family below). */
.popup button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
}

.popup h1 {
    margin: 0 0 2px;
}

.popup-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--tile-rarity, var(--border));
}

.popup-icon {
    width: 72px;
    height: 72px;
    border-radius: 2px;
}

.popup-title {
    flex: 1;
}

.popup-close {
    align-self: flex-start;
    padding: 2px 9px;
}

.popup-error {
    padding: 8px 10px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--damage-solar);
    border-radius: 3px;
    word-break: break-word;
}

/* --- pill rows: power/slot/rarity/state/tier (.popup-type) and
   damage/ammo/weapon-type/champion/kills (.popup-details) --- */

.popup-type {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    font-size: 12px;
}

.popup-name-row {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
}

.popup-season {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: normal;
    padding-left: 8px;
    border-left: 1px solid var(--border);
}

.popup-season-icon-wrap {
    display: flex;
    flex: none;
}

.popup-season-text {
    font-size: 12px;
}

.popup-season-icon {
    width: 16px;
    height: 16px;
    flex: none;
}

.popup-details {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    margin-top: 2px;
}

/* New popup-only pill (WeaponPopup.js's Pill component), parallel to
   filters.css's .filter-pill but never sharing its rule (resolution 9) —
   sized down for the popup's tighter rows. Non-interactive info pills are
   plain <div>s that still pick up :hover's accent border; carried over from
   the sandbox as-is. */
.popup-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px;
    min-height: 22px;
    line-height: 16px;
    font-size: 13px;
    color: var(--text);
    background: none;
    border: 1px solid transparent;
    border-radius: 11px;
    cursor: pointer;
}

.popup-pill:hover {
    border-color: var(--accent);
}

.popup-pill.is-selected {
    background: #2c3a4c;
    border-color: var(--accent);
}

/* Keep/Trash buttons (TagActions) — plain rectangular buttons like
   Lock/Unlock, not the rounded .popup-pill shape; is-selected marks the
   currently-set tag, outlined in that tag's own colour rather than the
   generic accent. */
.popup-tag-group button.is-selected.icon-keep {
    background: #2c3a4c;
    border-color: var(--tag-keep);
}

.popup-tag-group button.is-selected.icon-trash {
    background: #2c3a4c;
    border-color: var(--tag-trash);
}

.popup-power-pill {
    font-size: 14px;
}

.popup-power-icon {
    width: 16px;
    height: 16px;
    flex: none;
    fill: currentColor;
}

/* Crafted/Craftable and Masterworked state pills — the icon's own shipped
   colour (domain/iconData.js UI_ICONS, via ColouredIcon) sets the fill, not
   currentColor. */
.popup-state-icon {
    width: 16px;
    height: 16px;
    flex: none;
}

/* Damage Type's real coloured SVG — also reused for the ammo/champion/rarity
   mask-glyph pills' icon box below (no separate class per glyph, unlike
   filters.css's .filter-pill-icon-damage / .filter-pill-glyph-ammo split). */
.popup-pill-icon {
    display: block;
    width: 16px;
    height: 16px;
    flex: none;
}

.popup-pill-glyph {
    width: 18px;
    height: 16px;
    flex: none;
}

.popup-pill-glyph-weapon {
    height: 16px;
    max-width: 44px;
    flex: none;
}

.popup-pill:has(.popup-pill-glyph-weapon) {
    padding-left: 5px;
}

/* Lock/Unlock and Keep/Trash button glyphs (LockActions/TagActions,
   WeaponPopup.js). */
.popup-btn-icon {
    width: 18px;
    height: 18px;
    flex: none;
    fill: currentColor;
}

.popup-btn-icon.icon-keep {
    fill: var(--tag-keep);
}

.popup-btn-icon.icon-trash {
    fill: var(--tag-trash);
}

.popup-body {
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 10px;
}

.popup-body > * + * {
    border-left: 1px solid var(--border);
    padding-left: 10px;
}

.popup-stats-col {
    flex: 0 0 auto;
    margin-right: -10px;
}

.popup-wishlist-perks {
    flex: 0 0 auto;
}

.wishlist-perks-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wishlist-perks-row {
    display: flex;
    gap: 6px;
}

.wishlist-perk-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 20px;
    height: 20px;
    line-height: 1;
    padding: 0;
    border-radius: 4px;
    font-size: 11px;
}

.popup-col-header {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-dim);
}

.popup-perks-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.popup-perks-header-row .popup-col-header {
    margin: 0 0 6px;
}

.popup button.popup-perks-add {
    font-size: 10px;
    padding: 1.5px 5px;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 2px 0;
    border-bottom: 1px solid var(--border);
}

.popup-row-label {
    color: var(--text-dim);
}

.popup-row-value {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.popup-row-mono {
    font-family: monospace;
}

.popup-copy-btn-wrap {
    display: inline-flex;
    gap: 4px;
}

.popup-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
}

.popup-copy-icon {
    width: 13px;
    height: 13px;
    aspect-ratio: 1 / 1;
    flex: none;
    fill: currentColor;
}

/* --- stats --- */

.popup-stats {
    --stat-bar-width: 150px;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: max-content max-content var(--stat-bar-width);
    align-items: center;
    column-gap: 6px;
    row-gap: 0;
}

.popup-stats > .popup-stat-label,
.popup-stats > .popup-stat-value {
    padding: 1px 0;
}

/* The bar/number split is structural now (07-weapon-stats-popup.md section 2)
   — two sibling .popup-stats grids sharing the same column template so labels
   and values still align vertically across both, separated by a margin
   instead of an in-grid spacer row. .popup-stats-group stacks them as one
   flex child of .popup-body (row-direction) so they render as one column
   instead of side by side. */
.popup-stats-group {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
}

.popup-stats-bar {
    margin-bottom: 8px;
}

.popup-stats-bar::after {
    content: "";
    grid-column: 1 / -1;
    height: 1px;
    margin-top: 8px;
    background: var(--border);
}

.popup-stat-label {
    color: var(--text-dim);
}

.popup-stat-value {
    font-variant-numeric: tabular-nums;
}

/* Internal chart colours with no existing token (#333/#fff here and in
   .popup-recoil-dial's dial track/sweep below) — carried over as-is;
   inventing four tokens for a one-off bar chart is out of scope. */
.popup-stat-bar {
    height: 10px;
    background: #333;
    border-radius: 1px;
    overflow: hidden;
}

.popup-stat-bar-fill {
    height: 100%;
    background: #fff;
}

.popup-stat-bar-empty {
    display: block;
}

.popup-recoil-dial {
    width: 28px;
    height: 12px;
    display: block;
}

/* --- perk columns --- */

.perk-columns {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 4px;
}

.perk-column {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

.perk-subcolumn {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Holds a row open where a canonical perk has no base or no enhanced variant,
   so the two trait sub-columns stay row-aligned. */
.perk-cell-spacer {
    width: 42px;
    height: 42px;
}

.perk-cell {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 2px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 50%;
    opacity: 0.55;
}

/* Re-asserts display/padding against .popup button (same 1-class-1-type
   specificity, wins on source order): that rule's inline-flex + 3px 8px
   padding is meant for labelled action buttons, not this perk avatar, and
   its asymmetric horizontal padding squeezed the icon into a 24x34 oval
   instead of the definition-mode <div>'s 36x36 circle. */
button.perk-cell {
    display: flex;
    padding: 2px;
    cursor: pointer;
}

.perk-cell img {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
}

.perk-cell.is-active,
.perk-cell.is-selected {
    opacity: 1;
    border-color: var(--accent);
    background: #2c3a4c;
}

/* A retired perk is dimmed rather than hidden — knowing it cannot currently
   roll is useful. */
.perk-cell.is-retired {
    opacity: 0.25;
}

/* Enhanced variants sit adjacent to their base perk; the inset ring is the
   visual link. */
.perk-cell.is-enhanced {
    box-shadow: inset 0 0 0 2px var(--rarity-exotic);
}

/* A perk excluded by the current selection's enhanced-ness. Dimmer than
   .is-retired so the two states stay distinguishable at a glance. Placed
   after is-active/is-selected/is-retired (same specificity, source order
   decides) so it wins the cascade; is-enhanced's box-shadow still draws at
   this opacity, so a greyed enhanced perk keeps its ring. */
.perk-cell.is-disabled {
    opacity: 0.15;
    pointer-events: none;
}

/* Columns 1/2/5 while picking a wishlist entry — never selectable, so
   greyscale marks them apart from the two trait columns' dimmed-but-pickable
   perks. */
.perk-cell.is-nonselectable {
    opacity: 0.3;
    filter: grayscale(1);
}

.perk-cell-badge {
    position: absolute;
    width: 12px;
    height: 12px;
}

.perk-cell-badge-tr {
    top: -1px;
    right: -1px;
}

.perk-empty {
    padding: 8px 0;
}

/* --- actions --- */

.popup-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    padding-top: 5px;
    border-top: 1px solid var(--border);
}

.popup-tag-group {
    display: flex;
    gap: 4px;
}

.popup-tag-group button {
    padding-left: 4px;
    padding-right: 4px;
}

.popup-note {
    margin: 0;
    color: var(--status-error);
    font-size: 13px;
}

.popup-note ul {
    margin: 2px 0 0;
    padding-left: 18px;
}

.popup-btn-danger {
    background: var(--status-error);
    border-color: var(--status-error);
    color: #fff;
}

/* Debug-only ID row (users_whitelist.debug_user) — its own section below
   .popup-actions rather than folded into it, so Weapon ID/Instance ID never
   compete with Lock/Tag/Wishlist Add for that row's wrapping. */
/* Pulls up into .popup's 10px flex gap (the space above popup-actions) —
   that gap is shared by every popup section, so this is the only way to
   tighten just this one pairing without touching the others. */
.popup-debug-row {
    display: flex;
    gap: 16px;
    margin-top: -6px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

/* Side-by-side rather than .popup-row's default space-between/full-width
   divider styling, which assumes one row per line. */
.popup-row-inline {
    flex: 0 0 auto;
    justify-content: flex-start;
    padding: 0;
    border-bottom: none;
}

/* Inline "Wishlist Perks already exist" message beside the Add button.
   Deliberately its own class, not .popup-error above — that one is a padded,
   bordered full-width banner (actionError), and reusing its name here would
   have this rule's color/font-size win the cascade on that banner too. */
.popup-perk-error {
    color: var(--status-error);
    font-size: 12px;
    margin-left: 8px;
}

/* Export/import dialogs (TransferDialogs.js). */
.popup-dialog h2 {
    margin: 0;
}

.popup-dialog-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.popup-dialog-option button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    flex-shrink: 0;
}

.popup-dialog-option p {
    margin: 2px 0 0;
    white-space: pre-line;
}

.popup-dialog-text {
    white-space: pre-line;
}

.popup-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.popup-dialog-actions-center {
    justify-content: center;
}

