/* ============================================================
   CATEGORIES BROWSE PAGE
   ============================================================ */

/* Hero Section */
.categories-hero {
    text-align: center;
    padding: 40px 20px;
    max-width: 800px;
    margin: 0 auto 40px;
}

.categories-hero h1 {
    font-size: 32px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
}

.hero-description {
    font-size: 16px;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 8px;
}

.hero-subtext {
    font-size: 14px;
    color: #6b7280;
    margin-top: 8px;
}

.hero-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.hero-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* Tag Search Container */
.tag-search-container {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.search-input-wrapper {
    position: relative;
    width: 100%;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0.5;
    pointer-events: none;
}

.tag-search-input {
    padding: 12px 20px 12px 44px;
    font-size: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    width: 100%;
    transition: all 0.3s ease;
    background: white;
}

.tag-search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.tag-count-display {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Categories Section - Match meme grid width (700px) */
.categories-section {
    padding: 40px 20px 60px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

/* Categories Grid - Single column stack (for categories page) */
.categories-section:not(.tags-page) .categories-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

/* Loading State */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}

/* Category Card - Horizontal layout matching tags */
.category-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 18px 24px;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.category-card:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
    transform: translateY(-3px);
}

/* Tag List Item - Horizontal layout for tags page */
#tags-grid .category-card {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    gap: 16px;
    min-height: auto;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border: 2px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#tags-grid .category-card:hover {
    border-color: #667eea;
    background: linear-gradient(135deg, #ffffff 0%, #eff6ff 100%);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
    transform: translateY(-3px);
}

/* Category Content - Horizontal layout */
.category-content {
    flex: 1;
    min-width: 0;
}

.category-link {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.category-link:hover {
    text-decoration: none !important;
}

.category-link:hover .category-name {
    color: #667eea;
    transform: translateX(4px);
}

.category-name {
    font-size: 19px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
    transition: all 0.2s ease;
}

.category-count {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 12px;
}

/* Legacy styles for backward compatibility */
.category-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.category-info {
    flex: 1;
    min-width: 0;
}

.category-meme-count {
    font-size: 14px;
    color: #6b7280;
}

/* Tag-specific content styling */
#tags-grid .category-content {
    flex: 1;
    min-width: 0;
}

#tags-grid .category-link {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 12px;
    text-decoration: none;
    transition: all 0.2s ease;
}

#tags-grid .category-link:hover .category-name {
    color: #667eea;
    transform: translateX(4px);
}

#tags-grid .category-name {
    font-size: 19px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0;
    transition: all 0.2s ease;
}

#tags-grid .category-count {
    font-size: 14px;
    color: #64748b;
    font-weight: 500;
    background: #f1f5f9;
    padding: 4px 12px;
    border-radius: 12px;
}

/* Follow Button - Tags page specific */
#tags-grid .category-follow-btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

#tags-grid .category-follow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

#tags-grid .category-follow-btn:active {
    transform: translateY(0);
}

/* Following State - Red to match site standard */
#tags-grid .category-follow-btn.following {
    background: #ef4444;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

#tags-grid .category-follow-btn.following:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

