/**
 * Iridia Daily - Complete Stylesheet
 * 
 * A modern, accessible stylesheet implementing WCAG 2.1 Level AA standards
 * with enhanced archive features including search, filters, and pagination.
 * 
 * Features:
 * - Semantic styling with accessible color contrasts
 * - FontAwesome icon integration
 * - Responsive grid layouts for 10/25/50 records
 * - Focus management and keyboard navigation
 * - Reduced motion support
 * - High contrast mode compatibility
 * 
 * @author Alex Howell
 */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   
   Centralized design system variables for consistent theming and easy
   maintenance. All values can be modified here to update the entire site.
   ========================================================================== */

:root {
    /* Color Palette - WCAG AA compliant */
    --color-bg: #FEFDFB;
    --color-paper: #F8F7F5;
    --color-text: #1a1a1a;
    --color-text-secondary: #545454;
    --color-border: #d0ccc6;
    --color-accent: #0f2027;
    --color-accent-hover: #1a2f3a;
    --color-focus: #0066cc;
    
    /* Topic Colors */
    --color-neuroscience: #7d3bb8;
    --color-space: #3651d4;
    --color-biology: #05a77c;
    --color-environment: #1f8a7e;
    --color-physics: #d4244d;
    --color-medicine: #d11363;
    --color-technology: #2ba9cc;
    --color-chemistry: #a855f7;
    
    /* Typography */
    --font-serif: 'Lora', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Spacing Scale - 8px baseline */
    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2rem;
    --space-xl: 3rem;
    --space-xxl: 4rem;
    
    /* Animation Timing */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
    
    /* Elevation */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    
    /* Focus Ring */
    --focus-ring: 0 0 0 3px var(--color-focus);
    --focus-ring-offset: 2px;
}

/* ==========================================================================
   CSS Reset
   ========================================================================== */

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/**
 * Smooth Scrolling
 * Enhances navigation experience while respecting motion preferences
 */
html {
    scroll-behavior: smooth;
}

/* ==========================================================================
   Skip Navigation Link
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    z-index: 9999;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-accent);
    color: white;
    text-decoration: none;
    font-weight: 600;
    transition: top var(--transition-fast);
}

.skip-link:focus {
    top: 0;
    outline: 3px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   Typography
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.2;
    color: var(--color-accent);
}

h1 {
    font-size: 2.5rem;
}

h2 {
    font-size: 2rem;
}

h3 {
    font-size: 1.5rem;
}

/* ==========================================================================
   Header & Navigation
   
   Sticky header with accessible navigation controls and focus management.
   Includes backdrop blur effect for modern appearance.
   ========================================================================== */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: var(--space-md) var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    background: rgba(254, 253, 251, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: box-shadow var(--transition-fast);
}

.header.scrolled {
    box-shadow: var(--shadow-sm);
}

.header-content {
    width: 100%;
    max-width: 1400px;
    padding: 0 var(--space-lg);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent);
    text-decoration: none;
    letter-spacing: -0.02em;
    display: inline-block;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.logo:hover {
    opacity: 0.8;
    transform: translateY(-1px);
}

.logo:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.subscribe-btn {
    padding: 0.625rem 1.5rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    color: white;
    background: var(--color-accent);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.subscribe-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left var(--transition-slow);
    border-radius: 4px;
}

.subscribe-btn:hover::before {
    left: 100%;
}

.subscribe-btn:hover {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.subscribe-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

.subscribe-btn:active {
    transform: translateY(0);
}

.subscribe-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Hero Section
   
   Primary banner with animated entrance. Animations respect user's motion
   preferences via prefers-reduced-motion media query.
   ========================================================================== */

.hero {
    width: 100%;
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    animation: fadeInUp 0.8s ease both;
    position: relative;
}

/* Full-width decorative separator after hero */
.hero::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, 
        transparent, 
        var(--color-border) 10%, 
        var(--color-border) 90%, 
        transparent
    );
}

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

.hero h1 {
    max-width: 900px;
    margin: 0 auto var(--space-md);
}

.hero p {
    max-width: 900px;
    margin: 0 auto var(--space-lg);
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--color-text-secondary);
}

/* ==========================================================================
   Search Container
   ========================================================================== */

.search-container {
    max-width: 1400px;
    margin: var(--space-xxl) auto 0;
    padding: 0 var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
}

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

