/* 
  EPSE Profile Styling 
  Color System & Industrial Aesthetics 
*/

:root {
  --primary-red: #C8102E;
  --primary-red-hover: #A00B22;
  --deep-charcoal: #2C2C2A;
  --dark-accent: #1E1E1C;
  --light-gray: #F5F5F5;
  --card-white: #FFFFFF;
  --text-dark: #1F2937;
  --text-light: #9CA3AF;
  
  --font-arabic: 'Cairo', sans-serif;
  --font-english: 'Inter', sans-serif;
}

/* Base resets & variables */
html, body {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
}

body {
  font-family: var(--font-english);
  background-color: var(--light-gray);
  color: var(--text-dark);
}

html[dir="rtl"] {
  font-family: var(--font-arabic);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--deep-charcoal);
}
::-webkit-scrollbar-thumb {
  background: var(--primary-red);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-red-hover);
}

/* ============================================
   MOBILE NAV — Always-on overrides
   These MUST live outside any media query so
   they beat the JS-added Tailwind classes.
   ============================================ */

/* Mobile centered title — always brand red */
#mobile-nav-title {
  color: var(--primary-red);
  transition: color 0.3s ease;
}

/* Mobile menu links always stay white — the scroll listener must not touch them */
#mobile-menu a,
#mobile-menu a:visited {
  color: #ffffff !important;
}
#mobile-menu a:hover,
#mobile-menu a:focus {
  color: var(--primary-red) !important;
}

/* Glassmorphism Classes */
.glass-nav {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(229, 231, 235, 0.5);
  transition: all 0.3s ease;
}

.glass-nav-transparent {
  background: rgba(44, 44, 42, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.glass-card {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Geometric Red Accents */
.diagonal-accent-left {
  position: relative;
}
.diagonal-accent-left::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background-color: var(--primary-red);
  transition: height 0.3s ease;
}

.diagonal-accent-right {
  position: relative;
}
.diagonal-accent-right::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background-color: var(--primary-red);
  transition: height 0.3s ease;
}

/* Premium Card Lift & Accent */
.premium-card {
  background: var(--card-white);
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 12px;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
}

.premium-card::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  background-color: var(--primary-red);
  transition: transform 0.3s ease;
  transform: scaleY(0);
}

/* For RTL the accent should be on the right, LTR on the left */
html[dir="ltr"] .premium-card::after {
  left: 0;
  transform-origin: bottom;
}
html[dir="rtl"] .premium-card::after {
  right: 0;
  transform-origin: bottom;
}

.premium-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
  border-color: rgba(200, 16, 46, 0.2);
}

.premium-card:hover::after {
  transform: scaleY(1);
}

/* Power line SVG animation */
.power-line-path {
  stroke-dasharray: 20, 10;
  animation: powerFlow 4s linear infinite;
}

@keyframes powerFlow {
  from {
    stroke-dashoffset: 60;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* Pulsing dot for live status indicators */
.status-dot-pulse {
  animation: pulseStatus 2s infinite;
}

@keyframes pulseStatus {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(200, 16, 46, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(200, 16, 46, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(200, 16, 46, 0);
  }
}

/* Vertical Timeline (Bilingual) */
.timeline-item {
  position: relative;
  padding-left: 2.5rem;
  padding-bottom: 2rem;
  border-left: 2px solid rgba(229, 231, 235, 1);
}
html[dir="rtl"] .timeline-item {
  padding-left: 0;
  padding-right: 2.5rem;
  border-left: none;
  border-right: 2px solid rgba(229, 231, 235, 1);
}

.timeline-item:last-child {
  border-color: transparent;
}

.timeline-badge {
  position: absolute;
  left: -9px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--primary-red);
  border: 3px solid var(--card-white);
  box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.15);
}
html[dir="rtl"] .timeline-badge {
  left: auto;
  right: -9px;
}

/* Modals */
.modal-overlay {
  background: rgba(17, 24, 39, 0.75);
  backdrop-filter: blur(8px);
  transition: opacity 0.3s ease;
}

.modal-content {
  transform: translateY(20px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-active .modal-content {
  transform: translateY(0);
  opacity: 1;
}

/* Organization Chart Nodes styling */
.org-chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: auto;
  padding: 1rem;
}

.org-node {
  background: var(--card-white);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  min-width: 180px;
  text-align: center;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
  transition: all 0.3s ease;
}

.org-node:hover {
  border-color: var(--primary-red);
  box-shadow: 0 4px 15px rgba(200, 16, 46, 0.1);
  transform: scale(1.03);
}

/* Language toggle dynamic hide/show */
.lang-ar, .lang-en {
  transition: opacity 0.3s ease;
}

html[dir="rtl"] .lang-en {
  display: none !important;
}

html[dir="ltr"] .lang-ar {
  display: none !important;
}

/* Masonry for Careers */
.careers-masonry {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 640px) {
  .careers-masonry {
    grid-template-columns: 1fr;
  }
}
.careers-masonry img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}
.careers-masonry img:hover {
  border-color: var(--primary-red);
  transform: scale(1.02);
}

/* ===================================================
   MOBILE RESPONSIVENESS — Full Layout Fixes
   =================================================== */

/* Prevent AOS-triggered layout breaks on mobile */
[data-aos] {
  pointer-events: none;
}
[data-aos].aos-animate {
  pointer-events: auto;
}

/* Disable hover lift on touch devices to avoid sticky states */
@media (hover: none) {
  .premium-card:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  }
  .premium-card:hover::after {
    transform: scaleY(0);
  }
}

