/* ============================================
   Authors Page — Elegant Author Directory
   ============================================ */

.authors-page {
    padding-top: 80px;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Compact fixed header on tablet/mobile (~66px) — keep the hero gap balanced */
@media (max-width: 1200px) {
    .authors-page { padding-top: 72px; }
    .authors-hero { padding: 2rem 1.5rem 2rem; }
}

/* Hero */
.authors-hero {
    position: relative;
    text-align: center;
    padding: 4rem 1.5rem 3rem;
    overflow: hidden;
}

.authors-hero-bg {
    position: absolute;
    inset: 0;
    margin-top: 20px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d1b69 50%, #1a1a2e 100%);
    opacity: 0.06;
    z-index: 0;
}

[data-theme="dark"] .authors-hero-bg {
    opacity: 0.3;
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0c0a09 100%);
}

.authors-hero .container {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

.authors-hero-title {
    font-size: clamp(1.75rem, 3.5vw, 2.25rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 1rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.authors-hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.15rem);
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* Controls Section */
.authors-controls {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

.authors-controls .container {
    max-width: 1300px;
    margin: 0 auto;
}

.authors-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.authors-search-wrapper {
    position: relative;
    flex: 1;
    max-width: 400px;
}

.authors-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

[dir="rtl"] .authors-search-icon {
    left: auto;
    right: 14px;
}

.authors-search-input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    font-size: 0.9rem;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

[dir="rtl"] .authors-search-input {
    padding: 10px 44px 10px 16px;
}

.authors-search-input:focus {
    outline: none;
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.authors-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* Language Filter */
.authors-lang-filter {
    flex-shrink: 0;
}

/* Filter Dropdown (matching library page style) */
.filter-dropdown { position: relative; }

.filter-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 16px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-dropdown-btn:hover { 
    border-color: var(--color-primary, #2563eb); 
    color: var(--color-primary, #2563eb);
}

.filter-dropdown.open .filter-dropdown-btn {
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-dropdown-icon { flex-shrink: 0; color: var(--text-secondary); }
.filter-dropdown-label { flex: 1; text-align: left; }
[dir="rtl"] .filter-dropdown-label { text-align: right; }
.filter-dropdown-arrow { flex-shrink: 0; color: var(--text-secondary); transition: transform 0.2s; }
.filter-dropdown.open .filter-dropdown-arrow { transform: rotate(180deg); }

.filter-dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    padding: 6px;
    display: none;
    animation: filterDropFade 0.15s ease;
}

[dir="rtl"] .filter-dropdown-menu { left: auto; right: 0; }
.filter-dropdown.open .filter-dropdown-menu { display: block; }

@keyframes filterDropFade {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.filter-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    font-size: 0.86rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
    text-align: left;
}

[dir="rtl"] .filter-dropdown-item { text-align: right; }
.filter-dropdown-item:hover { background: rgba(37, 99, 235, 0.08); }
.filter-dropdown-item.active { background: rgba(37, 99, 235, 0.12); color: var(--color-primary, #2563eb); font-weight: 600; }
.filter-dropdown-flag { display: inline-flex; line-height: 1; }
.filter-dropdown-flag svg { border-radius: 2px; display: block; }

/* Alphabet Navigation */
.authors-alphabet {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.alpha-btn {
    padding: 5px 9px;
    font-size: 0.78rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    min-width: 28px;
    text-align: center;
}

.alpha-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.alpha-btn.active {
    background: var(--color-primary, #2563eb);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* Grid Section */
.authors-grid-section {
    padding: 2.5rem 1.5rem 4rem;
}

.authors-grid-section .container {
    max-width: 1300px;
    margin: 0 auto;
}

.authors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}

/* Author Card */
.author-card {
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.author-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.08);
    border-color: var(--color-primary, #2563eb);
}

[data-theme="dark"] .author-card:hover {
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.author-card-link {
    display: flex;
    align-items: stretch;
    text-decoration: none;
    color: inherit;
    padding: 1.25rem;
    gap: 1rem;
    cursor: pointer;
}

/* Portrait */
.author-card-portrait {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .author-card-portrait {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
}

.author-card-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-card-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.author-card-initials span {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-primary, #4f46e5);
    opacity: 0.8;
}

[data-theme="dark"] .author-card-initials span {
    color: #a5b4fc;
}

/* Card Body */
.author-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.author-card-name {
    font-size: 1rem;
    font-weight: 650;
    color: var(--text-primary);
    margin: 0 0 0.3rem;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.author-card-bio {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* When name wraps to 2 lines, reduce bio to 1 line */
.author-card.name-wrapped .author-card-bio {
    -webkit-line-clamp: 1;
}

.author-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.author-card-books {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.author-card-books svg {
    opacity: 0.6;
}

.author-card-langs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.85rem;
}

.author-lang-dot {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 1px 4px;
    border-radius: 3px;
    letter-spacing: 0.02em;
}

/* Empty State */
.authors-empty {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-secondary);
}

.authors-empty p {
    margin-top: 1rem;
    font-size: 1rem;
}

/* Load More */
.authors-load-more-wrapper {
    text-align: center;
    padding: 2rem 0 0;
}

.authors-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 12px 28px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.authors-load-more-btn:hover {
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary, #2563eb);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

/* Responsive */
@media (max-width: 768px) {
    .authors-page { padding-top: 72px; }
    .authors-hero {
        padding: 2rem 1rem 1.5rem;
    }

    .authors-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .authors-search-wrapper {
        max-width: 100%;
    }

    .authors-count {
        text-align: center;
    }

    .authors-alphabet {
        justify-content: center;
    }

    .alpha-btn {
        padding: 6px 8px;
        font-size: 0.72rem;
        min-width: 26px;
    }

    .authors-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .authors-grid-section {
        padding: 1.5rem 1rem 3rem;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .authors-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1400px) {
    .authors-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}


/* ============================================
   Author Overlay Modal
   ============================================ */

.author-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

.author-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

[data-theme="dark"] .author-overlay-backdrop {
    background: rgba(0, 0, 0, 0.75);
}

.author-overlay-panel {
    position: relative;
    width: 100%;
    max-width: 640px;
    height: 100vh;
    background: var(--bg-primary);
    overflow-y: auto;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RTL: Slide from left */
[dir="rtl"] .author-overlay-panel {
    transform: translateX(-100%);
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.15);
}

.author-overlay.active .author-overlay-panel {
    transform: translateX(0);
}

.author-overlay-close {
    position: sticky;
    top: 16px;
    float: right;
    margin: 16px 16px 0 0;
    z-index: 10;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.author-overlay-close:hover {
    background: var(--border-color);
    transform: scale(1.1);
}

.author-overlay-content {
    padding: 2rem 2.5rem 3rem;
}

/* Loading */
.author-overlay-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.author-overlay-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary, #2563eb);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Header */
.overlay-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.overlay-portrait {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
}

[data-theme="dark"] .overlay-portrait {
    background: linear-gradient(135deg, #312e81 0%, #1e1b4b 100%);
}

.overlay-portrait-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.overlay-portrait-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-portrait-initials span {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary, #4f46e5);
    opacity: 0.7;
}

[data-theme="dark"] .overlay-portrait-initials span {
    color: #a5b4fc;
}

.overlay-header-info {
    flex: 1;
    min-width: 0;
}

.overlay-author-name {
    font-size: 1.6rem;
    font-weight: 750;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
    line-height: 1.2;
}

.overlay-author-dates {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.2rem;
}

.overlay-author-nationality {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 0.4rem;
}

.overlay-author-bookcount {
    font-size: 0.85rem;
    color: var(--color-primary, #2563eb);
    font-weight: 600;
    margin: 0;
}

/* Sections */
.overlay-section-title {
    font-size: 1rem;
    font-weight: 650;
    color: var(--text-primary);
    margin: 0 0 0.75rem;
    letter-spacing: -0.01em;
}

.overlay-bio-section {
    margin-bottom: 2rem;
}

.overlay-bio-text {
    font-size: 0.9rem;
    line-height: 1.75;
    color: var(--text-secondary);
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
}

.overlay-bio-text::-webkit-scrollbar {
    width: 4px;
}

.overlay-bio-text::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* Books Grid */
.overlay-books-section {
    margin-bottom: 2rem;
}

.overlay-books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
}

.overlay-book-card {
    text-decoration: none;
    color: inherit;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.overlay-book-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .overlay-book-card:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.overlay-book-cover {
    width: 100%;
    aspect-ratio: 2/3;
    overflow: hidden;
    background: var(--bg-secondary);
}

.overlay-book-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.overlay-book-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: var(--color-primary, #4f46e5);
    font-size: 1.2rem;
    font-weight: 700;
}

[data-theme="dark"] .overlay-book-placeholder {
    background: linear-gradient(135deg, #312e81, #1e1b4b);
    color: #a5b4fc;
}

.overlay-book-info {
    padding: 0.6rem 0.75rem;
}

.overlay-book-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.overlay-book-price {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-primary, #2563eb);
}

.overlay-book-free {
    font-size: 0.72rem;
    font-weight: 600;
    color: #10b981;
}

/* Responsive */
@media (max-width: 768px) {
    .author-overlay-panel {
        max-width: 100%;
    }

    .author-overlay-content {
        padding: 1.5rem 1.25rem 2rem;
    }

    .overlay-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }

    .overlay-portrait {
        width: 80px;
        height: 80px;
    }

    .overlay-books-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 0.75rem;
    }
}


/* ============================================
   Portrait Lightbox
   ============================================ */

.portrait-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.portrait-lightbox.active {
    opacity: 1;
}

.portrait-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.portrait-lightbox-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.portrait-lightbox.active .portrait-lightbox-content {
    transform: scale(1);
}

.portrait-lightbox-close {
    position: absolute;
    top: -48px;
    right: -48px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.portrait-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.portrait-lightbox-img {
    max-width: min(90vw, 500px);
    max-height: 70vh;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    object-fit: contain;
}

.portrait-lightbox-name {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* Make the overlay portrait clickable */
.overlay-portrait {
    cursor: zoom-in;
    transition: transform 0.2s, box-shadow 0.2s;
}

.overlay-portrait:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .portrait-lightbox-close {
        top: -44px;
        right: 0;
    }

    .portrait-lightbox-img {
        max-width: 85vw;
        max-height: 60vh;
        border-radius: 12px;
    }
}


/* Cosmos CTA — link from the Authors hero into the 3D timeline */
.authors-cosmos-link {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    margin-top: 1.5rem;
    padding: 0.72rem 1.6rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(120deg, #4f46e5 0%, #7c3aed 55%, #b0526b 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.authors-cosmos-link svg { opacity: 0.9; }
.authors-cosmos-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(124, 58, 237, 0.5);
    filter: brightness(1.08);
}
[data-theme="dark"] .authors-cosmos-link {
    box-shadow: 0 8px 30px rgba(124, 58, 237, 0.45);
}


/* Origin filter dropdown — scrollable list with a subtle themed scrollbar */
.filter-dropdown-menu--origins {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--text-secondary) 40%, transparent) transparent;
}
.filter-dropdown-menu--origins::-webkit-scrollbar { width: 8px; }
.filter-dropdown-menu--origins::-webkit-scrollbar-track { background: transparent; }
.filter-dropdown-menu--origins::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--text-secondary) 35%, transparent);
    border-radius: 999px;
}
.filter-dropdown-menu--origins::-webkit-scrollbar-thumb:hover {
    background: color-mix(in srgb, var(--text-secondary) 55%, transparent);
}
.filter-dropdown.has-value .filter-dropdown-btn {
    border-color: var(--color-primary);
    color: var(--color-primary);
}
