/* =====================================================
   PROJECTS.CSS STRUCTURE
   1. Layout & Hero
   2. Grid, Cards & Effects
   3. Modal & Gallery
   4. States, Toolbar & Pagination
   5. Responsive & Utilities
   ===================================================== */

html[lang="cuneiform_old_babylonian"] .projects-page,
html[lang="cuneiform_old_babylonian"] .projects-page *,
html[lang="cuneiform"] .projects-page,
html[lang="cuneiform"] .projects-page * {
  font-family: 'Cairo', 'Cuneiform', sans-serif !important;
  letter-spacing: 0.03em;
}

/* === 1. Layout & Hero === */
/* Projects Hero Text, Grid layout, responsive columns */

body.projects-page {
  --projects-silver-light: rgba(200, 200, 200, 0.55);
  --projects-silver-dark: rgba(120, 120, 120, 0.65);
  --projects-silver-bright: rgba(240, 240, 240, 0.4);
}

/* Background Pan Animation - Same as products.html */
@keyframes backgroundPan {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes tiltReturn {
  to { transform: rotateX(0deg) rotateY(0deg); }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes hoverPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Enhancement: subtle pulse used behind hero headline */
@keyframes heroPulseGlow {
  0% {
    transform: translate(-50%, -50%) scale(0.85);
    opacity: 0.32;
    filter: blur(18px);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.15);
    opacity: 0.55;
    filter: blur(22px);
  }
  100% {
    transform: translate(-50%, -50%) scale(0.85);
    opacity: 0.32;
    filter: blur(18px);
  }
}

/* Hero Section - Dark gradient with animated background (Same as products.html) */
.projects-hero {
    position: relative;
  min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  /* No margin-top - header floats over hero */
  padding: clamp(4rem, 10vw, 8rem) 2rem;
  background: linear-gradient(135deg, #0B0F1A 0%, #1a2f4f 40%, #00BFA6 70%, var(--projects-silver-dark) 100%);
  background-size: 400% 400%;
  background-attachment: fixed;
  animation: backgroundPan 80s ease-in-out infinite;
}

/* Background Image with Blend Mode - Same as products.html */
.projects-hero::before {
  content: '';
    position: absolute;
  inset: 0;
  background-image: url('https://images.unsplash.com/photo-1509391366360-2e959784a276?w=1920&q=80');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.3; /* Slightly increased for better visibility */
  background-blend-mode: overlay;
  mix-blend-mode: overlay;
  z-index: 0; /* Behind gradient (z:1) and content (z:2), same layer as particles (z:0) */
}

/* Root Cause: Element positioning and z-index ensure text appears above particles but below header */
/* Projects Hero Text - Centered with typing and glowing effects (Same as products.html) */
#projects-hero {
    position: relative;
}

.projects-hero-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  color: #fff;
  z-index: 2; /* Above particles (z:0), below header (z:10) */
  text-shadow: 0 0 20px rgba(255,255,255,0.6);
  pointer-events: none; /* Allow clicks to pass through to particles/background */
}

/* Enhancement: hero pulse layer adds depth without affecting interactions */
.hero-glow-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(220px, 28vw, 420px);
  aspect-ratio: 1/1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.08) 55%, transparent 70%);
  mix-blend-mode: screen;
  pointer-events: none;
  animation: heroPulseGlow 8s ease-in-out infinite;
  opacity: 0.4;
}

@media (prefers-reduced-motion: reduce) {
  .hero-glow-pulse {
    animation: none;
    opacity: 0.25;
  }
}

/* Projects Grid */
.projects-grid-container {
    display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(20px, 3vw, 30px);
  padding: clamp(24px, 4vw, 40px) clamp(12px, 3vw, 22px);
}

/* ========== (1) GRID RESPONSIVE - Fixed breakpoints for proper card distribution ========== */
/* Desktop >= 1100px: 3 cards per row */
@media (min-width: 1100px) {
  .projects-grid-container { grid-template-columns: repeat(12, 1fr); }
  .project-card { grid-column: span 4; }
}
/* Tablet 768-1099px: 2 cards per row */
@media (min-width: 768px) and (max-width: 1099px) {
  .projects-grid-container { grid-template-columns: repeat(12, 1fr); }
  .project-card { grid-column: span 6; }
}
/* Mobile <= 767px: 1 card per row */
@media (max-width: 767px) {
  .projects-grid-container { grid-template-columns: repeat(12, 1fr); }
  .project-card { grid-column: span 12; }
}

