/* ===== LIBRARY PAGE - CLEAN GRID LAYOUT ===== */

/* Library Title Section - Between Header and Grid */
.library-title-section {
    background: #fff;
    padding: 4rem 0 1.5rem;
    margin-top: 160px;
    /* Space for fixed header */
}

.library-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 3rem;
}

/* Left Side: Title Content */
.library-title-content {
    flex: 1;
}

.library-page-title {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.library-page-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
    font-style: italic;
    margin: 0;
}

/* Right Side: Search Container */
.library-search-container {
    flex: 0 0 auto;
    min-width: 420px;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 50px;
    padding: 1rem 1.75rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.search-wrapper:focus-within {
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    border-color: var(--secondary-blue);
}

.search-icon {
    color: #666;
    margin-right: 1rem;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 1.05rem;
    font-family: var(--font-body);
    color: var(--text-dark);
    font-weight: 400;
}

.search-input::placeholder {
    color: #999;
}

.search-clear {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
    margin-left: 0.5rem;
}

.search-clear:hover {
    background: #e0e0e0;
    color: #333;
}

/* Subjects Section - Starts after title section */
.subjects-section {
    background: #fff;
    padding: 1.8rem 0 4rem;
    min-height: calc(100vh - 400px);
}

.container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Subjects Grid - Clean 3 Column Layout exactly like screenshot */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

/* Subject Card - Just the Image Placard */
.subject-card {
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    aspect-ratio: 1.6;
    background: #f5f5f5;
}

.subject-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* Hover Effect - Lift and Scale */
.subject-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
}

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

/* Active/Click Effect */
.subject-card:active {
    transform: translateY(-4px) scale(0.98);
}

/* Loading State */
.subject-card.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* No Results */
.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
    grid-column: 1 / -1;
}

.no-results h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.no-results p {
    font-size: 1rem;
    color: #999;
}

/* Fade-in Animation */
.subject-card {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.subject-card:nth-child(1) {
    animation-delay: 0.05s;
}

.subject-card:nth-child(2) {
    animation-delay: 0.1s;
}

.subject-card:nth-child(3) {
    animation-delay: 0.15s;
}

.subject-card:nth-child(4) {
    animation-delay: 0.2s;
}

.subject-card:nth-child(5) {
    animation-delay: 0.25s;
}

.subject-card:nth-child(6) {
    animation-delay: 0.3s;
}

.subject-card:nth-child(7) {
    animation-delay: 0.35s;
}

.subject-card:nth-child(8) {
    animation-delay: 0.4s;
}

.subject-card:nth-child(9) {
    animation-delay: 0.45s;
}

.subject-card:nth-child(n+10) {
    animation-delay: 0.5s;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container-wide {
        max-width: 100%;
        padding: 0 2rem;
    }

    .library-search-container {
        min-width: 380px;
    }

    .library-page-title {
        font-size: 3rem;
    }
}

@media (max-width: 968px) {
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .subjects-section {
        padding: 2.5rem 0 3rem;
    }

    .library-title-section {
        padding: 3rem 0 2.5rem;
        margin-top: 155px;
    }

    .library-page-title {
        font-size: 2.5rem;
    }

    .library-search-container {
        min-width: 320px;
    }
}

@media (max-width: 768px) {

    /* Stack title and search vertically on mobile */
    .library-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1.5rem;
        /* Balanced internal gap */
    }

    .library-title-content {
        width: 100%;
    }

    .library-search-container {
        width: 100%;
        min-width: auto;
    }

    .subjects-grid {
        gap: 1.25rem;
    }

    .library-page-title {
        font-size: 2.25rem;
        margin-bottom: 0.5rem;
        /* Tighter title-subtitle gap for mobile */
    }

    .library-page-subtitle {
        font-size: 1.05rem;
    }

    .library-title-section {
        padding: 2rem 0 1.5rem;
        /* Proportional top/bottom padding */
        margin-top: 130px;
    }

    .subjects-section {
        padding: 1.5rem 0 2.5rem;
        /* Matches section padding for balance */
    }
}

@media (max-width: 480px) {
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .subjects-section {
        padding: 1.25rem 0 2rem;
    }

    .library-title-section {
        padding: 1.75rem 0 1.25rem;
        margin-top: 125px;
    }

    .library-page-title {
        font-size: 2rem;
    }

    .library-page-subtitle {
        font-size: 1rem;
    }

    .container-wide {
        padding: 0 1rem;
    }

    .search-wrapper {
        padding: 0.85rem 1.5rem;
    }

    .search-input {
        font-size: 1rem;
    }
}

/* Print Styles */
@media print {

    .header,
    .footer,
    .library-title-section {
        display: none;
    }

    .subject-card {
        box-shadow: none;
        border: 1px solid #ddd;
        page-break-inside: avoid;
    }
}