.search-input {
    width: 100%;
    padding: 12px 45px;
    font-size: 16px;
    font-family: var(--font-sans);
    border: 2px solid var(--color-border);
    border-radius: 8px;
    background: white;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-input:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.search-input::placeholder {
    color: var(--color-text-secondary);
    opacity: 0.7;
}

.clear-search-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 5px;
    transition: color var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.clear-search-btn.hidden {
    display: none;
}

.clear-search-btn:hover {
    color: #ef4444;
}

.clear-search-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ==========================================================================
   Display Controls (Per-Page Selector)
   ========================================================================== */

.display-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    font-size: 14px;
    color: var(--color-text-secondary);
}

.display-controls label {
    font-weight: 500;
}

.per-page-selector {
    padding: 8px 32px 8px 12px;
    font-size: 14px;
    font-family: var(--font-sans);
    border: 2px solid var(--color-border);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.per-page-selector:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.per-page-selector:hover {
    border-color: #9ca3af;
}

/* ==========================================================================
   Archive Stats Display
   ========================================================================== */

#archiveStats {
    text-align: center;
    margin: var(--space-md) auto;
    padding: 0.75rem var(--space-md);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    background: var(--color-paper);
    border-radius: 8px;
    max-width: 700px;
}

/* ==========================================================================
   Filter Bar
   ========================================================================== */

.filter-bar {
    position: sticky;
    top: 73px;
    z-index: 90;
    width: 100%;
    padding: var(--space-xs) 0 var(--space-md) 0;
    margin-top: var(--space-md);
    background: rgba(254, 253, 251, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: fadeInUp 0.8s ease both;
    animation-delay: 0.2s;
}

/* Visual separator at bottom of filter bar - full width */
.filter-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, 
        transparent, 
        var(--color-border) 20%, 
        var(--color-border) 80%, 
        transparent
    );
}

.filter-buttons {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    justify-content: center;
}

.filter-btn {
    padding: 0.625rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    background: white;
    border: 2px solid var(--color-border);
    border-radius: 9999px;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--color-accent);
    background: var(--color-paper);
    transform: translateY(-1px);
}

.filter-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

.filter-btn.active {
    color: white;
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.filter-btn.active:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
}

/* Topic-specific filter button colors - only show on active/hover */
.filter-btn[data-topic="neuroscience"]:hover:not(.active) {
    background: rgba(125, 59, 184, 0.1);
}

.filter-btn[data-topic="neuroscience"].active {
    background: var(--color-neuroscience);
    border-color: var(--color-neuroscience);
    color: white;
}

.filter-btn[data-topic="space"]:hover:not(.active) {
    background: rgba(54, 81, 212, 0.1);
}

.filter-btn[data-topic="space"].active {
    background: var(--color-space);
    border-color: var(--color-space);
    color: white;
}

.filter-btn[data-topic="biology"]:hover:not(.active) {
    background: rgba(5, 167, 124, 0.1);
}

.filter-btn[data-topic="biology"].active {
    background: var(--color-biology);
    border-color: var(--color-biology);
    color: white;
}

.filter-btn[data-topic="environment"]:hover:not(.active) {
    background: rgba(31, 138, 126, 0.1);
}

.filter-btn[data-topic="environment"].active {
    background: var(--color-environment);
    border-color: var(--color-environment);
    color: white;
}

.filter-btn[data-topic="physics"]:hover:not(.active) {
    background: rgba(212, 36, 77, 0.1);
}

.filter-btn[data-topic="physics"].active {
    background: var(--color-physics);
    border-color: var(--color-physics);
    color: white;
}

.filter-btn[data-topic="medicine"]:hover:not(.active) {
    background: rgba(209, 19, 99, 0.1);
}

.filter-btn[data-topic="medicine"].active {
    background: var(--color-medicine);
    border-color: var(--color-medicine);
    color: white;
}

.filter-btn[data-topic="technology"]:hover:not(.active) {
    background: rgba(43, 169, 204, 0.1);
}

.filter-btn[data-topic="technology"].active {
    background: var(--color-technology);
    border-color: var(--color-technology);
    color: white;
}

.filter-btn[data-topic="chemistry"]:hover:not(.active) {
    background: rgba(168, 85, 247, 0.1);
}