/* Categories page follow button - match tags styling */
.categories-section:not(.tags-page) .category-follow-btn,
.category-follow-btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.categories-section:not(.tags-page) .category-follow-btn:hover,
.category-follow-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.categories-section:not(.tags-page) .category-follow-btn.following,
.category-follow-btn.following {
    background: #ef4444;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.categories-section:not(.tags-page) .category-follow-btn.following:hover,
.category-follow-btn.following:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

/* Category Description */
.category-description {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Legacy Category Link - for backward compatibility */
.category-header .category-link,
.category-description + .category-link {
    text-decoration: none;
    color: #2563eb;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s;
}

.category-header .category-link:hover,
.category-description + .category-link:hover {
    color: #1d4ed8;
    text-decoration: none;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 80px 20px;
}

.empty-state h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 24px;
}

.empty-state-btn {
    padding: 12px 24px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.empty-state-btn:hover {
    background: #1d4ed8;
}

/* Mobile Styles */
@media (max-width: 768px) {
    /* Add top padding to prevent header overlap */
    .main-content {
        padding-top: 70px;
    }
    
    .categories-section {
        margin-left: 0; /* Remove sidebar margin on mobile */
        max-width: 100%;
        padding: 0 !important;
    }
    
    .categories-hero {
        padding: 16px 12px !important;
        margin-bottom: 12px !important;
    }
    
    .categories-hero h1 {
        font-size: 20px !important;
        margin-bottom: 8px !important;
    }
    
    .hero-description {
        font-size: 13px !important;
    }
    
    .categories-grid {
        padding: 8px 0 !important;
        gap: 6px !important;
    }
    
    .category-card {
        padding: 10px 12px !important;
        gap: 10px !important;
        margin: 0 !important;
        border-radius: 8px !important;
    }
    
    .category-name {
        font-size: 15px !important;
        font-weight: 600 !important;
    }
    
    .category-count {
        font-size: 12px !important;
        padding: 2px 8px !important;
    }
    
    .category-follow-btn {
        padding: 8px 16px !important;
        font-size: 12px !important;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   TAG LIST STYLES - SINGLE COLUMN LAYOUT
   ============================================================ */

/* Tag Grid - Single column list */
#tags-grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    max-width: 700px !important;
    margin: 0 auto !important;
    padding: 20px !important;
    width: 100%;
}

/* Individual Tag Cloud Item */
.tag-cloud-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 25px;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    position: relative;
    animation: floatIn 0.8s ease-out forwards, gentleFloat 6s ease-in-out infinite;
    cursor: pointer;
    will-change: transform;
}

/* Followed Tag - Green gradient and border with high specificity */
.tag-cloud-item.followed {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: 2px solid #34d399 !important;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.4) !important;
}

/* Followed tag hover effects */
.tag-cloud-item.followed:hover {
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.6), 
                0 0 25px rgba(5, 150, 105, 0.4) !important;
}

/* Random vertical offset for organic cloud effect */
.tag-cloud-item:nth-child(6n+1) {
    animation-delay: 0.1s, 0s;
    margin-top: -5px;
}

.tag-cloud-item:nth-child(6n+2) {
    animation-delay: 0.15s, 1.5s;
    margin-top: 8px;
}

.tag-cloud-item:nth-child(6n+3) {
    animation-delay: 0.2s, 3s;
    margin-top: -3px;
}

.tag-cloud-item:nth-child(6n+4) {
    animation-delay: 0.12s, 4.5s;
    margin-top: 5px;
}

.tag-cloud-item:nth-child(6n+5) {
    animation-delay: 0.18s, 2s;
    margin-top: -7px;
}

.tag-cloud-item:nth-child(6n) {
    animation-delay: 0.25s, 3.5s;
    margin-top: 3px;
}

/* Float in animation - smooth entrance */
@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Gentle continuous floating motion - no rotation */
@keyframes gentleFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    33% {
        transform: translateY(-4px);
    }
    66% {
        transform: translateY(2px);
    }
}

/* Hover: Dramatic scale-up with smooth glow - NO ROTATION */
.tag-cloud-item:hover {
    transform: translateY(-10px) scale(1.35) !important;
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.6), 
                0 0 25px rgba(118, 75, 162, 0.4);
    z-index: 10;
}

