/* 
 * سِفر قيس Platform - Main Stylesheet
 * 
 * A comprehensive stylesheet for the سِفر قيس historical studies platform,
 * featuring a scholarly color palette and refined typography.
 * 
 * MOBILE TOUCH OPTIMIZATIONS:
 * - Fixed z-index hierarchy to prevent touch event capture issues
 * - Improved touch target areas for better mobile usability
 * - Enhanced touch feedback for interactive elements
 * - Fixed RTL positioning issues for mobile navigation
 */

/* Base Style Variables - NEW COLOR SCHEME */
:root {
  /* Primary Colors */
  --primary-color: #4A5568; /* Darker slate gray - scholarly, serious */
  --primary-light: #718096; /* Lighter slate for hover states and accents */
  --primary-dark: #2D3748; /* Deep slate for headers and emphasis */
  
  /* Accent Colors */
  --accent-color: #8A5A44; /* Warm terra cotta - reminiscent of ancient pottery */
  --accent-hover: #9B6A53; /* Lighter terra cotta for hover states */
  --accent-light: #C8B6A6; /* Light sandstone for subtle accents */
  
  /* Background Colors */
  --background-color: #F8F5F1; /* Soft parchment color - mimics old paper */
  --card-background: #FFFFFF; /* Clean white for content areas */
  --alt-background: #F0EBE3; /* Slightly darker background for alternate sections */
  
  /* Text Colors */
  --text-color: #1A202C; /* Near black for main text */
  --text-dark: #000000; /* Pure black for headings */
  --text-muted: #718096; /* Muted text for secondary information */
  
  /* Border Colors */
  --border-color: #E2E8F0; /* Subtle border color */
  --border-dark: #CBD5E0; /* Darker border for emphasis */
  
  /* Form and UI Elements */
  --input-background: #FFFFFF;
  --input-border: #CBD5E0;
  --input-focus: #8A5A44;
  
  /* Status Colors */
  --success: #48BB78; /* Green for success messages */
  --error: #E53E3E; /* Red for errors */
  --warning: #ECC94B; /* Yellow for warnings */
  --info: #4299E1; /* Blue for information */
  
  /* Typography */
  --font-heading: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif;
  --font-poetry: 'Amiri', serif;
  --font-fallback: 'IBM Plex Sans Arabic', 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  
  /* Font Sizes - Using a more refined scale */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-md: 1rem;       /* 16px - Base size */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 1.875rem;  /* 30px */
  --text-4xl: 2.25rem;   /* 36px */
  --text-5xl: 3rem;      /* 48px */
  
  /* Line Heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.6;
  --line-height-relaxed: 1.8;
  
  /* Font Weights */
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Spacing Scale */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.5rem;   /* 24px */
  --space-6: 2rem;     /* 32px */
  --space-8: 3rem;     /* 48px */
  --space-10: 4rem;    /* 64px */
  --space-12: 6rem;    /* 96px */
  
  /* Border Radius */
  --radius-sm: 0.125rem; /* 2px */
  --radius-md: 0.25rem;  /* 4px */
  --radius-lg: 0.5rem;   /* 8px */
  --radius-xl: 1rem;     /* 16px */
  --radius-full: 9999px; /* Fully rounded */
  
  /* Box Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Transitions */
  --transition-fast: 150ms;
  --transition-normal: 300ms;
  --transition-slow: 500ms;

  /* Card Hover Transform */
  --card-hover-transform: translateY(-5px);
  
  /* Touch Target Sizes - IMPROVED */
  --touch-target-min: 44px;     /* Minimum touch target size */
  --touch-target-spacing: 8px;  /* Minimum spacing between touch targets */
  
  /* Menu transition duration */
  --menu-transition-duration: 300ms;
  
  /* CRITICAL FIX: Z-index levels - reduced to more reasonable values */
  --z-index-dropdown: 10;       /* Dropdown menus, search results */
  --z-index-sticky: 20;         /* Sticky headers */
  --z-index-fixed: 30;          /* Fixed position elements */
  --z-index-modal-backdrop: 40; /* Modal backdrops */
  --z-index-modal: 50;          /* Modal dialogs */
  --z-index-popover: 60;        /* Popovers, tooltips */
  --z-index-header: 70;         /* Site header */
  --z-index-mobile-nav: 80;     /* Mobile navigation */
  --z-index-user-menu: 90;      /* User dropdown menu */
  --z-index-mobile-toggle: 100; /* Mobile toggle button - IMPORTANT */
}

/* =========================
   Base Element Styles
   ========================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  height: 100%;
  /* Set default touch-action behavior */
  touch-action: manipulation;
  /* CRITICAL FIX: Added to improve touch highlighting */
  -webkit-tap-highlight-color: rgba(138, 90, 68, 0.2);
}

body {
  font-family: var(--font-body);
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: var(--line-height-normal);
  direction: rtl;
  min-height: 100%;
  position: relative;
  /* Default pointer behavior */
  cursor: default;
  /* Default touch behavior */
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
  position: relative; /* Ensure z-index context */
}

a {
  text-decoration: none;
  color: var(--accent-color);
  transition: color var(--transition-normal) ease;
  /* Ensure touchable links */
  display: inline-block;
  position: relative;
  cursor: pointer;
}

a:hover {
  color: var(--accent-hover);
}

ul {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-5);
  color: var(--text-dark);
}

h1 {
  font-size: var(--text-4xl);
}

h2 {
  font-size: var(--text-3xl);
}

h3 {
  font-size: var(--text-2xl);
}

h4 {
  font-size: var(--text-xl);
}

h5 {
  font-size: var(--text-lg);
}

h6 {
  font-size: var(--text-md);
}

p {
  margin-bottom: var(--space-4);
}

.section-title {
  text-align: center;
  margin-bottom: var(--space-8);
  color: var(--text-dark);
  position: relative;
  padding-bottom: var(--space-3);
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 50%;
  transform: translateX(50%);
  width: 80px;
  height: 3px;
  background-color: var(--accent-color);
}

/* =========================
   Form Elements
   ========================= */

input, select, textarea, button {
  font-family: var(--font-body);
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background-color: var(--input-background);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  color: var(--text-color);
  transition: border-color var(--transition-normal) ease;
  /* Ensuring touch-friendly inputs */
  min-height: var(--touch-target-min);
  touch-action: manipulation;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(138, 90, 68, 0.2);
}

label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--font-weight-medium);
  color: var(--text-color);
}

.form-group {
  margin-bottom: var(--space-4);
  position: relative; /* For absolute positioned elements */
}

/* Enhanced touch target sizes */
.form-control {
  min-height: var(--touch-target-min);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal) ease;
  border: none;
  font-size: var(--text-md);
  /* Enhanced touch targets */
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  position: relative;
  /* Improved accessibility */
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* CRITICAL FIX: Added improved touch feedback */
.btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: transparent;
  border-radius: inherit;
  transition: background-color 0.15s ease;
  pointer-events: none;
}

.btn:active::after {
  background-color: rgba(0, 0, 0, 0.1);
}

/* Button feedback for touch */
.btn:active {
  transform: translateY(1px);
  opacity: 0.9;
}

.btn-primary {
  background-color: var(--accent-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--primary-color);
  color: white;
}

.btn-secondary:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
}

.btn-danger {
  background-color: var(--error);
  color: white;
}

.btn-success {
  background-color: var(--success);
  color: white;
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  /* Still maintain minimum touch target */
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-lg);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* =========================
   Header Styles - ENHANCED FOR TOUCH
   ========================= */

.site-header {
  background-color: var(--card-background);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  /* CRITICAL FIX: Set appropriate z-index from new scale */
  z-index: var(--z-index-header);
  padding: var(--space-3) 0;
  /* Added for transition */
  transition: box-shadow var(--transition-normal) ease;
  /* Create stacking context */
  isolation: isolate;
}

.site-header.scrolled {
  box-shadow: var(--shadow-lg);
}

.header-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* CRITICAL FIX: Create a new stacking context */
  isolation: isolate;
}

.site-brand {
  display: flex;
  align-items: center;
  /* CRITICAL FIX: Lower z-index */
  z-index: 1;
}

.site-brand h1 {
  margin: 0;
  font-size: var(--text-2xl);
  color: var(--text-dark);
}

.site-brand a {
  display: block;
  /* Ensure touch target size */
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  display: flex;
  align-items: center;
}

