/* Default author card styles */
.authors-card {
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease-in-out, box-shadow 0.3s ease-in-out;
    animation: fadeInUp 0.6s ease-out;
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    height: 250px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.authors-card img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 15px auto;
    display: block;
    border: 4px solid var(--primary-color, #deb86c);
    transition: transform 0.3s ease;
}

.authors-card h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
    line-height: 1.3;
    flex-shrink: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

.authors-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    z-index: 10;
}

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

/* Default popup styles */
.authors-card {
    position: relative;
}

.author-bio-popup {
    position: absolute;
    left: 100%;
    top: 0;
    transform: translate(20px, 0) scale(0.95);
    width: 400px;
    height: 500px;
    background-color: #ffffff;
    color: #000000;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    overflow: hidden;
    pointer-events: none;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.author-bio-popup-inner {
    padding: 20px;
    overflow-y: auto;
    height: 100%;
    scrollbar-width: thin;
    scrollbar-color: #666 #f0f0f0;
}

/* Custom scrollbar for Webkit browsers */
.author-bio-popup-inner::-webkit-scrollbar {
    width: 6px;
}

.author-bio-popup-inner::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 3px;
}

.author-bio-popup-inner::-webkit-scrollbar-thumb {
    background-color: #666;
    border-radius: 3px;
}

.authors-card:hover .author-bio-popup {
    opacity: 1;
    transform: translate(20px, 0) scale(1);
    pointer-events: auto;
}

/* Responsive adjustments for all popups */
@media (max-width: 1024px) {
    .author-bio-popup {
        width: 350px;
    }
}

@media (max-width: 768px) {
    /* Disable hover popup on mobile */
    .author-bio-popup {
        display: none !important;
    }

    /* Make cards more touch-friendly */
    .authors-card {
        cursor: pointer;
        transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
        -webkit-tap-highlight-color: transparent;
        position: relative;
        padding: 15px 15px 45px 15px; /* Added bottom padding for tap indicator */
        height: 200px;
        margin-bottom: 25px; /* Space between cards */
    }

    .authors-card img {
        width: 120px;
        height: 120px;
        margin-bottom: 12px;
    }

    .authors-card h2 {
        font-size: 1.1rem;
    }

    /* Tap indicator positioned within the card's bottom padding */
    .authors-card::after {
        content: '👆 Tap to view bio';
        position: absolute;
        bottom: 8px; /* Inside the card's bottom padding */
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.8rem;
        color: var(--secondary-color, #FFB800);
        opacity: 0.8;
        white-space: nowrap;
        pointer-events: none;
        animation: pulse 2s infinite;
        display: block !important;
        z-index: 1;
    }

    .authors-card:active {
        transform: scale(0.98);
    }

    /* Remove hover effects on mobile */
    .authors-card:hover {
        transform: none;
    }

    .authors-card:hover img {
        transform: none;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

/* General popup styles */
.author-bio-popup p {
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.author-bio-popup strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #333;
}

/* Mobile Modal Styles */
.author-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.author-modal.active {
    opacity: 1;
    visibility: visible;
}

.author-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.author-modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 20px;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    max-width: 90vw;
    width: 500px;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.author-modal.active .author-modal-content {
    transform: scale(1) translateY(0);
}

.author-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--primary-color, #1a1a1a) 0%, var(--secondary-color, #FFB800) 100%);
    color: white;
}

.author-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.author-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.author-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.author-modal-body {
    padding: 1.5rem;
    max-height: calc(90vh - 120px);
    overflow-y: auto;
}

.author-modal-image {
    text-align: center;
    margin-bottom: 1.5rem;
}

.author-modal-image img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary-color, #1a1a1a);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.author-modal-info h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color, #1a1a1a);
    margin-bottom: 1rem;
    text-align: center;
}

.author-modal-info p {
    font-size: 1rem;
    line-height: 1.6;
    color: #333;
    text-align: justify;
    margin: 0;
    animation: fadeIn 0.5s ease-out 0.2s both;
}

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

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .author-modal-content {
        width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }

    .author-modal-header {
        padding: 1rem;
    }

    .author-modal-header h2 {
        font-size: 1.3rem;
    }

    .author-modal-body {
        padding: 1rem;
        max-height: calc(95vh - 100px);
    }

    .author-modal-image img {
        width: 120px;
        height: 120px;
    }

    .author-modal-info h3 {
        font-size: 1.1rem;
    }

    .author-modal-info p {
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .authors-card {
        padding: 12px 12px 40px 12px; /* Added bottom padding for tap indicator */
        height: 180px;
        margin-bottom: 20px; /* Space between cards */
    }

    .authors-card img {
        width: 100px;
        height: 100px;
        margin-bottom: 10px;
    }

    .authors-card h2 {
        font-size: 1rem;
    }
    
    /* Adjust tap indicator for smaller screens */
    .authors-card::after {
        bottom: 6px; /* Inside the card's bottom padding */
        font-size: 0.75rem;
    }

    .author-modal-content {
        width: 98vw;
        margin: 5px;
    }

    .author-modal-header {
        padding: 0.8rem;
    }

    .author-modal-header h2 {
        font-size: 1.2rem;
    }

    .author-modal-body {
        padding: 0.8rem;
    }

    .author-modal-image img {
        width: 100px;
        height: 100px;
    }

    .author-modal-info h3 {
        font-size: 1rem;
    }

    .author-modal-info p {
        font-size: 0.9rem;
    }
}


/* Center the author popup over its card on desktop (web view) to avoid side space and cutoffs */
@media (min-width: 769px) {
  .authors-card {
    position: relative;
  }
  .author-bio-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    width: clamp(320px, 90vw, 600px);
    max-height: 85vh;
    height: auto;
    transform: translate(-50%, -50%) scale(0.95);
    box-shadow: 0 25px 60px rgba(0,0,0,0.25);
    z-index: 10000;
  }
  /* Keep popup visible while hovering the card or the popup itself */
  .authors-card:hover .author-bio-popup,
  .author-bio-popup:hover {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
  }
  /* Ensure inner content scrolls appropriately when tall */
  .author-bio-popup-inner {
    height: auto;
    max-height: 70vh;
    overflow-y: auto;
  }
}