.filter-btn[data-topic="chemistry"].active {
    background: var(--color-chemistry);
    border-color: var(--color-chemistry);
    color: white;
}

/* ==========================================================================
   Archive Section & Grid
   ========================================================================== */

.archive {
    width: 100%;
    max-width: 1400px;
    padding: var(--space-xl) var(--space-lg);
    margin: 0 auto;
    animation: fadeInUp 0.8s ease both;
    animation-delay: 0.4s;
}

.archive-grid {
    display: grid;
    gap: 2rem;
    margin-top: var(--space-xl);
    transition: opacity var(--transition-fast);
}

/* Responsive Grid Layout */
@media (min-width: 640px) {
    .archive-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .archive-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1280px) {
    .archive-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
}

/* Loading State */
.archive-grid.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================================================
   Paper Cards
   ========================================================================== */

.paper-card {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: transform var(--transition-normal), 
                box-shadow var(--transition-normal), 
                border-color var(--transition-normal);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient overlay on hover */
.paper-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0) 0%, rgba(248, 247, 245, 0.3) 100%);
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
    z-index: 0;
}

.paper-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: rgba(15, 32, 39, 0.2);
}

.paper-card:hover::before {
    opacity: 1;
}

.paper-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    gap: 0.75rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.topic-badge {
    display: inline-block;
    padding: 0.375rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-fast);
}

.paper-card:hover .topic-badge {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

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

.paper-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text);
    margin: 0 0 var(--space-sm) 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color var(--transition-fast);
    position: relative;
    z-index: 1;
}

.paper-card:hover .paper-title {
    color: var(--color-accent);
}

.paper-summary {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
    margin: 0 0 var(--space-md) 0;
    flex-grow: 1;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.paper-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: var(--space-md);
    border-top: 1px solid rgba(208, 204, 198, 0.3);
    gap: var(--space-sm);
    position: relative;
    z-index: 1;
}

.journal {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 1;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: #1a2f3a;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 2;
}

.read-more::after {
    content: '→';
    display: inline-block;
}

/* Only change button when directly hovering it */
.read-more:hover {
    background: #2c4a5a;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.read-more:hover::after {
    transform: translateX(2px);
    transition: transform 0.2s ease;
}

.read-more:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* ==========================================================================
   Floating Preview Card (Option B)
   
   A stylish tooltip-like preview panel that appears on the opposite side
   of the screen from the hovered card. Shows full title and summary.
   Dynamically positions near the hovered card.
   ========================================================================== */

.preview-card {
    position: fixed;
    width: 380px;
    max-width: calc(50vw - 60px);
    max-height: calc(100vh - 140px);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12), 0 4px 12px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease-in-out, left 0.3s ease-out, top 0.35s ease-out;
    overflow-y: auto;
}

.preview-card.active {
    opacity: 1;
}

/* Transitioning state when switching sides - smoother and faster */
.preview-card.transitioning {
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}

/* Simplified tooltip-style header */
.preview-card-header {
    margin-bottom: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 2px solid var(--color-accent);
}

.preview-title {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text);
    margin: 0 0 var(--space-xs) 0;
}

.preview-journal {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-style: italic;
    margin: 0;
}

.preview-summary {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--color-text);
    margin: var(--space-md) 0 0 0;
}

/* Hide preview on very small screens where it doesn't fit well */
@media (max-width: 900px) {
    .preview-card {
        display: none;
    }
}

/* ==========================================================================
   Load More Button
   ========================================================================== */

.load-more-btn {
    display: inline-block;
    padding: 1rem 2rem;
    margin: var(--space-lg) auto;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--color-accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
}

.load-more-btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.load-more-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

/* ==========================================================================
   Pagination Component
   ========================================================================== */

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-md);
    padding: var(--space-lg) 0;
    margin: var(--space-xl) 0;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

/* Lightweight top pagination - sits inline with search */
#paginationTop.pagination-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: var(--space-sm);
    padding: 0;
    margin: 0;
    border: none;
    flex-shrink: 0;
}

#paginationTop .pagination-info {
    display: none; /* Hide in lightweight version */
}

#paginationTop .pagination-controls {
    gap: 0.25rem;
}

#paginationTop .pagination-btn {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    border-radius: 4px;
}

#paginationTop .pagination-ellipsis {
    min-width: 2rem;
    height: 2rem;
    font-size: 0.875rem;
}