.main-nav {
  display: flex;
  align-items: center;
  /* CRITICAL FIX: Set appropriate z-index */
  z-index: var(--z-index-mobile-nav);
}

.nav-list {
  display: flex;
  padding: 0;
  margin: 0;
  list-style: none;
}

.nav-list li {
  margin-right: var(--space-5);
  /* Ensure adequate spacing for touch */
  padding: var(--space-1) 0;
}

.nav-list li:last-child {
  margin-right: 0;
}

.nav-list a {
  color: var(--text-color);
  font-weight: var(--font-weight-medium);
  position: relative;
  text-decoration: none;
  padding: var(--space-2) var(--space-1);
  /* Ensure touch target size */
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  display: flex;
  align-items: center;
}

.nav-list a::after {
  content: '';
  position: absolute;
  bottom: -4px;
  right: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent-color);
  transition: width var(--transition-normal) ease;
}

.nav-list a:hover::after,
.nav-list a.active::after {
  width: 100%;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  position: relative; /* For properly positioning dropdowns */
  /* CRITICAL FIX: Set appropriate z-index */
  z-index: var(--z-index-user-menu);
}

.search-form-wrapper {
  position: relative;
  margin-right: var(--space-3);
}

.search-form {
  display: flex;
  position: relative;
}

.search-form input {
  width: 240px;
  padding: var(--space-2) var(--space-6) var(--space-2) var(--space-2);
  background-color: var(--background-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  transition: all var(--transition-normal) ease;
  /* Min height for touch */
  min-height: var(--touch-target-min);
}

.search-form input:focus {
  width: 300px;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(138, 90, 68, 0.1);
}

.search-form button {
  position: absolute;
  left: var(--space-2); /* Changed from right to left */
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
  margin: 0; /* Simplified the margin */
  z-index: 2;
}

.search-input-container {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.search-form button:hover {
  color: var(--accent-color);
}

/* Improved search suggestions for touch */
.search-suggestions {
  position: absolute;
  top: 100%;
  right: 0;
  width: 100%;
  max-width: 320px;
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  /* CRITICAL FIX: Set appropriate z-index */
  z-index: var(--z-index-dropdown);
  overflow: hidden;
  border: 1px solid var(--border-color);
  /* Proper transitions for smooth UX */
  transition: opacity var(--transition-normal) ease, 
              transform var(--transition-normal) ease;
}

/* Suggestion items enhanced for touch */
.suggestion-item {
  padding: var(--space-3);
  cursor: pointer;
  transition: background-color var(--transition-normal) ease;
  border-bottom: 1px solid var(--border-color);
  /* Ensure adequate touch target size */
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
}

.suggestion-item:hover,
.suggestion-item.selected {
  background-color: var(--alt-background);
}

.suggestion-item:active {
  background-color: var(--accent-light);
}

.notification-icon {
  position: relative;
  margin-right: var(--space-2);
}

.icon-button {
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--background-color);
  color: var(--text-color);
  transition: all var(--transition-normal) ease;
  /* Improved touch feedback */
  position: relative;
  overflow: hidden;
}

.icon-button::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: transparent;
  transition: background-color var(--transition-fast) ease;
  pointer-events: none;
  border-radius: 50%;
}

.icon-button:hover {
  background-color: var(--accent-light);
  color: var(--accent-color);
}

.icon-button:active::after {
  background-color: rgba(0, 0, 0, 0.1);
}

.notification-badge {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 20px;
  height: 20px;
  background-color: var(--accent-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  pointer-events: none; /* Allow click through to parent */
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--border-color);
  transition: all var(--transition-normal) ease;
  /* Improve touch feedback */
  -webkit-tap-highlight-color: rgba(138, 90, 68, 0.2);
}

.user-menu-trigger:hover {
  border-color: var(--accent-color);
}

.user-menu-trigger:active {
  opacity: 0.9;
}

.user-avatar-small, 
.user-avatar-placeholder-small {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-light);
  color: var(--primary-dark);
  font-weight: var(--font-weight-bold);
}

.user-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 260px; /* Increased for better touch targets */
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  margin-top: var(--space-2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--transition-normal) ease;
  /* CRITICAL FIX: Use appropriate z-index */
  z-index: var(--z-index-dropdown);
  border: 1px solid var(--border-color);
}

.user-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-info {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.user-name {
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-1);
  color: var(--text-dark);
}

.user-username {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.user-links {
  list-style: none;
  padding: 0;
  margin: 0;
}

.user-links li {
  margin-bottom: var(--space-2);
}

.user-links a {
  display: flex;
  align-items: center;
  color: var(--text-color);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal) ease;
  /* Ensure minimum touch target size */
  min-height: var(--touch-target-min);
}

.user-links a:hover {
  background-color: var(--background-color);
  color: var(--accent-color);
}

.user-links a:active {
  background-color: var(--accent-light);
}

.user-links i {
  margin-left: var(--space-2);
  color: var(--text-muted);
}

.user-links .separator {
  height: 1px;
  background-color: var(--border-color);
  margin: var(--space-2) 0;
}

/* CRITICAL FIX: Completely restructured mobile toggle for better touch */
.mobile-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  border-radius: var(--radius-md);
  background-color: transparent;
  border: none;
  transition: background-color var(--transition-normal) ease;
  padding: 0;
  /* CRITICAL FIX: Set appropriate z-index */
  z-index: var(--z-index-mobile-toggle);
  /* CRITICAL FIX: Touch-specific enhancements */
  position: relative;
  -webkit-tap-highlight-color: rgba(138, 90, 68, 0.3);
}

/* CRITICAL FIX: Added touch feedback ripple */
.mobile-toggle::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-md);
  background-color: rgba(138, 90, 68, 0);
  transition: background-color 0.3s ease;
  pointer-events: none;
}

.mobile-toggle:active::after {
  background-color: rgba(138, 90, 68, 0.15);
}

.mobile-toggle span {
  width: 25px;
  height: 3px;
  background-color: var(--text-color);
  margin-bottom: 5px;
  border-radius: 2px;
  transition: all var(--transition-normal) ease;
}

.mobile-toggle span:last-child {
  margin-bottom: 0;
}

.mobile-toggle:hover {
  background-color: var(--alt-background);
}

.mobile-toggle:active {
  background-color: var(--accent-light);
}

.mobile-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Add or modify this CSS rule */
.mobile-filters-toggle {
    position: relative;
    z-index: 100; /* Higher than other elements */
    padding: var(--space-3) var(--space-4);
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    width: 100%;
    text-align: center;
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    transition: all var(--transition-normal);
}

/* Also check that this exists in your CSS */
.mobile-filters-toggle i {
    margin-left: var(--space-2);
}

/* =========================
   Sidebar Styles - ENHANCED FOR TOUCH
   ========================= */

.content-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
}

.main-column {
  min-width: 0; /* Prevents overflow in grid layouts */
  /* Enabling touch scrolling */
  -webkit-overflow-scrolling: touch;
  position: relative; /* For z-index stacking */
  z-index: 1;
}

.sidebar, .sidebar-column {
  position: relative;
}

.sidebar-widget {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.sidebar-widget h3, .widget-title {
  position: relative;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  font-size: var(--text-lg);
  color: var(--text-dark);
}

.sidebar-widget h3::after, .widget-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 40px;
  height: 2px;
  background-color: var(--accent-color);
}

.user-profile-widget {
  padding: 0;
  overflow: hidden;
}

.user-profile-card {
  display: flex;
  flex-direction: column;
}

.user-profile-header {
  display: flex;
  align-items: center;
  padding: var(--space-4);
  background-color: var(--alt-background);
}

.user-avatar {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid var(--accent-light);
  object-fit: cover;
  margin-left: var(--space-3);
}

.user-avatar-placeholder {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-light);
  color: var(--primary-dark);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
  margin-left: var(--space-3);
}

.user-profile-info {
  flex: 1;
}

.user-profile-name {
  margin-bottom: var(--space-1);
  font-size: var(--text-lg);
}

