/* General Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; /* 常用无衬线字体栈 */
    margin: 0;
    padding: 0;
    background-color: #f8f8f8; /* 更轻的背景色 */
    color: #333;
    line-height: 1.6;
}

/* Main Container for max width and centering */
.main-container {
    max-width: 1500px; /* Limit content width, adjust as needed */
    margin: 0 auto; /* Center the container */
    padding: 0 10px; /* Add some padding on the sides */
}


header {
    background-color: #c0392b; /* 深红色 */
    color: #fff;
    padding: 20px 0;
    text-align: center;
    margin-bottom: 20px;
}

header h1 {
    margin: 0;
    font-size: 2.5em;
    font-weight: bold; /* 标题加粗 */
}

header h2 {
    margin: 5px 0 15px 0;
    font-size: 1.2em;
    font-weight: normal;
    color: #f5f5f5;
}

#join-button {
    background-color: #f39c12; /* 橙色 */
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

#join-button:hover {
    background-color: #e67e22; /* 深橙色 */
}

/* --- Sort Controls Styling --- */
.sort-controls {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
    background-color: #eee;
    border-radius: 5px;
    display: flex; /* Use flexbox for layout */
    flex-wrap: wrap; /* Allow wrapping on extremely small screens */
    justify-content: center; /* Center items horizontally */
    align-items: center; /* Center items vertically */
}

.sort-controls span {
    margin-right: 10px; /* Space between text and buttons */
    font-size: 0.95em;
    color: #555;
}

.sort-controls button {
    margin: 5px; /* Adjusted margin for spacing on all screens */
    padding: 5px 10px;
    cursor: pointer;
    border: 1px solid #ccc;
    background-color: #fff;
    border-radius: 3px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    font-size: 0.9em; /* Slightly smaller button font */
}

.sort-controls button:hover:not(.active) {
    background-color: #f0f0f0;
}

.sort-controls button.active {
    background-color: #3498db; /* 蓝色 */
    color: white;
    border-color: #3498db;
}
/* --- End Sort Controls Styling --- */


section {
    margin-bottom: 30px;
    /* Padding moved to .main-container */
}

section h3 {
    text-align: center;
    color: #c0392b; /* 深红色 */
    margin-bottom: 20px;
    border-bottom: 2px solid #c0392b;
    display: inline-block;
    padding-bottom: 5px;
    margin-left: auto;
    margin-right: auto;
    display: block;
    width: fit-content;
}


/* Stone List Layout */
.stone-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* Base: Allows approx 2 columns on mobile */
    gap: 20px; /* Space between items - will adjust on mobile */
}

/* Stone Card Styles */
.stone-card {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer; /* Indicate it's clickable */

    /* Animation for card entrance */
    animation: fadeIn 0.5s ease-out;

    position: relative; /* Needed for positioning the badge */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}


.stone-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* --- Recommended Card Specific Style --- */
.stone-card.is-recommended {
    border-color: #f39c12; /* Orange border */
    box-shadow: 0 4px 8px rgba(243, 156, 18, 0.3); /* Orange shadow */
    /* You could add a subtle background color too if desired */
    /* background-color: #fffaf0; */
}

