/* memesnews/css/style.css */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Card sizing variables */
:root {
    --gif-item-height: 320px;
    --gif-info-height: 72px;
}

header {
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.search-section {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

#search-input {
    padding: 0.8rem 1rem;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 30px;
    width: 300px;
    outline: none;
    transition: border-color 0.3s;
}

#search-input:focus {
    border-color: #2575fc;
}

button {
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: bold;
}

#search-btn {
    background-color: #2575fc;
    color: white;
}

#search-btn:hover {
    background-color: #1c64e0;
    transform: translateY(-2px);
}

#trending-btn {
    background-color: #6a11cb;
    color: white;
}

#trending-btn:hover {
    background-color: #5a0db9;
    transform: translateY(-2px);
}

.gif-item {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    background: white;
    display: flex;
    flex-direction: column;
    /* Force all cards to a uniform height so the grid looks consistent */
    height: var(--gif-item-height);
    min-height: var(--gif-item-height);
}

.gif-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.gif-item img {
    width: 100%;
    /* Fill the available vertical space above the info area */
    height: calc(100% - var(--gif-info-height));
    display: block;
    object-fit: cover;
}

.gif-info {
    padding: 0.75rem;
    /* Fix info area height so card heights remain uniform */
    height: var(--gif-info-height);
    box-sizing: border-box;
    overflow: hidden;
}

.gif-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gif-user {
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gif-metadata {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.25rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
}

.close:hover {
    color: black;
}

.gif-detail-container {
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.gif-detail-container img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    margin-bottom: 20px;
    align-self: center;
}

.gif-detail-info {
    text-align: left;
}

.gif-detail-info h2 {
    margin-bottom: 10px;
    color: #333;
}

.gif-detail-info p {
    margin: 5px 0;
    color: #555;
}

.gif-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-btn {
    padding: 10px 15px;
    background-color: #2575fc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.action-btn:hover {
    background-color: #1c64e0;
}

/* Share options */
.share-options {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.share-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 5px;
}

.whatsapp-share {
    background-color: #25D366;
    color: white;
}

.facebook-share {
    background-color: #4267B2;
    color: white;
}

.twitter-share {
    background-color: #1DA1F2;
    color: white;
}

.copy-link {
    background-color: #6c757d;
    color: white;
}

/* Responsive design for modal */
@media (min-width: 768px) {
    .gif-detail-container {
        flex-direction: row;
    }
    
    .gif-detail-container img {
        max-width: 60%;
        margin-bottom: 0;
        margin-right: 20px;
    }
    
    .gif-detail-info {
        max-width: 40%;
    }
}

.gifs-container {
    /* Outer wrapper for GIF list; the actual grid lives on #gifs-list */
    padding: 1rem;
}

/* Grid for GIF items. GIF elements should be appended as children of #gifs-list */
#gifs-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem; /* gap between gif items */
    align-items: start; /* keep items aligned at the top for variable heights */
}

footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
}

.categories-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem;
}

.category-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
}

.category-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.category-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .search-section {
        flex-direction: column;
    }
    
    #search-input {
        width: 100%;
        max-width: 300px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .gifs-container {
        padding: 0.5rem;
    }

    /* Mobile grid adjustments for the list */
    #gifs-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 0.75rem; /* Smaller gap on mobile */
    }
    
    /* no per-selector mobile overrides needed for .gif-item img; sizing is handled via CSS variables */

    /* Mobile size adjustments */
    :root {
        --gif-item-height: 260px;
        --gif-info-height: 64px;
    }
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}