.user-profile-username {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.user-profile-actions {
  padding: var(--space-4);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.user-profile-researcher-actions {
  margin-top: var(--space-3);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.login-widget {
  padding: var(--space-5);
}

.login-card {
  text-align: center;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.eras-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.eras-list li {
  margin-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-2);
}

.eras-list li:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.eras-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-color);
  transition: color var(--transition-normal) ease;
  /* Touch-friendly size */
  min-height: var(--touch-target-min);
  padding: var(--space-1) 0;
}

.eras-list a:hover {
  color: var(--accent-color);
}

.eras-list a:active {
  opacity: 0.8;
}

.eras-list .count {
  font-size: var(--text-sm);
  color: var(--text-muted);
  background-color: var(--alt-background);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  transition: all var(--transition-normal) ease;
}

.eras-list a:hover .count {
  background-color: var(--accent-light);
  color: var(--accent-color);
}

.tags-cloud, .tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tags-cloud .tag, .tag-cloud .tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  background-color: var(--alt-background);
  color: var(--text-color);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: 32px;
  min-width: 32px;
}

.tags-cloud .tag:hover, .tag-cloud .tag:hover, 
.tag-cloud .tag.active {
  background-color: var(--accent-color);
  color: white;
}

.tags-cloud .tag:active, .tag-cloud .tag:active {
  transform: scale(0.95);
}

.tag-lg {
  font-size: var(--text-md) !important;
  font-weight: var(--font-weight-medium);
  min-height: var(--touch-target-min) !important;
}

.featured-researchers {
  padding: 0;
  margin: 0;
  list-style: none;
}

.researcher-item {
  margin-bottom: var(--space-3);
}

.researcher-item:last-child {
  margin-bottom: 0;
}

.researcher-link {
  display: flex;
  align-items: center;
  color: var(--text-color);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: var(--touch-target-min);
}

.researcher-link:hover {
  background-color: var(--alt-background);
  color: var(--text-color);
}

.researcher-link:active {
  background-color: var(--accent-light);
}

.researcher-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  margin-left: var(--space-3);
  border: 2px solid var(--accent-light);
}

.researcher-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.researcher-info {
  flex: 1;
}

.researcher-name {
  margin-bottom: var(--space-1);
  font-size: var(--text-md);
  font-weight: var(--font-weight-medium);
}

.researcher-specialty {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.popular-articles {
  padding: 0;
  margin: 0;
  list-style: none;
}

.article-item {
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-3);
}

.article-item:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.article-link {
  display: flex;
  color: var(--text-color);
  /* Touch-friendly */
  min-height: var(--touch-target-min);
  padding: var(--space-1) 0;
}

.article-thumbnail {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-left: var(--space-3);
}

.article-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) ease;
}

.article-link:hover .article-thumbnail img {
  transform: scale(1.05);
}

.article-info {
  flex: 1;
}

.article-title {
  margin-bottom: var(--space-1);
  font-size: var(--text-md);
  line-height: 1.4;
  transition: color var(--transition-normal) ease;
}

.article-link:hover .article-title {
  color: var(--accent-color);
}

.article-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.article-author {
  font-weight: var(--font-weight-medium);
}

.article-views i {
  color: var(--accent-color);
  margin-left: var(--space-1);
}

.widget-footer {
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-3);
  margin-top: var(--space-3);
  text-align: center;
}

.view-all {
  color: var(--primary-color);
  font-size: var(--text-sm);
  display: inline-flex;
  align-items: center;
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: var(--touch-target-min);
  padding: var(--space-1) var(--space-2);
}

.view-all::after {
  content: "\f054"; /* FontAwesome chevron-right */
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  margin-right: var(--space-1);
  font-size: 0.7em;
  transition: transform var(--transition-normal) ease;
}

.view-all:hover {
  color: var(--accent-color);
}

.view-all:hover::after {
  transform: translateX(-3px);
}

/* Enhanced sidebar toggle and close buttons */
.sidebar-close, .sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-dark);
  font-size: var(--text-xl);
  cursor: pointer;
  /* Touch-friendly */
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: var(--z-index-fixed);
  border-radius: var(--radius-md);
}

.sidebar-close:hover, .sidebar-toggle:hover {
  background-color: var(--alt-background);
}

.sidebar-close:active, .sidebar-toggle:active {
  background-color: var(--accent-light);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--z-index-modal-backdrop);
  opacity: 0;
  transition: opacity var(--transition-normal) ease;
  -webkit-tap-highlight-color: transparent;
}

.sidebar-overlay.active {
  display: block; /* ADD THIS LINE to make overlay visible */
  opacity: 1;
}

/* =========================
   Article Cards - ENHANCED FOR TOUCH
   ========================= */

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.article-card {
  display: flex;
  flex-direction: column;
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal) ease;
  height: 100%;
  border: 1px solid var(--border-color);
  /* Ensure proper hover and touch behavior */
  position: relative;
  z-index: 1;
  -webkit-tap-highlight-color: rgba(138, 90, 68, 0.1);
}

.article-card:hover {
  transform: var(--card-hover-transform);
  box-shadow: var(--shadow-lg);
}

/* Touch feedback */
.article-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.article-image {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.article-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) ease;
}

.article-card:hover .article-image img {
  transform: scale(1.05);
}

.era-badge, .poetry-badge {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  background-color: var(--accent-color);
  color: white;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semibold);
  z-index: 1;
  /* Improved touch target */
  min-height: 32px;
  display: flex;
  align-items: center;
}

.poetry-badge {
  background-color: var(--primary-color);
  right: auto;
  left: var(--space-3);
}

.era-badge a {
  color: white;
}

.article-content {
  flex: 1;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
}

.article-card h3 {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
  line-height: 1.4;
  font-weight: var(--font-weight-bold);
}

.article-card h3 a {
  color: var(--text-dark);
  text-decoration: none;
  transition: color var(--transition-normal) ease;
  /* Ensure full card area is touchable */
  display: block;
}

.article-card h3 a:hover {
  color: var(--accent-color);
}

/* Make entire card clickable */
.article-card h3 a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.article-excerpt {
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: var(--line-height-relaxed);
  flex-grow: 1;
}

.article-stats {
  display: flex;
  align-items: center;
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
  font-size: var(--text-sm);
  color: var(--text-muted);
  position: relative;
  z-index: 2; /* Above the card-level link */
}

.article-stats .views, 
.article-stats .comments {
  display: flex;
  align-items: center;
  margin-left: var(--space-3);
}

.article-stats i {
  margin-left: var(--space-1);
  color: var(--accent-color);
}

/* Enhanced list view for articles */
.list-view-active .articles-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.list-view-active .article-card {
  display: flex;
  flex-direction: row;
  height: auto;
  min-height: 150px;
}

.list-view-active .article-image {
  width: 200px;
  height: auto;
  flex-shrink: 0;
}

.list-view-active .article-content {
  padding: var(--space-4);
  flex: 1;
}

/* =========================
   Researcher Cards - ENHANCED FOR TOUCH
   ========================= */

.researchers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.researcher-card {
  display: flex;
  flex-direction: column;
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal) ease;
  padding: var(--space-4);
  border: 1px solid var(--border-color);
  /* Enhanced for touch */
  position: relative;
  -webkit-tap-highlight-color: rgba(138, 90, 68, 0.1);
}

.researcher-card:hover {
  transform: var(--card-hover-transform);
  box-shadow: var(--shadow-lg);
}

.researcher-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.researcher-header {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-4);
  position: relative;
  z-index: 2; /* Above the full-card link */
}

.researcher-header .researcher-avatar {
  /* Responsive sizing: 60px on mobile, up to 75px on desktop */
  width: clamp(60px, 12vw, 75px);
  height: clamp(60px, 12vw, 75px);
  border-radius: 50%;
  overflow: hidden;
  /* RTL-aware margin */
  margin-inline-start: var(--space-3);
  border: 2px solid var(--accent-light);
  flex-shrink: 0; /* Prevent avatar from shrinking */
  /* Ensure perfect circle */
  position: relative;
  display: block;
  /* Remove any padding/spacing */
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.researcher-header .researcher-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  /* Force perfect circular aspect ratio */
  border-radius: 50%;
  /* Remove any spacing and ensure full fill */
  margin: 0;
  padding: 0;
  border: none;
  outline: none;
}

.researcher-info {
  flex: 1;
}

.researcher-info h3 {
  margin-bottom: var(--space-1);
  font-size: var(--text-xl);
}

.researcher-info h3 a {
  color: var(--text-dark);
  transition: color var(--transition-normal) ease;
}

.researcher-info h3 a:hover {
  color: var(--accent-color);
}

/* Make entire card clickable for better touch */
.researcher-info h3 a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
}