#paginationTop .per-page-selector-wrapper {
    display: flex; /* Show but keep compact */
}

#paginationTop .per-page-selector-wrapper label {
    font-size: 0.875rem;
}

#paginationTop .per-page-selector {
    font-size: 0.875rem;
    padding: 0.375rem 1.75rem 0.375rem 0.625rem;
    min-height: 2rem;
}

/* Bottom pagination - full featured, but less top margin */
#paginationBottom.pagination-container {
    margin-top: var(--space-md);
}

.pagination-info {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
    background: white;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--color-accent);
    background: var(--color-paper);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
    font-weight: 600;
}

.pagination-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    color: var(--color-text-secondary);
    user-select: none;
}

.per-page-selector-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.per-page-selector-wrapper label {
    font-size: 0.9375rem;
    color: var(--color-text-secondary);
    font-weight: 500;
    white-space: nowrap;
}

/* Mobile adjustments for pagination */
@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }
    
    .pagination-info {
        text-align: center;
        order: -1;
    }
    
    .pagination-controls {
        justify-content: center;
    }
    
    .per-page-selector-wrapper {
        justify-content: center;
    }
}

/* ==========================================================================
   Modal Dialog
   
   Accessible modal implementation with focus trap, keyboard navigation,
   and proper ARIA attributes. Follows WAI-ARIA authoring practices.
   ========================================================================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

/**
 * Active Modal State
 * Makes modal visible and interactive
 */
.modal-overlay.active,
.modal-overlay[aria-hidden="false"] {
    opacity: 1;
    visibility: visible;
}

/**
 * Modal Container
 * Main dialog box with content
 */
