/**
 * Discovery & Browse Page Styles
 * Clean, functional search experience
 * Black background, Navy cards, Terracotta accents
 */

/* ==========================================
   COLOR SYSTEM
   ========================================== */
:root {
    --black-bg: #000000;
    --navy-card: #0a1e43;
    --navy-hover: #1a3a5c;
    --terracotta: #95472d;
    --terracotta-hover: #b86847;
    --text-white: #FFFFFF;
    --text-grey: #A0A0A0;
    --text-dim: #707070;
    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-medium: rgba(255, 255, 255, 0.2);
}

/* Default English font for all text */
body, button, input, select, textarea {
    font-family: 'Crimson Pro', Georgia, serif;
}

/* ==========================================
   PAGE LAYOUT
   ========================================== */
.discover-page {
    background: var(--black-bg);
    min-height: 100vh;
    padding-top: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

/* ==========================================
   SEARCH HEADER (STATIC)
   ========================================== */
.search-header {
    background: var(--navy-card);
    padding: 30px 0 25px;
    position: relative;
    z-index: 100;
}

.search-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

/* ==========================================
   SEARCH BAR
   ========================================== */
.search-bar-wrapper {
    margin-bottom: 20px;
}

.search-bar {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-grey);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 50px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    padding: 0 48px;
    color: var(--text-white);
    font-size: 1.27rem; /* Increased from 1.1rem (+15%) */
    transition: all 0.2s ease;
}

.search-input::placeholder {
    color: var(--text-grey);
}

.search-input:focus {
    outline: none;
    border-color: var(--terracotta);
    background: rgba(255, 255, 255, 0.08);
}

.clear-search {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-grey);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.clear-search:hover {
    color: var(--text-white);
}

/* ==========================================
   FILTERS ROW
   ========================================== */
.filters-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-dropdown {
    flex: 0 0 auto;
}

.filter-select {
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0 32px 0 12px;
    color: var(--text-white);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23A0A0A0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 20px;
}

.filter-select:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: var(--border-medium);
}

.filter-select:focus {
    outline: none;
    border-color: var(--terracotta);
}

.filter-select option {
    background: var(--navy-card);
    color: var(--text-white);
}

/* ==========================================
   ACTIVE FILTERS DISPLAY
   ========================================== */
.active-filters {
    background: var(--black-bg);
    padding: 15px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.active-filters .container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filters-label {
    color: var(--text-grey);
    font-size: 0.9rem;
}

.filter-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-badge {
    background: var(--terracotta);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.remove-filter {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: opacity 0.2s ease;
}

.remove-filter:hover {
    opacity: 0.7;
}

.clear-all-filters {
    background: none;
    border: 1px solid var(--border-medium);
    color: var(--text-white);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.clear-all-filters:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--terracotta);
}

/* ==========================================
   BROWSE SECTIONS - HORIZONTAL SCROLLING
   Spotify-style curated sections
   ========================================== */
.browse-sections {
    padding: 40px 0 60px;
}

.browse-section {
    margin-bottom: 48px;
}

.browse-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 0 0 20px;
    padding: 0;
}

/* Horizontal scrolling row */
.section-row {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 0 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Hide scrollbar but keep functionality */
.section-row::-webkit-scrollbar {
    height: 8px;
}

.section-row::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.section-row::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    transition: background 0.2s ease;
}

.section-row::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Cards in horizontal rows - fixed width */
.section-row .poem-card {
    flex: 0 0 200px; /* Fixed width, no shrink/grow */
    width: 200px;
}

/* ==========================================
   RESULTS SECTION
   ========================================== */
.results-section {
    padding: 40px 0 80px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 16px;
}

.results-count {
    color: var(--text-grey);
    font-size: 1rem;
}

.results-count strong {
    color: var(--text-white);
    font-weight: 600;
}

.sort-dropdown {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-dropdown label {
    color: var(--text-grey);
    font-size: 0.9rem;
}

.sort-select {
    height: 36px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 0 32px 0 12px;
    color: var(--text-white);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23A0A0A0'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 20px;
}

.sort-select:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.sort-select option {
    background: var(--navy-card);
}

/* ==========================================
   RESULTS GRID - SPOTIFY/YOUTUBE MUSIC STYLE
   ========================================== */
.results-grid {
    position: relative;
    min-height: 400px;
}

.poems-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px 24px; /* More horizontal gap, larger vertical */
    row-gap: 40px;
}

/* ==========================================
   POEM CARD - SPOTIFY PATTERN
   Cover dominates, text below
   ========================================== */