.researcher-info .specialty {
  display: block;
  color: var(--accent-color);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.researcher-info .institution {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.researcher-bio {
  margin-bottom: var(--space-4);
  color: var(--text-color);
  font-size: var(--text-sm);
  line-height: var(--line-height-relaxed);
}

.researcher-stats {
  display: flex;
  justify-content: space-around;
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-3);
  margin-bottom: var(--space-3);
  position: relative;
  z-index: 2; /* Above the full-card link */
}

.researcher-stats .stat {
  text-align: center;
}

.researcher-stats .value {
  display: block;
  font-size: var(--text-xl);
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
}

.researcher-stats .label {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.researcher-actions {
  margin-bottom: var(--space-3);
  position: relative;
  z-index: 2; /* Above the full-card link */
}

.researcher-actions .btn {
  width: 100%;
}

.view-profile-link {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
  font-size: var(--text-sm);
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: var(--touch-target-min);
  position: relative;
  z-index: 2; /* Above the full-card link */
}

.view-profile-link:hover {
  color: var(--accent-color);
  transform: translateX(-5px);
}

.view-profile-link i {
  margin-right: var(--space-1);
  transition: transform var(--transition-normal) ease;
}

.view-profile-link:hover i {
  transform: translateX(-3px);
}

/* =========================
   Enhanced Researcher Card Elements - NEW FEATURES
   ========================= */

/* Verification badge */
.verified-badge {
  margin-inline-start: var(--space-1);
  color: var(--accent-color);
  font-size: var(--text-sm);
}

.verified-badge i {
  color: var(--accent-color); /* Platform accent color for verification */
}

/* Researcher meta information */
.researcher-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.join-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Research interests section */
.research-interests {
  margin-bottom: var(--space-3);
  padding: var(--space-2);
  background-color: rgba(var(--accent-color-rgb), 0.05);
  border-radius: var(--radius-md);
  border: 1px solid rgba(var(--accent-color-rgb), 0.1);
}

.interests-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
  display: block;
  margin-bottom: var(--space-2);
}

.interests-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.interest-tag {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  background-color: var(--accent-light);
  color: var(--accent-color);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(var(--accent-color-rgb), 0.2);
}

.more-interests {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
  padding: var(--space-1) var(--space-2);
}

/* =========================
   Main Search Bar - NEW PROMINENT SEARCH
   ========================= */

.main-search-bar {
  margin-bottom: var(--space-6);
  padding: var(--space-4);
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.researchers-search {
  display: flex;
  gap: var(--space-3);
  align-items: stretch;
}

.search-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper .search-icon {
  position: absolute;
  left: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
  z-index: 2;
}

.search-input {
  width: 100%;
  padding: var(--space-3) var(--space-8) var(--space-3) var(--space-8);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background-color: var(--background-color);
  color: var(--text-color);
  transition: all var(--transition-normal) ease;
  min-height: 44px; /* Touch-friendly */
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(var(--accent-color-rgb), 0.1);
}

.search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.8;
}

.clear-search {
  position: absolute;
  right: var(--space-3);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  transition: all var(--transition-normal) ease;
  z-index: 2;
}

.clear-search:hover {
  color: var(--accent-color);
  background-color: rgba(var(--accent-color-rgb), 0.1);
}

.search-submit {
  padding: var(--space-3) var(--space-4);
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: all var(--transition-normal) ease;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px; /* Touch-friendly */
  white-space: nowrap;
}

.search-submit:hover {
  background-color: var(--accent-dark, #8B5A42);
  transform: translateY(-1px);
}

.search-submit:active {
  transform: translateY(0);
}

.search-text {
  font-size: var(--text-sm);
}

/* Mobile optimizations */
@media (max-width: 768px) {
  .main-search-bar {
    margin-bottom: var(--space-4);
    padding: var(--space-3);
  }
  
  .researchers-search {
    flex-direction: column;
    gap: var(--space-2);
  }
  
  .search-submit {
    align-self: stretch;
    justify-content: center;
  }
  
  .search-input {
    font-size: 16px; /* Prevent iOS zoom */
  }
}

@media (max-width: 576px) {
  .search-input::placeholder {
    font-size: var(--text-sm);
  }
  
  .search-text {
    display: none; /* Show icon only on very small screens */
  }
}

/* Dark mode support for search bar */
.dark-mode .main-search-bar {
  background-color: var(--card-background);
  border-color: var(--border-color);
}

.dark-mode .search-input {
  background-color: var(--background-color);
  border-color: var(--border-color);
  color: var(--text-color);
}

.dark-mode .search-input:focus {
  border-color: var(--accent-color);
}

/* Dark mode support for research interests */
.dark-mode .research-interests {
  background-color: rgba(138, 90, 68, 0.1);
  border-color: rgba(138, 90, 68, 0.2);
}

/* =========================
   Researcher Grid List View - NEW IMPLEMENTATION
   ========================= */

.researchers-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.researchers-grid.list-view .researcher-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: var(--space-3);
  min-height: auto;
}

.researchers-grid.list-view .researcher-header {
  grid-column: 1 / 2;
  margin-bottom: 0;
  flex-direction: column;
  text-align: center;
}

.researchers-grid.list-view .researcher-info {
  grid-column: 2 / 3;
  padding-inline: var(--space-4);
}

.researchers-grid.list-view .researcher-info h3 {
  font-size: var(--text-lg);
}

.researchers-grid.list-view .researcher-stats {
  grid-column: 3 / 4;
  border: none;
  padding: 0;
  gap: var(--space-3);
  margin-bottom: 0;
}

.researchers-grid.list-view .researcher-bio,
.researchers-grid.list-view .researcher-actions,
.researchers-grid.list-view .view-profile-link {
  display: none;
}

/* Mobile optimization for list view */
@media (max-width: 768px) {
  .researchers-grid.list-view .researcher-card {
    grid-template-columns: auto 1fr;
    gap: var(--space-2);
  }
  
  .researchers-grid.list-view .researcher-stats {
    grid-column: 2 / 3;
    justify-content: flex-start;
    padding-inline: var(--space-4);
    margin-top: var(--space-2);
  }
  
  .researchers-grid.list-view .researcher-header .researcher-avatar {
    width: 50px;
    height: 50px;
    aspect-ratio: 1;
  }
  
  .researchers-grid.list-view .researcher-header .researcher-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    /* Full fill in list view */
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
  }
}

/* =========================
   Hero Section - ENHANCED FOR TOUCH
   ========================= */

.hero {
  position: relative;
  padding: var(--space-12) 0;
  text-align: center;
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('../images/hero-bg.jpg');
  background-size: cover;
  background-position: center;
  margin-bottom: var(--space-10);
  color: white;
  overflow: hidden;
  /* Better touch scrolling */
  -webkit-overflow-scrolling: touch; 
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 0%, rgba(0,0,0,0.5) 100%);
  pointer-events: none; /* Allows touch to pass through */
}

.hero-content {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
  z-index: 1; /* Ensure content stays above overlay */
}

.hero h1 {
  font-size: var(--text-5xl);
  margin-bottom: var(--space-4);
  color: white;
  position: relative;
}

.hero p {
  font-size: var(--text-xl);
  max-width: 800px;
  margin: 0 auto 30px;
  position: relative;
  color: var(--accent-light);
}

.hero-search {
  max-width: 700px;
  margin: 0 auto var(--space-6);
  position: relative;
}

.hero-search form {
  display: flex;
}

.hero-search input {
  flex: 1;
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-lg);
  border-top-right-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background-color: rgba(255, 255, 255, 0.9);
  border: none;
  color: var(--text-dark);
  min-height: var(--touch-target-min);
}

.hero-search button {
  padding: 0 var(--space-5);
  font-size: var(--text-lg);
  border-top-left-radius: var(--radius-lg);
  border-bottom-left-radius: var(--radius-lg);
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  background-color: var(--accent-color);
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-normal) ease;
  min-height: var(--touch-target-min);
  min-width: var(--touch-target-min);
}

.hero-search button:hover {
  background-color: var(--accent-hover);
}

.hero-search button:active {
  background-color: var(--accent-hover);
  opacity: 0.9;
}

.hero-cta {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  position: relative;
}

.hero-cta .btn {
  min-width: 150px;
}

/* =========================
   Footer Styles - ENHANCED FOR TOUCH
   ========================= */

