/*!
 * 晓港收录检测 · 前台样式
 */

.xgic {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    vertical-align: middle;
    margin: 6px 0;
    font-size: 12px;
    line-height: 1;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

.xgic-label {
    color: #9aa1ac;
    font-size: 12px;
    letter-spacing: .5px;
    white-space: nowrap;
}

.xgic-label b {
    font-weight: 600;
    color: #6b7280;
    margin-left: 2px;
    font-variant-numeric: tabular-nums;
}

.xgic-items {
    display: inline-flex;
    align-items: center;
    /* 图标越大，间距跟着放大一点，否则大图标挤成一团 */
    gap: clamp(5px, calc(var(--xgic-size, 20px) * .26), 10px);
}

/* ---------- 单个图标 ---------- */
/* 尺寸由后台「图标大小」决定，PHP 输出 --xgic-size；缺省 20px */
.xgic-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--xgic-size, 20px);
    height: var(--xgic-size, 20px);
    border-radius: 5px;
    text-decoration: none !important;
    border: none !important;
    background: none !important;
    color: #c2c7cf;
    transition: transform .16s ease, color .16s ease, opacity .16s ease, box-shadow .16s ease;
    opacity: .95;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.xgic-item svg,
.xgic-item .xgic-logo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.xgic-item .xgic-logo {
    transition: filter .18s ease, opacity .18s ease;
}

/* 已收录：原彩 logo */
.xgic-item.is-hit {
    color: var(--xgic-brand, #165dff);
    opacity: 1;
}

.xgic-item.is-hit .xgic-logo {
    filter: none;
    opacity: 1;
}

/* 未收录：去色 */
.xgic-item.is-miss {
    color: #b3b9c2;
    opacity: 1;
}

.xgic-item.is-miss .xgic-logo {
    filter: grayscale(1);
    opacity: .42;
}

/* 待检测：去色且更淡，加虚线框表示「还没确认」 */
.xgic-item.is-unknown {
    color: #ccd1d8;
    opacity: 1;
    outline: 1px dashed #dfe3e8;
    outline-offset: -1px;
}

.xgic-item.is-unknown .xgic-logo {
    filter: grayscale(1);
    opacity: .3;
}

.xgic-item:hover {
    transform: translateY(-2px) scale(1.08);
    opacity: 1;
}

.xgic-item.is-hit:hover {
    box-shadow: 0 3px 10px -2px var(--xgic-brand, #165dff);
}

.xgic-item.is-miss:hover .xgic-logo,
.xgic-item.is-unknown:hover .xgic-logo {
    filter: grayscale(1);
    opacity: .62;
}

.xgic-item.is-miss:hover,
.xgic-item.is-unknown:hover {
    color: #8a919c;
}

.xgic-svg {
    border-radius: 5px;
    overflow: visible;
}

/* ---------- 刷新按钮 ---------- */
.xgic-refresh {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: #b6bcc6;
    text-decoration: none !important;
    border: none !important;
    transition: color .16s, transform .3s;
    opacity: .7;
    line-height: 0;
}

.xgic-refresh:hover {
    color: #6b7280;
    opacity: 1;
    transform: rotate(90deg);
}

.xgic-refresh.is-loading svg {
    animation: xgic-spin .9s linear infinite;
}

@keyframes xgic-spin {
    to { transform: rotate(360deg); }
}

/* ---------- 弹出面板 ---------- */
.xgic-pop {
    position: absolute;
    top: 0;
    left: 0;
    min-width: 236px;
    max-width: 268px;
    width: 258px;
    background: #fff;
    border: 1px solid #ebedf0;
    border-radius: 10px;
    box-shadow: 0 8px 28px -8px rgba(15, 23, 42, .22), 0 2px 6px -2px rgba(15, 23, 42, .08);
    padding: 12px 13px;
    z-index: 99999;
    text-align: left;
    box-sizing: border-box;
    opacity: 1;
}

.xgic-pop::before {
    content: "";
    position: absolute;
    top: -5px;
    left: var(--arrow-x, 10px);
    width: 9px;
    height: 9px;
    background: #fff;
    border-left: 1px solid #ebedf0;
    border-top: 1px solid #ebedf0;
    transform: rotate(45deg);
}

/* 空间不够时翻到图标上方，箭头朝下 */
.xgic-pop.is-up::before {
    top: auto;
    bottom: -5px;
    transform: rotate(225deg);
}

.xgic-pop-title {
    font-size: 13px;
    font-weight: 600;
    color: #1d2129;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    line-height: 1.4;
}

.xgic-pop-title i {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    flex: none;
}

.xgic-pop-desc {
    font-size: 12px;
    color: #86909c;
    line-height: 1.6;
    margin-bottom: 10px;
}

.xgic-pop-btns {
    display: flex;
    gap: 7px;
    align-items: center;
}

.xgic-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 27px;
    padding: 0 11px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all .15s;
    text-decoration: none !important;
    white-space: nowrap;
    font-family: inherit;
}

.xgic-btn-primary {
    background: #165dff;
    color: #fff !important;
}

.xgic-btn-primary:hover {
    background: #0e42d2;
}

.xgic-btn-primary:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.xgic-btn-ghost {
    background: #f7f8fa;
    color: #4e5969 !important;
    border-color: #e5e6eb;
}

.xgic-btn-ghost:hover {
    background: #eff1f4;
}

.xgic-pop-tip {
    font-size: 11px;
    color: #a8aeb8;
    margin-top: 8px;
    line-height: 1.5;
}

/* ---------- 轻提示 ---------- */
.xgic-toast {
    position: fixed;
    left: 50%;
    bottom: 40px;
    transform: translateX(-50%) translateY(10px);
    background: rgba(29, 33, 41, .92);
    color: #fff;
    font-size: 13px;
    padding: 9px 18px;
    border-radius: 20px;
    z-index: 99999;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    max-width: 80vw;
    text-align: center;
    line-height: 1.5;
}

.xgic-toast.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---------- 深色主题适配 ---------- */
@media (prefers-color-scheme: dark) {
    .xgic-pop {
        background: #22252b;
        border-color: #33373f;
        box-shadow: 0 10px 32px -10px rgba(0, 0, 0, .7);
    }
    .xgic-pop::before {
        background: #22252b;
        border-color: #33373f;
    }
    .xgic-pop-title { color: #e8eaed; }
    .xgic-pop-desc { color: #9096a0; }
    .xgic-btn-ghost {
        background: #2c3038;
        border-color: #3a3f48;
        color: #c3c8d0 !important;
    }
    .xgic-btn-ghost:hover { background: #353a43; }
    .xgic-label { color: #7b828d; }
    .xgic-label b { color: #b3b9c2; }
    .xgic-item.is-miss { color: #5d636d; }
    .xgic-item.is-unknown { color: #4d525b; outline-color: #3b4048; }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 480px) {
    .xgic { gap: 6px; }
    /* 手机上一排放不下太大的图标，最多收到 22px，但不会小于 16px */
    .xgic-item {
        width: clamp(16px, var(--xgic-size, 20px), 22px);
        height: clamp(16px, var(--xgic-size, 20px), 22px);
    }
    .xgic-pop { min-width: 190px; }
}