.recommended-badge {
    position: absolute;
    top: 10px; /* Adjust position as needed */
    right: 10px; /* Adjust position as needed */
    background-color: #f39c12; /* Orange background */
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    z-index: 10; /* Ensure badge is above image */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
/* --- End Recommended Card Specific Style --- */


/* Image Container for Square Aspect Ratio */
.stone-image-container {
    width: 100%;
    padding-top: 100%; /* This makes the container height equal to its width */
    position: relative; /* Needed for absolute positioning of the image */
    overflow: hidden; /* Hide parts of the image outside the square */
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.stone-card img {
    position: absolute; /* Position image within the container */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Crop image to fill the square container */
    display: block;
}

/* --- Stone Info Styling --- */
.stone-info {
    padding: 15px;
    flex-grow: 1; /* Allows info block to take available space */
    display: flex;
    flex-direction: column;
    font-size: 0.9em;
    color: #555;
}

.stone-info h4 {
    margin-top: 0;
    margin-bottom: 8px;
    color: #2c3e50; /* 深蓝灰色 */
    font-size: 1.1em;
    font-weight: bold;
}

/* Smaller font and less margin for Type and Collector */
.stone-info p {
    margin: 2px 0; /* Reduced vertical margin/line height */
    font-size: 0.85em; /* Smaller font size */
}

.stone-info .price {
    font-size: 1.4em;
    color: #e74c3c; /* 红色 */
    font-weight: bold;
    margin: 5px 0 5px 0; /* Reduced top/bottom margin */
    text-align: center;
    border-top: 1px solid #eee; /* Add a subtle line above price */
    padding-top: 8px; /* Add space above line */
}

.stone-info .hotness {
    text-align: center;
    margin-top: auto; /* Pushes hotness to the bottom */
    color: #f1c40f; /* 黄色 */
    font-size: 1.2em;
    padding-top: 5px; /* Reduced space above hotness */
}
/* --- End Stone Info Styling --- */


/* Animation for flame icon */
@keyframes pulseFlame {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

.hotness .flame-icon {
    display: inline-block;
    margin: 0 1px; /* Small space between flames */
    animation: pulseFlame 1.5s ease-in-out infinite; /* Apply animation */
}

/* Add animation delay for staggering effect (optional, makes it look nicer) */
.hotness .flame-icon:nth-child(2) { animation-delay: 0.2s; }
.hotness .flame-icon:nth-child(3) { animation-delay: 0.4s; }
.hotness .flame-icon:nth-child(4) { animation-delay: 0.6s; }
.hotness .flame-icon:nth-child(5) { animation-delay: 0.8s; }


/* Load More Button */
#load-more-button {
    display: block; /* Center the button */
    margin: 20px auto;
    background-color: #3498db; /* 蓝色 */
    color: white;
    border: none;
    padding: 10px 20px;
    font-size: 1.1em;
    cursor: pointer;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

#load-more-button:hover {
    background-color: #2980b9; /* 深蓝色 */
}

#load-more-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}


/* --- Footer Styles --- */
footer {
    text-align: center;
    padding: 20px;
    margin-top: 30px;
    background-color: #333;
    color: #fff; /* Default color for footer text */
    font-size: 0.9em;
}

footer p {
    margin: 5px 0;
}

/* Style for the less noticeable Beian link */
.beian-link {
    color: #bbb; /* A lighter grey, less prominent than white */
    text-decoration: none; /* Remove underline from the link */
    transition: color 0.3s ease; /* Smooth color transition on hover */
}

.beian-link:hover {
    color: #ccc; /* Slightly lighter on hover */
    text-decoration: underline; /* Add underline back on hover for accessibility */
}
/* --- End Footer Styles --- */


/* Popup Overlay (shared for QR and Image) */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent black */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    visibility: hidden; /* Hidden by default */
    opacity: 0;
    transition: visibility 0s, opacity 0.3s ease;
}

.popup-overlay.visible {
    visibility: visible;
    opacity: 1;
}

/* QR Code Popup Content (Added qr-content class) */
.popup-content.qr-content {
    background-color: #fff;
    padding: 10px; /* Reduced padding to give more space for image */
    border-radius: 8px;
    text-align: center;
    position: relative;
    max-width: 95%; /* Allow wider on mobile if needed */
    width: 250px; /* Control the maximum width of the popup */
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Style for image inside QR popup */
.popup-content.qr-content img {
    display: block;
    max-width: 100%; /* Ensure image fits within the content box */
    height: auto; /* Maintain aspect ratio */
    margin: 0 auto; /* Center the image if it's smaller than container */
}


/* Image Popup Content */
.popup-image-content {
    background-color: transparent; /* Transparent background for image */
    padding: 0; /* No padding for image */
    box-shadow: none; /* No shadow for image */
    max-width: 95%; /* Allow image to be larger */
    max-height: 95vh; /* Limit image height */
    display: flex; /* Use flexbox to center image inside */
    justify-content: center;
    align-items: center;
}

.popup-image-content img {
    display: block; /* Remove extra space below image */
    max-width: 100%; /* Image should not exceed popup content width */
    max-height: 95vh; /* Image should not exceed viewport height */
    object-fit: contain; /* Scale image without cropping */
}


.popup-content .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    font-weight: bold;
    color: #fff; /* White close button for image popup */
    mix-blend-mode: difference; /* Ensure visibility on both light/dark images */
    cursor: pointer;
    z-index: 1010; /* Above the image */
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent background for readability */
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1; /* Adjust line height for centering */
}

.popup-content .close-button:hover {
    color: #ddd;
    background-color: rgba(0, 0, 0, 0.7);
}

/* Specific style for QR popup close button */
.popup-content.qr-content .close-button {
     color: #aaa; /* Original color for QR popup */
     mix-blend-mode: normal;
     background-color: transparent;
}
.popup-content.qr-content .close-button:hover {
    color: #777;
    background-color: transparent;
}


/* Responsive Design for Stone List Grid */

/* Base: Allows approx 2 columns on mobile */
.stone-list {
    display: grid; /* Ensure display is grid */
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px; /* Reduced default gap */
}

/* Tablet/Larger Phone (>= 600px): Allow ~2-3 columns */
@media (min-width: 600px) {
     .stone-list {
         grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
         gap: 20px; /* Restore original gap on larger screens */
     }
}

/* Small Desktop (>= 900px): Allow ~3-4 columns */
@media (min-width: 900px) {
     .stone-list {
         grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
         gap: 20px;
     }
}

/* Larger Desktop (>= 1200px): Allow ~4-5 columns (limited by main-container max-width) */
@media (min-width: 1200px) {
     .stone-list {
         grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); /* Increase min size slightly */
         gap: 20px;
     }
}