.site-footer {
  background-color: var(--primary-dark);
  color: var(--text-muted);
  padding-top: var(--space-10);
  position: relative;
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.footer-brand {
  grid-column: span 1;
}

.footer-brand h2 {
  color: white;
  margin-bottom: var(--space-2);
  font-size: var(--text-3xl);
}

.footer-tagline {
  color: var(--accent-light);
  font-size: var(--text-md);
  margin-bottom: var(--space-4);
}

.footer-links {
  grid-column: span 3;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
}

.footer-links-column h3 {
  color: white;
  margin-bottom: var(--space-4);
  font-size: var(--text-lg);
  position: relative;
  padding-bottom: var(--space-2);
}

.footer-links-column h3::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30px;
  height: 2px;
  background-color: var(--accent-color);
}

.footer-links-column ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.footer-links-column ul li {
  margin-bottom: var(--space-2);
}

.footer-links-column ul li a {
  color: var(--text-muted);
  transition: all var(--transition-normal) ease;
  display: inline-block;
  /* Touch-friendly */
  min-height: var(--touch-target-min);
  padding: var(--space-1) 0;
  display: flex;
  align-items: center;
}

.footer-links-column ul li a:hover {
  color: white;
  transform: translateX(-5px);
}

.footer-links-column ul li a:active {
  opacity: 0.8;
}

.social-icons {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.social-icons a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  border-radius: 50%;
  transition: all var(--transition-normal) ease;
}

.social-icons a:hover {
  background-color: var(--accent-color);
  transform: translateY(-3px);
}

.social-icons a:active {
  transform: translateY(-1px);
  opacity: 0.9;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: var(--space-4) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
}

.footer-meta-links {
  display: flex;
  gap: var(--space-4);
}

.footer-meta-links a {
  color: var(--text-muted);
  /* Touch-friendly */
  min-height: var(--touch-target-min);
  display: flex;
  align-items: center;
  padding: 0 var(--space-1);
}

.footer-meta-links a:hover {
  color: white;
}

.footer-meta-links a:active {
  opacity: 0.8;
}

/* Back to Top Button */
.back-to-top {
  position: fixed;
  bottom: var(--space-4);
  left: var(--space-4);
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background-color: var(--accent-color);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: all var(--transition-normal) ease;
  z-index: var(--z-index-fixed);
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: var(--accent-hover);
  transform: translateY(-3px);
}

.back-to-top:active {
  transform: translateY(-1px);
  opacity: 0.9;
}

/* =========================
   Article Content Styles
   ========================= */

.article-wrapper {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-6);
}

.single-article {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.article-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.article-header h1 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-4);
  line-height: 1.3;
}

.article-header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.article-header-meta > div {
  display: flex;
  align-items: center;
}

.article-header-meta i {
  margin-left: var(--space-1);
  color: var(--accent-color);
}

.article-author {
  display: flex;
  align-items: center;
  margin-top: var(--space-4);
}

.article-author-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  overflow: hidden;
  margin-left: var(--space-3);
  border: 2px solid var(--accent-light);
}

.article-author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-author-info {
  flex: 1;
}

.article-author-name {
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
  margin-bottom: var(--space-1);
}

.article-author-specialty {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.article-cover {
  height: 400px;
  overflow: hidden;
}

.article-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article-content {
  padding: var(--space-6);
}

.article-content p {
  margin-bottom: var(--space-4);
  line-height: var(--line-height-relaxed);
}

.article-content h2 {
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
  font-size: var(--text-2xl);
}

.article-content h3 {
  margin-top: var(--space-5);
  margin-bottom: var(--space-3);
  font-size: var(--text-xl);
}

.article-content ol, 
.article-content ul {
  margin-bottom: var(--space-4);
  padding-right: var(--space-5);
}

.article-content ol li, 
.article-content ul li {
  margin-bottom: var(--space-2);
}

.article-content ul {
  list-style: disc outside;
}

.article-content ol {
  list-style: decimal outside;
}

.article-content blockquote {
  margin: var(--space-5) 0;
  padding: var(--space-4) var(--space-5);
  border-right: 4px solid var(--accent-color);
  background-color: var(--alt-background);
  font-family: var(--font-poetry);
  font-size: var(--text-lg);
  line-height: var(--line-height-relaxed);
  color: var(--text-dark);
}

.article-content blockquote p:last-child {
  margin-bottom: 0;
}

.article-content .poem {
  font-family: var(--font-poetry);
  text-align: center;
  margin: var(--space-6) 0;
  line-height: 2;
  font-size: var(--text-lg);
}

.article-content .poem .verse {
  margin-bottom: var(--space-3);
}

.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  margin: var(--space-4) 0;
}

/* Article Tables */
.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-5) 0;
  overflow-x: auto;
  display: block;
}

.article-content table th,
.article-content table td {
  padding: var(--space-3);
  border: 1px solid var(--border-color);
  text-align: right;
}

.article-content table th {
  background-color: var(--alt-background);
  font-weight: var(--font-weight-bold);
}

.article-content table tr:nth-child(even) {
  background-color: var(--alt-background);
}

/* Article Footnotes */
.article-content .footnotes {
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-color);
  font-size: var(--text-sm);
}

.article-content .footnotes ol {
  padding-right: var(--space-6);
}

.article-content .footnotes li {
  margin-bottom: var(--space-3);
}

.article-content .footnote-backref {
  font-size: var(--text-xs);
  vertical-align: super;
  color: var(--accent-color);
}

/* Citation References */
.article-content .citation-ref {
  font-size: var(--text-xs);
  vertical-align: super;
  color: var(--accent-color);
  margin-right: 2px;
  text-decoration: none;
  font-weight: var(--font-weight-bold);
}

.article-content .reference-highlight {
  background-color: rgba(138, 90, 68, 0.1);
  transition: background-color var(--transition-normal) ease;
}

/* Article Footer */
.article-footer {
  padding: var(--space-6);
  border-top: 1px solid var(--border-color);
}

.article-tags {
  margin-bottom: var(--space-4);
}

.article-tags .tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-3);
  background-color: var(--alt-background);
  color: var(--text-color);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  margin-bottom: var(--space-2);
  margin-left: var(--space-2);
  transition: all var(--transition-normal) ease;
}

.article-tags .tag:hover {
  background-color: var(--accent-color);
  color: white;
}

.article-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-5);
}

.article-share {
  display: flex;
  gap: var(--space-2);
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background-color: var(--alt-background);
  color: var(--text-color);
  border-radius: 50%;
  transition: all var(--transition-normal) ease;
}

.share-btn:hover {
  background-color: var(--accent-color);
  color: white;
  transform: translateY(-3px);
}

.share-btn:active {
  transform: translateY(-1px);
  opacity: 0.9;
}

.btn-bookmark {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.btn-bookmark i {
  transition: all var(--transition-normal) ease;
}

.btn-bookmark.bookmarked {
  background-color: transparent;
  color: var(--accent-color);
  border: 1px solid currentColor;
}

.btn-bookmark.bookmarked i {
  color: var(--accent-color);
}

/* Table of Contents */
.toc-widget {
  position: sticky;
  top: 100px;
}

.toc-list {
  padding-right: var(--space-4);
}

.toc-list ul {
  padding-right: var(--space-3);
  margin-top: var(--space-2);
}

.toc-list li {
  margin-bottom: var(--space-2);
}

.toc-link {
  display: block;
  color: var(--text-color);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  transition: all var(--transition-normal) ease;
  border-right: 2px solid transparent;
  padding-right: var(--space-2);
}

.toc-link:hover {
  color: var(--accent-color);
  border-right-color: var(--accent-light);
}

.toc-link.active {
  color: var(--accent-color);
  border-right-color: var(--accent-color);
  font-weight: var(--font-weight-medium);
}

.toc-link.level-3 {
  padding-right: var(--space-3);
  font-size: var(--text-xs);
}

.toc-link.level-4 {
  padding-right: var(--space-5);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Related Articles */
.related-articles-widget h3 {
  margin-bottom: var(--space-4);
}

.related-articles {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.related-article {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-3);
}

.related-article:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.related-article-thumb {
  width: 70px;
  height: 70px;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-left: var(--space-3);
}

.related-article-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) ease;
}

.related-article:hover .related-article-thumb img {
  transform: scale(1.05);
}

.related-article-content {
  flex: 1;
}

.related-article-title {
  font-size: var(--text-md);
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-1);
  transition: color var(--transition-normal) ease;
}

.related-article:hover .related-article-title {
  color: var(--accent-color);
}

.related-article-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Reading Progress Bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background-color: var(--accent-color);
  z-index: var(--z-index-header);
  transition: width 0.1s ease;
}

/* =========================
   Comment System Styles
   ========================= */

.comments-section {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  margin-top: var(--space-6);
}