.poem-card {
    /* NO background, NO borders - transparent card */
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.poem-card:hover {
    /* Subtle lift, no border */
    transform: translateY(-4px);
}

/* ==========================================
   COVER IMAGE - SQUARE, DOMINANT
   ========================================== */
.card-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* STRICT square ratio */
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    background: transparent; /* NO background - let image/generated cover fill */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.poem-card:hover .card-cover {
    transform: scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

/* Real uploaded cover image - FILLS ENTIRE CARD */
.cover-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 8px; /* Match parent border-radius for smooth corners */
}

/* Generated cover (CSS-based) - MATCHES SUBMIT PAGE STYLE */
.cover-generated {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    text-align: center;
    background: linear-gradient(135deg, #0A0A0A 0%, #1a1a1a 100%);
    position: relative;
}

/* Metadata at bottom - era badge */
.cover-metadata {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(to top, rgba(10, 10, 10, 0.95), transparent);
    z-index: 2;
}

.cover-era {
    color: rgba(250, 250, 250, 0.6);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Arabic title on cover - MAIN */
.cover-text {
    font-family: 'UKIJ Merdane', 'HSN Naskh', 'Amiri', serif;
    font-size: 1.1rem;
    color: #FAFAFA; /* var(--paper-white) */
    margin-bottom: 8px;
    direction: rtl;
    line-height: 1.6;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 2;
    position: relative;
}

/* English title on cover - SECONDARY */
.cover-text-en {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 0.85rem;
    color: rgba(250, 250, 250, 0.8);
    margin-bottom: 15px;
    z-index: 2;
    position: relative;
}

/* ==========================================
   PLAY BUTTON OVERLAY - SPOTIFY STYLE
   ========================================== */
.card-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 48px;
    height: 48px;
    background: rgba(149, 71, 45, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 3px; /* Center triangle visually */
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
}

.poem-card:hover .card-play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.card-play-overlay svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* ==========================================
   TEXT SECTION - BELOW COVER
   ========================================== */
.card-text {
    padding: 0; /* NO padding, NO background */
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* English Title - MAIN (bigger, white, bold) */
.card-title-en {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-white);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.poem-card:hover .card-title-en {
    color: var(--terracotta);
}

/* Arabic Title - SECONDARY (smaller, below English) */
.card-title-ar {
    font-family: 'UKIJ Merdane', 'HSN Naskh', serif;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-grey);
    margin: 0 0 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Metadata Row (poet • era) */
.card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-dim);
    line-height: 1;
}

.card-poet {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.meta-dot {
    opacity: 0.5;
}

.card-era {
    text-transform: uppercase;
    color: var(--terracotta);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* ==========================================
   LOADING STATE - SPOTIFY PATTERN
   ========================================== */
.loading-state {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 24px 24px;
    row-gap: 40px;
}

.skeleton-card {
    /* Transparent card like actual cards */
    background: transparent;
    border: none;
    padding: 0;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* Square cover skeleton */
.skeleton-card::before {
    content: '';
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-bottom: 12px;
}

/* Text section skeleton (below cover) */
.skeleton-card::after {
    content: '';
    display: block;
    height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

/* ==========================================
   EMPTY STATE
   ========================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.empty-icon {
    color: var(--text-dim);
    margin-bottom: 20px;
}

.empty-title {
    font-size: 1.5rem;
    color: var(--text-white);
    margin: 0 0 12px;
}

.empty-desc {
    font-size: 1rem;
    color: var(--text-grey);
    margin: 0 0 24px;
}

.btn-clear-filters {
    padding: 12px 32px;
    background: var(--terracotta);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-clear-filters:hover {
    background: var(--terracotta-hover);
    transform: translateY(-2px);
}

/* ==========================================
   PAGINATION
   ========================================== */
.pagination-section {
    margin-top: 60px;
    text-align: center;
}

.btn-load-more {
    padding: 14px 48px;
    background: var(--terracotta);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 16px;
}

.btn-load-more:hover {
    background: var(--terracotta-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.pagination-info {
    color: var(--text-grey);
    font-size: 0.9rem;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */
@media (max-width: 1024px) {
    .container,
    .search-container {
        padding: 0 30px;
    }

    .poems-grid,
    .loading-state {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 20px 20px;
        row-gap: 35px;
    }
}

@media (max-width: 768px) {
    .container,
    .search-container {
        padding: 0 20px;
    }

    .search-header {
        padding: 20px 0 15px;
    }

    .search-bar {
        max-width: 100%;
    }

    .search-input {
        height: 45px;
        font-size: 1rem;
        padding: 0 40px;
    }

    /* Compact horizontal filters on mobile */
    .filters-row {
        flex-direction: row;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }

    .filter-dropdown {
        flex: 0 0 auto;
    }

    .filter-select {
        width: auto;
        min-width: 100px;
        font-size: 0.85rem;
        padding: 0 28px 0 10px;
        height: 36px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-section {
        padding: 30px 0 60px;
    }

    .poems-grid,
    .loading-state {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 16px 16px;
        row-gap: 30px;
    }

    /* Maintain hierarchy: English MAIN, Arabic secondary */
    .card-title-en {
        font-size: 1rem;
    }

    .card-title-ar {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .poems-grid,
    .loading-state {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px 12px;
        row-gap: 24px;
    }

    /* Even more compact filters on small phones */
    .filter-select {
        min-width: 90px;
        font-size: 0.8rem;
        padding: 0 24px 0 8px;
        height: 32px;
    }

    .search-header {
        padding: 15px 0 12px;
    }

    .search-bar-wrapper {
        margin-bottom: 12px;
    }

    .empty-state {
        padding: 60px 20px;
    }

    .active-filters .container {
        flex-direction: column;
        align-items: flex-start;
    }

    .clear-all-filters {
        margin-left: 0;
        margin-top: 8px;
    }

    /* Smaller text on very small screens */
    .card-title-en {
        font-size: 0.9rem;
    }

    .card-title-ar {
        font-size: 0.75rem;
    }

    .card-meta {
        font-size: 0.7rem;
    }

    /* Browse sections - smaller cards on mobile */
    .section-title {
        font-size: 1.4rem;
        margin-bottom: 16px;
    }

    .section-row .poem-card {
        flex: 0 0 140px;
        width: 140px;
    }

    .browse-sections {
        padding: 30px 0 50px;
    }

    .browse-section {
        margin-bottom: 36px;
    }
}

/* ==========================================
   THEME CARDS - QUICK ACCESS BROWSING
   ========================================== */
.theme-cards-section {
    margin-bottom: 50px;
}

.theme-cards-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}

.theme-card {
    position: relative;
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    min-height: 140px;
}

.theme-card:hover {
    transform: translateY(-5px);
    border-color: var(--terracotta);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.theme-card:hover .theme-image {
    transform: scale(1.1);
}

/* Custom image background */
.theme-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: transform 0.4s ease;
    z-index: 1;
}

/* Dark overlay for readability */
.theme-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.3) 50%, rgba(0, 0, 0, 0.1) 100%);
    z-index: 2;
}

/* Content container */
.theme-content {
    position: relative;
    z-index: 3;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.theme-icon {
    font-size: 2rem;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.theme-name {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-white);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.theme-name-ar {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
    direction: rtl;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ==========================================
   SECTION IMPROVEMENTS
   ========================================== */
.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header-row .section-title {
    margin: 0;
}

.section-subtitle {
    color: var(--text-grey);
    font-size: 1rem;
    margin: -8px 0 20px;
    line-height: 1.5;
}

.section-badge {
    display: inline-block;
    background: rgba(255, 215, 0, 0.2);
    color: #FFD700;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 10px;
    border-radius: 4px;
    margin-right: 10px;
    vertical-align: middle;
}

.see-all-link {
    color: var(--terracotta);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 600;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.see-all-link:hover {
    color: var(--terracotta-hover);
}

/* Featured section styling */
.featured-section {
    background: linear-gradient(180deg, rgba(149, 71, 45, 0.1) 0%, transparent 100%);
    margin: 0 -40px 48px;
    padding: 30px 40px;
    border-radius: 0;
}

/* ==========================================
   THEME CARDS - RESPONSIVE
   ========================================== */
@media (max-width: 1200px) {
    .theme-cards-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .theme-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .theme-card {
        min-height: 120px;
    }

    .theme-content {
        padding: 16px 12px;
    }

    .theme-icon {
        font-size: 1.5rem;
    }

    .theme-name {
        font-size: 0.95rem;
    }

    .theme-name-ar {
        font-size: 0.8rem;
    }

    .section-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .see-all-link {
        font-size: 0.85rem;
    }

    .featured-section {
        margin: 0 -20px 36px;
        padding: 24px 20px;
    }

    .section-subtitle {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .theme-cards-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .theme-card {
        min-height: 100px;
    }

    .theme-content {
        padding: 14px 10px;
    }

    .theme-icon {
        font-size: 1.3rem;
    }

    .theme-name {
        font-size: 0.85rem;
    }
}