@media (max-width: 520px) {
  /* Prevent mobile card overlap by adding breathing room */
  .project-card {
    margin-bottom: 10px;
  }
}

/* === 2. Grid, Cards & Effects === */
/* ========== (3) PROJECT CARDS - Refined color system ========== */
/* Light mode: soft off-white with subtle borders, green as accent only */
.project-card {
  position: relative;
  border-radius: 18px;
  overflow: visible;
  perspective: 1100px;
    display: flex;
    flex-direction: column;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
  will-change: transform;
  /* Softer off-white instead of stark white */
  background: #FAFAFC;
  /* Subtle warm border */
  border: 1px solid rgba(15, 28, 63, 0.06);
  /* Softer shadows */
  box-shadow: 0 2px 8px rgba(15, 28, 63, 0.06), 0 8px 20px rgba(15, 28, 63, 0.04);
  cursor: pointer;
  margin-bottom: clamp(18px, 2vw, 28px);
  isolation: isolate;
}

.project-card.visible {
  will-change: auto;
}

/* Hover: green accent border appears */
.project-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 12px rgba(15, 28, 63, 0.08), 0 12px 28px rgba(0, 191, 166, 0.12);
  border-color: rgba(0, 191, 166, 0.25);
}

.project-card-surface {
    position: relative;
  border-radius: 18px;
    overflow: hidden;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
  will-change: transform;
  transform-origin: center center;
  background: linear-gradient(135deg, #FFFFFF 0%, #FAFAFA 100%);
}

/* Dark mode: deep navy/slate with subtle green tint */
body.dark-mode .project-card {
  /* Deep navy-slate blend */
  background: #0F1419;
  /* Very subtle green tint border */
  border-color: rgba(0, 191, 166, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4), 0 8px 32px rgba(0, 0, 0, 0.25);
}

body.dark-mode .project-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45), 0 12px 36px rgba(0, 191, 166, 0.15);
  border-color: rgba(0, 191, 166, 0.3);
}

body.dark-mode .project-card-surface {
  /* Slate gradient with hint of navy */
  background: linear-gradient(135deg, #1A1F28 0%, #141820 100%);
}

/* Loading + Empty states */
.projects-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--primary-color);
}
.projects-loading .spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(0, 191, 166, 0.25);
  border-top-color: #00BFA6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.projects-empty {
  text-align: center;
  color: #888;
  padding: 48px 0;
}

.projects-error {
  /* Keeps error state confined to grid while preserving hero animations */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 48px 20px;
}

.projects-retry-btn {
  /* Retry button mirrors brand styling without overpowering layout */
  padding: 12px 28px;
  border-radius: 999px;
  border: 1px solid rgba(0, 191, 166, 0.45);
  background: rgba(0, 191, 166, 0.12);
  color: rgba(0, 105, 92, 0.95);
  font-weight: 700;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  .projects-retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(0, 191, 166, 0.18);
    background: rgba(0, 191, 166, 0.2);
  }
}

.error-message {
  text-align: center;
  font-size: 1.1rem;
  color: #dc3545;
  padding: 0 20px;
}

/* ========== (4) FEATURED SWIPER - Container with navigation buttons ========== */
.featured-section { 
  padding: clamp(24px,4vw,40px) 0; 
  position: relative;
}

.featured-projects {
  position: relative;
}