/* === NAVBAR === */
@media (max-width: 640px) {
  /* Tighten navbar height on mobile */
  #navbar .flex.items-center.justify-between {
    height: 64px !important;
  }

  /* Ensure language toggle button stays small */
  #navbar button[onclick="toggleLanguage()"] {
    padding: 6px 10px;
    font-size: 11px;
  }

  /* Mobile menu links — generous tap targets */
  #mobile-menu a {
    padding: 14px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: block;
    font-size: 15px;
    /* colour is set globally above — no override needed here */
  }
}

/* === HERO SECTION === */
@media (max-width: 640px) {
  header {
    min-height: 100svh; /* Use small viewport height unit */
    padding-top: 80px;
  }

  header h1 {
    font-size: 1.75rem !important;
    line-height: 1.3;
  }

  header p {
    font-size: 0.9rem;
  }

  /* Hero logo container */
  header a.w-32 {
    width: 96px !important;
    height: 96px !important;
    margin-bottom: 1.25rem !important;
  }

  /* CTA buttons full width on mobile */
  header .flex-col.sm\:flex-row {
    flex-direction: column !important;
    width: 100%;
    align-items: stretch;
  }
  header .flex-col.sm\:flex-row a {
    width: 100% !important;
    text-align: center;
  }
}

/* === ABOUT / STATS GRID === */
@media (max-width: 640px) {
  /* Give stat cards minimum breathing room */
  .premium-card.p-4 {
    border-radius: 10px;
  }

  /* About image — don't overflow */
  #about img {
    max-width: 100%;
    height: auto !important;
  }

  /* Tighten about section heading */
  #about h2 {
    font-size: 1.5rem !important;
  }
}

/* === SERVICES GRID === */
@media (max-width: 640px) {
  /* Single column services on small screens */
  #services .grid.grid-cols-1.md\:grid-cols-2.lg\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Reduce service card internal padding */
  #services .premium-card {
    padding: 1.25rem !important;
  }
  #services .premium-card .w-14 {
    width: 3rem !important;
    height: 3rem !important;
  }
  #services .premium-card h3 {
    font-size: 1rem !important;
  }
}

/* === PROFILE NAV GRID === */
@media (max-width: 640px) {
  #profile-nav .grid.grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }
  #profile-nav .grid.grid-cols-2.sm\:grid-cols-4 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* === LOCATIONS SECTION === */
@media (max-width: 1024px) {
  /* Stack the location cards + map vertically */
  #locations .grid.grid-cols-1.lg\:grid-cols-12 {
    grid-template-columns: 1fr !important;
    gap: 1.5rem;
  }
  /* Give the map iframe a sensible height on mobile */
  #locations iframe {
    height: 280px !important;
  }
}

/* === CONTACT FORM === */
@media (max-width: 640px) {
  #contact .grid.grid-cols-1.md\:grid-cols-2 {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  /* Quick contact links: 1 column instead of 3 */
  #contact .grid.grid-cols-1.sm\:grid-cols-3 {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  /* Certifications badges — wrap nicely */
  #contact .flex.flex-wrap {
    gap: 0.5rem;
  }

  /* Footer: stack vertically */
  #contact footer .flex.flex-col.md\:flex-row {
    flex-direction: column !important;
    text-align: center;
    gap: 0.5rem;
  }
}

/* === MODAL === */
@media (max-width: 640px) {
  #modal-card {
    margin: 0.75rem !important;
    padding: 1.25rem !important;
    max-height: 90vh !important;
  }
}

/* === TYPOGRAPHY SCALE DOWN ON XS === */
@media (max-width: 400px) {
  h1 { font-size: 1.5rem !important; }
  h2 { font-size: 1.25rem !important; }
  .text-3xl { font-size: 1.5rem !important; }
  .text-4xl { font-size: 1.75rem !important; }
}

/* === GENERAL SECTION INNER CONTAINER === */
@media (max-width: 640px) {
  .max-w-7xl,
  .max-w-4xl,
  .max-w-3xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}
