/* Homer Patuach Grid - General Styles */
body {
    direction: rtl;
}
#hpg-container {
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    font-family: 'Rubik', sans-serif;
}
/* Filters Bar */
#hpg-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.hpg-filter-item {
    flex: 1 1 220px;
}
.hpg-search-item {
    flex: 2 1 300px;
}
#hpg-filters select,
#hpg-filters input[type="search"] {
    width: 100%;
    padding: 0 25px; /* Adjusted padding */
    border: 1px solid #ddd;
    border-radius: 50px;
    background-color: #fff;
    font-size: 16px;
    transition: border-color 0.3s, box-shadow 0.3s;
    font-family: 'Rubik', sans-serif; /* Added font */
    height: 50px; /* Explicit height */
    line-height: 50px; /* Match height to vertically center */
    -webkit-appearance: none; /* Remove default OS styling */
    -moz-appearance: none;
    appearance: none;
}
#hpg-filters select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23555' class='bi bi-chevron-down' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 20px center;
    padding-left: 45px;
}
#hpg-clear-filters {
    background: linear-gradient(135deg, #ff9a44, #ff5f6d);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 0 25px;
    border-radius: 50px;
    font-weight: bold;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
    box-shadow: 0 4px 15px rgba(255, 107, 129, 0.4);
    width: 100%;
    text-align: center;
    height: 50px;
    line-height: 50px;
}
#hpg-clear-filters:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 129, 0.5);
    color: white;
}
#hpg-filters select:focus,
#hpg-filters input[type="search"]:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
    outline: none;
}
/* Grid and card styles are now in submission.css for global access */

#hpg-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}
.spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #0073aa;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}
.hpg-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #777;
}

/* Custom Class Filter Styles */
.hpg-class-filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: flex-start;
}

.class-circle {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 45px;
    height: 45px;
    padding: 0 10px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    font-weight: 500;
    font-size: 14px;
    color: #555;
}

.class-circle:hover {
    border-color: #ff9a44;
    color: #ff9a44;
}

.class-circle.active {
    background: linear-gradient(135deg, #ff9a44, #ff5f6d);
    color: white;
    border-color: transparent;
    font-weight: bold;
    transform: scale(1.05);
} 

.hpg-card-footer .hpg-meta-item:hover {
    color: #000;
}

/*--------------------------------------------------------------
4.0 - Rating Stars
--------------------------------------------------------------*/
.hpg-card-content .hpg-card-meta {
    flex-grow: 1; /* Pushes the title/text part down, aligning footers */
}

.hpg-card-thumbnail {
    position: relative;
    height: 180px; /* Force a fixed, uniform height */
    flex-shrink: 0;
    overflow: hidden;
    background-color: #f9f9f9;
    z-index: 1; /* Sits at the bottom of the stack */
}

.hpg-card-thumbnail a,
.hpg-card-thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures the image covers the area without distortion */
}

.hpg-rating-stars-container {
    position: absolute;
    top: 180px; /* Aligns the top of the stars with the bottom of the thumbnail */
    left: 50%;
    transform: translate(-50%, -50%); /* Centers the stars exactly on the line */
    z-index: 3; /* Position above thumbnail and content */
    font-size: 20px;
    line-height: 1;
    
    /* Remove the ellipse background and padding */
    background-color: transparent;
    padding: 0;
    box-shadow: none;

    /* Add a shadow to the text itself so it's visible over complex images */
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.hpg-rating-stars-background,
.hpg-rating-stars-foreground {
    display: inline-block;
    letter-spacing: 1px;
    font-family: sans-serif; /* Use a stable font */
}

.hpg-rating-stars-background {
    color: rgba(255, 255, 255, 0.6); /* Semi-transparent white for background stars */
}

.hpg-rating-stars-foreground {
    position: absolute;
    top: 0;
    left: 0;
    white-space: nowrap;
    overflow: hidden;
    color: #fb8255;
} 

/*--------------------------------------------------------------
5.0 - Card Footer & Type Icon
--------------------------------------------------------------*/
.hpg-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-top: 1px solid #eee;
}

.hpg-footer-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.hpg-card-type-icon {
    font-size: 22px;
    line-height: 1;
    /* This will automatically be on the right in RTL due to HTML order */
}

.hpg-card {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.08);
    overflow: hidden; /* Keep this to maintain rounded corners on children */
    transition: transform 0.2s;
    position: relative;
}