.comments-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.comments-header h3 {
  margin-bottom: 0;
}

.comments-list {
  padding: var(--space-6);
}

.comment {
  display: flex;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-color);
}

.comment:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.comment-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  margin-left: var(--space-3);
}

.comment-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment-avatar-placeholder {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-light);
  color: var(--primary-dark);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-lg);
  margin-left: var(--space-3);
}

.comment-content {
  flex: 1;
}

.comment-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.comment-author {
  font-weight: var(--font-weight-bold);
  color: var(--text-dark);
}

.comment-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.comment-body {
  margin-bottom: var(--space-3);
  line-height: var(--line-height-relaxed);
}

.comment-footer {
  display: flex;
  gap: var(--space-3);
}

.comment-actions {
  display: flex;
  gap: var(--space-2);
}

.btn-reply, .btn-report, .comment-like {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: 32px;
  padding: 0 var(--space-1);
}

.btn-reply:hover, .btn-report:hover, .comment-like:hover {
  color: var(--accent-color);
}

.comment-like.liked {
  color: var(--accent-color);
}

.comment-like.liked i {
  color: var(--accent-color);
}

.comment-replies {
  margin-top: var(--space-4);
  margin-right: var(--space-6);
  padding-right: var(--space-4);
  border-right: 2px solid var(--border-color);
}

.reply-form {
  margin-top: var(--space-4);
  display: none;
}

.reply-form textarea {
  height: 100px;
  resize: vertical;
}

.reply-form .form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.comment-form {
  padding: var(--space-6);
  border-top: 1px solid var(--border-color);
}

.comment-form h3 {
  margin-bottom: var(--space-4);
}

.comment-form textarea {
  height: 150px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* =========================
   Pagination Styles
   ========================= */

.pagination {
  display: flex;
  justify-content: center;
  margin-top: var(--space-8);
}

.pagination ul {
  display: flex;
  gap: var(--space-1);
}

.pagination li a,
.pagination li span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background-color: var(--card-background);
  color: var(--text-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal) ease;
  border: 1px solid var(--border-color);
}

.pagination li a:hover {
  background-color: var(--alt-background);
  border-color: var(--border-dark);
}

.pagination li.active span {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.pagination li.disabled span {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================
   Filter and Sorting Styles
   ========================= */

.filters-bar {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

.filter-section {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.filter-label {
  font-weight: var(--font-weight-medium);
  white-space: nowrap;
}

.filter-select {
  min-width: 150px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--background-color);
  /* Touch-friendly */
  min-height: var(--touch-target-min);
}

.view-toggle {
  margin-left: auto;
  display: flex;
  gap: var(--space-1);
}

.view-toggle button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  background-color: var(--background-color);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: all var(--transition-normal) ease;
}

.view-toggle button:hover {
  background-color: var(--alt-background);
  color: var(--text-color);
}

.view-toggle button.active {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.filter-tag {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background-color: var(--alt-background);
  color: var(--text-color);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  transition: all var(--transition-normal) ease;
}

.filter-tag:hover {
  background-color: var(--accent-light);
}

.filter-tag:active {
  transform: scale(0.95);
}

.filter-tag i {
  color: var(--text-muted);
}

.filter-tag:hover i {
  color: var(--accent-color);
}

.filter-tag.removing {
  transform: translateY(-10px);
  opacity: 0;
}

/* =========================
   Modal Styles
   ========================= */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-index-modal);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal) ease;
}

.modal.show {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.modal-content {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px);
  transition: transform var(--transition-normal) ease;
  /* Improved touch scrolling */
  -webkit-overflow-scrolling: touch;
}

.modal.show .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin-bottom: 0;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: var(--text-2xl);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-normal) ease;
  /* Touch-friendly */
  width: var(--touch-target-min);
  height: var(--touch-target-min);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--error);
}

.modal-body {
  padding: var(--space-4);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4);
  border-top: 1px solid var(--border-color);
}

/* Image Viewer Modal */
.image-viewer-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-index-modal);
  opacity: 1;
  transition: opacity var(--transition-normal) ease;
}

.image-viewer-modal.fade-out {
  opacity: 0;
}

.image-container {
  max-width: 90%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.image-container img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-lg);
}

.image-caption {
  color: white;
  text-align: center;
  padding: var(--space-2);
  font-size: var(--text-sm);
}

/* Article Image Wrapper */
.article-image-wrapper {
  margin: var(--space-4) 0;
  position: relative;
}

.article-image-wrapper img {
  cursor: pointer;
  transition: transform var(--transition-normal) ease;
}

.article-image-wrapper img:hover {
  transform: scale(1.02);
}

/*
===============================================
SAFE DISABLE: Modal Viewer System CSS Safety
===============================================
Purpose: Prevent modal display even if JS disable fails
Reactivation: Remove or comment out this section
*/

body.modal-viewer-disabled .image-viewer-modal {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
}

/* Ensure no modal-related interactions */
body.modal-viewer-disabled .modal-backdrop {
  display: none !important;
  pointer-events: none !important;
}

body.modal-viewer-disabled .modal-content {
  display: none !important;
}

.article-image-wrapper .image-caption {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-top: var(--space-2);
  text-align: center;
}

/* Notification Style */
.notification-container {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: var(--z-index-popover);
  width: 300px;
}

.notification {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.notification-success {
  background-color: #F0FDF4;
  color: #166534;
  border-right: 4px solid var(--success);
}

.notification-error {
  background-color: #FEF2F2;
  color: #B91C1C;
  border-right: 4px solid var(--error);
}

.notification-warning {
  background-color: #FEF9C3;
  color: #854D0E;
  border-right: 4px solid var(--warning);
}

.notification-info {
  background-color: #EFF6FF;
  color: #1E40AF;
  border-right: 4px solid var(--info);
}

/* Form Error Styles */
.invalid-feedback {
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

.is-invalid {
  border-color: var(--error) !important;
}

.form-error {
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

/* Password Strength Meter */
.password-strength-meter {
  margin-top: var(--space-2);
  margin-bottom: var(--space-4);
}

.password-strength-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.strength-meter {
  height: 6px;
  background-color: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.strength-meter-fill {
  height: 100%;
  width: 0;
  border-radius: var(--radius-full);
  transition: width 0.3s ease, background-color 0.3s ease;
}

.strength-weak {
  background-color: var(--error);
}

.strength-medium {
  background-color: var(--warning);
}

.strength-strong {
  background-color: var(--success);
}

.strength-very-strong {
  background-color: #059669; /* Darker green */
}

.password-requirements {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

/* Password Input Container */
.password-input-container {
  position: relative;
}

/* Password Toggle Button - RTL Fix */
.password-toggle {
  position: absolute;
  right: auto;
  left: 10px; /* Fixed position from left edge */
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  z-index: 5;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

/* Ensure the input has proper padding to accommodate the icon */
.form-control-wrapper input[type="password"] {
  padding-left: 40px; /* Make room for the eye icon */
}

/* Fix for login.php password toggle overlap - matches register.php functionality */
.input-wrapper input[type="password"] {
  padding-left: 40px; /* Make room for the eye icon */
}

.password-toggle:hover {
  color: var(--accent-color);
}

/* File Upload Styles */
.file-upload-container {
  position: relative;
  margin-bottom: var(--space-2);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.file-upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--background-color);
  transition: all var(--transition-normal) ease;
  cursor: pointer;
}

.file-upload-label:hover {
  border-color: var(--accent-color);
  background-color: rgba(138, 90, 68, 0.05);
}

.file-upload-label i {
  font-size: var(--text-3xl);
  color: var(--accent-color);
  margin-bottom: var(--space-2);
}

.selected-file-name {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--accent-color);
  word-break: break-all;
}

.image-preview-container {
  margin-top: var(--space-3);
  text-align: center;
}

.image-preview-container img {
  max-width: 200px;
  max-height: 200px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

/* Profile Settings Styles */
.settings-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-6);
}

.settings-sidebar {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
}

.user-profile-brief {
  padding: var(--space-4);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
}

.settings-nav {
  padding: var(--space-4);
}

.settings-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.settings-nav-link {
  display: flex;
  align-items: center;
  color: var(--text-color);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: var(--touch-target-min);
}

.settings-nav-link i {
  margin-left: var(--space-3);
  color: var(--text-muted);
  width: 20px;
  text-align: center;
}

.settings-nav-link:hover {
  background-color: var(--alt-background);
  color: var(--text-color);
}

.settings-nav-link:hover i {
  color: var(--accent-color);
}

.settings-nav-link.active {
  background-color: var(--accent-light);
  color: var(--accent-color);
}

.settings-nav-link.active i {
  color: var(--accent-color);
}

.settings-nav-link.external {
  color: var(--primary-color);
  margin-top: var(--space-4);
}

.settings-content {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-panel-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-color);
}

.settings-panel-header h2 {
  margin-bottom: var(--space-2);
}

.settings-panel-body {
  padding: var(--space-6);
}

.settings-form {
  max-width: 800px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--space-4);
}

.form-hint {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-actions {
  margin-top: var(--space-5);
}

.current-image {
  margin-bottom: var(--space-5);
}

.profile-image-preview {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-light);
}

.profile-image-placeholder {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--accent-light);
  color: var(--primary-dark);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-2xl);
}