/* Desktop navigation buttons - subtle and elegant */
.featured-projects .swiper-button-next,
.featured-projects .swiper-button-prev {
  width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  color: #00bfa6;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.featured-projects .swiper-button-next:after,
.featured-projects .swiper-button-prev:after {
  font-size: 18px;
  font-weight: 700;
}

body.dark-mode .featured-projects .swiper-button-next,
body.dark-mode .featured-projects .swiper-button-prev {
  background: rgba(18, 26, 40, 0.9);
  color: #00bfa6;
}

@media (hover: hover) {
  .featured-projects .swiper-button-next:hover,
  .featured-projects .swiper-button-prev:hover {
    background: #00bfa6;
    color: #fff;
    transform: scale(1.1);
  }
}

/* Hide navigation on mobile to save space */
@media (max-width: 767px) {
  .featured-projects .swiper-button-next,
  .featured-projects .swiper-button-prev {
    display: none;
  }
}

.featured-track { display: flex; gap: clamp(12px,2.5vw,18px); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
.featured-card { 
  flex: 0 0 320px; 
  height: 200px; 
  border-radius: 18px; 
  position: relative; 
  overflow: hidden; 
  scroll-snap-align: start; 
  background: radial-gradient(120% 120% at 0% 0%, rgba(192,192,192,.25), rgba(140,140,140,.12)); 
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  cursor: pointer;
  transition: transform 0.3s ease;
}

.featured-card:hover {
  transform: translateY(-4px);
}

.featured-card .title { position:absolute; bottom:16px; left:16px; right:16px; color:#1c1c1c; font-weight:800; text-shadow:0 2px 6px rgba(255,255,255,.4); }
.featured-card::after { content:""; position:absolute; inset:0; background: radial-gradient(50% 50% at 80% 0%, rgba(200,200,200,.32), transparent 60%); mix-blend-mode: screen; }
body.dark-mode .featured-card { background: radial-gradient(120% 120% at 0% 0%, rgba(192,192,192,.18), rgba(120,120,120,.1)); }

/* === 3. Modal & Gallery Styling === */
/* Modal overlay */
.project-modal {
  --modal-accent: #00bfa6;
  --modal-backdrop-image: none;
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 6vw, 4rem);
  background: rgba(6, 12, 24, 0.65);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  z-index: 9999;
}

.project-modal.active {
  display: flex;
}

.project-modal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--modal-backdrop-image, none);
  background-size: cover;
  background-position: center;
  filter: blur(45px) saturate(180%) brightness(0.55);
  opacity: 0.35;
  pointer-events: none;
}

.project-modal .modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 960px;
  max-height: min(92vh, 880px);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.94), rgba(255,255,255,0.86));
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 25px 70px rgba(12, 18, 32, 0.45);
  overflow: hidden;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

body.dark-mode .project-modal .modal-content {
  background: linear-gradient(135deg, rgba(13,19,32,0.94), rgba(13,19,32,0.88));
  border-color: rgba(255, 255, 255, 0.12);
  color: #E6EDF3;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: clamp(12px, 2vw, 18px) clamp(16px, 2.5vw, 24px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.project-modal .modal-header h3 {
  margin: 0;
  color: inherit;
  font-size: clamp(1.25rem, 1.8vw, 1.5rem);
}

body.dark-mode .modal-header {
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.modal-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(0.5rem, 1.6vw, 1rem);
  padding: clamp(1rem, 3vw, 1.4rem);
  overflow-y: auto;
  min-height: 0;
}

.modal-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}

/* Swiper gallery */
.project-gallery {
  width: 100%;
  flex: 0 0 clamp(260px, 42vh, 420px);
  border-radius: 20px;
  overflow: hidden;
  max-height: clamp(260px, 42vh, 420px);
  margin-top: 0.25rem;
}

.project-gallery .swiper-wrapper {
  align-items: center;
}

.project-gallery .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  height: 100%;
}

.project-gallery .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  height: 100%;
}

.project-gallery .swiper-slide img {
  border-radius: 20px;
  width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
  transition: transform 0.6s ease;
  transform-origin: center;
}

@media (hover: hover) and (pointer: fine) {
  .project-gallery .swiper-slide:hover img {
    transform: scale(1.03);
  }
}

