/**
 * Comment Rating & Image Upload Styles
 *
 * Star rating, image preview, and comment display styles.
 */

/* ============================================
   Star Rating - Comment Form
   ============================================ */

.star-rating-wrapper {
    display: inline-flex;
    flex-direction: row-reverse; /* 从右向左，hover 时左边也跟着亮 */
    gap: 2px;
    font-size: 0; /* 消除 inline-block 间隙 */
}

.star-rating-wrapper input[type="radio"] {
    display: none; /* 隐藏原生 radio */
}

.star-rating-wrapper label {
    font-size: 24px;
    color: #ccc;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
    user-select: none;
    line-height: 1;
}

.star-rating-wrapper label:hover,
.star-rating-wrapper label.hover {
    color: #f5a623;
    transform: scale(1.15);
}

/* 选中状态的星星 */
.star-rating-wrapper label.selected {
    color: #f5a623;
}

/* 由于是 flex-direction: row-reverse，
   hover 时当前 label 及其右边的（实际上是左边的）都会高亮 */
.star-rating-wrapper label:hover ~ label,
.star-rating-wrapper label.hover ~ label {
    color: #f5a623;
}

/* 选中状态的星星：所有值 <= 已选值的都亮 */
.star-rating-wrapper label.selected ~ label {
    color: #f5a623;
}

/* ============================================
   Comment Form - Rating Error Shake
   ============================================ */

@keyframes rating-shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-4px); }
    30%, 70% { transform: translateX(4px); }
}

.star-rating-wrapper.rating-error-shake label {
    animation: rating-shake 0.5s ease;
}

.comment-form-rating {
    margin-bottom: 1rem;
}

.comment-form-rating label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

/* ============================================
   Image Upload - Comment Form
   ============================================ */

.comment-form-images {
    margin-bottom: 1rem;
}

.comment-form-images label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.comment-form-images .image-hint {
    font-weight: 400;
    font-size: 0.85em;
    color: #888;
    margin-left: 4px;
}

.comment-form-images input[type="file"] {
    display: block;
    margin-bottom: 10px;
    font-size: 0.9em;
}

.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    background: #f9f9f9;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#comments .image-preview-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s ease;
}

.image-preview-remove:hover {
    background: rgba(217, 83, 79, 0.9);
}

.image-error {
    font-size: 0.85em;
    margin-top: 4px;
}

/* ============================================
   Comment Display - Rating Stars
   ============================================ */

.comment-rating-display {
    margin-bottom: 8px;
    font-size: 0;
    line-height: 1;
}

.comment-rating-display .star {
    font-size: 18px;
    display: inline-block;
    margin-right: 1px;
}

.comment-rating-display .star.filled {
    color: #f5a623;
}

.comment-rating-display .star.empty {
    color: #ddd;
}

/* ============================================
   Comment Display - Uploaded Images
   ============================================ */

.comment-images-display {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 12px;
}

.comment-images-display .comment-image-link {
    display: block;
    width: 70px;
    height: 70px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    transition: border-color 0.2s ease, opacity 0.2s ease;
}

.comment-images-display .comment-image-link:hover {
    border-color: #f5a623;
    opacity: 0.85;
}

.comment-images-display .comment-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ============================================
   Collapsible Comment Form - "Leave a Reply" toggle
   ============================================ */

/* 默认折叠状态：隐藏表单 */
#respond.collapsed #commentform {
    display: none;
}

/* 标题作为可点击的切换按钮 */
#reply-title {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fafafa;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

#reply-title:hover {
    background: #fff8ee;
    border-color: #f5a623;
    color: #d4891a;
}

/* 展开后的样式 */
#respond:not(.collapsed) #reply-title {
    background: #fff8ee;
    border-color: #f5a623;
    border-style: solid;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}

/* ★ 星级图标 */
#reply-title::before {
    content: '★';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 22px;
    line-height: 1;
    color: #f5a623;
    background: linear-gradient(135deg, #fff7e6, #ffe8c0);
    border: 2px solid #f5a623;
    border-radius: 50%;
    flex-shrink: 0;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.35s ease;
}

/* 折叠时：脉冲动画吸引点击 */
#respond.collapsed #reply-title::before {
    animation: star-pulse 2.2s ease-in-out infinite;
}

/* 展开时：星星变实心，放大 */
#respond:not(.collapsed) #reply-title::before {
    transform: scale(1.15);
    background: linear-gradient(135deg, #f5a623, #e8961a);
    color: #fff;
    box-shadow: 0 2px 10px rgba(245, 166, 35, 0.4);
}

@keyframes star-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245, 166, 35, 0.4);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 0 0 8px rgba(245, 166, 35, 0);
    }
}

/* 标题中的 "Cancel reply" 链接保持可点击 */
#reply-title small {
    margin-left: auto;
}

#reply-title small a {
    cursor: pointer;
}

/* 新评论插入高亮动画 */
@keyframes comment-highlight {
    0%   { background-color: rgba(245, 166, 35, 0.25); }
    100% { background-color: transparent; }
}

.comment-new-highlight {
    animation: comment-highlight 2.5s ease-out;
    border-radius: 6px;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 480px) {
    .star-rating-wrapper label {
        font-size: 24px;
    }

    .image-preview-item {
        width: 60px;
        height: 60px;
    }

    .comment-images-display .comment-image-link {
        width: 55px;
        height: 55px;
    }
}