.user-role {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  margin-top: var(--space-2);
}

.user-role.researcher {
  background-color: rgba(138, 90, 68, 0.2);
  color: var(--accent-color);
}

.user-role.admin {
  background-color: rgba(66, 153, 225, 0.2);
  color: var(--info);
}

.user-role.user {
  background-color: rgba(113, 128, 150, 0.2);
  color: var(--text-muted);
}

.form-section {
  margin-bottom: var(--space-6);
}

.form-section h3 {
  margin-bottom: var(--space-3);
  font-size: var(--text-lg);
}

.form-check {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-2);
}

.form-check-input {
  margin-left: var(--space-3);
  width: 20px;
  height: 20px;
}

.form-check-label {
  font-weight: normal;
  margin-bottom: 0;
}

.popular-tags {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-color);
}

.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.add-interest {
  cursor: pointer;
}

.input-prefix-container {
  position: relative;
}

.input-prefix {
  position: absolute;
  right: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.prefix-input {
  padding-right: var(--space-6) !important;
}

/* Create Article Form */
.article-form-header {
  margin-bottom: var(--space-6);
}

.article-form-section {
  margin-bottom: var(--space-6);
}

.article-form-section h3 {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-color);
}

.editor-container {
  margin-top: var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
  background-color: var(--alt-background);
  border-bottom: 1px solid var(--border-color);
}

.editor-button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-1) var(--space-2);
  background-color: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-color);
  cursor: pointer;
  transition: all var(--transition-normal) ease;
  /* Touch-friendly */
  min-height: 32px;
  min-width: 32px;
}

.editor-button:hover {
  background-color: var(--card-background);
}

.editor-button.active {
  background-color: var(--accent-light);
  color: var(--accent-color);
}

.editor-content {
  padding: var(--space-4);
  min-height: 400px;
  background-color: var(--card-background);
}

.tags-input-container {
  position: relative;
}

.tags-input {
  padding-bottom: 40px !important;
}

.tags-suggestions {
  position: absolute;
  bottom: 5px;
  right: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  padding: var(--space-2);
}

.tag-suggestion {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  background-color: var(--alt-background);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.tag-suggestion:hover {
  background-color: var(--accent-light);
  color: var(--accent-color);
}

.form-buttons {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* Search Results Styles */
.search-header {
  margin-bottom: var(--space-6);
}

.search-stats {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.search-highlight {
  background-color: rgba(138, 90, 68, 0.2);
  padding: 0 2px;
  border-radius: 2px;
}

.search-result {
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-color);
}

.search-result:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.search-result-title {
  margin-bottom: var(--space-2);
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.search-result-meta i {
  color: var(--accent-color);
}

.search-result-excerpt {
  margin-bottom: var(--space-2);
}

.search-result-url {
  font-size: var(--text-sm);
  color: var(--accent-color);
}

.search-settings {
  margin-top: var(--space-3);
}

.search-settings h3 {
  margin-bottom: var(--space-3);
  font-size: var(--text-lg);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: var(--space-3);
}

.search-filter-section {
  margin-bottom: var(--space-4);
}

.search-filter-section h4 {
  margin-bottom: var(--space-3);
  font-size: var(--text-md);
}

.search-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Historical Eras Grid */
.eras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-6);
}

.era-card {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal) ease;
  border: 1px solid var(--border-color);
  position: relative;
}

.era-card:hover {
  transform: var(--card-hover-transform);
  box-shadow: var(--shadow-lg);
}

.era-card:active {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.era-image {
  height: 180px;
  overflow: hidden;
}

.era-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal) ease;
}

.era-card:hover .era-image img {
  transform: scale(1.05);
}

.era-content {
  padding: var(--space-4);
  text-align: center;
}

.era-content h3 {
  margin-bottom: var(--space-2);
  font-size: var(--text-xl);
}

.era-period {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.era-count {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  background-color: var(--accent-light);
  color: var(--accent-color);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
}

/* Missing Articles */
.missing-articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.missing-article-card {
  background-color: var(--card-background);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: all var(--transition-normal) ease;
  display: flex;
  flex-direction: column;
}

.missing-article-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.missing-article-card h3 {
  margin-bottom: var(--space-3);
  font-size: var(--text-lg);
}

.reference-count {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  background-color: var(--alt-background);
  color: var(--text-muted);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.missing-article-card .btn {
  margin-top: auto;
}

/* CTA Section */
.cta-section {
  background-color: var(--accent-light);
  padding: var(--space-10) 0;
  margin: var(--space-10) 0;
  text-align: center;
}

.cta-content {
  max-width: 700px;
  margin: 0 auto;
}

.cta-content h2 {
  color: var(--accent-color);
  margin-bottom: var(--space-4);
}

.cta-content p {
  margin-bottom: var(--space-6);
  font-size: var(--text-lg);
  color: var(--text-color);
}

.cta-buttons {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-color);
}

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-light);
}

/* =========================
   Mobile-Specific Enhancements
   ========================= */