.project-description {
  flex: 1 1 35%;
  max-width: 900px;
  overflow-y: auto;
  padding: 1.3rem 1.5rem;
  border-radius: 16px;
  background: var(--card-bg-light, rgba(255, 255, 255, 0.2));
  margin: 0.75rem auto 0;
  font-family: "Cairo", sans-serif;
  color: var(--text-color-light, #102036);
  line-height: 1.45;
  font-size: 0.95rem;
  word-break: break-word;
  min-height: 7rem;
}

.project-description img,
.project-description table,
.project-description figure,
.project-description iframe {
  /* Ensure rich media never exceeds modal width */
  max-width: 100%;
  width: 100%;
  height: auto;
}

.project-description h1,
.project-description h2 {
  color: var(--primary-color, #00bfa6);
}

.project-description strong {
  color: var(--accent-color, var(--projects-silver-dark));
}

body.dark-mode .project-description {
  background: var(--card-bg-dark, rgba(18, 26, 40, 0.58));
  color: #f5f5f5;
}

/* Share buttons */
.share-section {
  flex: 0 0 auto;
  text-align: center;
  margin-top: auto;
  padding-top: 0.5rem;
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 10px;
}

.share-btn {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 191, 166, 0.85);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  transition: transform 0.25s ease, background 0.35s ease, box-shadow 0.35s ease;
  box-shadow: 0 12px 24px rgba(0, 191, 166, 0.26);
}

@media (hover: hover) and (pointer: fine) {
  .share-btn:hover {
    transform: scale(1.1);
    background: rgba(185, 185, 185, 0.85);
  }
}

.share-btn.is-copied {
  background: rgba(185, 185, 185, 0.85);
}

.share-btn.is-copied::after {
  content: 'تم النسخ!';
  position: absolute;
  bottom: calc(100% + 6px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  background: rgba(150, 150, 150, 0.92);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
}


/* Loading and Error States */
.loading {
    text-align: center;
    font-size: 1.5rem;
    color: var(--primary-color, #00BFA6);
    padding: 40px 20px;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.no-projects {
    text-align: center;
    font-size: 1.2rem;
    color: #666;
    padding: 40px 20px;
}

/* (old truncated description inside cards retained in JS when needed) */

/* ============================================================
   PROJECTS — VISUAL EFFECTS (2025 ENHANCEMENT PACK)
============================================================ */

#projects-gallery {
  position: relative;
  background: radial-gradient(circle at top right, rgba(0, 191, 166, 0.1), transparent 45%) no-repeat,
              radial-gradient(circle at bottom left, rgba(160, 160, 160, 0.1), transparent 55%) no-repeat;
  background-size: 140% 140%;
  border-radius: 28px;
  transition: background-position 0.6s ease;
}

/* ========== (5) FILTERS UX - Sticky toolbar above grid ========== */
.projects-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(0.75rem, 2vw, 1rem) clamp(0.5rem, 2vw, 1rem);
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 4px 12px rgba(15, 28, 63, 0.08);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

body.dark-mode .projects-toolbar {
  background: rgba(18, 26, 40, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Filter buttons container with sort dropdown */
.projects-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.projects-filter-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  color: #102036;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease, color 0.28s ease;
}

.projects-filter-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(15, 28, 63, 0.18);
}

.projects-filter-btn.is-active {
  border-color: rgba(0, 191, 166, 0.65);
  box-shadow: 0 12px 30px rgba(0, 191, 166, 0.25);
  color: #012b32;
}

body.dark-mode .projects-filter-btn {
  background: rgba(15, 26, 46, 0.65);
  color: #e6edf3;
}

body.dark-mode .projects-filter-btn.is-active {
  border-color: rgba(0, 191, 166, 0.65);
  box-shadow: 0 12px 32px rgba(0, 191, 166, 0.35);
  color: #e6f8f5;
}

.projects-filter-btn__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(0, 191, 166, 0.12);
  color: #00bfa6;
  font-size: 0.85rem;
}

.projects-filter-btn.is-active .projects-filter-btn__icon {
  background: rgba(0, 191, 166, 0.2);
}

.projects-pagination-indicator {
  font-size: 0.9rem;
  color: rgba(16, 32, 54, 0.7);
  transition: color 0.4s ease;
}

body.dark-mode .projects-pagination-indicator {
  color: rgba(230, 237, 243, 0.75);
}

.project-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(135deg, var(--projects-silver-bright), var(--projects-silver-dark));
  transition: opacity 0.35s ease;
}

.project-card:hover::after {
  opacity: 0.2;
}

.project-card.is-featured::after {
  opacity: 0.3;
  box-shadow: 0 16px 32px rgba(180, 180, 180, 0.28), 0 0 20px rgba(140, 140, 140, 0.22);
}

.project-card.is-featured .project-card-surface {
  box-shadow: 0 20px 36px rgba(180, 180, 180, 0.24), 0 6px 16px rgba(140, 140, 140, 0.18);
}

/* ========== (6) IMAGE CONTAINER - Fixed aspect ratio to prevent CLS ========== */
.project-image-container {
  position: relative;
  width: 100%;
  /* 3:2 aspect ratio (800x533) */
  aspect-ratio: 3 / 2;
  /* Fallback for older browsers */
  padding-top: 66.66%;
  overflow: hidden;
  border-radius: 20px 20px 0 0;
}

@supports (aspect-ratio: 3 / 2) {
  .project-image-container {
    padding-top: 0;
  }
}

.project-image-container::before {
  content: '';
  position: absolute;
  inset: -30% -55% -30% -55%;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.55) 45%, rgba(255, 255, 255, 0) 80%);
  opacity: 0;
  transform: translateX(-55%) rotate(12deg);
  transition: transform 0.6s ease, opacity 0.6s ease;
  pointer-events: none;
  mix-blend-mode: screen;
}