/* Mobile specific adjustments (max-width: 768px) */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    header h2 {
        font-size: 1em;
    }

    /* Ensure sort controls stay on one line if possible */
    .sort-controls {
         /* Flex properties already set */
    }
    .sort-controls button {
         margin: 3px; /* Further reduce button margin on smaller screens */
         font-size: 0.85em; /* Slightly smaller font for very small screens */
         padding: 4px 8px; /* Slightly smaller padding */
    }
     .sort-controls span {
         margin-right: 5px; /* Reduce space next to text */
         font-size: 0.9em;
     }


    /* Increase price font size on mobile */
    .stone-info .price {
        font-size: 1.6em; /* Larger price font on smaller screens */
         margin: 8px 0 5px 0; /* Adjust margins */
         padding-top: 6px; /* Adjust padding */
         border-top-width: 0; /* Remove border on mobile for cleaner look near price */
    }

     /* Adjust hotness spacing on mobile */
    .stone-info .hotness {
        padding-top: 5px; /* Already set, ensure it's not too large */
        margin-top: auto; /* Keep it pushed to bottom */
    }

    /* Image container aspect ratio already handles height */
    /* .stone-card img { height: auto; } */

    .stone-info {
        padding: 10px; /* Reduce info padding on mobile */
    }

    .stone-info h4 {
        font-size: 1.1em;
    }

    /* Adjust font and spacing for Type and Collector on mobile */
    .stone-info p {
        margin: 1px 0; /* Further reduced vertical margin */
        font-size: 0.8em; /* Smallest font size for details on mobile */
    }

    /* Adjust mobile card gap */
     .stone-list {
         gap: 15px; /* Ensure smaller gap is applied */
    }

    /* For very narrow screens, ensure 2 columns with minimal gap still works */
    @media (max-width: 380px) {
        .stone-list {
             grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); /* Allow slightly smaller card min-width */
             gap: 10px; /* Further reduce gap if necessary */
        }
         .stone-info {
              padding: 8px; /* Even less padding if needed */
         }
    }
}