/* 相册网格布局 */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    grid-auto-rows: max-content; 
    gap: 10px;
    padding: 10px;
    border: 1px solid gray;
    border-radius: 10px;
    background: white;
    margin: 0 1rem;
    align-content: start; 
    overflow-y: auto;
}

@media (max-width: 500px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }
}

@media (prefers-color-scheme: dark) {
    .gallery-grid {
        background-color: #1E1E1E;
    }
}

/* 单个图片卡片 */
.gallery-item {
    position: relative;
    aspect-ratio: 1 / 1; /* 强制正方形 */
    overflow: hidden;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s;
    background: #eee;
}

.gallery-item:hover {
    transform: scale(1.05);
    z-index: 10;
}

/* 缩略图 */
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* 填充但不变形 */
}

/* 当容器开启模糊模式时，里面的图片变糊 */
.gallery-grid.blur-mode .gallery-item img {
    filter: blur(15px);
}

/* 状态标签 (比如: 已加密) */
.gallery-label {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.8rem;
    text-align: center;
    padding: 2px 0;
}

/* --- 灯箱 (大图预览) 样式 --- */
.lightbox {
    display: none; /* 默认隐藏 */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.lightbox img {
    max-width: 90%;
    max-height: 80%;
    border: 2px solid white;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px; /* 位置微调，靠右一点 */
    z-index: 1002;
    
    /* 圆形按钮样式 */
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    
    /* 文字居中 */
    font-size: 30px; /* 叉号稍微大一点 */
    font-weight: normal; /* 不用太粗 */
    line-height: 34px; /* 微调垂直对齐 */
    text-align: center;
    
    cursor: pointer;
    transition: 0.3s;
    user-select: none;
}

/* 悬停效果 */
.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
    transform: scale(1.1);
}

#lightbox-caption {
    margin-top: 10px;
    color: #ccc;
    font-size: 14px;
}

/* 左右切换按钮 */
.lightbox-prev, .lightbox-next {
    cursor: pointer;
    position: absolute;
    top: 50%;
    width: auto;
    padding: 16px;
    margin-top: -50px; /* 垂直居中 */
    color: white;
    font-weight: bold;
    font-size: 30px;
    transition: 0.6s ease;
    border-radius: 0 3px 3px 0;
    user-select: none;
    background-color: rgba(0,0,0,0.3); /* 半透明背景，防止在白图上看不见 */
}

/* 位置设定 */
.lightbox-prev {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.lightbox-next {
    right: 0;
    border-radius: 3px 0 0 3px;
}

/* 悬停效果 */
.lightbox-prev:hover, .lightbox-next:hover {
    background-color: rgba(0,0,0,0.8);
    transform: scale(1.1);
}

#lightbox-blur-toggle:hover, #lightbox-blur-toggle.active:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
}

/* 激活状态 (模糊开启时) */
#lightbox-blur-toggle.active {
    background: rgba(255, 255, 255, 0.4);
    color: #333;
}

/* 图片模糊类 */
.lightbox-img-blur {
    filter: blur(20px); /* 模糊程度 */
    clip-path: inset(0); 
    transition: filter 0.3s ease;
}

/* 按钮组容器 */
.lightbox-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    /*transform: translateX(-50%); /* 居中显示 */
    display: flex;
    gap: 15px; /* 按钮间距 */
    z-index: 1001;
}

/* 按钮通用样式 */
.lightbox-controls button {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%; /* 圆形按钮 */
    width: 45px;
    height: 45px;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    outline: none;
}

.lightbox-controls button:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: white;
    transform: scale(1.1);
}

#lightbox-caption {
    position: absolute;
    bottom: 20px;
    left: 20px;
}

/* 确保按钮是定位基准 */
#lightbox-blur-toggle {
    position: relative; 
    /* 如果按钮原本有 overflow: hidden，需要去掉，否则气泡会被切掉 */
    overflow: visible; 
}

/* 气泡本体样式 */
.hint-bubble {
    position: absolute;
    bottom: 130%; /* 移到按钮上方，留一点距离 */
    left: 50%;
    transform: translateX(-50%); /* 水平居中 */
    
    background-color: #333; /* 深色背景 */
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 6px;
    white-space: nowrap; /* 防止文字换行 */
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    
    /* 关键：默认隐藏 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, bottom 0.3s;
    
    /* 防止气泡挡住鼠标点击，让点击穿透到按钮上 */
    pointer-events: none;
    z-index: 10;
}

/* 气泡下方的小三角形 */
.hint-bubble::after {
    content: "";
    position: absolute;
    top: 100%; /* 在气泡底部 */
    left: 50%;
    margin-left: -5px; /* 居中校正 */
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent; /* 只显示上边框颜色 */
}

/* 激活状态：显示气泡 */
.hint-bubble.show {
    opacity: 1;
    visibility: visible;
    bottom: 140%; /* 加一点向上浮动的动画效果 */
}