.project-image-container img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Prevent layout shift while loading */
  min-height: 100%;
  transition: transform 3s cubic-bezier(0.25, 0.1, 0.25, 1), filter 0.45s ease;
  filter: none;
}

.project-image-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.35) 100%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
}

@media (hover: hover) and (pointer: fine) {
  .project-card:hover .project-image-container img {
    transform: scale(1.2) translateZ(0);
  }

  .project-card:hover .project-image-overlay {
    opacity: 1;
  }

  .project-card:hover .project-image-container::before {
    opacity: 0.45;
    transform: translateX(65%) rotate(12deg);
  }

  body.dark-mode .project-card:hover::after {
    opacity: 0.35;
  }
}

.project-image.is-loading {
  opacity: 0.75;
}

/* ========== (2) CARD LAYOUT - Flex structure ensures button stays at bottom ========== */
.project-info {
  padding: clamp(1.1rem, 2.2vw, 1.6rem);
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: rgba(16, 32, 54, 0.85);
  transition: color 0.4s ease;
  flex: 1; /* Allow info to fill available space */
  min-height: 0; /* Enable flex shrinking */
}

.project-info-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  letter-spacing: 0.3px;
}

/* ========== (3) IMPROVED TEXT CONTRAST ========== */
/* Light mode: deeper gray for better readability */
.project-title {
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  margin: 0;
  color: #1A202C; /* Darker for better contrast */
  display: -webkit-box;
  line-clamp: 2;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  text-overflow: ellipsis;
}

/* Description with improved contrast */
.project-description-preview {
  overflow: hidden;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  line-height: 1.65;
  color: #4A5568; /* Better contrast than previous */
  transition: color 0.4s ease;
  flex-grow: 0;
  flex-shrink: 0;
}

/* ========== (5) SORT DROPDOWN STYLING - RTL/LTR support ========== */
.projects-sort-dropdown {
  position: relative;
  display: inline-block;
}

.projects-sort-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 191, 166, 0.4);
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #102036;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.28s ease;
  white-space: nowrap;
}

.projects-sort-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 191, 166, 0.15);
}

.projects-sort-btn .sort-arrow {
  font-size: 0.7rem;
  transition: transform 0.3s ease;
}

.projects-sort-btn[aria-expanded="true"] .sort-arrow {
  transform: rotate(180deg);
}

.projects-sort-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 28, 63, 0.15);
  padding: 8px;
  z-index: 200;
  border: 1px solid rgba(0, 191, 166, 0.2);
}

[dir="rtl"] .projects-sort-menu {
  right: auto;
  left: 0;
}

.sort-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: #102036;
  font-size: 0.9rem;
  text-align: start;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sort-option:hover {
  background: rgba(0, 191, 166, 0.1);
  color: #00bfa6;
}