.hpg-card:hover {
    transform: translateY(-5px);
}

.hpg-card-content {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    position: relative;
    z-index: 2;
    background: #fff;
}

.hpg-card-content .hpg-card-meta {
    flex-grow: 1;
}

/*--------------------------------------------------------------
6.0 - Related Posts Section
--------------------------------------------------------------*/
.hpg-related-posts-container .hpg-results-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Always 3 columns */
    gap: 20px;
}

/* Responsive adjustments for related posts */
@media (max-width: 768px) {
    .hpg-related-posts-container .hpg-results-grid-wrapper {
        grid-template-columns: 1fr; /* Stack on smaller screens */
    }
}

/* Ensure linked card titles remain black */
.hpg-card-title a {
    color: inherit; /* Inherit color from the h3 element */
    text-decoration: none; /* Remove underline */
}

.hpg-card-title a:hover {
    text-decoration: none; /* Optional: remove underline on hover too */
    color: inherit;
}

/* Edit button on profile page - NEW, MORE SPECIFIC SELECTORS */
.hpg-profile-posts .hpg-profile-post-item-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.hpg-profile-posts .hpg-profile-post-item-wrapper .hpg-card {
    flex-grow: 1;
}

.hpg-profile-posts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 35px; /* Increased gap to accommodate button */
    align-items: stretch;
}

.hpg-profile-posts .hpg-profile-edit-button {
    position: absolute;
    bottom: -15px;
    left: -15px;
    z-index: 10;
    
    display: flex;
    justify-content: center;
    align-items: center;
    
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: #FB8255;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: all 0.2s ease-in-out;
    text-decoration: none;
}

.hpg-profile-posts .hpg-profile-edit-button svg {
    width: 24px;
    height: 24px;
    fill: #FFFFFF;
}

.hpg-profile-posts .hpg-profile-edit-button:hover {
    transform: scale(1.1);
    background: #FB6965;
    color: #fff; /* Ensure icon color is white on hover too if it was text */
}

.hpg-profile-edit-button {
    position: absolute;
    top: 10px;
    left: 10px; /* Adjusted for RTL */
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background-color 0.3s;
    z-index: 11;
}

.hpg-profile-edit-button:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.hpg-profile-edit-button svg {
    fill: white;
}


/**
 * Collections Overview Grid
 * Styles for the [hpg_collections_grid] shortcode.
 */
.hpg-collections-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    direction: rtl;
}

/* Ensure collection cards use the main card styles */
.hpg-collection-card.hpg-card {
    position: relative;
}

/* Override thumbnail to be a background image */
.hpg-card-thumbnail-img {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 8px 8px 0 0;
    transition: transform 0.3s;
}

.hpg-card:hover .hpg-card-thumbnail-img {
    transform: scale(1.05);
}

.hpg-collection-creator {
    position: absolute;
    bottom: 10px;
    left: 10px; /* This will be the bottom-left corner */
    z-index: 5; /* Ensure it's above the footer meta */
}

.hpg-collection-creator-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: transform 0.3s;
}

.hpg-collection-creator-avatar:hover {
    transform: scale(1.1);
}

/* Make sure the footer meta on the left has enough space */
.hpg-collection-card .hpg-card-footer .hpg-footer-meta {
    margin-left: 55px; /* Add space for the avatar */
}

/* Adjustments for the item count meta item */
.hpg-collection-card .hpg-footer-meta .hpg-meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Back to All Collections Button */
.hpg-back-to-collections-container {
    margin-bottom: 2rem;
    direction: rtl;
}

.hpg-back-to-collections-button {
    display: inline-block;
    padding: 8px 16px;
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: background-color 0.3s, color 0.3s;
}

.hpg-back-to-collections-button:hover {
    background-color: #e0e0e0;
    color: #000;
}

.hpg-collection-card-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
}

.hpg-collection-card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.4s;
}

.hpg-collection-card:hover .hpg-collection-card-image {
    transform: scale(1.05);
}

.hpg-collection-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0) 100%);
    z-index: 1;
}

.hpg-collection-card-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    color: #fff;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align content to the start (right in RTL) */
}

.hpg-collection-creator-info {
    margin-bottom: 15px;
}

.hpg-collection-creator-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #fff;
    object-fit: cover;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.hpg-collection-card-title {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 0 5px 0;
    line-height: 1.2;
    color: #fff;
}

.hpg-collection-card-item-count {
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.2);
    padding: 3px 8px;
    border-radius: 15px;
}