/* Tag Link */
.tag-cloud-link {
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.tag-cloud-link:hover {
    text-shadow: 0 0 15px rgba(255, 255, 255, 1),
                 0 0 25px rgba(255, 255, 255, 0.6);
    transform: scale(1.05);
}

/* Multiple sparkle effects on hover - continuous */
.tag-cloud-item:hover .tag-cloud-link::after {
    content: '✨';
    position: absolute;
    right: -20px;
    top: -10px;
    animation: sparkle1 1.2s ease-in-out infinite;
    font-size: 14px;
}

.tag-cloud-item:hover .tag-cloud-link::before {
    content: '⭐';
    position: absolute;
    left: -20px;
    top: -5px;
    animation: sparkle2 1.5s ease-in-out infinite;
    font-size: 12px;
}

.tag-cloud-item:hover::before {
    content: '✨';
    position: absolute;
    right: -10px;
    bottom: -8px;
    animation: sparkle3 1.8s ease-in-out 0.3s infinite;
    font-size: 10px;
}

.tag-cloud-item:hover::after {
    content: '⭐';
    position: absolute;
    left: -15px;
    bottom: -5px;
    animation: sparkle4 1.4s ease-in-out 0.6s infinite;
    font-size: 11px;
}

/* Sparkle animation 1 - spin and pulse */
@keyframes sparkle1 {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg) translateY(0);
    }
    25% {
        opacity: 1;
        transform: scale(1.3) rotate(90deg) translateY(-3px);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.1) rotate(180deg) translateY(-5px);
    }
    75% {
        opacity: 0.6;
        transform: scale(0.9) rotate(270deg) translateY(-3px);
    }
}

/* Sparkle animation 2 - float and twinkle */
@keyframes sparkle2 {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg) translate(0, 0);
    }
    30% {
        opacity: 1;
        transform: scale(1.2) rotate(120deg) translate(-5px, -8px);
    }
    60% {
        opacity: 0.7;
        transform: scale(1) rotate(240deg) translate(-8px, -4px);
    }
}

/* Sparkle animation 3 - bounce sparkle */
@keyframes sparkle3 {
    0%, 100% {
        opacity: 0;
        transform: scale(0) translateY(0);
    }
    40% {
        opacity: 1;
        transform: scale(1.4) translateY(-10px);
    }
    70% {
        opacity: 0.5;
        transform: scale(0.8) translateY(-5px);
    }
}

/* Sparkle animation 4 - swirl */
@keyframes sparkle4 {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    35% {
        opacity: 1;
        transform: scale(1.3) rotate(-180deg) translate(-8px, -8px);
    }
    65% {
        opacity: 0.6;
        transform: scale(0.9) rotate(-360deg) translate(-4px, -4px);
    }
}

/* Compact Follow Button */
.tag-follow-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.tag-follow-btn:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: rotate(180deg) scale(1.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
}

.tag-follow-btn:active {
    transform: rotate(180deg) scale(0.9);
}

.tag-follow-btn.following {
    background: rgba(239, 68, 68, 0.9);
    border-color: rgba(239, 68, 68, 1);
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
    }
}

/* Tag Count Badge */
.tag-count {
    font-size: 0.75em;
    opacity: 0.8;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

/* Mobile Tag List Optimization */
@media (max-width: 768px) {
    /* Remove side padding and maximize width */
    #tags-grid {
        padding: 8px 0 !important;
        gap: 6px !important;
        max-width: 100% !important;
    }
    
    /* Compact tag cards for mobile */
    #tags-grid .category-card {
        padding: 10px 12px !important;
        gap: 10px !important;
        margin: 0 !important;
        border-radius: 8px !important;
    }
    
    /* Smaller text on mobile */
    #tags-grid .category-name {
        font-size: 15px !important;
        font-weight: 600 !important;
    }
    
    #tags-grid .category-count {
        font-size: 12px !important;
        padding: 2px 8px !important;
    }
    
    /* Compact button for mobile */
    #tags-grid .category-follow-btn {
        padding: 8px 16px !important;
        font-size: 12px !important;
    }
    
    /* Reduce hero section padding */
    .categories-hero {
        padding: 16px 12px !important;
        margin-bottom: 12px !important;
    }
    
    .categories-hero h1 {
        font-size: 20px !important;
        margin-bottom: 8px !important;
    }
    
    .hero-description {
        font-size: 13px !important;
    }
    
    /* Compact search container */
    .tag-search-container {
        margin-top: 12px !important;
        gap: 8px !important;
    }
    
    .tag-search-input {
        padding: 10px 14px !important;
        font-size: 14px !important;
    }
    
    .tag-count-display {
        font-size: 12px !important;
    }
}