.sort-option.is-active {
  background: rgba(0, 191, 166, 0.15);
  color: #00bfa6;
  font-weight: 600;
}

.sort-option i {
  width: 16px;
  text-align: center;
}

body.dark-mode .projects-sort-btn {
  background: rgba(15, 26, 46, 0.65);
  color: #e6edf3;
  border-color: rgba(0, 191, 166, 0.4);
}

body.dark-mode .projects-sort-menu {
  background: rgba(18, 26, 40, 0.98);
  border-color: rgba(0, 191, 166, 0.3);
}

body.dark-mode .sort-option {
  color: #e6edf3;
}

body.dark-mode .sort-option:hover {
  background: rgba(0, 191, 166, 0.15);
  color: #00bfa6;
}

body.dark-mode .sort-option.is-active {
  background: rgba(0, 191, 166, 0.2);
  color: #00bfa6;
}
.project-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

.project-tag {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  letter-spacing: 0.2px;
  background: rgba(0, 191, 166, 0.12);
  color: rgba(0, 105, 92, 0.95);
}

.project-tag--featured {
  background: rgba(0, 191, 166, 0.18);
  color: #015f52;
}

.project-badge {
  position: absolute;
  inset-inline-end: 16px;
  inset-block-start: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.9);
  color: #1a2f4f;
  box-shadow: 0 8px 18px rgba(15, 28, 63, 0.18);
  z-index: 2;
}

.project-badge--new {
  inset-inline-end: auto;
  inset-inline-start: 16px;
  background: rgba(0, 191, 166, 0.92);
  color: #052f37;
}

/* Dark mode: lighter text for contrast on dark backgrounds */
body.dark-mode .project-info,
body.dark-mode .project-description-preview {
  color: #E2E8F0; /* Lighter for better readability */
}

body.dark-mode .project-title {
  color: #F7FAFC; /* Very light for headlines */
}

/* Tags: green as accent only */
body.dark-mode .project-tag {
  background: rgba(0, 191, 166, 0.15);
  color: #81E6D9; /* Lighter green for dark mode */
  border: 1px solid rgba(0, 191, 166, 0.25);
}

.project-hover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(190, 190, 190, 0.25), rgba(140, 140, 140, 0.12));
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.4s ease;
  z-index: 5;
  pointer-events: none;
}

body.dark-mode .project-hover {
  background: linear-gradient(145deg, rgba(80, 80, 80, 0.35), rgba(120, 120, 120, 0.16));
}

.project-card:hover .project-hover {
  opacity: 1;
  transform: translateZ(2px);
  pointer-events: auto;
}

.project-hover .btn-view {
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(0, 191, 166, 0.85);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
}

.project-hover .btn-view:hover {
  background: rgba(0, 191, 166, 0.9);
  box-shadow: 0 10px 24px rgba(0, 191, 166, 0.3);
}