@media (max-width: 1200px) {
  .content-grid,
  .content-sidebar-grid {
    grid-template-columns: 1fr;
  }
  
  .footer-content {
    grid-template-columns: 1fr 1fr;
  }
  
  .footer-brand {
    grid-column: span 2;
    margin-bottom: var(--space-6);
  }
  
  .footer-links {
    grid-column: span 2;
  }
  
  .article-sidebar .sidebar-widget {
    max-width: 600px;
    margin-right: auto;
    margin-left: auto;
  }
  
  .article-wrapper {
    grid-template-columns: 1fr;
  }
  
  .settings-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .researchers-grid,
  .articles-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .hero h1 {
    font-size: var(--text-4xl);
  }
  
  .article-header h1 {
    font-size: var(--text-3xl);
  }
  
  .article-cover {
    height: 300px;
  }
  
  .article-content {
    padding: var(--space-4);
  }
  
  .eras-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* CRITICAL FIX: Enhanced Mobile Touch Support */
@media (max-width: 768px) {
  /* Global Touch Optimizations */
  body, main, .container, .content-grid, .main-column {
    touch-action: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: auto;
  }
  
  /* Increase all touch targets */
  a, button, .interactive, [role="button"] {
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
    padding: var(--space-2);
  }
  
  /* Ensure overlay is not capturing touch when inactive */
  .sidebar-overlay:not(.active) {
    pointer-events: none;
  }
  
  /* Ensure main content is touchable */
  .main-content, .article-card, .researcher-card, 
  .hero, .featured-slider, .hero-search {
    pointer-events: auto;
    touch-action: auto;
  }
  
  /* Header Layout */
  .header-wrapper {
    flex-wrap: wrap;
  }
  
  .site-brand {
    flex: 1;
  }
  
  /* CRITICAL FIX: Mobile Toggle Position and Styling */
  .mobile-toggle {
    display: flex;
    order: 2;
    margin-left: var(--space-2);
    /* CRITICAL FIX: Create positioning context */
    position: relative;
    /* CRITICAL FIX: Add specific touch feedback */
    -webkit-tap-highlight-color: rgba(138, 90, 68, 0.3);
  }
  
  /* CRITICAL FIX: Adjust tap highlight color for important touch targets */
  .mobile-toggle, .site-brand a, .user-menu-trigger {
    -webkit-tap-highlight-color: rgba(138, 90, 68, 0.3);
  }
  
  /* Mobile Nav Enhancement */
  .main-nav {
    order: 3;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    display: none;
    padding: var(--space-4) 0;
    margin-top: var(--space-3);
    transform: translateY(-10px);
    opacity: 0;
    transition: opacity var(--menu-transition-duration) ease, 
                transform var(--menu-transition-duration) ease;
    /* CRITICAL FIX: Ensure this is not overlapping other elements */
    height: 0;
    pointer-events: none;
  }
  
  .main-nav.active {
    display: flex;
    transform: translateY(0);
    opacity: 1;
    height: auto;
    pointer-events: auto;
  }
  
  .nav-list {
    flex-direction: column;
    width: 100%;
  }
  
  .nav-list li {
    margin-right: 0;
    margin-bottom: var(--space-2);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-color);
    /* CRITICAL FIX: Ensure touch target containment */
    position: relative;
  }
  
  .nav-list li:last-child {
    border-bottom: none;
  }
  
  /* Mobile-friendly touch targets */
  .nav-list a {
    padding: var(--space-2) 0;
    width: 100%;
    min-height: var(--touch-target-min);
    /* CRITICAL FIX: Ensure touch target is contained */
    position: relative;
    z-index: 1;
  }
  
  /* CRITICAL FIX: Improved touch feedback for nav links */
  .nav-list a::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    transition: background-color 0.15s ease;
    pointer-events: none;
    border-radius: var(--radius-md);
    z-index: -1;
  }
  
  .nav-list a:active::before {
    background-color: rgba(138, 90, 68, 0.1);
  }
  
  /* Search Form */
  .search-form-wrapper {
    width: 100%;
    margin: var(--space-3) 0;
    margin-right: 0;
  }
  
  .search-form {
    width: 100%;
  }
  
  .search-form input {
    width: 100%;
  }
  
  .search-form input:focus {
    width: 100%;
  }
  
  /* Ensure touching outside the menu works */
  body.nav-open {
    overflow: hidden;
  }
  
  /* Article Layout */
  .article-header {
    padding: var(--space-4);
  }
  
  .article-header h1 {
    font-size: var(--text-2xl);
  }
  
  .article-cover {
    height: 200px;
  }
  
  .article-content {
    padding: var(--space-4);
  }
  
  .article-content h2 {
    font-size: var(--text-xl);
  }
  
  .article-content h3 {
    font-size: var(--text-lg);
  }
  
  .article-footer {
    padding: var(--space-4);
  }
  
  .article-actions {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  .article-share {
    order: 2;
    justify-content: center;
  }
  
  /* Comment System */
  .comments-header {
    padding: var(--space-4);
  }
  
  .comments-list {
    padding: var(--space-4);
  }
  
  .comment {
    flex-direction: column;
  }
  
  .comment-avatar {
    margin-bottom: var(--space-3);
    margin-left: 0;
  }
  
  .comment-replies {
    margin-right: var(--space-3);
  }
  
  /* Modal Adjustments */
  .modal-content {
    width: 95%;
  }
  
  /* Settings Page */
  .user-profile-brief {
    flex-direction: column;
    text-align: center;
  }
  
  .settings-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .settings-nav-link {
    flex-direction: column;
    text-align: center;
    padding: var(--space-2);
  }
  
  .settings-nav-link i {
    margin-left: 0;
    margin-bottom: var(--space-1);
  }
  
  .settings-panel-header {
    padding: var(--space-4);
  }
  
  .settings-panel-body {
    padding: var(--space-4);
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 576px) {
  /* Enhanced Researcher Grid Mobile Layout */
  .researchers-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
    padding-inline: var(--space-2);
  }
  
  .researcher-card {
    padding: var(--space-3);
  }
  
  .researcher-header {
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
  }
  
  .researcher-header .researcher-avatar {
    width: 70px;
    height: 70px;
    margin-inline-start: 0 !important;
    margin-bottom: var(--space-3);
    /* Ensure perfect circle on mobile */
    aspect-ratio: 1;
    padding: 0 !important;
    box-sizing: border-box;
  }
  
  .researcher-header .researcher-avatar img {
    /* Additional mobile circular enforcement */
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    /* Full fill on mobile */
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
  }
  
  .researcher-info {
    width: 100%;
    text-align: center;
  }
  
  .researcher-info h3 {
    font-size: var(--text-lg);
  }
  
  .researcher-bio {
    font-size: var(--text-xs);
    padding-inline: var(--space-2);
  }
  
  .researcher-stats {
    padding-inline: var(--space-2);
  }
  
  .researcher-stats .value {
    font-size: var(--text-lg);
  }
  
  .researcher-stats .label {
    font-size: var(--text-xs);
  }
  
  /* Footer and other elements */
  .footer-content {
    grid-template-columns: 1fr;
  }
  
  .footer-brand {
    grid-column: span 1;
  }
  
  .user-actions .btn {
    display: none;
  }
  
  .hero h1 {
    font-size: var(--text-3xl);
  }
  
  .hero p {
    font-size: var(--text-lg);
  }
  
  /* Adjust Grids */
  .researchers-grid,
  .articles-grid,
  .eras-grid {
    grid-template-columns: 1fr;
  }
  
  /* CRITICAL FIX: Better Touch Targets for Mobile */
  .btn {
    min-height: 48px; /* Larger for very small screens */
  }
  
  /* Improve Form Elements */
  input, select, textarea {
    font-size: 16px; /* Prevent iOS zoom */
  }
  
  /* CRITICAL FIX: Enhanced Touch Feedback */
  .article-card:active,
  .researcher-card:active,
  .btn:active {
    transform: scale(0.98);
  }
  
  /* Footer Enhancements */
  .footer-links {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  
  .footer-bottom {
    flex-direction: column;
    gap: var(--space-3);
    text-align: center;
  }
  
  .footer-meta-links {
    justify-content: center;
  }
  
  /* Adjust Featured Slider for Mobile */
  .featured-article-image {
    height: 200px;
  }
  
  .featured-article-content {
    padding: var(--space-4);
  }
  
  .featured-article h3 {
    font-size: var(--text-xl);
  }
  
  /* CTA Section */
  .cta-buttons {
    flex-direction: column;
    gap: var(--space-3);
  }
  
  /* Filter Bar */
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filter-section {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .view-toggle {
    margin-left: 0;
    margin-top: var(--space-3);
    justify-content: flex-start;
  }
}

/* CRITICAL FIX: Touch Device Specific Optimizations */
@media (hover: none) {
  /* Improve touch feedback */
  a:active, button:active, .btn:active, .mobile-toggle:active {
    opacity: 0.7;
    transition: opacity 0.1s ease;
  }
  
  /* CRITICAL FIX: Add specific tap highlight for all important touch elements */
  a, button, .btn, [role="button"] {
    -webkit-tap-highlight-color: rgba(138, 90, 68, 0.2);
  }
  
  /* Make sure cards provide feedback */
  .article-card:active, .researcher-card:active {
    transform: translateY(-2px);
    transition: transform 0.1s ease;
  }
  
  /* CRITICAL FIX: Make menu items bigger on touch devices */
  .nav-list a, .user-links a {
    padding: var(--space-3) var(--space-2);
  }
  
  /* CRITICAL FIX: Ensure mobile toggle has clear touch feedback */
  .mobile-toggle:active::after {
    background-color: rgba(138, 90, 68, 0.15);
  }
}

/* Dark Mode Styles */
.dark-mode {
  --background-color: #121212;
  --card-background: #1e1e1e;
  --alt-background: #2a2a2a;
  --text-color: #e0e0e0;
  --text-dark: #ffffff;
  --text-muted: #a0a0a0;
  --border-color: #333333;
  --border-dark: #444444;
  --input-background: #2a2a2a;
  --input-border: #444444;
  --input-focus: #9B6A53;
}

/* Specific Dark Mode Overrides */
.dark-mode .site-header {
  background-color: #1a1a1a;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark-mode .accent-color {
  color: #C8B6A6;
}

.dark-mode .era-badge, 
.dark-mode .btn-primary {
  background-color: #9B6A53;
}

.dark-mode .slider-arrow {
  background-color: rgba(40, 40, 40, 0.8);
  color: #e0e0e0;
}

.dark-mode .slider-arrow:hover {
  background-color: #9B6A53;
}

.dark-mode .article-card,
.dark-mode .researcher-card,
.dark-mode .sidebar-widget {
  border-color: #333333;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* CRITICAL FIX: Improved Visual Feedback for Touch */
.touch-feedback {
  position: relative;
  overflow: hidden;
}

.touch-feedback::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(138, 90, 68, 0.3) 0%, transparent 70%);
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.touch-feedback:active::after {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Accessibility Utilities */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}