.modal {
    position: relative;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    padding: var(--space-xl);
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

/**
 * Modal Entrance Animation
 * Smooth appearance with scale and translate
 */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/**
 * Close Button
 * Accessible button to dismiss modal
 */
.close-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.close-btn:hover {
    color: var(--color-accent);
    background: var(--color-paper);
    transform: rotate(90deg);
}

.close-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.modal h2 {
    margin-bottom: var(--space-sm);
}

.modal-description {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
}

/* ==========================================================================
   Form Elements
   
   Accessible form controls with clear labels, error states, and
   focus indicators. Follows WCAG form guidelines.
   ========================================================================== */

.form-group {
    margin-bottom: var(--space-md);
}

/**
 * Fieldset Styling
 * For checkbox groups with proper legend
 */
fieldset.form-group {
    border: none;
    padding: 0;
}

/**
 * Form Labels
 * Clear, accessible labels with sufficient contrast
 */
.form-label {
    display: block;
    margin-bottom: var(--space-xs);
    font-weight: 500;
    color: var(--color-text);
}

legend.form-label {
    padding: 0;
    margin-bottom: var(--space-sm);
}

/**
 * Form Hint Text
 * Additional context for form fields
 */
.form-hint {
    font-weight: 400;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/**
 * Text Input Field
 * Standard text/email input with accessible focus states
 */
.form-input {
    width: 100%;
    padding: 0.75rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    background: white;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:hover {
    border-color: var(--color-accent);
}

/**
 * Input Focus State
 * High-visibility focus ring for keyboard navigation
 */
.form-input:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

/**
 * Input Error State
 * Red border for validation errors
 */
.form-input.error,
.form-input[aria-invalid="true"] {
    border-color: #dc3545;
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25);
}

/**
 * Error Message
 * Displayed when form validation fails
 */
.error-message {
    display: block;
    margin-top: var(--space-xs);
    font-size: 0.875rem;
    color: #dc3545;
}

.error-message:empty {
    display: none;
}

/* ==========================================================================
   Checkbox Styles
   
   Custom-styled accessible checkboxes with enhanced click targets
   and visual feedback for all states.
   ========================================================================== */

.topic-checkboxes {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
}

/**
 * Checkbox Wrapper
 * Enlarged click target for better accessibility
 */
.topic-checkbox-wrapper {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.topic-checkbox-wrapper:hover {
    border-color: var(--color-accent);
    background: var(--color-paper);
    transform: translateX(2px);
}

/**
 * Checkbox Focus State
 * Only visible for keyboard navigation (not mouse clicks)
 */
.topic-checkbox-wrapper:has(input:focus-visible) {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/**
 * Checked State
 * Visual feedback for selected checkboxes
 */
.topic-checkbox-wrapper.checked {
    border-color: var(--color-accent);
    background: rgba(15, 32, 39, 0.05);
}

.topic-checkbox-wrapper input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: var(--space-xs);
    cursor: pointer;
    accent-color: #0066cc;
}

/* Remove default focus ring for mouse clicks, only show for keyboard */
.topic-checkbox-wrapper input[type="checkbox"]:focus {
    outline: none;
}

.topic-checkbox-wrapper input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.topic-checkbox-label {
    font-size: 0.9375rem;
    cursor: pointer;
}

/* ==========================================================================
   Submit Button
   
   Form submission button with loading state and accessibility features.
   ========================================================================== */

.submit-btn {
    width: 100%;
    padding: 0.875rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    color: white;
    background: var(--color-accent);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

/**
 * Submit Button Ripple Effect
 * Background overlay animation on hover that covers entire button
 */
.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.submit-btn:hover:not(:disabled)::before {
    opacity: 1;
}

.submit-btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.submit-btn:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

.submit-btn:active:not(:disabled) {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ==========================================================================
   Message Components
   
   Success and error messages with proper ARIA live regions for
   screen reader announcements.
   ========================================================================== */

#message {
    margin-top: var(--space-md);
}

.message {
    padding: var(--space-sm) var(--space-md);
    border-radius: 8px;
    font-size: 0.9375rem;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/**
 * Message Animation
 * Slides in from above
 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message i {
    font-size: 1.125rem;
    flex-shrink: 0;
}

.message.success {
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #a7f3d0;
}

/**
 * Error Message
 * Red background for error feedback
 */
.message.error {
    color: #991b1b;
    background: #fee2e2;
    border: 1px solid #fecaca;
}

/* Notification (Toast) */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

.notification-error {
    background: #ef4444;
    color: white;
}

.notification-info {
    background: #3b82f6;
    color: white;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    width: 100%;
    padding: var(--space-xl) var(--space-lg);
    background: var(--color-paper);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-xxl);
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
}

.footer-logo {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: var(--space-xs);
}

.footer-tagline {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--color-accent);
}

.footer-links a:focus {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

.footer-copyright {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

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

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Shake Animation (for form errors) */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-xxl) var(--space-lg);
    color: var(--color-text-secondary);
}

.empty-state i {
    font-size: 4rem;
    color: var(--color-border);
    margin-bottom: var(--space-md);
}

.empty-state p {
    font-size: 1.125rem;
    margin: 0;
}

/* ==========================================================================
   Accessibility Utilities
   ========================================================================== */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

*:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

*:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
    .subscribe-btn,
    .filter-btn,
    .submit-btn,
    .load-more-btn {
        border: 2px solid currentColor;
    }
    
    .paper-card {
        border: 2px solid currentColor;
    }
}

/* ==========================================================================
   Responsive Design - Mobile
   ========================================================================== */

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .archive-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }
    
    .topic-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .footer-links {
        flex-direction: column;
        gap: var(--space-xs);
    }
    
    .filter-bar {
        position: static;
    }
    
    .filter-buttons {
        gap: 0.5rem;
    }
    
    .filter-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .modal {
        padding: var(--space-lg);
    }
    
    .search-container {
        padding: 0 var(--space-md);
    }
}

@media (max-width: 480px) {
    .hero h1 {
        font-size: 1.75rem;
    }
    
    .hero {
        padding: var(--space-lg) var(--space-sm);
    }
    
    .archive {
        padding: var(--space-lg) var(--space-sm);
    }
    
    .header-content {
        padding: 0 var(--space-sm);
    }
    
    .search-container {
        padding: 0 var(--space-sm);
    }
}

/* ==========================================================================
   Print Styles
   
   Optimized styles for printed pages, removing unnecessary elements
   and ensuring readability.
   ========================================================================== */

@media print {
    .header,
    .filter-bar,
    .footer,
    .subscribe-btn,
    .modal-overlay,
    .skip-link,
    .search-container,
    .display-controls,
    .load-more-btn {
        display: none !important;
    }
    
    body {
        color: #000;
        background: #fff;
    }
    
    .paper-card {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    a {
        text-decoration: underline;
    }
    
    /* Show URLs for external links */
    a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}