.project-mobile-btn {
  display: none;
  margin-top: 0.85rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(0, 191, 166, 0.6);
  background: rgba(0, 191, 166, 0.12);
  color: rgba(1, 43, 50, 0.95);
  font-weight: 700;
  font-family: "Cairo", sans-serif;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.project-mobile-btn:active {
  transform: scale(0.97);
}

@media (max-width: 768px) {
  .project-mobile-btn {
    display: block;
  }

  .project-card:hover {
    transform: none;
    box-shadow: 0 12px 24px rgba(15, 28, 63, 0.12);
  }
}

.projects-grid-container.card-focused .project-card:not(.is-focused) {
  opacity: 0.55;
  filter: none;
  transform: scale(0.97);
}

.project-card.is-focused {
  z-index: 2;
}

.project-card--skeleton {
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.skeleton-block {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(90deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.32) 50%, rgba(255,255,255,0.12) 100%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton-block--thumb {
  width: 100%;
  height: 100%;
  border-radius: 20px 20px 0 0;
}

.skeleton-block--title {
  width: 65%;
  height: 18px;
  margin: 18px 0 12px;
}

.skeleton-block--line {
  width: 90%;
  height: 14px;
  margin-bottom: 10px;
}

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

.pagination {
    display: flex;
  align-items: center;
    justify-content: center;
    gap: 10px;
  padding: clamp(1rem, 2vw, 1.6rem) 0;
}

.pagination-btn {
  min-width: 42px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(0, 191, 166, 0.25);
  background: rgba(0, 191, 166, 0.08);
  color: rgba(0, 105, 92, 0.95);
  font-weight: 600;
  letter-spacing: 0.3px;
    cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.pagination-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 12px 26px rgba(0, 191, 166, 0.22);
}

.pagination-btn.is-active {
  background: linear-gradient(135deg, var(--projects-silver-bright), var(--projects-silver-dark));
  color: #fff;
  box-shadow: 0 16px 35px rgba(160, 160, 160, 0.35);
  border-color: transparent;
  cursor: default;
}

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

.section-subtitle {
  position: relative;
  padding-inline-start: clamp(1.25rem, 2.5vw, 1.75rem);
}

.section-subtitle::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  inset-block-start: 50%;
  width: clamp(38px, 6vw, 58px);
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--projects-silver-bright), var(--projects-silver-dark));
  box-shadow: 0 0 12px rgba(160, 160, 160, 0.35);
  transform: translateY(-50%);
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

body.projects-page header,
body.projects-page header * {
  transition: color 0.4s ease, background-color 0.4s ease;
}

body.projects-page[dir="rtl"] footer .footer-content {
  flex-direction: row-reverse;
}

body.projects-page[dir="rtl"] footer .footer-brand {
  order: 3;
}
body.projects-page[dir="rtl"] footer .footer-links {
  order: 2;
}
body.projects-page[dir="rtl"] footer .footer-contact {
  order: 1;
}

body.projects-page[dir="ltr"] footer .footer-content {
  flex-direction: row;
}

body.projects-page[dir="ltr"] footer .footer-brand {
  order: 1;
}
body.projects-page[dir="ltr"] footer .footer-links {
  order: 2;
}
body.projects-page[dir="ltr"] footer .footer-contact {
  order: 3;
}

/* === 4. Mobile Responsiveness === */

/* (3) FIX: Featured cards visual distinction WITHOUT breaking grid */
/* Remove old span rules that conflict with 3/2/1 grid system */
/* Featured cards get visual emphasis through styling, not span changes */

.project-card.is-featured {
  /* Enhanced border and shadow for visual distinction */
  border: 2px solid rgba(0, 191, 166, 0.3);
  box-shadow: 0 4px 16px rgba(0, 191, 166, 0.12), 
              0 12px 32px rgba(15, 28, 63, 0.08);
}

.project-card.is-featured:hover {
  border-color: rgba(0, 191, 166, 0.5);
  box-shadow: 0 6px 20px rgba(0, 191, 166, 0.18), 
              0 16px 40px rgba(15, 28, 63, 0.12);
}

body.dark-mode .project-card.is-featured {
  border-color: rgba(0, 191, 166, 0.2);
  box-shadow: 0 6px 20px rgba(0, 191, 166, 0.15), 
              0 12px 36px rgba(0, 0, 0, 0.3);
}

body.dark-mode .project-card.is-featured:hover {
  border-color: rgba(0, 191, 166, 0.4);
  box-shadow: 0 8px 24px rgba(0, 191, 166, 0.2), 
              0 16px 44px rgba(0, 0, 0, 0.35);
}

@media (max-width: 768px) {
  .project-modal .modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }

  .project-gallery {
    flex: 0 0 clamp(240px, 48vh, 400px);
    max-height: 48vh;
  }
}

@media (max-width: 767px) {
  .projects-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .projects-pagination-indicator {
    width: 100%;
  }
}

/* Custom scrollbar */
/* === 5. Cleanup & Utilities === */
body::-webkit-scrollbar {
  width: 10px;
}

body::-webkit-scrollbar-track {
  background: rgba(10, 18, 32, 0.08);
}

body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--projects-silver-bright), var(--projects-silver-dark));
  border-radius: 999px;
}

body.dark-mode::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(200, 200, 200, 0.45), rgba(120, 120, 120, 0.55));
}

